From 19aab5302c71edccae7959065062fd1695a396aa Mon Sep 17 00:00:00 2001 From: Evan Haas Date: Fri, 30 Apr 2021 23:07:40 -0700 Subject: translate-c: Ensure extra_cflags are passed to clang Additionally ensure that the Zig cache incorporates any extra cflags when using translate-c. Fixes the issue identified in #8662 --- src/Compilation.zig | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'src/Compilation.zig') diff --git a/src/Compilation.zig b/src/Compilation.zig index 71df776855..6a9f75acf5 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -2260,23 +2260,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_comp_progress_node: * man.hash.add(comp.clang_preprocessor_mode); - _ = try man.addFile(c_object.src.src_path, null); - { - // Hash the extra flags, with special care to call addFile for file parameters. - // TODO this logic can likely be improved by utilizing clang_options_data.zig. - const file_args = [_][]const u8{"-include"}; - var arg_i: usize = 0; - while (arg_i < c_object.src.extra_flags.len) : (arg_i += 1) { - const arg = c_object.src.extra_flags[arg_i]; - man.hash.addBytes(arg); - for (file_args) |file_arg| { - if (mem.eql(u8, file_arg, arg) and arg_i + 1 < c_object.src.extra_flags.len) { - arg_i += 1; - _ = try man.addFile(c_object.src.extra_flags[arg_i], null); - } - } - } - } + try man.hashCSource(c_object.src); { const is_collision = blk: { -- cgit v1.2.3 From 4b59f564344598b4d1f1a51839a4dc5cbf357012 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 12 May 2021 22:25:20 -0700 Subject: stage2: build and provide libunwind when compiling for native libc 5ac91794cce8bd53916a378815be01e4365d53d9 made Zig link against the system libc when targeting the native C ABI. However this made it stop putting libunwind.a on the linker line when it needed to sometimes, causing undefined symbols when linking against C++ code. --- src/Compilation.zig | 1 - src/link/Elf.zig | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Compilation.zig') diff --git a/src/Compilation.zig b/src/Compilation.zig index 6a9f75acf5..b14e598f71 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -3023,7 +3023,6 @@ fn wantBuildLibUnwindFromSource(comp: *Compilation) bool { .Exe => true, }; return comp.bin_file.options.link_libc and is_exe_or_dyn_lib and - comp.bin_file.options.libc_installation == null and target_util.libcNeedsLibUnwind(comp.getTarget()); } diff --git a/src/link/Elf.zig b/src/link/Elf.zig index 9a0aeabe6c..fbbe40022a 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -1648,6 +1648,9 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { // libc dep if (self.base.options.link_libc) { if (self.base.options.libc_installation != null) { + if (target_util.libcNeedsLibUnwind(target)) { + try argv.append(comp.libunwind_static_lib.?.full_object_path); + } const needs_grouping = self.base.options.link_mode == .Static; if (needs_grouping) try argv.append("--start-group"); try argv.appendSlice(target_util.libcFullLinkFlags(target)); -- cgit v1.2.3