| author | |
| committer | |
| log | a2c546fea30de2caf1efb454d327e70270c07338 |
| tree | 0bfdd47e5600b7e4430c167d8c30b073c4da8604 |
| parent | da7baf7daec175f63e336082d4bcada9ccf4d55c |
| parent | d6f43a1eac6d8d0405b870a46f202d71957b5ba4 |
3 files changed, 17 insertions(+), 1 deletions(-)
lib/std/target.zig+11| ... | ... | @@ -895,6 +895,13 @@ pub const Target = struct { |
| 895 | 895 | }; |
| 896 | 896 | } |
| 897 | 897 | |
| 898 | pub fn isBpf(arch: Arch) bool { | |
| 899 | return switch (arch) { | |
| 900 | .bpfel, .bpfeb => true, | |
| 901 | else => false, | |
| 902 | }; | |
| 903 | } | |
| 904 | ||
| 898 | 905 | pub fn parseCpuModel(arch: Arch, cpu_name: []const u8) !*const Cpu.Model { |
| 899 | 906 | for (arch.allCpuModels()) |cpu| { |
| 900 | 907 | if (mem.eql(u8, cpu_name, cpu.name)) { |
| ... | ... | @@ -1421,6 +1428,10 @@ pub const Target = struct { |
| 1421 | 1428 | return self.os.tag.isBSD(); |
| 1422 | 1429 | } |
| 1423 | 1430 | |
| 1431 | pub fn isBpfFreestanding(self: Target) bool { | |
| 1432 | return self.cpu.arch.isBpf() and self.os.tag == .freestanding; | |
| 1433 | } | |
| 1434 | ||
| 1424 | 1435 | pub fn isGnuLibC_os_tag_abi(os_tag: Os.Tag, abi: Abi) bool { |
| 1425 | 1436 | return os_tag == .linux and abi.isGnu(); |
| 1426 | 1437 | } |
src/link.zig+1| ... | ... | @@ -531,6 +531,7 @@ pub const File = struct { |
| 531 | 531 | try fs.cwd().copyFile(cached_pp_file_path, fs.cwd(), full_out_path, .{}); |
| 532 | 532 | return; |
| 533 | 533 | } |
| 534 | ||
| 534 | 535 | const use_lld = build_options.have_llvm and base.options.use_lld; |
| 535 | 536 | if (use_lld and base.options.output_mode == .Lib and base.options.link_mode == .Static) { |
| 536 | 537 | return base.linkAsArchive(comp); |
src/link/Elf.zig+5-1| ... | ... | @@ -1381,7 +1381,11 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { |
| 1381 | 1381 | } |
| 1382 | 1382 | |
| 1383 | 1383 | const full_out_path = try directory.join(arena, &[_][]const u8{self.base.options.emit.?.sub_path}); |
| 1384 | if (self.base.options.output_mode == .Obj and self.base.options.lto) { | |
| 1384 | ||
| 1385 | // Due to a deficiency in LLD, we need to special-case BPF to a simple file copy when generating | |
| 1386 | // relocatables. Normally, we would expect `lld -r` to work. However, because LLD wants to resolve | |
| 1387 | // BPF relocations which it shouldn't, it fails before even generating the relocatable. | |
| 1388 | if (self.base.options.output_mode == .Obj and (self.base.options.lto or target.isBpfFreestanding())) { | |
| 1385 | 1389 | // In this case we must do a simple file copy |
| 1386 | 1390 | // here. TODO: think carefully about how we can avoid this redundant operation when doing |
| 1387 | 1391 | // build-obj. See also the corresponding TODO in linkAsArchive. |