diff --git a/lib/std/target.zig b/lib/std/target.zig index 18e1f28f4a..fba399f02c 100644 --- a/lib/std/target.zig +++ b/lib/std/target.zig @@ -944,7 +944,7 @@ pub const Target = struct { }; } - pub fn isSPIRV(arch: Arch) bool { + pub fn isSpirV(arch: Arch) bool { return switch (arch) { .spirv32, .spirv64 => true, else => false, @@ -1534,6 +1534,10 @@ pub const Target = struct { return !self.cpu.arch.isWasm(); } + pub fn isSpirV(self: Target) bool { + return self.cpu.arch.isSpirV(); + } + pub const FloatAbi = enum { hard, soft, diff --git a/src/Compilation.zig b/src/Compilation.zig index caa572e29d..6eef76cf14 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -722,10 +722,11 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { // Once they are capable this condition could be removed. When removing this condition, // also test the use case of `build-obj -fcompiler-rt` with the native backends // and make sure the compiler-rt symbols are emitted. - const capable_of_building_compiler_rt = build_options.have_llvm and options.target.os.tag != .plan9; - - const capable_of_building_zig_libc = build_options.have_llvm and options.target.os.tag != .plan9; - const capable_of_building_ssp = build_options.have_llvm and options.target.os.tag != .plan9; + const is_p9 = options.target.os.tag == .plan9; + const is_spv = options.target.cpu.arch.isSpirV(); + const capable_of_building_compiler_rt = build_options.have_llvm and !is_p9 and !is_spv; + const capable_of_building_zig_libc = build_options.have_llvm and !is_p9 and !is_spv; + const capable_of_building_ssp = build_options.have_llvm and !is_p9 and !is_spv; const comp: *Compilation = comp: { // For allocations that have the same lifetime as Compilation. This arena is used only during this diff --git a/src/target.zig b/src/target.zig index f785082bd4..ad3e0905eb 100644 --- a/src/target.zig +++ b/src/target.zig @@ -163,7 +163,7 @@ pub fn canBuildLibC(target: std.Target) bool { pub fn cannotDynamicLink(target: std.Target) bool { return switch (target.os.tag) { .freestanding, .other => true, - else => false, + else => target.isSpirV(), }; } @@ -331,18 +331,18 @@ pub fn supportsStackProbing(target: std.Target) bool { } pub fn supportsStackProtector(target: std.Target) bool { - _ = target; - return true; + return !target.isSpirV(); } pub fn libcProvidesStackProtector(target: std.Target) bool { - return !target.isMinGW() and target.os.tag != .wasi; + return !target.isMinGW() and target.os.tag != .wasi and !target.isSpirV(); } pub fn supportsReturnAddress(target: std.Target) bool { return switch (target.cpu.arch) { .wasm32, .wasm64 => target.os.tag == .emscripten, .bpfel, .bpfeb => false, + .spirv32, .spirv64 => false, else => true, }; }