authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-08-25 03:10:41-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-08-25 03:10:41-07:00
log3a7ea0b65e4edb3e13218023eb667792ab2d0d51
treedd968bb9858a94003678975f81a31fbe8c29e5b3
parent7453f56e678c80928ababa2868c69cfe41647fed

fix order of CLI args passed to clang

Commit eb3f7d2f37cab1d3df7c4493b8239e802b83e521 changed the order of CLI args passed to clang, making object-specific "extra flags" passed first. However, these are supposed to be able to override other flags, and this behavior is exploited by workarounds in mingw.zig to disable LTO. This commit rectifies the situation by moving extra flags back to being passed after the call to addCCArgs().

1 files changed, 2 insertions(+), 1 deletions(-)

src/Compilation.zig+2-1
...@@ -3758,7 +3758,6 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P...@@ -3758,7 +3758,6 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P
3758 "clang",3758 "clang",
3759 c_object.src.src_path,3759 c_object.src.src_path,
3760 });3760 });
3761 try argv.appendSlice(c_object.src.extra_flags);
37623761
3763 const ext = classifyFileExt(c_object.src.src_path);3762 const ext = classifyFileExt(c_object.src.src_path);
37643763
...@@ -3771,6 +3770,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P...@@ -3771,6 +3770,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P
3771 comp.disable_c_depfile and comp.clang_passthrough_mode)3770 comp.disable_c_depfile and comp.clang_passthrough_mode)
3772 {3771 {
3773 try comp.addCCArgs(arena, &argv, ext, null);3772 try comp.addCCArgs(arena, &argv, ext, null);
3773 try argv.appendSlice(c_object.src.extra_flags);
37743774
3775 const out_obj_path = if (comp.bin_file.options.emit) |emit|3775 const out_obj_path = if (comp.bin_file.options.emit) |emit|
3776 try emit.directory.join(arena, &.{emit.sub_path})3776 try emit.directory.join(arena, &.{emit.sub_path})
...@@ -3811,6 +3811,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P...@@ -3811,6 +3811,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P
3811 else3811 else
3812 try std.fmt.allocPrint(arena, "{s}.d", .{out_obj_path});3812 try std.fmt.allocPrint(arena, "{s}.d", .{out_obj_path});
3813 try comp.addCCArgs(arena, &argv, ext, out_dep_path);3813 try comp.addCCArgs(arena, &argv, ext, out_dep_path);
3814 try argv.appendSlice(c_object.src.extra_flags);
38143815
3815 try argv.ensureUnusedCapacity(5);3816 try argv.ensureUnusedCapacity(5);
3816 switch (comp.clang_preprocessor_mode) {3817 switch (comp.clang_preprocessor_mode) {