authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-21 21:42:27-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-21 21:42:27-07:00
log974333faaf70eb67b78d3fa83bdc92e91379631a
treef7f59ef4df3bc2390ff2d06af25fba213f9fc9ce
parent0c70bb4fce8b0460f86ed218f54ba31b291f2bfb

stage2: fix linking libc trying to depend on itself


4 files changed, 9 insertions(+), 3 deletions(-)

src/Compilation.zig+4-2
......@@ -324,6 +324,8 @@ pub const InitOptions = struct {
324324 verbose_cimport: bool = false,
325325 verbose_llvm_cpu_features: bool = false,
326326 is_test: bool = false,
327 test_evented_io: bool = false,
328 is_compiler_rt_or_libc: bool = false,
327329 stack_size_override: ?u64 = null,
328330 self_exe_path: ?[]const u8 = null,
329331 version: ?std.builtin.Version = null,
......@@ -333,7 +335,6 @@ pub const InitOptions = struct {
333335 color: @import("main.zig").Color = .Auto,
334336 test_filter: ?[]const u8 = null,
335337 test_name_prefix: ?[]const u8 = null,
336 test_evented_io: bool = false,
337338};
338339
339340pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
......@@ -704,9 +705,9 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
704705 .dll_export_fns = dll_export_fns,
705706 .error_return_tracing = error_return_tracing,
706707 .llvm_cpu_features = llvm_cpu_features,
708 .is_compiler_rt_or_libc = options.is_compiler_rt_or_libc,
707709 });
708710 errdefer bin_file.destroy();
709
710711 comp.* = .{
711712 .gpa = gpa,
712713 .arena_state = arena_allocator.state,
......@@ -2116,6 +2117,7 @@ fn buildStaticLibFromZig(comp: *Compilation, basename: []const u8, out: *?CRTFil
21162117 .verbose_cimport = comp.verbose_cimport,
21172118 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
21182119 .clang_passthrough_mode = comp.clang_passthrough_mode,
2120 .is_compiler_rt_or_libc = true,
21192121 });
21202122 defer sub_compilation.destroy();
21212123
src/glibc.zig+2
......@@ -720,6 +720,7 @@ fn build_crt_file(
720720 .verbose_cimport = comp.verbose_cimport,
721721 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
722722 .clang_passthrough_mode = comp.clang_passthrough_mode,
723 .is_compiler_rt_or_libc = true,
723724 });
724725 defer sub_compilation.destroy();
725726
......@@ -1006,6 +1007,7 @@ fn buildSharedLib(
10061007 .version_script = map_file_path,
10071008 .override_soname = override_soname,
10081009 .c_source_files = &c_source_files,
1010 .is_compiler_rt_or_libc = true,
10091011 });
10101012 defer sub_compilation.destroy();
10111013
src/link.zig+1
......@@ -64,6 +64,7 @@ pub const Options = struct {
6464 verbose_link: bool = false,
6565 dll_export_fns: bool,
6666 error_return_tracing: bool,
67 is_compiler_rt_or_libc: bool,
6768 gc_sections: ?bool = null,
6869 allow_shlib_undefined: ?bool = null,
6970 linker_script: ?[]const u8 = null,
src/link/Elf.zig+2-1
......@@ -1272,6 +1272,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
12721272 ch.hash.add(self.base.options.rdynamic);
12731273 ch.hash.addListOfBytes(self.base.options.extra_lld_args);
12741274 ch.hash.addListOfBytes(self.base.options.lib_dirs);
1275 ch.hash.add(self.base.options.is_compiler_rt_or_libc);
12751276 ch.hash.add(self.base.options.z_nodelete);
12761277 ch.hash.add(self.base.options.z_defs);
12771278 if (self.base.options.link_libc) {
......@@ -1491,7 +1492,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
14911492 }
14921493
14931494 // compiler-rt and libc
1494 if (is_exe_or_dyn_lib) {
1495 if (is_exe_or_dyn_lib and !self.base.options.is_compiler_rt_or_libc) {
14951496 if (!self.base.options.link_libc) {
14961497 try argv.append(comp.libc_static_lib.?.full_object_path);
14971498 }