diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2025-08-30 12:08:18 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-09-21 14:09:14 -0700 |
| commit | f58200e3f2967a06f343c9fc9dcae9de18def92a (patch) | |
| tree | 84257e40a7a0186fbc10cf7467e65f004036d3e3 /src/Compilation | |
| parent | 2a97e0af6d42e038d962890a320e262e676d44cb (diff) | |
| download | zig-f58200e3f2967a06f343c9fc9dcae9de18def92a.tar.gz zig-f58200e3f2967a06f343c9fc9dcae9de18def92a.zip | |
Elf2: create a new linker from scratch
This iteration already has significantly better incremental support.
Closes #24110
Diffstat (limited to 'src/Compilation')
| -rw-r--r-- | src/Compilation/Config.zig | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/Compilation/Config.zig b/src/Compilation/Config.zig index d8751251da..45f7e509de 100644 --- a/src/Compilation/Config.zig +++ b/src/Compilation/Config.zig @@ -49,6 +49,8 @@ use_lib_llvm: bool, use_lld: bool, c_frontend: CFrontend, lto: std.zig.LtoMode, +use_new_linker: bool, +incremental: bool, /// WASI-only. Type of WASI execution model ("command" or "reactor"). /// Always set to `command` for non-WASI targets. wasi_exec_model: std.builtin.WasiExecModel, @@ -104,6 +106,8 @@ pub const Options = struct { use_lld: ?bool = null, use_clang: ?bool = null, lto: ?std.zig.LtoMode = null, + use_new_linker: ?bool = null, + incremental: bool = false, /// WASI-only. Type of WASI execution model ("command" or "reactor"). wasi_exec_model: ?std.builtin.WasiExecModel = null, import_memory: ?bool = null, @@ -147,6 +151,8 @@ pub const ResolveError = error{ LldUnavailable, ClangUnavailable, DllExportFnsRequiresWindows, + NewLinkerIncompatibleWithLld, + NewLinkerIncompatibleObjectFormat, }; pub fn resolve(options: Options) ResolveError!Config { @@ -458,6 +464,22 @@ pub fn resolve(options: Options) ResolveError!Config { break :b .none; }; + const use_new_linker = b: { + if (use_lld) { + if (options.use_new_linker == true) return error.NewLinkerIncompatibleWithLld; + break :b false; + } + + if (!target_util.hasNewLinkerSupport(target.ofmt)) { + if (options.use_new_linker == true) return error.NewLinkerIncompatibleObjectFormat; + break :b false; + } + + if (options.use_new_linker) |x| break :b x; + + break :b options.incremental; + }; + const root_strip = b: { if (options.root_strip) |x| break :b x; if (root_optimize_mode == .ReleaseSmall) break :b true; @@ -531,6 +553,8 @@ pub fn resolve(options: Options) ResolveError!Config { .root_error_tracing = root_error_tracing, .pie = pie, .lto = lto, + .use_new_linker = use_new_linker, + .incremental = options.incremental, .import_memory = import_memory, .export_memory = export_memory, .shared_memory = shared_memory, |
