authorgravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2023-04-09 01:50:43+02:00
committergravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2023-04-09 01:51:48+02:00
logba60d456b45bd391ec25195c800d61ab14de7985
treecda4a72fce1d9f66c94f4b483c3aca8dbba79e47
parent12ff36265448850add6917c20a49a7f56a95dfe4
signaturelock-open Commit is signed but in an unrecognized format.

spirv: cannot build libc

SPIR-V cannot build libc, ssp, compiler-rt, etc at the time of this commit, so prevent trying to build them.

3 files changed, 14 insertions(+), 9 deletions(-)

lib/std/target.zig+5-1
...@@ -944,7 +944,7 @@ pub const Target = struct {...@@ -944,7 +944,7 @@ pub const Target = struct {
944 };944 };
945 }945 }
946946
947 pub fn isSPIRV(arch: Arch) bool {947 pub fn isSpirV(arch: Arch) bool {
948 return switch (arch) {948 return switch (arch) {
949 .spirv32, .spirv64 => true,949 .spirv32, .spirv64 => true,
950 else => false,950 else => false,
...@@ -1534,6 +1534,10 @@ pub const Target = struct {...@@ -1534,6 +1534,10 @@ pub const Target = struct {
1534 return !self.cpu.arch.isWasm();1534 return !self.cpu.arch.isWasm();
1535 }1535 }
15361536
1537 pub fn isSpirV(self: Target) bool {
1538 return self.cpu.arch.isSpirV();
1539 }
1540
1537 pub const FloatAbi = enum {1541 pub const FloatAbi = enum {
1538 hard,1542 hard,
1539 soft,1543 soft,
src/Compilation.zig+5-4
...@@ -722,10 +722,11 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {...@@ -722,10 +722,11 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
722 // Once they are capable this condition could be removed. When removing this condition,722 // Once they are capable this condition could be removed. When removing this condition,
723 // also test the use case of `build-obj -fcompiler-rt` with the native backends723 // also test the use case of `build-obj -fcompiler-rt` with the native backends
724 // and make sure the compiler-rt symbols are emitted.724 // and make sure the compiler-rt symbols are emitted.
725 const capable_of_building_compiler_rt = build_options.have_llvm and options.target.os.tag != .plan9;725 const is_p9 = options.target.os.tag == .plan9;
726726 const is_spv = options.target.cpu.arch.isSpirV();
727 const capable_of_building_zig_libc = build_options.have_llvm and options.target.os.tag != .plan9;727 const capable_of_building_compiler_rt = build_options.have_llvm and !is_p9 and !is_spv;
728 const capable_of_building_ssp = build_options.have_llvm and options.target.os.tag != .plan9;728 const capable_of_building_zig_libc = build_options.have_llvm and !is_p9 and !is_spv;
729 const capable_of_building_ssp = build_options.have_llvm and !is_p9 and !is_spv;
729730
730 const comp: *Compilation = comp: {731 const comp: *Compilation = comp: {
731 // For allocations that have the same lifetime as Compilation. This arena is used only during this732 // For allocations that have the same lifetime as Compilation. This arena is used only during this
src/target.zig+4-4
...@@ -163,7 +163,7 @@ pub fn canBuildLibC(target: std.Target) bool {...@@ -163,7 +163,7 @@ pub fn canBuildLibC(target: std.Target) bool {
163pub fn cannotDynamicLink(target: std.Target) bool {163pub fn cannotDynamicLink(target: std.Target) bool {
164 return switch (target.os.tag) {164 return switch (target.os.tag) {
165 .freestanding, .other => true,165 .freestanding, .other => true,
166 else => false,166 else => target.isSpirV(),
167 };167 };
168}168}
169169
...@@ -331,18 +331,18 @@ pub fn supportsStackProbing(target: std.Target) bool {...@@ -331,18 +331,18 @@ pub fn supportsStackProbing(target: std.Target) bool {
331}331}
332332
333pub fn supportsStackProtector(target: std.Target) bool {333pub fn supportsStackProtector(target: std.Target) bool {
334 _ = target;334 return !target.isSpirV();
335 return true;
336}335}
337336
338pub fn libcProvidesStackProtector(target: std.Target) bool {337pub fn libcProvidesStackProtector(target: std.Target) bool {
339 return !target.isMinGW() and target.os.tag != .wasi;338 return !target.isMinGW() and target.os.tag != .wasi and !target.isSpirV();
340}339}
341340
342pub fn supportsReturnAddress(target: std.Target) bool {341pub fn supportsReturnAddress(target: std.Target) bool {
343 return switch (target.cpu.arch) {342 return switch (target.cpu.arch) {
344 .wasm32, .wasm64 => target.os.tag == .emscripten,343 .wasm32, .wasm64 => target.os.tag == .emscripten,
345 .bpfel, .bpfeb => false,344 .bpfel, .bpfeb => false,
345 .spirv32, .spirv64 => false,
346 else => true,346 else => true,
347 };347 };
348}348}