| author | |
| committer | |
| log | 4c70aea460d0cf4a5c1f77ec662837680e272220 |
| tree | f20b65234d2f7e949d18fdd9d4f54c39924c65f3 |
| parent | 39abcc303c471c0180cdb0f5dce4303bbbe45362 |
| signature |
addCCArgs() will then pass the appropriate flag to Clang.5 files changed, 23 insertions(+), 23 deletions(-)
src/Compilation.zig+3-1| ... | @@ -6266,6 +6266,7 @@ pub fn build_crt_file( | ... | @@ -6266,6 +6266,7 @@ pub fn build_crt_file( |
| 6266 | comp: *Compilation, | 6266 | comp: *Compilation, |
| 6267 | root_name: []const u8, | 6267 | root_name: []const u8, |
| 6268 | output_mode: std.builtin.OutputMode, | 6268 | output_mode: std.builtin.OutputMode, |
| 6269 | pic: ?bool, | ||
| 6269 | misc_task_tag: MiscTask, | 6270 | misc_task_tag: MiscTask, |
| 6270 | prog_node: std.Progress.Node, | 6271 | prog_node: std.Progress.Node, |
| 6271 | /// These elements have to get mutated to add the owner module after it is | 6272 | /// These elements have to get mutated to add the owner module after it is |
| ... | @@ -6318,7 +6319,8 @@ pub fn build_crt_file( | ... | @@ -6318,7 +6319,8 @@ pub fn build_crt_file( |
| 6318 | .omit_frame_pointer = comp.root_mod.omit_frame_pointer, | 6319 | .omit_frame_pointer = comp.root_mod.omit_frame_pointer, |
| 6319 | .valgrind = false, | 6320 | .valgrind = false, |
| 6320 | .unwind_tables = false, | 6321 | .unwind_tables = false, |
| 6321 | .pic = comp.root_mod.pic, | 6322 | // Some CRT objects (rcrt1.o, Scrt1.o) are opinionated about PIC. |
| 6323 | .pic = pic orelse comp.root_mod.pic, | ||
| 6322 | .optimize_mode = comp.compilerRtOptMode(), | 6324 | .optimize_mode = comp.compilerRtOptMode(), |
| 6323 | .structured_cfg = comp.root_mod.structured_cfg, | 6325 | .structured_cfg = comp.root_mod.structured_cfg, |
| 6324 | }, | 6326 | }, |
src/glibc.zig+4-4| ... | @@ -221,7 +221,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre | ... | @@ -221,7 +221,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 221 | .owner = comp.root_mod, | 221 | .owner = comp.root_mod, |
| 222 | }, | 222 | }, |
| 223 | }; | 223 | }; |
| 224 | return comp.build_crt_file("crti", .Obj, .@"glibc crti.o", prog_node, &files); | 224 | return comp.build_crt_file("crti", .Obj, null, .@"glibc crti.o", prog_node, &files); |
| 225 | }, | 225 | }, |
| 226 | .crtn_o => { | 226 | .crtn_o => { |
| 227 | var args = std.ArrayList([]const u8).init(arena); | 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,7 +242,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 242 | .owner = undefined, | 242 | .owner = undefined, |
| 243 | }, | 243 | }, |
| 244 | }; | 244 | }; |
| 245 | return comp.build_crt_file("crtn", .Obj, .@"glibc crtn.o", prog_node, &files); | 245 | return comp.build_crt_file("crtn", .Obj, null, .@"glibc crtn.o", prog_node, &files); |
| 246 | }, | 246 | }, |
| 247 | .scrt1_o => { | 247 | .scrt1_o => { |
| 248 | const start_o: Compilation.CSourceFile = blk: { | 248 | const start_o: Compilation.CSourceFile = blk: { |
| ... | @@ -295,7 +295,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre | ... | @@ -295,7 +295,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 295 | }; | 295 | }; |
| 296 | var files = [_]Compilation.CSourceFile{ start_o, abi_note_o, init_o }; | 296 | var files = [_]Compilation.CSourceFile{ start_o, abi_note_o, init_o }; |
| 297 | const basename = if (comp.config.output_mode == .Exe and !comp.config.pie) "crt1" else "Scrt1"; | 297 | const basename = if (comp.config.output_mode == .Exe and !comp.config.pie) "crt1" else "Scrt1"; |
| 298 | return comp.build_crt_file(basename, .Obj, .@"glibc Scrt1.o", prog_node, &files); | 298 | return comp.build_crt_file(basename, .Obj, null, .@"glibc Scrt1.o", prog_node, &files); |
| 299 | }, | 299 | }, |
| 300 | .libc_nonshared_a => { | 300 | .libc_nonshared_a => { |
| 301 | const s = path.sep_str; | 301 | const s = path.sep_str; |
| ... | @@ -413,7 +413,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre | ... | @@ -413,7 +413,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 413 | files_index += 1; | 413 | files_index += 1; |
| 414 | } | 414 | } |
| 415 | const files = files_buf[0..files_index]; | 415 | const files = files_buf[0..files_index]; |
| 416 | return comp.build_crt_file("c_nonshared", .Lib, .@"glibc libc_nonshared.a", prog_node, files); | 416 | return comp.build_crt_file("c_nonshared", .Lib, null, .@"glibc libc_nonshared.a", prog_node, files); |
| 417 | }, | 417 | }, |
| 418 | } | 418 | } |
| 419 | } | 419 | } |
src/mingw.zig+3-3| ... | @@ -41,7 +41,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre | ... | @@ -41,7 +41,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 41 | .owner = undefined, | 41 | .owner = undefined, |
| 42 | }, | 42 | }, |
| 43 | }; | 43 | }; |
| 44 | return comp.build_crt_file("crt2", .Obj, .@"mingw-w64 crt2.o", prog_node, &files); | 44 | return comp.build_crt_file("crt2", .Obj, null, .@"mingw-w64 crt2.o", prog_node, &files); |
| 45 | }, | 45 | }, |
| 46 | 46 | ||
| 47 | .dllcrt2_o => { | 47 | .dllcrt2_o => { |
| ... | @@ -56,7 +56,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre | ... | @@ -56,7 +56,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 56 | .owner = undefined, | 56 | .owner = undefined, |
| 57 | }, | 57 | }, |
| 58 | }; | 58 | }; |
| 59 | return comp.build_crt_file("dllcrt2", .Obj, .@"mingw-w64 dllcrt2.o", prog_node, &files); | 59 | return comp.build_crt_file("dllcrt2", .Obj, null, .@"mingw-w64 dllcrt2.o", prog_node, &files); |
| 60 | }, | 60 | }, |
| 61 | 61 | ||
| 62 | .mingw32_lib => { | 62 | .mingw32_lib => { |
| ... | @@ -118,7 +118,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre | ... | @@ -118,7 +118,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 118 | } else { | 118 | } else { |
| 119 | @panic("unsupported arch"); | 119 | @panic("unsupported arch"); |
| 120 | } | 120 | } |
| 121 | return comp.build_crt_file("mingw32", .Lib, .@"mingw-w64 mingw32.lib", prog_node, c_source_files.items); | 121 | return comp.build_crt_file("mingw32", .Lib, null, .@"mingw-w64 mingw32.lib", prog_node, c_source_files.items); |
| 122 | }, | 122 | }, |
| 123 | } | 123 | } |
| 124 | } | 124 | } |
src/musl.zig+6-8| ... | @@ -39,7 +39,7 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro | ... | @@ -39,7 +39,7 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro |
| 39 | .owner = undefined, | 39 | .owner = undefined, |
| 40 | }, | 40 | }, |
| 41 | }; | 41 | }; |
| 42 | return comp.build_crt_file("crti", .Obj, .@"musl crti.o", prog_node, &files); | 42 | return comp.build_crt_file("crti", .Obj, null, .@"musl crti.o", prog_node, &files); |
| 43 | }, | 43 | }, |
| 44 | .crtn_o => { | 44 | .crtn_o => { |
| 45 | var args = std.ArrayList([]const u8).init(arena); | 45 | var args = std.ArrayList([]const u8).init(arena); |
| ... | @@ -51,7 +51,7 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro | ... | @@ -51,7 +51,7 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro |
| 51 | .owner = undefined, | 51 | .owner = undefined, |
| 52 | }, | 52 | }, |
| 53 | }; | 53 | }; |
| 54 | return comp.build_crt_file("crtn", .Obj, .@"musl crtn.o", prog_node, &files); | 54 | return comp.build_crt_file("crtn", .Obj, null, .@"musl crtn.o", prog_node, &files); |
| 55 | }, | 55 | }, |
| 56 | .crt1_o => { | 56 | .crt1_o => { |
| 57 | var args = std.ArrayList([]const u8).init(arena); | 57 | var args = std.ArrayList([]const u8).init(arena); |
| ... | @@ -69,13 +69,12 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro | ... | @@ -69,13 +69,12 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro |
| 69 | .owner = undefined, | 69 | .owner = undefined, |
| 70 | }, | 70 | }, |
| 71 | }; | 71 | }; |
| 72 | return comp.build_crt_file("crt1", .Obj, .@"musl crt1.o", prog_node, &files); | 72 | return comp.build_crt_file("crt1", .Obj, null, .@"musl crt1.o", prog_node, &files); |
| 73 | }, | 73 | }, |
| 74 | .rcrt1_o => { | 74 | .rcrt1_o => { |
| 75 | var args = std.ArrayList([]const u8).init(arena); | 75 | var args = std.ArrayList([]const u8).init(arena); |
| 76 | try addCcArgs(comp, arena, &args, false); | 76 | try addCcArgs(comp, arena, &args, false); |
| 77 | try args.appendSlice(&[_][]const u8{ | 77 | try args.appendSlice(&[_][]const u8{ |
| 78 | "-fPIC", | ||
| 79 | "-fno-stack-protector", | 78 | "-fno-stack-protector", |
| 80 | "-DCRT", | 79 | "-DCRT", |
| 81 | }); | 80 | }); |
| ... | @@ -88,13 +87,12 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro | ... | @@ -88,13 +87,12 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro |
| 88 | .owner = undefined, | 87 | .owner = undefined, |
| 89 | }, | 88 | }, |
| 90 | }; | 89 | }; |
| 91 | return comp.build_crt_file("rcrt1", .Obj, .@"musl rcrt1.o", prog_node, &files); | 90 | return comp.build_crt_file("rcrt1", .Obj, true, .@"musl rcrt1.o", prog_node, &files); |
| 92 | }, | 91 | }, |
| 93 | .scrt1_o => { | 92 | .scrt1_o => { |
| 94 | var args = std.ArrayList([]const u8).init(arena); | 93 | var args = std.ArrayList([]const u8).init(arena); |
| 95 | try addCcArgs(comp, arena, &args, false); | 94 | try addCcArgs(comp, arena, &args, false); |
| 96 | try args.appendSlice(&[_][]const u8{ | 95 | try args.appendSlice(&[_][]const u8{ |
| 97 | "-fPIC", | ||
| 98 | "-fno-stack-protector", | 96 | "-fno-stack-protector", |
| 99 | "-DCRT", | 97 | "-DCRT", |
| 100 | }); | 98 | }); |
| ... | @@ -107,7 +105,7 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro | ... | @@ -107,7 +105,7 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro |
| 107 | .owner = undefined, | 105 | .owner = undefined, |
| 108 | }, | 106 | }, |
| 109 | }; | 107 | }; |
| 110 | return comp.build_crt_file("Scrt1", .Obj, .@"musl Scrt1.o", prog_node, &files); | 108 | return comp.build_crt_file("Scrt1", .Obj, true, .@"musl Scrt1.o", prog_node, &files); |
| 111 | }, | 109 | }, |
| 112 | .libc_a => { | 110 | .libc_a => { |
| 113 | // When there is a src/<arch>/foo.* then it should substitute for src/foo.* | 111 | // When there is a src/<arch>/foo.* then it should substitute for src/foo.* |
| ... | @@ -190,7 +188,7 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro | ... | @@ -190,7 +188,7 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro |
| 190 | .owner = undefined, | 188 | .owner = undefined, |
| 191 | }; | 189 | }; |
| 192 | } | 190 | } |
| 193 | return comp.build_crt_file("c", .Lib, .@"musl libc.a", prog_node, c_source_files.items); | 191 | return comp.build_crt_file("c", .Lib, null, .@"musl libc.a", prog_node, c_source_files.items); |
| 194 | }, | 192 | }, |
| 195 | .libc_so => { | 193 | .libc_so => { |
| 196 | const optimize_mode = comp.compilerRtOptMode(); | 194 | const optimize_mode = comp.compilerRtOptMode(); |
src/wasi_libc.zig+7-7| ... | @@ -81,7 +81,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre | ... | @@ -81,7 +81,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 81 | .owner = undefined, | 81 | .owner = undefined, |
| 82 | }, | 82 | }, |
| 83 | }; | 83 | }; |
| 84 | return comp.build_crt_file("crt1-reactor", .Obj, .@"wasi crt1-reactor.o", prog_node, &files); | 84 | return comp.build_crt_file("crt1-reactor", .Obj, null, .@"wasi crt1-reactor.o", prog_node, &files); |
| 85 | }, | 85 | }, |
| 86 | .crt1_command_o => { | 86 | .crt1_command_o => { |
| 87 | var args = std.ArrayList([]const u8).init(arena); | 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,7 +96,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 96 | .owner = undefined, | 96 | .owner = undefined, |
| 97 | }, | 97 | }, |
| 98 | }; | 98 | }; |
| 99 | return comp.build_crt_file("crt1-command", .Obj, .@"wasi crt1-command.o", prog_node, &files); | 99 | return comp.build_crt_file("crt1-command", .Obj, null, .@"wasi crt1-command.o", prog_node, &files); |
| 100 | }, | 100 | }, |
| 101 | .libc_a => { | 101 | .libc_a => { |
| 102 | var libc_sources = std.ArrayList(Compilation.CSourceFile).init(arena); | 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,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, .@"wasi libc.a", prog_node, libc_sources.items); | 153 | try comp.build_crt_file("c", .Lib, null, .@"wasi libc.a", prog_node, libc_sources.items); |
| 154 | }, | 154 | }, |
| 155 | .libwasi_emulated_process_clocks_a => { | 155 | .libwasi_emulated_process_clocks_a => { |
| 156 | var args = std.ArrayList([]const u8).init(arena); | 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,7 +167,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 167 | .owner = undefined, | 167 | .owner = undefined, |
| 168 | }); | 168 | }); |
| 169 | } | 169 | } |
| 170 | try comp.build_crt_file("wasi-emulated-process-clocks", .Lib, .@"libwasi-emulated-process-clocks.a", prog_node, emu_clocks_sources.items); | 170 | try comp.build_crt_file("wasi-emulated-process-clocks", .Lib, null, .@"libwasi-emulated-process-clocks.a", prog_node, emu_clocks_sources.items); |
| 171 | }, | 171 | }, |
| 172 | .libwasi_emulated_getpid_a => { | 172 | .libwasi_emulated_getpid_a => { |
| 173 | var args = std.ArrayList([]const u8).init(arena); | 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,7 +184,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 184 | .owner = undefined, | 184 | .owner = undefined, |
| 185 | }); | 185 | }); |
| 186 | } | 186 | } |
| 187 | try comp.build_crt_file("wasi-emulated-getpid", .Lib, .@"libwasi-emulated-getpid.a", prog_node, emu_getpid_sources.items); | 187 | try comp.build_crt_file("wasi-emulated-getpid", .Lib, null, .@"libwasi-emulated-getpid.a", prog_node, emu_getpid_sources.items); |
| 188 | }, | 188 | }, |
| 189 | .libwasi_emulated_mman_a => { | 189 | .libwasi_emulated_mman_a => { |
| 190 | var args = std.ArrayList([]const u8).init(arena); | 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,7 +201,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 201 | .owner = undefined, | 201 | .owner = undefined, |
| 202 | }); | 202 | }); |
| 203 | } | 203 | } |
| 204 | try comp.build_crt_file("wasi-emulated-mman", .Lib, .@"libwasi-emulated-mman.a", prog_node, emu_mman_sources.items); | 204 | try comp.build_crt_file("wasi-emulated-mman", .Lib, null, .@"libwasi-emulated-mman.a", prog_node, emu_mman_sources.items); |
| 205 | }, | 205 | }, |
| 206 | .libwasi_emulated_signal_a => { | 206 | .libwasi_emulated_signal_a => { |
| 207 | var emu_signal_sources = std.ArrayList(Compilation.CSourceFile).init(arena); | 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,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, .@"libwasi-emulated-signal.a", prog_node, emu_signal_sources.items); | 241 | try comp.build_crt_file("wasi-emulated-signal", .Lib, null, .@"libwasi-emulated-signal.a", prog_node, emu_signal_sources.items); |
| 242 | }, | 242 | }, |
| 243 | } | 243 | } |
| 244 | } | 244 | } |