From 3a7ea0b65e4edb3e13218023eb667792ab2d0d51 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 25 Aug 2022 03:10:41 -0700 Subject: 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(). --- src/Compilation.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Compilation.zig') diff --git a/src/Compilation.zig b/src/Compilation.zig index d6bf121adb..03d7962ccc 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -3758,7 +3758,6 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P "clang", c_object.src.src_path, }); - try argv.appendSlice(c_object.src.extra_flags); const ext = classifyFileExt(c_object.src.src_path); @@ -3771,6 +3770,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P comp.disable_c_depfile and comp.clang_passthrough_mode) { try comp.addCCArgs(arena, &argv, ext, null); + try argv.appendSlice(c_object.src.extra_flags); const out_obj_path = if (comp.bin_file.options.emit) |emit| 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 else try std.fmt.allocPrint(arena, "{s}.d", .{out_obj_path}); try comp.addCCArgs(arena, &argv, ext, out_dep_path); + try argv.appendSlice(c_object.src.extra_flags); try argv.ensureUnusedCapacity(5); switch (comp.clang_preprocessor_mode) { -- cgit v1.2.3