aboutsummaryrefslogtreecommitdiff
path: root/src/target.zig
diff options
context:
space:
mode:
authorAli Cheraghi <alichraghi@proton.me>2025-04-25 13:46:06 +0330
committerAli Cheraghi <alichraghi@proton.me>2025-04-28 10:49:17 +0330
commit710f9325ff951c187cf8c7d8eae14330e7b42cd6 (patch)
treed3aa45d0d2082ca413f72267b9e3246049ad29b6 /src/target.zig
parent296b17f37b5c2c28dc909e37d0bb15853338eb79 (diff)
downloadzig-710f9325ff951c187cf8c7d8eae14330e7b42cd6.tar.gz
zig-710f9325ff951c187cf8c7d8eae14330e7b42cd6.zip
Compilation: don't build `compiler_rt` for `amdgcn` and `ubsan_rt` for ptx
Diffstat (limited to 'src/target.zig')
-rw-r--r--src/target.zig27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/target.zig b/src/target.zig
index 7179868f42..b7cda53cf1 100644
--- a/src/target.zig
+++ b/src/target.zig
@@ -313,6 +313,33 @@ pub fn defaultCompilerRtOptimizeMode(target: std.Target) std.builtin.OptimizeMod
}
}
+pub fn canBuildLibCompilerRt(target: std.Target, use_llvm: bool, have_llvm: bool) bool {
+ switch (target.os.tag) {
+ .plan9 => return false,
+ else => {},
+ }
+ switch (target.cpu.arch) {
+ .spirv, .spirv32, .spirv64 => return false,
+ // Remove this once https://github.com/ziglang/zig/issues/23714 is fixed
+ .amdgcn => return false,
+ else => {},
+ }
+ return switch (zigBackend(target, use_llvm)) {
+ .stage2_llvm => true,
+ .stage2_x86_64 => if (target.ofmt == .elf or target.ofmt == .macho) true else have_llvm,
+ else => have_llvm,
+ };
+}
+
+pub fn canBuildLibUbsanRt(target: std.Target) bool {
+ switch (target.cpu.arch) {
+ .spirv, .spirv32, .spirv64 => return false,
+ // Remove this once https://github.com/ziglang/zig/issues/23715 is fixed
+ .nvptx, .nvptx64 => return false,
+ else => return true,
+ }
+}
+
pub fn hasRedZone(target: std.Target) bool {
return switch (target.cpu.arch) {
.aarch64,