| author | |
| committer | |
| log | 1db8cade5ab5c05fa3c6a884e50947633ebcf065 |
| tree | 5a74083c154ad53748440fa85c75a16b009043d9 |
| parent | bbbc95afd0d035224047443d56ed2252d8f47cb9 |
| parent | c9052ef93105107bd20bd52ee51197d55e7ace34 |
| signature |
compiler: Improve handling of `-fno-builtin` and compiler-rt options14 files changed, 156 insertions(+), 124 deletions(-)
lib/c.zig+11-13| ... | ... | @@ -11,16 +11,14 @@ const native_os = builtin.os.tag; |
| 11 | 11 | const native_arch = builtin.cpu.arch; |
| 12 | 12 | const native_abi = builtin.abi; |
| 13 | 13 | |
| 14 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .internal else .strong; | |
| 15 | ||
| 14 | 16 | const is_wasm = switch (native_arch) { |
| 15 | 17 | .wasm32, .wasm64 => true, |
| 16 | 18 | else => false, |
| 17 | 19 | }; |
| 18 | const is_msvc = switch (native_abi) { | |
| 19 | .msvc => true, | |
| 20 | else => false, | |
| 21 | }; | |
| 22 | 20 | const is_freestanding = switch (native_os) { |
| 23 | .freestanding => true, | |
| 21 | .freestanding, .other => true, | |
| 24 | 22 | else => false, |
| 25 | 23 | }; |
| 26 | 24 | |
| ... | ... | @@ -30,14 +28,14 @@ comptime { |
| 30 | 28 | } |
| 31 | 29 | |
| 32 | 30 | if (builtin.link_libc) { |
| 33 | @export(&strcmp, .{ .name = "strcmp", .linkage = .strong }); | |
| 34 | @export(&strncmp, .{ .name = "strncmp", .linkage = .strong }); | |
| 35 | @export(&strerror, .{ .name = "strerror", .linkage = .strong }); | |
| 36 | @export(&strlen, .{ .name = "strlen", .linkage = .strong }); | |
| 37 | @export(&strcpy, .{ .name = "strcpy", .linkage = .strong }); | |
| 38 | @export(&strncpy, .{ .name = "strncpy", .linkage = .strong }); | |
| 39 | @export(&strcat, .{ .name = "strcat", .linkage = .strong }); | |
| 40 | @export(&strncat, .{ .name = "strncat", .linkage = .strong }); | |
| 31 | @export(&strcmp, .{ .name = "strcmp", .linkage = linkage }); | |
| 32 | @export(&strncmp, .{ .name = "strncmp", .linkage = linkage }); | |
| 33 | @export(&strerror, .{ .name = "strerror", .linkage = linkage }); | |
| 34 | @export(&strlen, .{ .name = "strlen", .linkage = linkage }); | |
| 35 | @export(&strcpy, .{ .name = "strcpy", .linkage = linkage }); | |
| 36 | @export(&strncpy, .{ .name = "strncpy", .linkage = linkage }); | |
| 37 | @export(&strcat, .{ .name = "strcat", .linkage = linkage }); | |
| 38 | @export(&strncat, .{ .name = "strncat", .linkage = linkage }); | |
| 41 | 39 | } |
| 42 | 40 | } |
| 43 | 41 |
lib/std/Target.zig+1-1| ... | ... | @@ -1076,7 +1076,7 @@ pub fn toElfMachine(target: Target) std.elf.EM { |
| 1076 | 1076 | pub fn toCoffMachine(target: Target) std.coff.MachineType { |
| 1077 | 1077 | return switch (target.cpu.arch) { |
| 1078 | 1078 | .arm => .ARM, |
| 1079 | .thumb => .THUMB, | |
| 1079 | .thumb => .ARMNT, | |
| 1080 | 1080 | .aarch64 => .ARM64, |
| 1081 | 1081 | .loongarch32 => .LOONGARCH32, |
| 1082 | 1082 | .loongarch64 => .LOONGARCH64, |
src/Compilation.zig+26-14| ... | ... | @@ -89,7 +89,6 @@ windows_libs: std.StringArrayHashMapUnmanaged(void), |
| 89 | 89 | version: ?std.SemanticVersion, |
| 90 | 90 | libc_installation: ?*const LibCInstallation, |
| 91 | 91 | skip_linker_dependencies: bool, |
| 92 | no_builtin: bool, | |
| 93 | 92 | function_sections: bool, |
| 94 | 93 | data_sections: bool, |
| 95 | 94 | link_eh_frame_hdr: bool, |
| ... | ... | @@ -852,6 +851,7 @@ pub const cache_helpers = struct { |
| 852 | 851 | hh.add(mod.fuzz); |
| 853 | 852 | hh.add(mod.unwind_tables); |
| 854 | 853 | hh.add(mod.structured_cfg); |
| 854 | hh.add(mod.no_builtin); | |
| 855 | 855 | hh.addListOfBytes(mod.cc_argv); |
| 856 | 856 | } |
| 857 | 857 | |
| ... | ... | @@ -1057,7 +1057,6 @@ pub const CreateOptions = struct { |
| 1057 | 1057 | want_lto: ?bool = null, |
| 1058 | 1058 | function_sections: bool = false, |
| 1059 | 1059 | data_sections: bool = false, |
| 1060 | no_builtin: bool = false, | |
| 1061 | 1060 | time_report: bool = false, |
| 1062 | 1061 | stack_report: bool = false, |
| 1063 | 1062 | link_eh_frame_hdr: bool = false, |
| ... | ... | @@ -1299,7 +1298,11 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1299 | 1298 | }, |
| 1300 | 1299 | .fully_qualified_name = "compiler_rt", |
| 1301 | 1300 | .cc_argv = &.{}, |
| 1302 | .inherited = .{}, | |
| 1301 | .inherited = .{ | |
| 1302 | .stack_check = false, | |
| 1303 | .stack_protector = 0, | |
| 1304 | .no_builtin = true, | |
| 1305 | }, | |
| 1303 | 1306 | .global = options.config, |
| 1304 | 1307 | .parent = options.root_mod, |
| 1305 | 1308 | .builtin_mod = options.root_mod.getBuiltinDependency(), |
| ... | ... | @@ -1353,7 +1356,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1353 | 1356 | cache.hash.add(options.config.link_mode); |
| 1354 | 1357 | cache.hash.add(options.function_sections); |
| 1355 | 1358 | cache.hash.add(options.data_sections); |
| 1356 | cache.hash.add(options.no_builtin); | |
| 1357 | 1359 | cache.hash.add(link_libc); |
| 1358 | 1360 | cache.hash.add(options.config.link_libcpp); |
| 1359 | 1361 | cache.hash.add(options.config.link_libunwind); |
| ... | ... | @@ -1490,7 +1492,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1490 | 1492 | .framework_dirs = options.framework_dirs, |
| 1491 | 1493 | .llvm_opt_bisect_limit = options.llvm_opt_bisect_limit, |
| 1492 | 1494 | .skip_linker_dependencies = options.skip_linker_dependencies, |
| 1493 | .no_builtin = options.no_builtin, | |
| 1494 | 1495 | .job_queued_update_builtin_zig = have_zcu, |
| 1495 | 1496 | .function_sections = options.function_sections, |
| 1496 | 1497 | .data_sections = options.data_sections, |
| ... | ... | @@ -5261,7 +5262,7 @@ pub fn addCCArgs( |
| 5261 | 5262 | try argv.append("-fdata-sections"); |
| 5262 | 5263 | } |
| 5263 | 5264 | |
| 5264 | if (comp.no_builtin) { | |
| 5265 | if (mod.no_builtin) { | |
| 5265 | 5266 | try argv.append("-fno-builtin"); |
| 5266 | 5267 | } |
| 5267 | 5268 | |
| ... | ... | @@ -6154,7 +6155,6 @@ fn buildOutputFromZig( |
| 6154 | 6155 | |
| 6155 | 6156 | assert(output_mode != .Exe); |
| 6156 | 6157 | |
| 6157 | const unwind_tables = comp.link_eh_frame_hdr; | |
| 6158 | 6158 | const strip = comp.compilerRtStrip(); |
| 6159 | 6159 | const optimize_mode = comp.compilerRtOptMode(); |
| 6160 | 6160 | |
| ... | ... | @@ -6168,7 +6168,6 @@ fn buildOutputFromZig( |
| 6168 | 6168 | .root_optimize_mode = optimize_mode, |
| 6169 | 6169 | .root_strip = strip, |
| 6170 | 6170 | .link_libc = comp.config.link_libc, |
| 6171 | .any_unwind_tables = unwind_tables, | |
| 6172 | 6171 | }); |
| 6173 | 6172 | |
| 6174 | 6173 | const root_mod = try Package.Module.create(arena, .{ |
| ... | ... | @@ -6185,10 +6184,11 @@ fn buildOutputFromZig( |
| 6185 | 6184 | .stack_protector = 0, |
| 6186 | 6185 | .red_zone = comp.root_mod.red_zone, |
| 6187 | 6186 | .omit_frame_pointer = comp.root_mod.omit_frame_pointer, |
| 6188 | .unwind_tables = unwind_tables, | |
| 6187 | .unwind_tables = comp.root_mod.unwind_tables, | |
| 6189 | 6188 | .pic = comp.root_mod.pic, |
| 6190 | 6189 | .optimize_mode = optimize_mode, |
| 6191 | 6190 | .structured_cfg = comp.root_mod.structured_cfg, |
| 6191 | .no_builtin = true, | |
| 6192 | 6192 | .code_model = comp.root_mod.code_model, |
| 6193 | 6193 | }, |
| 6194 | 6194 | .global = config, |
| ... | ... | @@ -6237,7 +6237,6 @@ fn buildOutputFromZig( |
| 6237 | 6237 | }, |
| 6238 | 6238 | .function_sections = true, |
| 6239 | 6239 | .data_sections = true, |
| 6240 | .no_builtin = true, | |
| 6241 | 6240 | .emit_h = null, |
| 6242 | 6241 | .verbose_cc = comp.verbose_cc, |
| 6243 | 6242 | .verbose_link = comp.verbose_link, |
| ... | ... | @@ -6262,16 +6261,24 @@ fn buildOutputFromZig( |
| 6262 | 6261 | comp.queueLinkTaskMode(crt_file.full_object_path, output_mode); |
| 6263 | 6262 | } |
| 6264 | 6263 | |
| 6264 | pub const CrtFileOptions = struct { | |
| 6265 | function_sections: ?bool = null, | |
| 6266 | data_sections: ?bool = null, | |
| 6267 | omit_frame_pointer: ?bool = null, | |
| 6268 | pic: ?bool = null, | |
| 6269 | no_builtin: ?bool = null, | |
| 6270 | }; | |
| 6271 | ||
| 6265 | 6272 | pub fn build_crt_file( |
| 6266 | 6273 | comp: *Compilation, |
| 6267 | 6274 | root_name: []const u8, |
| 6268 | 6275 | output_mode: std.builtin.OutputMode, |
| 6269 | pic: ?bool, | |
| 6270 | 6276 | misc_task_tag: MiscTask, |
| 6271 | 6277 | prog_node: std.Progress.Node, |
| 6272 | 6278 | /// These elements have to get mutated to add the owner module after it is |
| 6273 | 6279 | /// created within this function. |
| 6274 | 6280 | c_source_files: []CSourceFile, |
| 6281 | options: CrtFileOptions, | |
| 6275 | 6282 | ) !void { |
| 6276 | 6283 | const tracy_trace = trace(@src()); |
| 6277 | 6284 | defer tracy_trace.end(); |
| ... | ... | @@ -6316,13 +6323,16 @@ pub fn build_crt_file( |
| 6316 | 6323 | .sanitize_c = false, |
| 6317 | 6324 | .sanitize_thread = false, |
| 6318 | 6325 | .red_zone = comp.root_mod.red_zone, |
| 6319 | .omit_frame_pointer = comp.root_mod.omit_frame_pointer, | |
| 6326 | // Some libcs (e.g. musl) are opinionated about -fomit-frame-pointer. | |
| 6327 | .omit_frame_pointer = options.omit_frame_pointer orelse comp.root_mod.omit_frame_pointer, | |
| 6320 | 6328 | .valgrind = false, |
| 6321 | 6329 | .unwind_tables = false, |
| 6322 | // Some CRT objects (rcrt1.o, Scrt1.o) are opinionated about PIC. | |
| 6323 | .pic = pic orelse comp.root_mod.pic, | |
| 6330 | // Some CRT objects (e.g. musl's rcrt1.o and Scrt1.o) are opinionated about PIC. | |
| 6331 | .pic = options.pic orelse comp.root_mod.pic, | |
| 6324 | 6332 | .optimize_mode = comp.compilerRtOptMode(), |
| 6325 | 6333 | .structured_cfg = comp.root_mod.structured_cfg, |
| 6334 | // Some libcs (e.g. musl) are opinionated about -fno-builtin. | |
| 6335 | .no_builtin = options.no_builtin orelse comp.root_mod.no_builtin, | |
| 6326 | 6336 | }, |
| 6327 | 6337 | .global = config, |
| 6328 | 6338 | .cc_argv = &.{}, |
| ... | ... | @@ -6350,6 +6360,8 @@ pub fn build_crt_file( |
| 6350 | 6360 | .directory = null, // Put it in the cache directory. |
| 6351 | 6361 | .basename = basename, |
| 6352 | 6362 | }, |
| 6363 | .function_sections = options.function_sections orelse false, | |
| 6364 | .data_sections = options.data_sections orelse false, | |
| 6353 | 6365 | .emit_h = null, |
| 6354 | 6366 | .c_source_files = c_source_files, |
| 6355 | 6367 | .verbose_cc = comp.verbose_cc, |
src/Package/Module.zig+12| ... | ... | @@ -31,6 +31,7 @@ unwind_tables: bool, |
| 31 | 31 | cc_argv: []const []const u8, |
| 32 | 32 | /// (SPIR-V) whether to generate a structured control flow graph or not |
| 33 | 33 | structured_cfg: bool, |
| 34 | no_builtin: bool, | |
| 34 | 35 | |
| 35 | 36 | /// If the module is an `@import("builtin")` module, this is the `File` that |
| 36 | 37 | /// is preallocated for it. Otherwise this field is null. |
| ... | ... | @@ -95,6 +96,7 @@ pub const CreateOptions = struct { |
| 95 | 96 | sanitize_thread: ?bool = null, |
| 96 | 97 | fuzz: ?bool = null, |
| 97 | 98 | structured_cfg: ?bool = null, |
| 99 | no_builtin: ?bool = null, | |
| 98 | 100 | }; |
| 99 | 101 | }; |
| 100 | 102 | |
| ... | ... | @@ -298,6 +300,13 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { |
| 298 | 300 | }; |
| 299 | 301 | }; |
| 300 | 302 | |
| 303 | const no_builtin = b: { | |
| 304 | if (options.inherited.no_builtin) |x| break :b x; | |
| 305 | if (options.parent) |p| break :b p.no_builtin; | |
| 306 | ||
| 307 | break :b target.cpu.arch.isBpf(); | |
| 308 | }; | |
| 309 | ||
| 301 | 310 | const llvm_cpu_features: ?[*:0]const u8 = b: { |
| 302 | 311 | if (resolved_target.llvm_cpu_features) |x| break :b x; |
| 303 | 312 | if (!options.global.use_llvm) break :b null; |
| ... | ... | @@ -350,6 +359,7 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { |
| 350 | 359 | .unwind_tables = unwind_tables, |
| 351 | 360 | .cc_argv = options.cc_argv, |
| 352 | 361 | .structured_cfg = structured_cfg, |
| 362 | .no_builtin = no_builtin, | |
| 353 | 363 | .builtin_file = null, |
| 354 | 364 | }; |
| 355 | 365 | |
| ... | ... | @@ -442,6 +452,7 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { |
| 442 | 452 | .unwind_tables = unwind_tables, |
| 443 | 453 | .cc_argv = &.{}, |
| 444 | 454 | .structured_cfg = structured_cfg, |
| 455 | .no_builtin = no_builtin, | |
| 445 | 456 | .builtin_file = new_file, |
| 446 | 457 | }; |
| 447 | 458 | new_file.* = .{ |
| ... | ... | @@ -502,6 +513,7 @@ pub fn createLimited(gpa: Allocator, options: LimitedOptions) Allocator.Error!*P |
| 502 | 513 | .unwind_tables = undefined, |
| 503 | 514 | .cc_argv = undefined, |
| 504 | 515 | .structured_cfg = undefined, |
| 516 | .no_builtin = undefined, | |
| 505 | 517 | .builtin_file = null, |
| 506 | 518 | }; |
| 507 | 519 | return mod; |
src/codegen/llvm.zig+8-4| ... | ... | @@ -3222,8 +3222,6 @@ pub const Object = struct { |
| 3222 | 3222 | owner_mod: *Package.Module, |
| 3223 | 3223 | omit_frame_pointer: bool, |
| 3224 | 3224 | ) Allocator.Error!void { |
| 3225 | const comp = o.pt.zcu.comp; | |
| 3226 | ||
| 3227 | 3225 | if (!owner_mod.red_zone) { |
| 3228 | 3226 | try attributes.addFnAttr(.noredzone, &o.builder); |
| 3229 | 3227 | } |
| ... | ... | @@ -3242,8 +3240,7 @@ pub const Object = struct { |
| 3242 | 3240 | if (owner_mod.unwind_tables) { |
| 3243 | 3241 | try attributes.addFnAttr(.{ .uwtable = Builder.Attribute.UwTable.default }, &o.builder); |
| 3244 | 3242 | } |
| 3245 | const target = owner_mod.resolved_target.result; | |
| 3246 | if (comp.skip_linker_dependencies or comp.no_builtin or target.cpu.arch.isBpf()) { | |
| 3243 | if (owner_mod.no_builtin) { | |
| 3247 | 3244 | // The intent here is for compiler-rt and libc functions to not generate |
| 3248 | 3245 | // infinite recursion. For example, if we are compiling the memcpy function, |
| 3249 | 3246 | // and llvm detects that the body is equivalent to memcpy, it may replace the |
| ... | ... | @@ -3258,6 +3255,7 @@ pub const Object = struct { |
| 3258 | 3255 | try attributes.addFnAttr(.minsize, &o.builder); |
| 3259 | 3256 | try attributes.addFnAttr(.optsize, &o.builder); |
| 3260 | 3257 | } |
| 3258 | const target = owner_mod.resolved_target.result; | |
| 3261 | 3259 | if (target.cpu.model.llvm_name) |s| { |
| 3262 | 3260 | try attributes.addFnAttr(.{ .string = .{ |
| 3263 | 3261 | .kind = try o.builder.string("target-cpu"), |
| ... | ... | @@ -5578,6 +5576,10 @@ pub const FuncGen = struct { |
| 5578 | 5576 | var attributes: Builder.FunctionAttributes.Wip = .{}; |
| 5579 | 5577 | defer attributes.deinit(&o.builder); |
| 5580 | 5578 | |
| 5579 | if (self.ng.ownerModule().no_builtin) { | |
| 5580 | try attributes.addFnAttr(.nobuiltin, &o.builder); | |
| 5581 | } | |
| 5582 | ||
| 5581 | 5583 | switch (modifier) { |
| 5582 | 5584 | .auto, .never_tail, .always_tail => {}, |
| 5583 | 5585 | .never_inline => try attributes.addFnAttr(.@"noinline", &o.builder), |
| ... | ... | @@ -12728,6 +12730,8 @@ fn backendSupportsF16(target: std.Target) bool { |
| 12728 | 12730 | .mips64, |
| 12729 | 12731 | .mips64el, |
| 12730 | 12732 | .s390x, |
| 12733 | .sparc, | |
| 12734 | .sparc64, | |
| 12731 | 12735 | => false, |
| 12732 | 12736 | .arm, |
| 12733 | 12737 | .armeb, |
src/glibc.zig+4-5| ... | ... | @@ -221,7 +221,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 221 | 221 | .owner = comp.root_mod, |
| 222 | 222 | }, |
| 223 | 223 | }; |
| 224 | return comp.build_crt_file("crti", .Obj, null, .@"glibc crti.o", prog_node, &files); | |
| 224 | return comp.build_crt_file("crti", .Obj, .@"glibc crti.o", prog_node, &files, .{}); | |
| 225 | 225 | }, |
| 226 | 226 | .crtn_o => { |
| 227 | 227 | var args = std.ArrayList([]const u8).init(arena); |
| ... | ... | @@ -242,7 +242,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 242 | 242 | .owner = undefined, |
| 243 | 243 | }, |
| 244 | 244 | }; |
| 245 | return comp.build_crt_file("crtn", .Obj, null, .@"glibc crtn.o", prog_node, &files); | |
| 245 | return comp.build_crt_file("crtn", .Obj, .@"glibc crtn.o", prog_node, &files, .{}); | |
| 246 | 246 | }, |
| 247 | 247 | .scrt1_o => { |
| 248 | 248 | const start_o: Compilation.CSourceFile = blk: { |
| ... | ... | @@ -295,7 +295,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 295 | 295 | }; |
| 296 | 296 | var files = [_]Compilation.CSourceFile{ start_o, abi_note_o, init_o }; |
| 297 | 297 | const basename = if (comp.config.output_mode == .Exe and !comp.config.pie) "crt1" else "Scrt1"; |
| 298 | return comp.build_crt_file(basename, .Obj, null, .@"glibc Scrt1.o", prog_node, &files); | |
| 298 | return comp.build_crt_file(basename, .Obj, .@"glibc Scrt1.o", prog_node, &files, .{}); | |
| 299 | 299 | }, |
| 300 | 300 | .libc_nonshared_a => { |
| 301 | 301 | const s = path.sep_str; |
| ... | ... | @@ -373,7 +373,6 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 373 | 373 | "-fmerge-all-constants", |
| 374 | 374 | "-frounding-math", |
| 375 | 375 | "-Wno-unsupported-floating-point-opt", // For targets that don't support -frounding-math. |
| 376 | "-fno-stack-protector", | |
| 377 | 376 | "-fno-common", |
| 378 | 377 | "-fmath-errno", |
| 379 | 378 | "-ftls-model=initial-exec", |
| ... | ... | @@ -413,7 +412,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 413 | 412 | files_index += 1; |
| 414 | 413 | } |
| 415 | 414 | const files = files_buf[0..files_index]; |
| 416 | return comp.build_crt_file("c_nonshared", .Lib, null, .@"glibc libc_nonshared.a", prog_node, files); | |
| 415 | return comp.build_crt_file("c_nonshared", .Lib, .@"glibc libc_nonshared.a", prog_node, files, .{}); | |
| 417 | 416 | }, |
| 418 | 417 | } |
| 419 | 418 | } |
src/libcxx.zig+1-4| ... | ... | @@ -195,7 +195,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: std.Progress.Node) BuildError! |
| 195 | 195 | .valgrind = false, |
| 196 | 196 | .optimize_mode = optimize_mode, |
| 197 | 197 | .structured_cfg = comp.root_mod.structured_cfg, |
| 198 | .pic = comp.root_mod.pic, | |
| 198 | .pic = if (target_util.supports_fpic(target)) true else null, | |
| 199 | 199 | }, |
| 200 | 200 | .global = config, |
| 201 | 201 | .cc_argv = &.{}, |
| ... | ... | @@ -278,9 +278,6 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: std.Progress.Node) BuildError! |
| 278 | 278 | try cflags.append("-faligned-allocation"); |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | if (target_util.supports_fpic(target)) { | |
| 282 | try cflags.append("-fPIC"); | |
| 283 | } | |
| 284 | 281 | try cflags.append("-nostdinc++"); |
| 285 | 282 | try cflags.append("-std=c++23"); |
| 286 | 283 | try cflags.append("-Wno-user-defined-literals"); |
src/libtsan.zig+32-30| ... | ... | @@ -29,11 +29,11 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo |
| 29 | 29 | const root_name = switch (target.os.tag) { |
| 30 | 30 | // On Apple platforms, we use the same name as LLVM because the |
| 31 | 31 | // TSAN library implementation hard-codes a check for these names. |
| 32 | .macos => "clang_rt.tsan_osx_dynamic", | |
| 33 | .ios => switch (target.abi) { | |
| 34 | .simulator => "clang_rt.tsan_iossim_dynamic", | |
| 35 | else => "clang_rt.tsan_ios_dynamic", | |
| 36 | }, | |
| 32 | .driverkit, .macos => "clang_rt.tsan_osx_dynamic", | |
| 33 | .ios => if (target.abi == .simulator) "clang_rt.tsan_iossim_dynamic" else "clang_rt.tsan_ios_dynamic", | |
| 34 | .tvos => if (target.abi == .simulator) "clang_rt.tsan_tvossim_dynamic" else "clang_rt.tsan_tvos_dynamic", | |
| 35 | .visionos => if (target.abi == .simulator) "clang_rt.tsan_xrossim_dynamic" else "clang_rt.tsan_xros_dynamic", | |
| 36 | .watchos => if (target.abi == .simulator) "clang_rt.tsan_watchossim_dynamic" else "clang_rt.tsan_watchos_dynamic", | |
| 37 | 37 | else => "tsan", |
| 38 | 38 | }; |
| 39 | 39 | const link_mode: std.builtin.LinkMode = if (target.isDarwin()) .dynamic else .static; |
| ... | ... | @@ -93,11 +93,12 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo |
| 93 | 93 | .sanitize_c = false, |
| 94 | 94 | .sanitize_thread = false, |
| 95 | 95 | .red_zone = comp.root_mod.red_zone, |
| 96 | .omit_frame_pointer = comp.root_mod.omit_frame_pointer, | |
| 96 | .omit_frame_pointer = optimize_mode != .Debug and !target.os.tag.isDarwin(), | |
| 97 | 97 | .valgrind = false, |
| 98 | 98 | .optimize_mode = optimize_mode, |
| 99 | 99 | .structured_cfg = comp.root_mod.structured_cfg, |
| 100 | 100 | .pic = true, |
| 101 | .no_builtin = true, | |
| 101 | 102 | }, |
| 102 | 103 | .global = config, |
| 103 | 104 | .cc_argv = &common_flags, |
| ... | ... | @@ -123,10 +124,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo |
| 123 | 124 | try cflags.append("-I"); |
| 124 | 125 | try cflags.append(tsan_include_path); |
| 125 | 126 | |
| 126 | try cflags.append("-nostdinc++"); | |
| 127 | try cflags.append("-fvisibility-inlines-hidden"); | |
| 128 | try cflags.append("-std=c++17"); | |
| 129 | try cflags.append("-fno-rtti"); | |
| 127 | try addCcArgs(target, &cflags); | |
| 130 | 128 | |
| 131 | 129 | c_source_files.appendAssumeCapacity(.{ |
| 132 | 130 | .src_path = try comp.zig_lib_directory.join(arena, &.{ "tsan", tsan_src }), |
| ... | ... | @@ -147,10 +145,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo |
| 147 | 145 | try cflags.append("-I"); |
| 148 | 146 | try cflags.append(tsan_include_path); |
| 149 | 147 | |
| 150 | try cflags.append("-nostdinc++"); | |
| 151 | try cflags.append("-fvisibility-inlines-hidden"); | |
| 152 | try cflags.append("-std=c++17"); | |
| 153 | try cflags.append("-fno-rtti"); | |
| 148 | try addCcArgs(target, &cflags); | |
| 154 | 149 | |
| 155 | 150 | c_source_files.appendAssumeCapacity(.{ |
| 156 | 151 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "tsan", tsan_src }), |
| ... | ... | @@ -195,10 +190,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo |
| 195 | 190 | try cflags.append("-I"); |
| 196 | 191 | try cflags.append(tsan_include_path); |
| 197 | 192 | |
| 198 | try cflags.append("-nostdinc++"); | |
| 199 | try cflags.append("-fvisibility-inlines-hidden"); | |
| 200 | try cflags.append("-std=c++17"); | |
| 201 | try cflags.append("-fno-rtti"); | |
| 193 | try addCcArgs(target, &cflags); | |
| 202 | 194 | |
| 203 | 195 | c_source_files.appendAssumeCapacity(.{ |
| 204 | 196 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| ... | ... | @@ -222,10 +214,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo |
| 222 | 214 | try cflags.append("-I"); |
| 223 | 215 | try cflags.append(tsan_include_path); |
| 224 | 216 | |
| 225 | try cflags.append("-nostdinc++"); | |
| 226 | try cflags.append("-fvisibility-inlines-hidden"); | |
| 227 | try cflags.append("-std=c++17"); | |
| 228 | try cflags.append("-fno-rtti"); | |
| 217 | try addCcArgs(target, &cflags); | |
| 229 | 218 | |
| 230 | 219 | c_source_files.appendAssumeCapacity(.{ |
| 231 | 220 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| ... | ... | @@ -243,10 +232,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo |
| 243 | 232 | try cflags.append("-I"); |
| 244 | 233 | try cflags.append(tsan_include_path); |
| 245 | 234 | |
| 246 | try cflags.append("-nostdinc++"); | |
| 247 | try cflags.append("-fvisibility-inlines-hidden"); | |
| 248 | try cflags.append("-std=c++17"); | |
| 249 | try cflags.append("-fno-rtti"); | |
| 235 | try addCcArgs(target, &cflags); | |
| 250 | 236 | |
| 251 | 237 | c_source_files.appendAssumeCapacity(.{ |
| 252 | 238 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| ... | ... | @@ -272,10 +258,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo |
| 272 | 258 | try cflags.append("-I"); |
| 273 | 259 | try cflags.append(tsan_include_path); |
| 274 | 260 | |
| 275 | try cflags.append("-nostdinc++"); | |
| 276 | try cflags.append("-fvisibility-inlines-hidden"); | |
| 277 | try cflags.append("-std=c++17"); | |
| 278 | try cflags.append("-fno-rtti"); | |
| 261 | try addCcArgs(target, &cflags); | |
| 279 | 262 | |
| 280 | 263 | c_source_files.appendAssumeCapacity(.{ |
| 281 | 264 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| ... | ... | @@ -348,6 +331,25 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo |
| 348 | 331 | comp.tsan_lib = crt_file; |
| 349 | 332 | } |
| 350 | 333 | |
| 334 | fn addCcArgs(target: std.Target, args: *std.ArrayList([]const u8)) error{OutOfMemory}!void { | |
| 335 | try args.appendSlice(&[_][]const u8{ | |
| 336 | "-nostdinc++", | |
| 337 | "-fvisibility=hidden", | |
| 338 | "-fvisibility-inlines-hidden", | |
| 339 | "-std=c++17", | |
| 340 | "-fno-rtti", | |
| 341 | "-fno-exceptions", | |
| 342 | }); | |
| 343 | ||
| 344 | if (target.abi.isAndroid() and target.os.version_range.linux.android >= 29) { | |
| 345 | try args.append("-fno-emulated-tls"); | |
| 346 | } | |
| 347 | ||
| 348 | if (target.isMinGW()) { | |
| 349 | try args.append("-fms-extensions"); | |
| 350 | } | |
| 351 | } | |
| 352 | ||
| 351 | 353 | const tsan_sources = [_][]const u8{ |
| 352 | 354 | "tsan_debugging.cpp", |
| 353 | 355 | "tsan_external.cpp", |
src/libunwind.zig+4-8| ... | ... | @@ -46,6 +46,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr |
| 46 | 46 | ); |
| 47 | 47 | return error.SubCompilationFailed; |
| 48 | 48 | }; |
| 49 | const target = comp.root_mod.resolved_target.result; | |
| 49 | 50 | const root_mod = Module.create(arena, .{ |
| 50 | 51 | .global_cache_directory = comp.global_cache_directory, |
| 51 | 52 | .paths = .{ |
| ... | ... | @@ -63,8 +64,9 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr |
| 63 | 64 | .valgrind = false, |
| 64 | 65 | .sanitize_c = false, |
| 65 | 66 | .sanitize_thread = false, |
| 66 | .unwind_tables = false, | |
| 67 | .pic = comp.root_mod.pic, | |
| 67 | // necessary so that libunwind can unwind through its own stack frames | |
| 68 | .unwind_tables = true, | |
| 69 | .pic = if (target_util.supports_fpic(target)) true else null, | |
| 68 | 70 | .optimize_mode = comp.compilerRtOptMode(), |
| 69 | 71 | }, |
| 70 | 72 | .global = config, |
| ... | ... | @@ -83,7 +85,6 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr |
| 83 | 85 | |
| 84 | 86 | const root_name = "unwind"; |
| 85 | 87 | const link_mode = .static; |
| 86 | const target = comp.root_mod.resolved_target.result; | |
| 87 | 88 | const basename = try std.zig.binNameAlloc(arena, .{ |
| 88 | 89 | .root_name = root_name, |
| 89 | 90 | .target = target, |
| ... | ... | @@ -114,16 +115,11 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr |
| 114 | 115 | try cflags.append("-fno-exceptions"); |
| 115 | 116 | try cflags.append("-I"); |
| 116 | 117 | try cflags.append(try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libunwind", "include" })); |
| 117 | if (target_util.supports_fpic(target)) { | |
| 118 | try cflags.append("-fPIC"); | |
| 119 | } | |
| 120 | 118 | try cflags.append("-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS"); |
| 121 | 119 | try cflags.append("-Wa,--noexecstack"); |
| 122 | 120 | try cflags.append("-fvisibility=hidden"); |
| 123 | 121 | try cflags.append("-fvisibility-inlines-hidden"); |
| 124 | 122 | try cflags.append("-fvisibility-global-new-delete=force-hidden"); |
| 125 | // necessary so that libunwind can unwind through its own stack frames | |
| 126 | try cflags.append("-funwind-tables"); | |
| 127 | 123 | |
| 128 | 124 | // This is intentionally always defined because the macro definition means, should it only |
| 129 | 125 | // build for the target specified by compiler defines. Since we pass -target the compiler |
src/main.zig+4-6| ... | ... | @@ -810,7 +810,6 @@ fn buildOutputType( |
| 810 | 810 | var compatibility_version: ?std.SemanticVersion = null; |
| 811 | 811 | var function_sections = false; |
| 812 | 812 | var data_sections = false; |
| 813 | var no_builtin = false; | |
| 814 | 813 | var listen: Listen = .none; |
| 815 | 814 | var debug_compile_errors = false; |
| 816 | 815 | var verbose_link = (native_os != .wasi or builtin.link_libc) and |
| ... | ... | @@ -1550,9 +1549,9 @@ fn buildOutputType( |
| 1550 | 1549 | } else if (mem.eql(u8, arg, "-fno-data-sections")) { |
| 1551 | 1550 | data_sections = false; |
| 1552 | 1551 | } else if (mem.eql(u8, arg, "-fbuiltin")) { |
| 1553 | no_builtin = false; | |
| 1552 | mod_opts.no_builtin = false; | |
| 1554 | 1553 | } else if (mem.eql(u8, arg, "-fno-builtin")) { |
| 1555 | no_builtin = true; | |
| 1554 | mod_opts.no_builtin = true; | |
| 1556 | 1555 | } else if (mem.startsWith(u8, arg, "-fopt-bisect-limit=")) { |
| 1557 | 1556 | const next_arg = arg["-fopt-bisect-limit=".len..]; |
| 1558 | 1557 | llvm_opt_bisect_limit = std.fmt.parseInt(c_int, next_arg, 0) catch |err| |
| ... | ... | @@ -1963,8 +1962,8 @@ fn buildOutputType( |
| 1963 | 1962 | .no_function_sections => function_sections = false, |
| 1964 | 1963 | .data_sections => data_sections = true, |
| 1965 | 1964 | .no_data_sections => data_sections = false, |
| 1966 | .builtin => no_builtin = false, | |
| 1967 | .no_builtin => no_builtin = true, | |
| 1965 | .builtin => mod_opts.no_builtin = false, | |
| 1966 | .no_builtin => mod_opts.no_builtin = true, | |
| 1968 | 1967 | .color_diagnostics => color = .on, |
| 1969 | 1968 | .no_color_diagnostics => color = .off, |
| 1970 | 1969 | .stack_check => mod_opts.stack_check = true, |
| ... | ... | @@ -3468,7 +3467,6 @@ fn buildOutputType( |
| 3468 | 3467 | .image_base = image_base, |
| 3469 | 3468 | .function_sections = function_sections, |
| 3470 | 3469 | .data_sections = data_sections, |
| 3471 | .no_builtin = no_builtin, | |
| 3472 | 3470 | .clang_passthrough_mode = clang_passthrough_mode, |
| 3473 | 3471 | .clang_preprocessor_mode = clang_preprocessor_mode, |
| 3474 | 3472 | .version = optional_version, |
src/mingw.zig+3-3| ... | ... | @@ -41,7 +41,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 41 | 41 | .owner = undefined, |
| 42 | 42 | }, |
| 43 | 43 | }; |
| 44 | return comp.build_crt_file("crt2", .Obj, null, .@"mingw-w64 crt2.o", prog_node, &files); | |
| 44 | return comp.build_crt_file("crt2", .Obj, .@"mingw-w64 crt2.o", prog_node, &files, .{}); | |
| 45 | 45 | }, |
| 46 | 46 | |
| 47 | 47 | .dllcrt2_o => { |
| ... | ... | @@ -56,7 +56,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 56 | 56 | .owner = undefined, |
| 57 | 57 | }, |
| 58 | 58 | }; |
| 59 | return comp.build_crt_file("dllcrt2", .Obj, null, .@"mingw-w64 dllcrt2.o", prog_node, &files); | |
| 59 | return comp.build_crt_file("dllcrt2", .Obj, .@"mingw-w64 dllcrt2.o", prog_node, &files, .{}); | |
| 60 | 60 | }, |
| 61 | 61 | |
| 62 | 62 | .mingw32_lib => { |
| ... | ... | @@ -118,7 +118,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 118 | 118 | } else { |
| 119 | 119 | @panic("unsupported arch"); |
| 120 | 120 | } |
| 121 | return comp.build_crt_file("mingw32", .Lib, null, .@"mingw-w64 mingw32.lib", prog_node, c_source_files.items); | |
| 121 | return comp.build_crt_file("mingw32", .Lib, .@"mingw-w64 mingw32.lib", prog_node, c_source_files.items, .{}); | |
| 122 | 122 | }, |
| 123 | 123 | } |
| 124 | 124 | } |
src/musl.zig+41-25| ... | ... | @@ -38,7 +38,12 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro |
| 38 | 38 | .owner = undefined, |
| 39 | 39 | }, |
| 40 | 40 | }; |
| 41 | return comp.build_crt_file("crti", .Obj, null, .@"musl crti.o", prog_node, &files); | |
| 41 | return comp.build_crt_file("crti", .Obj, .@"musl crti.o", prog_node, &files, .{ | |
| 42 | .function_sections = true, | |
| 43 | .data_sections = true, | |
| 44 | .omit_frame_pointer = true, | |
| 45 | .no_builtin = true, | |
| 46 | }); | |
| 42 | 47 | }, |
| 43 | 48 | .crtn_o => { |
| 44 | 49 | var args = std.ArrayList([]const u8).init(arena); |
| ... | ... | @@ -50,15 +55,17 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro |
| 50 | 55 | .owner = undefined, |
| 51 | 56 | }, |
| 52 | 57 | }; |
| 53 | return comp.build_crt_file("crtn", .Obj, null, .@"musl crtn.o", prog_node, &files); | |
| 58 | return comp.build_crt_file("crtn", .Obj, .@"musl crtn.o", prog_node, &files, .{ | |
| 59 | .function_sections = true, | |
| 60 | .data_sections = true, | |
| 61 | .omit_frame_pointer = true, | |
| 62 | .no_builtin = true, | |
| 63 | }); | |
| 54 | 64 | }, |
| 55 | 65 | .crt1_o => { |
| 56 | 66 | var args = std.ArrayList([]const u8).init(arena); |
| 57 | 67 | try addCcArgs(comp, arena, &args, false); |
| 58 | try args.appendSlice(&[_][]const u8{ | |
| 59 | "-fno-stack-protector", | |
| 60 | "-DCRT", | |
| 61 | }); | |
| 68 | try args.append("-DCRT"); | |
| 62 | 69 | var files = [_]Compilation.CSourceFile{ |
| 63 | 70 | .{ |
| 64 | 71 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| ... | ... | @@ -68,15 +75,17 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro |
| 68 | 75 | .owner = undefined, |
| 69 | 76 | }, |
| 70 | 77 | }; |
| 71 | return comp.build_crt_file("crt1", .Obj, null, .@"musl crt1.o", prog_node, &files); | |
| 78 | return comp.build_crt_file("crt1", .Obj, .@"musl crt1.o", prog_node, &files, .{ | |
| 79 | .function_sections = true, | |
| 80 | .data_sections = true, | |
| 81 | .omit_frame_pointer = true, | |
| 82 | .no_builtin = true, | |
| 83 | }); | |
| 72 | 84 | }, |
| 73 | 85 | .rcrt1_o => { |
| 74 | 86 | var args = std.ArrayList([]const u8).init(arena); |
| 75 | 87 | try addCcArgs(comp, arena, &args, false); |
| 76 | try args.appendSlice(&[_][]const u8{ | |
| 77 | "-fno-stack-protector", | |
| 78 | "-DCRT", | |
| 79 | }); | |
| 88 | try args.append("-DCRT"); | |
| 80 | 89 | var files = [_]Compilation.CSourceFile{ |
| 81 | 90 | .{ |
| 82 | 91 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| ... | ... | @@ -86,15 +95,18 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro |
| 86 | 95 | .owner = undefined, |
| 87 | 96 | }, |
| 88 | 97 | }; |
| 89 | return comp.build_crt_file("rcrt1", .Obj, true, .@"musl rcrt1.o", prog_node, &files); | |
| 98 | return comp.build_crt_file("rcrt1", .Obj, .@"musl rcrt1.o", prog_node, &files, .{ | |
| 99 | .function_sections = true, | |
| 100 | .data_sections = true, | |
| 101 | .omit_frame_pointer = true, | |
| 102 | .pic = true, | |
| 103 | .no_builtin = true, | |
| 104 | }); | |
| 90 | 105 | }, |
| 91 | 106 | .scrt1_o => { |
| 92 | 107 | var args = std.ArrayList([]const u8).init(arena); |
| 93 | 108 | try addCcArgs(comp, arena, &args, false); |
| 94 | try args.appendSlice(&[_][]const u8{ | |
| 95 | "-fno-stack-protector", | |
| 96 | "-DCRT", | |
| 97 | }); | |
| 109 | try args.append("-DCRT"); | |
| 98 | 110 | var files = [_]Compilation.CSourceFile{ |
| 99 | 111 | .{ |
| 100 | 112 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| ... | ... | @@ -104,7 +116,13 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro |
| 104 | 116 | .owner = undefined, |
| 105 | 117 | }, |
| 106 | 118 | }; |
| 107 | return comp.build_crt_file("Scrt1", .Obj, true, .@"musl Scrt1.o", prog_node, &files); | |
| 119 | return comp.build_crt_file("Scrt1", .Obj, .@"musl Scrt1.o", prog_node, &files, .{ | |
| 120 | .function_sections = true, | |
| 121 | .data_sections = true, | |
| 122 | .omit_frame_pointer = true, | |
| 123 | .pic = true, | |
| 124 | .no_builtin = true, | |
| 125 | }); | |
| 108 | 126 | }, |
| 109 | 127 | .libc_a => { |
| 110 | 128 | // When there is a src/<arch>/foo.* then it should substitute for src/foo.* |
| ... | ... | @@ -197,7 +215,12 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro |
| 197 | 215 | .owner = undefined, |
| 198 | 216 | }; |
| 199 | 217 | } |
| 200 | return comp.build_crt_file("c", .Lib, null, .@"musl libc.a", prog_node, c_source_files.items); | |
| 218 | return comp.build_crt_file("c", .Lib, .@"musl libc.a", prog_node, c_source_files.items, .{ | |
| 219 | .function_sections = true, | |
| 220 | .data_sections = true, | |
| 221 | .omit_frame_pointer = true, | |
| 222 | .no_builtin = true, | |
| 223 | }); | |
| 201 | 224 | }, |
| 202 | 225 | .libc_so => { |
| 203 | 226 | const optimize_mode = comp.compilerRtOptMode(); |
| ... | ... | @@ -410,7 +433,6 @@ fn addCcArgs( |
| 410 | 433 | try args.appendSlice(&[_][]const u8{ |
| 411 | 434 | "-std=c99", |
| 412 | 435 | "-ffreestanding", |
| 413 | "-fno-builtin", | |
| 414 | 436 | "-fexcess-precision=standard", |
| 415 | 437 | "-frounding-math", |
| 416 | 438 | "-ffp-contract=off", |
| ... | ... | @@ -441,12 +463,6 @@ fn addCcArgs( |
| 441 | 463 | |
| 442 | 464 | o_arg, |
| 443 | 465 | |
| 444 | "-fomit-frame-pointer", | |
| 445 | "-fno-unwind-tables", | |
| 446 | "-fno-asynchronous-unwind-tables", | |
| 447 | "-ffunction-sections", | |
| 448 | "-fdata-sections", | |
| 449 | ||
| 450 | 466 | "-Qunused-arguments", |
| 451 | 467 | "-w", // disable all warnings |
| 452 | 468 | }); |
src/target.zig+2-3| ... | ... | @@ -327,9 +327,8 @@ pub fn libcFullLinkFlags(target: std.Target) []const []const u8 { |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | pub fn clangMightShellOutForAssembly(target: std.Target) bool { |
| 330 | // Clang defaults to using the system assembler over the internal one | |
| 331 | // when targeting a non-BSD OS. | |
| 332 | return target.cpu.arch.isSPARC(); | |
| 330 | // Clang defaults to using the system assembler in some cases. | |
| 331 | return target.cpu.arch.isNvptx() or target.cpu.arch == .xcore; | |
| 333 | 332 | } |
| 334 | 333 | |
| 335 | 334 | /// Each backend architecture in Clang has a different codepath which may or may not |
src/wasi_libc.zig+7-8| ... | ... | @@ -81,7 +81,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 81 | 81 | .owner = undefined, |
| 82 | 82 | }, |
| 83 | 83 | }; |
| 84 | return comp.build_crt_file("crt1-reactor", .Obj, null, .@"wasi crt1-reactor.o", prog_node, &files); | |
| 84 | return comp.build_crt_file("crt1-reactor", .Obj, .@"wasi crt1-reactor.o", prog_node, &files, .{}); | |
| 85 | 85 | }, |
| 86 | 86 | .crt1_command_o => { |
| 87 | 87 | var args = std.ArrayList([]const u8).init(arena); |
| ... | ... | @@ -96,7 +96,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 96 | 96 | .owner = undefined, |
| 97 | 97 | }, |
| 98 | 98 | }; |
| 99 | return comp.build_crt_file("crt1-command", .Obj, null, .@"wasi crt1-command.o", prog_node, &files); | |
| 99 | return comp.build_crt_file("crt1-command", .Obj, .@"wasi crt1-command.o", prog_node, &files, .{}); | |
| 100 | 100 | }, |
| 101 | 101 | .libc_a => { |
| 102 | 102 | var libc_sources = std.ArrayList(Compilation.CSourceFile).init(arena); |
| ... | ... | @@ -150,7 +150,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | try comp.build_crt_file("c", .Lib, null, .@"wasi libc.a", prog_node, libc_sources.items); | |
| 153 | try comp.build_crt_file("c", .Lib, .@"wasi libc.a", prog_node, libc_sources.items, .{}); | |
| 154 | 154 | }, |
| 155 | 155 | .libwasi_emulated_process_clocks_a => { |
| 156 | 156 | var args = std.ArrayList([]const u8).init(arena); |
| ... | ... | @@ -167,7 +167,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 167 | 167 | .owner = undefined, |
| 168 | 168 | }); |
| 169 | 169 | } |
| 170 | try comp.build_crt_file("wasi-emulated-process-clocks", .Lib, null, .@"libwasi-emulated-process-clocks.a", prog_node, emu_clocks_sources.items); | |
| 170 | try comp.build_crt_file("wasi-emulated-process-clocks", .Lib, .@"libwasi-emulated-process-clocks.a", prog_node, emu_clocks_sources.items, .{}); | |
| 171 | 171 | }, |
| 172 | 172 | .libwasi_emulated_getpid_a => { |
| 173 | 173 | var args = std.ArrayList([]const u8).init(arena); |
| ... | ... | @@ -184,7 +184,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 184 | 184 | .owner = undefined, |
| 185 | 185 | }); |
| 186 | 186 | } |
| 187 | try comp.build_crt_file("wasi-emulated-getpid", .Lib, null, .@"libwasi-emulated-getpid.a", prog_node, emu_getpid_sources.items); | |
| 187 | try comp.build_crt_file("wasi-emulated-getpid", .Lib, .@"libwasi-emulated-getpid.a", prog_node, emu_getpid_sources.items, .{}); | |
| 188 | 188 | }, |
| 189 | 189 | .libwasi_emulated_mman_a => { |
| 190 | 190 | var args = std.ArrayList([]const u8).init(arena); |
| ... | ... | @@ -201,7 +201,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 201 | 201 | .owner = undefined, |
| 202 | 202 | }); |
| 203 | 203 | } |
| 204 | try comp.build_crt_file("wasi-emulated-mman", .Lib, null, .@"libwasi-emulated-mman.a", prog_node, emu_mman_sources.items); | |
| 204 | try comp.build_crt_file("wasi-emulated-mman", .Lib, .@"libwasi-emulated-mman.a", prog_node, emu_mman_sources.items, .{}); | |
| 205 | 205 | }, |
| 206 | 206 | .libwasi_emulated_signal_a => { |
| 207 | 207 | var emu_signal_sources = std.ArrayList(Compilation.CSourceFile).init(arena); |
| ... | ... | @@ -238,7 +238,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 238 | 238 | } |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | try comp.build_crt_file("wasi-emulated-signal", .Lib, null, .@"libwasi-emulated-signal.a", prog_node, emu_signal_sources.items); | |
| 241 | try comp.build_crt_file("wasi-emulated-signal", .Lib, .@"libwasi-emulated-signal.a", prog_node, emu_signal_sources.items, .{}); | |
| 242 | 242 | }, |
| 243 | 243 | } |
| 244 | 244 | } |
| ... | ... | @@ -279,7 +279,6 @@ fn addCCArgs( |
| 279 | 279 | try args.appendSlice(&[_][]const u8{ |
| 280 | 280 | "-std=gnu17", |
| 281 | 281 | "-fno-trapping-math", |
| 282 | "-fno-stack-protector", | |
| 283 | 282 | "-w", // ignore all warnings |
| 284 | 283 | |
| 285 | 284 | o_arg, |