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
This commit is contained in:
xavier 2021-05-02 16:46:46 +02:00 committed by Andrew Kelley
parent 353c19468d
commit 564629f704

View File

@ -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,