authorgravatar for xavierb@gmail.comxavier <xavierb@gmail.com> 2021-05-02 16:46:46+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-11-15 16:15:39-07:00
log564629f70475a1e3b397179067e22d3f61772104
tree6253e413486c257db786657a9c19fc024227155d
parent353c19468df02db925a7b147cabb398d7e63de68

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 files changed, 4 insertions(+), 0 deletions(-)

src/mingw.zig+4
......@@ -92,6 +92,10 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
9292 "-D_WIN32_WINNT=0x0f00",
9393 "-D__MSVCRT_VERSION__=0x700",
9494 });
95 if (std.mem.eql(u8, dep, "tlssup.c")) {
96 // Can't let LTO drop symbols defined in this file (eg: _tls_index)
97 try args.append("-fno-lto");
98 }
9599 c_source_files[i] = .{
96100 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
97101 "libc", "mingw", "crt", dep,