mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 07:32:44 +00:00
zld: use zld when linking aarch64 by default and cross-comp
This commit is contained in:
parent
900658a85d
commit
7516dfff83
@ -564,7 +564,14 @@ set(ZIG_STAGE2_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/src/link/Coff.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/Elf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/Archive.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/CodeSignature.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/DebugSymbols.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/Object.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/Trie.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/Zld.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/bind.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/commands.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/Wasm.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/C/zig.h"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/msdos-stub.bin"
|
||||
|
@ -250,24 +250,6 @@ pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, c
|
||||
resetSegfaultHandler();
|
||||
}
|
||||
|
||||
if (comptime std.Target.current.isDarwin() and std.Target.current.cpu.arch == .aarch64)
|
||||
nosuspend {
|
||||
// As a workaround for not having threadlocal variable support in LLD for this target,
|
||||
// we have a simpler panic implementation that does not use threadlocal variables.
|
||||
// TODO https://github.com/ziglang/zig/issues/7527
|
||||
const stderr = io.getStdErr().writer();
|
||||
if (@atomicRmw(u8, &panicking, .Add, 1, .SeqCst) == 0) {
|
||||
stderr.print("panic: " ++ format ++ "\n", args) catch os.abort();
|
||||
if (trace) |t| {
|
||||
dumpStackTrace(t.*);
|
||||
}
|
||||
dumpCurrentStackTrace(first_trace_addr);
|
||||
} else {
|
||||
stderr.print("Panicked during a panic. Aborting.\n", .{}) catch os.abort();
|
||||
}
|
||||
os.abort();
|
||||
};
|
||||
|
||||
nosuspend switch (panic_stage) {
|
||||
0 => {
|
||||
panic_stage = 1;
|
||||
|
@ -447,7 +447,6 @@ pub const InitOptions = struct {
|
||||
want_lto: ?bool = null,
|
||||
use_llvm: ?bool = null,
|
||||
use_lld: ?bool = null,
|
||||
use_zld: ?bool = null,
|
||||
use_clang: ?bool = null,
|
||||
rdynamic: bool = false,
|
||||
strip: bool = false,
|
||||
@ -1021,7 +1020,6 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
|
||||
.link_mode = link_mode,
|
||||
.object_format = ofmt,
|
||||
.optimize_mode = options.optimize_mode,
|
||||
.use_zld = options.use_zld orelse false,
|
||||
.use_lld = use_lld,
|
||||
.use_llvm = use_llvm,
|
||||
.system_linker_hack = darwin_options.system_linker_hack,
|
||||
|
@ -61,8 +61,6 @@ pub const Options = struct {
|
||||
/// Darwin-only. If this is true, `use_llvm` is true, and `is_native_os` is true, this link code will
|
||||
/// use system linker `ld` instead of the LLD.
|
||||
system_linker_hack: bool,
|
||||
/// Experimental Zig linker.
|
||||
use_zld: bool,
|
||||
link_libc: bool,
|
||||
link_libcpp: bool,
|
||||
function_sections: bool,
|
||||
|
@ -634,12 +634,26 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
|
||||
try fs.cwd().copyFile(the_object_path, fs.cwd(), full_out_path, .{});
|
||||
}
|
||||
} else {
|
||||
// Create an LLD command line and invoke it.
|
||||
var argv = std.ArrayList([]const u8).init(self.base.allocator);
|
||||
defer argv.deinit();
|
||||
const use_zld = blk: {
|
||||
if (self.base.options.is_native_os and self.base.options.system_linker_hack) {
|
||||
break :blk false;
|
||||
}
|
||||
|
||||
if (true) {
|
||||
// if (self.base.options.use_zld) {
|
||||
if (self.base.options.target.cpu.arch == .aarch64) {
|
||||
break :blk true;
|
||||
}
|
||||
|
||||
if (self.base.options.link_libcpp or
|
||||
self.base.options.output_mode == .Lib or
|
||||
self.base.options.linker_script != null)
|
||||
{
|
||||
break :blk false;
|
||||
}
|
||||
|
||||
break :blk true;
|
||||
};
|
||||
|
||||
if (use_zld) {
|
||||
var zld = Zld.init(self.base.allocator);
|
||||
defer zld.deinit();
|
||||
zld.arch = target.cpu.arch;
|
||||
@ -663,6 +677,10 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
|
||||
return zld.link(input_files.items, full_out_path);
|
||||
}
|
||||
|
||||
// Create an LLD command line and invoke it.
|
||||
var argv = std.ArrayList([]const u8).init(self.base.allocator);
|
||||
defer argv.deinit();
|
||||
|
||||
// TODO https://github.com/ziglang/zig/issues/6971
|
||||
// Note that there is no need to check if running natively since we do that already
|
||||
// when setting `system_linker_hack` in Compilation struct.
|
||||
|
@ -547,7 +547,6 @@ fn buildOutputType(
|
||||
var image_base_override: ?u64 = null;
|
||||
var use_llvm: ?bool = null;
|
||||
var use_lld: ?bool = null;
|
||||
var use_zld: ?bool = null;
|
||||
var use_clang: ?bool = null;
|
||||
var link_eh_frame_hdr = false;
|
||||
var link_emit_relocs = false;
|
||||
@ -907,8 +906,6 @@ fn buildOutputType(
|
||||
use_lld = true;
|
||||
} else if (mem.eql(u8, arg, "-fno-LLD")) {
|
||||
use_lld = false;
|
||||
} else if (mem.eql(u8, arg, "-fZLD")) {
|
||||
use_zld = true;
|
||||
} else if (mem.eql(u8, arg, "-fClang")) {
|
||||
use_clang = true;
|
||||
} else if (mem.eql(u8, arg, "-fno-Clang")) {
|
||||
@ -1867,7 +1864,6 @@ fn buildOutputType(
|
||||
.want_compiler_rt = want_compiler_rt,
|
||||
.use_llvm = use_llvm,
|
||||
.use_lld = use_lld,
|
||||
.use_zld = use_zld,
|
||||
.use_clang = use_clang,
|
||||
.rdynamic = rdynamic,
|
||||
.linker_script = linker_script,
|
||||
@ -3245,7 +3241,8 @@ pub const ClangArgIterator = struct {
|
||||
self.zig_equivalent = clang_arg.zig_equivalent;
|
||||
break :find_clang_arg;
|
||||
},
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fatal("Unknown Clang option: '{s}'", .{arg});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user