aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2021-11-26 10:54:16 +0100
committerJakub Konka <kubkon@jakubkonka.com>2021-11-26 10:54:16 +0100
commita2c546fea30de2caf1efb454d327e70270c07338 (patch)
tree0bfdd47e5600b7e4430c167d8c30b073c4da8604 /src
parentda7baf7daec175f63e336082d4bcada9ccf4d55c (diff)
parentd6f43a1eac6d8d0405b870a46f202d71957b5ba4 (diff)
downloadzig-a2c546fea30de2caf1efb454d327e70270c07338.tar.gz
zig-a2c546fea30de2caf1efb454d327e70270c07338.zip
Merge branch 'mattnite-build-obj-no-link'
Diffstat (limited to 'src')
-rw-r--r--src/link.zig1
-rw-r--r--src/link/Elf.zig6
2 files changed, 6 insertions, 1 deletions
diff --git a/src/link.zig b/src/link.zig
index f4c51c735f..38b91c9e39 100644
--- a/src/link.zig
+++ b/src/link.zig
@@ -531,6 +531,7 @@ pub const File = struct {
try fs.cwd().copyFile(cached_pp_file_path, fs.cwd(), full_out_path, .{});
return;
}
+
const use_lld = build_options.have_llvm and base.options.use_lld;
if (use_lld and base.options.output_mode == .Lib and base.options.link_mode == .Static) {
return base.linkAsArchive(comp);
diff --git a/src/link/Elf.zig b/src/link/Elf.zig
index 646a568684..e96d776d2a 100644
--- a/src/link/Elf.zig
+++ b/src/link/Elf.zig
@@ -1381,7 +1381,11 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
}
const full_out_path = try directory.join(arena, &[_][]const u8{self.base.options.emit.?.sub_path});
- if (self.base.options.output_mode == .Obj and self.base.options.lto) {
+
+ // Due to a deficiency in LLD, we need to special-case BPF to a simple file copy when generating
+ // relocatables. Normally, we would expect `lld -r` to work. However, because LLD wants to resolve
+ // BPF relocations which it shouldn't, it fails before even generating the relocatable.
+ if (self.base.options.output_mode == .Obj and (self.base.options.lto or target.isBpfFreestanding())) {
// In this case we must do a simple file copy
// here. TODO: think carefully about how we can avoid this redundant operation when doing
// build-obj. See also the corresponding TODO in linkAsArchive.