link: Set machine and float ABI when invoking ld.lld and lld-link.
If this isn't done, LTO can completely miscompile the input bitcode modules for certain targets where we need to explicitly set these ABIs (because LLVM's defaults are bad).
This commit is contained in:
@@ -1876,6 +1876,13 @@ fn linkWithLLD(coff: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_node:
|
||||
if (comp.version) |version| {
|
||||
try argv.append(try allocPrint(arena, "-VERSION:{}.{}", .{ version.major, version.minor }));
|
||||
}
|
||||
|
||||
if (target_util.llvmMachineAbi(target)) |mabi| {
|
||||
try argv.append(try allocPrint(arena, "-MLLVM:-target-abi={s}", .{mabi}));
|
||||
}
|
||||
|
||||
try argv.append(try allocPrint(arena, "-MLLVM:-float-abi={s}", .{if (target.abi.floatAbi() == .hard) "hard" else "soft"}));
|
||||
|
||||
if (comp.config.lto != .none) {
|
||||
switch (optimize_mode) {
|
||||
.Debug => {},
|
||||
|
||||
@@ -1700,6 +1700,18 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s
|
||||
try argv.append(try std.fmt.allocPrint(arena, "--sysroot={s}", .{sysroot}));
|
||||
}
|
||||
|
||||
if (target_util.llvmMachineAbi(target)) |mabi| {
|
||||
try argv.appendSlice(&.{
|
||||
"-mllvm",
|
||||
try std.fmt.allocPrint(arena, "-target-abi={s}", .{mabi}),
|
||||
});
|
||||
}
|
||||
|
||||
try argv.appendSlice(&.{
|
||||
"-mllvm",
|
||||
try std.fmt.allocPrint(arena, "-float-abi={s}", .{if (target.abi.floatAbi() == .hard) "hard" else "soft"}),
|
||||
});
|
||||
|
||||
if (comp.config.lto != .none) {
|
||||
switch (comp.root_mod.optimize_mode) {
|
||||
.Debug => {},
|
||||
|
||||
Reference in New Issue
Block a user