Target: add OpenHarmonyOS ABI

Closes #20009
This commit is contained in:
Veikka Tuominen
2024-05-20 13:43:09 +03:00
committed by Andrew Kelley
parent 9691da71cd
commit 8aae0d87b5
4 changed files with 9 additions and 3 deletions

View File

@@ -649,6 +649,7 @@ pub const Abi = enum {
callable,
mesh,
amplification,
ohos,
pub fn default(arch: Cpu.Arch, os: Os) Abi {
return if (arch.isWasm()) .musl else switch (os.tag) {
@@ -688,6 +689,7 @@ pub const Abi = enum {
.wasi,
.emscripten,
=> .musl,
.liteos => .ohos,
.opencl, // TODO: SPIR-V ABIs with Linkage capability
.glsl450,
.vulkan,
@@ -699,7 +701,6 @@ pub const Abi = enum {
.visionos,
.driverkit,
.shadermodel,
.liteos, // TODO: audit this
.solaris,
.illumos,
.serenity,
@@ -716,7 +717,8 @@ pub const Abi = enum {
pub inline fn isMusl(abi: Abi) bool {
return switch (abi) {
.musl, .musleabi, .musleabihf => true,
.musl, .musleabi, .musleabihf, .muslx32 => true,
.ohos => true,
else => false,
};
}
@@ -727,6 +729,7 @@ pub const Abi = enum {
.eabihf,
.musleabihf,
=> .hard,
.ohos => .soft,
else => .soft,
};
}

View File

@@ -242,6 +242,7 @@ fn libCGenericName(target: std.Target) [:0]const u8 {
.musleabihf,
.muslx32,
.none,
.ohos,
=> return "musl",
.code16,
.eabi,

View File

@@ -212,6 +212,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
.callable => "callable",
.mesh => "mesh",
.amplification => "amplification",
.ohos => "ohos",
};
try llvm_triple.appendSlice(llvm_abi);

View File

@@ -45,7 +45,8 @@ pub fn requiresPIC(target: std.Target, linking_libc: bool) bool {
return target.isAndroid() or
target.os.tag == .windows or target.os.tag == .uefi or
osRequiresLibC(target) or
(linking_libc and target.isGnuLibC());
(linking_libc and target.isGnuLibC()) or
(target.abi == .ohos and target.cpu.arch == .aarch64);
}
/// This is not whether the target supports Position Independent Code, but whether the -fPIC