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 {
649649 callable,
650650 mesh,
651651 amplification,
652 ohos,
652653
653654 pub fn default(arch: Cpu.Arch, os: Os) Abi {
654655 return if (arch.isWasm()) .musl else switch (os.tag) {
......@@ -688,6 +689,7 @@ pub const Abi = enum {
688689 .wasi,
689690 .emscripten,
690691 => .musl,
692 .liteos => .ohos,
691693 .opencl, // TODO: SPIR-V ABIs with Linkage capability
692694 .glsl450,
693695 .vulkan,
......@@ -699,7 +701,6 @@ pub const Abi = enum {
699701 .visionos,
700702 .driverkit,
701703 .shadermodel,
702 .liteos, // TODO: audit this
703704 .solaris,
704705 .illumos,
705706 .serenity,
......@@ -716,7 +717,8 @@ pub const Abi = enum {
716717
717718 pub inline fn isMusl(abi: Abi) bool {
718719 return switch (abi) {
719 .musl, .musleabi, .musleabihf => true,
720 .musl, .musleabi, .musleabihf, .muslx32 => true,
721 .ohos => true,
720722 else => false,
721723 };
722724 }
......@@ -727,6 +729,7 @@ pub const Abi = enum {
727729 .eabihf,
728730 .musleabihf,
729731 => .hard,
732 .ohos => .soft,
730733 else => .soft,
731734 };
732735 }
lib/std/zig/LibCDirs.zig+1
......@@ -242,6 +242,7 @@ fn libCGenericName(target: std.Target) [:0]const u8 {
242242 .musleabihf,
243243 .muslx32,
244244 .none,
245 .ohos,
245246 => return "musl",
246247 .code16,
247248 .eabi,
src/codegen/llvm.zig+1
......@@ -212,6 +212,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
212212 .callable => "callable",
213213 .mesh => "mesh",
214214 .amplification => "amplification",
215 .ohos => "ohos",
215216 };
216217 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 {
4545 return target.isAndroid() or
4646 target.os.tag == .windows or target.os.tag == .uefi or
4747 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);
4950}
5051
5152/// This is not whether the target supports Position Independent Code, but whether the -fPIC