commit 88a0f3d0e55691aa2b341cfa6efc53f2540b22f9 (tree)
parent 7cfeae1ce7aa9f1b3a219d032c43bc2e694ba63b
Author: kcbanner <kcbanner@gmail.com>
Date: Thu, 17 Nov 2022 02:12:56 -0500
windows: fix _tls_index not being defined if libc wasn't linked, and fix x86 name mangling
Diffstat:
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/Compilation.zig b/src/Compilation.zig
@@ -2042,10 +2042,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
for (mingw.always_link_libs) |name| {
try comp.bin_file.options.system_libs.put(comp.gpa, name, .{});
}
-
- // LLD might drop some symbols as unused during LTO and GCing, therefore,
- // we force mark them for resolution here.
- try comp.bin_file.options.force_undefined_symbols.put(comp.gpa, "_tls_index", {});
}
// Generate Windows import libs.
if (target.os.tag == .windows) {
@@ -2067,6 +2063,18 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
try comp.work_queue.writeItem(.libtsan);
}
+ if (comp.getTarget().isMinGW() and !comp.bin_file.options.single_threaded) {
+ // LLD might drop some symbols as unused during LTO and GCing, therefore,
+ // we force mark them for resolution here.
+
+ var tls_index_sym = switch (comp.getTarget().cpu.arch) {
+ .x86 => "__tls_index",
+ else => "_tls_index",
+ };
+
+ try comp.bin_file.options.force_undefined_symbols.put(comp.gpa, tls_index_sym, {});
+ }
+
if (comp.bin_file.options.include_compiler_rt and capable_of_building_compiler_rt) {
if (is_exe_or_dyn_lib) {
log.debug("queuing a job to build compiler_rt_lib", .{});