authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2024-05-20 13:43:09+03:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-05-20 09:25:52-04:00
log8aae0d87b5808e3674f2d37c8de7b10e305de9da
treecbfb4662936bcc7cb2ba75bb36813c8658b6fb27
parent9691da71cdb90191abcd4b3cd2d586ab227a6da6

Target: add OpenHarmonyOS ABI

Closes #20009

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

lib/std/Target.zig+5-2
...@@ -649,6 +649,7 @@ pub const Abi = enum {...@@ -649,6 +649,7 @@ pub const Abi = enum {
649 callable,649 callable,
650 mesh,650 mesh,
651 amplification,651 amplification,
652 ohos,
652653
653 pub fn default(arch: Cpu.Arch, os: Os) Abi {654 pub fn default(arch: Cpu.Arch, os: Os) Abi {
654 return if (arch.isWasm()) .musl else switch (os.tag) {655 return if (arch.isWasm()) .musl else switch (os.tag) {
...@@ -688,6 +689,7 @@ pub const Abi = enum {...@@ -688,6 +689,7 @@ pub const Abi = enum {
688 .wasi,689 .wasi,
689 .emscripten,690 .emscripten,
690 => .musl,691 => .musl,
692 .liteos => .ohos,
691 .opencl, // TODO: SPIR-V ABIs with Linkage capability693 .opencl, // TODO: SPIR-V ABIs with Linkage capability
692 .glsl450,694 .glsl450,
693 .vulkan,695 .vulkan,
...@@ -699,7 +701,6 @@ pub const Abi = enum {...@@ -699,7 +701,6 @@ pub const Abi = enum {
699 .visionos,701 .visionos,
700 .driverkit,702 .driverkit,
701 .shadermodel,703 .shadermodel,
702 .liteos, // TODO: audit this
703 .solaris,704 .solaris,
704 .illumos,705 .illumos,
705 .serenity,706 .serenity,
...@@ -716,7 +717,8 @@ pub const Abi = enum {...@@ -716,7 +717,8 @@ pub const Abi = enum {
716717
717 pub inline fn isMusl(abi: Abi) bool {718 pub inline fn isMusl(abi: Abi) bool {
718 return switch (abi) {719 return switch (abi) {
719 .musl, .musleabi, .musleabihf => true,720 .musl, .musleabi, .musleabihf, .muslx32 => true,
721 .ohos => true,
720 else => false,722 else => false,
721 };723 };
722 }724 }
...@@ -727,6 +729,7 @@ pub const Abi = enum {...@@ -727,6 +729,7 @@ pub const Abi = enum {
727 .eabihf,729 .eabihf,
728 .musleabihf,730 .musleabihf,
729 => .hard,731 => .hard,
732 .ohos => .soft,
730 else => .soft,733 else => .soft,
731 };734 };
732 }735 }
lib/std/zig/LibCDirs.zig+1
...@@ -242,6 +242,7 @@ fn libCGenericName(target: std.Target) [:0]const u8 {...@@ -242,6 +242,7 @@ fn libCGenericName(target: std.Target) [:0]const u8 {
242 .musleabihf,242 .musleabihf,
243 .muslx32,243 .muslx32,
244 .none,244 .none,
245 .ohos,
245 => return "musl",246 => return "musl",
246 .code16,247 .code16,
247 .eabi,248 .eabi,
src/codegen/llvm.zig+1
...@@ -212,6 +212,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {...@@ -212,6 +212,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
212 .callable => "callable",212 .callable => "callable",
213 .mesh => "mesh",213 .mesh => "mesh",
214 .amplification => "amplification",214 .amplification => "amplification",
215 .ohos => "ohos",
215 };216 };
216 try llvm_triple.appendSlice(llvm_abi);217 try llvm_triple.appendSlice(llvm_abi);
217218
src/target.zig+2-1
...@@ -45,7 +45,8 @@ pub fn requiresPIC(target: std.Target, linking_libc: bool) bool {...@@ -45,7 +45,8 @@ pub fn requiresPIC(target: std.Target, linking_libc: bool) bool {
45 return target.isAndroid() or45 return target.isAndroid() or
46 target.os.tag == .windows or target.os.tag == .uefi or46 target.os.tag == .windows or target.os.tag == .uefi or
47 osRequiresLibC(target) or47 osRequiresLibC(target) or
48 (linking_libc and target.isGnuLibC());48 (linking_libc and target.isGnuLibC()) or
49 (target.abi == .ohos and target.cpu.arch == .aarch64);
49}50}
5051
51/// This is not whether the target supports Position Independent Code, but whether the -fPIC52/// This is not whether the target supports Position Independent Code, but whether the -fPIC