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 {
944944 };
945945 }
946946
947 pub fn isSPIRV(arch: Arch) bool {
947 pub fn isSpirV(arch: Arch) bool {
948948 return switch (arch) {
949949 .spirv32, .spirv64 => true,
950950 else => false,
......@@ -1534,6 +1534,10 @@ pub const Target = struct {
15341534 return !self.cpu.arch.isWasm();
15351535 }
15361536
1537 pub fn isSpirV(self: Target) bool {
1538 return self.cpu.arch.isSpirV();
1539 }
1540
15371541 pub const FloatAbi = enum {
15381542 hard,
15391543 soft,
src/Compilation.zig+5-4
......@@ -722,10 +722,11 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
722722 // Once they are capable this condition could be removed. When removing this condition,
723723 // also test the use case of `build-obj -fcompiler-rt` with the native backends
724724 // 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;
726
727 const capable_of_building_zig_libc = build_options.have_llvm and options.target.os.tag != .plan9;
728 const capable_of_building_ssp = build_options.have_llvm and options.target.os.tag != .plan9;
725 const is_p9 = options.target.os.tag == .plan9;
726 const is_spv = options.target.cpu.arch.isSpirV();
727 const capable_of_building_compiler_rt = build_options.have_llvm and !is_p9 and !is_spv;
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
730731 const comp: *Compilation = comp: {
731732 // 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 {
163163pub fn cannotDynamicLink(target: std.Target) bool {
164164 return switch (target.os.tag) {
165165 .freestanding, .other => true,
166 else => false,
166 else => target.isSpirV(),
167167 };
168168}
169169
......@@ -331,18 +331,18 @@ pub fn supportsStackProbing(target: std.Target) bool {
331331}
332332
333333pub fn supportsStackProtector(target: std.Target) bool {
334 _ = target;
335 return true;
334 return !target.isSpirV();
336335}
337336
338337pub 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();
340339}
341340
342341pub fn supportsReturnAddress(target: std.Target) bool {
343342 return switch (target.cpu.arch) {
344343 .wasm32, .wasm64 => target.os.tag == .emscripten,
345344 .bpfel, .bpfeb => false,
345 .spirv32, .spirv64 => false,
346346 else => true,
347347 };
348348}