authorgravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2022-11-17 02:12:56-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-11-17 11:08:21-05:00
log88a0f3d0e55691aa2b341cfa6efc53f2540b22f9
treec39475e7138a3843fb7121d2c70e83e38af3ed15
parent7cfeae1ce7aa9f1b3a219d032c43bc2e694ba63b

windows: fix _tls_index not being defined if libc wasn't linked, and fix x86 name mangling


1 files changed, 12 insertions(+), 4 deletions(-)

src/Compilation.zig+12-4
...@@ -2042,10 +2042,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {...@@ -2042,10 +2042,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
2042 for (mingw.always_link_libs) |name| {2042 for (mingw.always_link_libs) |name| {
2043 try comp.bin_file.options.system_libs.put(comp.gpa, name, .{});2043 try comp.bin_file.options.system_libs.put(comp.gpa, name, .{});
2044 }2044 }
2045
2046 // LLD might drop some symbols as unused during LTO and GCing, therefore,
2047 // we force mark them for resolution here.
2048 try comp.bin_file.options.force_undefined_symbols.put(comp.gpa, "_tls_index", {});
2049 }2045 }
2050 // Generate Windows import libs.2046 // Generate Windows import libs.
2051 if (target.os.tag == .windows) {2047 if (target.os.tag == .windows) {
...@@ -2067,6 +2063,18 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {...@@ -2067,6 +2063,18 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
2067 try comp.work_queue.writeItem(.libtsan);2063 try comp.work_queue.writeItem(.libtsan);
2068 }2064 }
20692065
2066 if (comp.getTarget().isMinGW() and !comp.bin_file.options.single_threaded) {
2067 // LLD might drop some symbols as unused during LTO and GCing, therefore,
2068 // we force mark them for resolution here.
2069
2070 var tls_index_sym = switch (comp.getTarget().cpu.arch) {
2071 .x86 => "__tls_index",
2072 else => "_tls_index",
2073 };
2074
2075 try comp.bin_file.options.force_undefined_symbols.put(comp.gpa, tls_index_sym, {});
2076 }
2077
2070 if (comp.bin_file.options.include_compiler_rt and capable_of_building_compiler_rt) {2078 if (comp.bin_file.options.include_compiler_rt and capable_of_building_compiler_rt) {
2071 if (is_exe_or_dyn_lib) {2079 if (is_exe_or_dyn_lib) {
2072 log.debug("queuing a job to build compiler_rt_lib", .{});2080 log.debug("queuing a job to build compiler_rt_lib", .{});