From 564629f70475a1e3b397179067e22d3f61772104 Mon Sep 17 00:00:00 2001 From: xavier Date: Sun, 2 May 2021 16:46:46 +0200 Subject: [PATCH] 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 --- src/mingw.zig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mingw.zig b/src/mingw.zig index c10dcbe3f0..b9d82ba784 100644 --- a/src/mingw.zig +++ b/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,