| ... | @@ -10,10 +10,24 @@ const Feature = @import("Zcu.zig").Feature; | ... | @@ -10,10 +10,24 @@ const Feature = @import("Zcu.zig").Feature; |
| 10 | | 10 | |
| 11 | pub const default_stack_protector_buffer_size = 4; | 11 | pub const default_stack_protector_buffer_size = 4; |
| 12 | | 12 | |
| 13 | pub fn cannotDynamicLink(target: *const std.Target) bool { | 13 | pub fn canDynamicLink(target: *const std.Target) bool { |
| 14 | return switch (target.os.tag) { | 14 | return switch (target.cpu.arch) { |
| 15 | .freestanding, .uefi => true, | 15 | .amdgcn, |
| 16 | else => target.cpu.arch.isSpirV(), | 16 | .bpfeb, |
| | 17 | .bpfel, |
| | 18 | .nvptx, |
| | 19 | .nvptx64, |
| | 20 | .spirv32, |
| | 21 | .spirv64, |
| | 22 | => false, |
| | 23 | .wasm32, |
| | 24 | .wasm64, |
| | 25 | => true, |
| | 26 | else => switch (target.os.tag) { |
| | 27 | // This list is likely incomplete. |
| | 28 | .freestanding, .uefi => false, |
| | 29 | else => true, |
| | 30 | }, |
| 17 | }; | 31 | }; |
| 18 | } | 32 | } |
| 19 | | 33 | |
| ... | @@ -41,11 +55,20 @@ pub fn libCxxNeedsLibUnwind(target: *const std.Target) bool { | ... | @@ -41,11 +55,20 @@ pub fn libCxxNeedsLibUnwind(target: *const std.Target) bool { |
| 41 | /// This function returns whether non-pic code is completely invalid on the given target. | 55 | /// This function returns whether non-pic code is completely invalid on the given target. |
| 42 | pub fn requiresPIC(target: *const std.Target, linking_libc: bool) bool { | 56 | pub fn requiresPIC(target: *const std.Target, linking_libc: bool) bool { |
| 43 | return target.abi.isAndroid() or | 57 | return target.abi.isAndroid() or |
| 44 | target.os.tag == .windows or target.os.tag == .uefi or | 58 | ((target.os.tag == .windows or target.os.tag == .uefi) and (target.cpu.arch == .aarch64 or target.cpu.arch == .x86_64)) or |
| 45 | target.requiresLibC() or | 59 | target.requiresLibC() or |
| 46 | (linking_libc and target.isGnuLibC()); | 60 | (linking_libc and target.isGnuLibC()); |
| 47 | } | 61 | } |
| 48 | | 62 | |
| | 63 | pub fn requiresPicForDynamicLink(target: *const std.Target) bool { |
| | 64 | assert(canDynamicLink(target)); |
| | 65 | |
| | 66 | return switch (target.os.tag) { |
| | 67 | .windows => target.cpu.arch == .aarch64 or target.cpu.arch == .x86_64, |
| | 68 | else => !target.cpu.arch.isWasm(), |
| | 69 | }; |
| | 70 | } |
| | 71 | |
| 49 | pub fn picLevel(target: *const std.Target) u32 { | 72 | pub fn picLevel(target: *const std.Target) u32 { |
| 50 | // MIPS always uses PIC level 1; other platforms vary in their default PIC levels, but they | 73 | // MIPS always uses PIC level 1; other platforms vary in their default PIC levels, but they |
| 51 | // support both level 1 and 2, in which case we prefer 2. | 74 | // support both level 1 and 2, in which case we prefer 2. |