Commit 564629f704

xavier <xavierb@gmail.com>
2021-05-02 16:46:46
build: workaround link error with LTO and mingw
The symbol "_tls_index" gets lost when using LTO. Disabling LTO on the object file that defines it allows the link to work. fixes https://github.com/ziglang/zig/issues/8531
1 parent 353c194
Changed files (1)
src/mingw.zig
@@ -92,6 +92,10 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
                     "-D_WIN32_WINNT=0x0f00",
                     "-D__MSVCRT_VERSION__=0x700",
                 });
+                if (std.mem.eql(u8, dep, "tlssup.c")) {
+                    // Can't let LTO drop symbols defined in this file (eg: _tls_index)
+                    try args.append("-fno-lto");
+                }
                 c_source_files[i] = .{
                     .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
                         "libc", "mingw", "crt", dep,