stage2: fix linking libc trying to depend on itself
This commit is contained in:
@@ -324,6 +324,8 @@ pub const InitOptions = struct {
|
||||
verbose_cimport: bool = false,
|
||||
verbose_llvm_cpu_features: bool = false,
|
||||
is_test: bool = false,
|
||||
test_evented_io: bool = false,
|
||||
is_compiler_rt_or_libc: bool = false,
|
||||
stack_size_override: ?u64 = null,
|
||||
self_exe_path: ?[]const u8 = null,
|
||||
version: ?std.builtin.Version = null,
|
||||
@@ -333,7 +335,6 @@ pub const InitOptions = struct {
|
||||
color: @import("main.zig").Color = .Auto,
|
||||
test_filter: ?[]const u8 = null,
|
||||
test_name_prefix: ?[]const u8 = null,
|
||||
test_evented_io: bool = false,
|
||||
};
|
||||
|
||||
pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
|
||||
@@ -704,9 +705,9 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
|
||||
.dll_export_fns = dll_export_fns,
|
||||
.error_return_tracing = error_return_tracing,
|
||||
.llvm_cpu_features = llvm_cpu_features,
|
||||
.is_compiler_rt_or_libc = options.is_compiler_rt_or_libc,
|
||||
});
|
||||
errdefer bin_file.destroy();
|
||||
|
||||
comp.* = .{
|
||||
.gpa = gpa,
|
||||
.arena_state = arena_allocator.state,
|
||||
@@ -2116,6 +2117,7 @@ fn buildStaticLibFromZig(comp: *Compilation, basename: []const u8, out: *?CRTFil
|
||||
.verbose_cimport = comp.verbose_cimport,
|
||||
.verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
|
||||
.clang_passthrough_mode = comp.clang_passthrough_mode,
|
||||
.is_compiler_rt_or_libc = true,
|
||||
});
|
||||
defer sub_compilation.destroy();
|
||||
|
||||
|
||||
@@ -720,6 +720,7 @@ fn build_crt_file(
|
||||
.verbose_cimport = comp.verbose_cimport,
|
||||
.verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
|
||||
.clang_passthrough_mode = comp.clang_passthrough_mode,
|
||||
.is_compiler_rt_or_libc = true,
|
||||
});
|
||||
defer sub_compilation.destroy();
|
||||
|
||||
@@ -1006,6 +1007,7 @@ fn buildSharedLib(
|
||||
.version_script = map_file_path,
|
||||
.override_soname = override_soname,
|
||||
.c_source_files = &c_source_files,
|
||||
.is_compiler_rt_or_libc = true,
|
||||
});
|
||||
defer sub_compilation.destroy();
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ pub const Options = struct {
|
||||
verbose_link: bool = false,
|
||||
dll_export_fns: bool,
|
||||
error_return_tracing: bool,
|
||||
is_compiler_rt_or_libc: bool,
|
||||
gc_sections: ?bool = null,
|
||||
allow_shlib_undefined: ?bool = null,
|
||||
linker_script: ?[]const u8 = null,
|
||||
|
||||
@@ -1272,6 +1272,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
|
||||
ch.hash.add(self.base.options.rdynamic);
|
||||
ch.hash.addListOfBytes(self.base.options.extra_lld_args);
|
||||
ch.hash.addListOfBytes(self.base.options.lib_dirs);
|
||||
ch.hash.add(self.base.options.is_compiler_rt_or_libc);
|
||||
ch.hash.add(self.base.options.z_nodelete);
|
||||
ch.hash.add(self.base.options.z_defs);
|
||||
if (self.base.options.link_libc) {
|
||||
@@ -1491,7 +1492,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
|
||||
}
|
||||
|
||||
// compiler-rt and libc
|
||||
if (is_exe_or_dyn_lib) {
|
||||
if (is_exe_or_dyn_lib and !self.base.options.is_compiler_rt_or_libc) {
|
||||
if (!self.base.options.link_libc) {
|
||||
try argv.append(comp.libc_static_lib.?.full_object_path);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user