| author | |
| committer | |
| log | 72f0ae7ec46c24d59aef2fae793275bede59ac8c |
| tree | 8aed846acdef74f722ef7b0c62bfee1efaae881f |
| parent | 95eb37a198271373b9c4918ce885bb959418e67e |
| signature |
...and allow using `Elf2` with backends other than self-hosted x86_64.
The new ELF linker is currently opt-in, so there's no harm in allowing
backends which are not yet "officially" supported. (And also I'm going
to make the LLVM backend work with `Elf2` in the next commit because
that seems pretty trivial.)3 files changed, 5 insertions(+), 7 deletions(-)
src/Compilation/Config.zig+1-1| ... | ... | @@ -441,7 +441,7 @@ pub fn resolve(options: Options) ResolveError!Config { |
| 441 | 441 | break :b false; |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | if (!target_util.hasNewLinkerSupport(target.ofmt, backend)) { | |
| 444 | if (!target_util.hasNewLinker(target.ofmt)) { | |
| 445 | 445 | if (options.use_new_linker == true) return error.NewLinkerIncompatibleObjectFormat; |
| 446 | 446 | break :b false; |
| 447 | 447 | } |
src/main.zig+1-1| ... | ... | @@ -4137,8 +4137,8 @@ fn createModule( |
| 4137 | 4137 | error.LldUnavailable => fatal("zig was compiled without LLD libraries", .{}), |
| 4138 | 4138 | error.ClangUnavailable => fatal("zig was compiled without Clang libraries", .{}), |
| 4139 | 4139 | error.DllExportFnsRequiresWindows => fatal("only Windows OS targets support DLLs", .{}), |
| 4140 | error.NewLinkerIncompatibleObjectFormat => fatal("using the new linker to link {s} files is unsupported", .{@tagName(target.ofmt)}), | |
| 4141 | 4140 | error.NewLinkerIncompatibleWithLld => fatal("using the new linker is incompatible with using lld", .{}), |
| 4141 | error.NewLinkerIncompatibleObjectFormat => fatal("no new linker available for '{t}' files", .{target.ofmt}), | |
| 4142 | 4142 | }; |
| 4143 | 4143 | } |
| 4144 | 4144 |
src/target.zig+3-5| ... | ... | @@ -275,12 +275,10 @@ pub fn hasLldSupport(ofmt: std.Target.ObjectFormat) bool { |
| 275 | 275 | }; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | pub fn hasNewLinkerSupport(ofmt: std.Target.ObjectFormat, backend: std.lang.CompilerBackend) bool { | |
| 278 | /// Returns `true` if `ofmt` has two linker implementations, so `-fnew-linker` is meaningful. | |
| 279 | pub fn hasNewLinker(ofmt: std.Target.ObjectFormat) bool { | |
| 279 | 280 | return switch (ofmt) { |
| 280 | .elf, .coff => switch (backend) { | |
| 281 | .stage2_x86_64 => true, | |
| 282 | else => false, | |
| 283 | }, | |
| 281 | .elf => true, | |
| 284 | 282 | else => false, |
| 285 | 283 | }; |
| 286 | 284 | } |