authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-10-03 00:15:35+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-10-03 00:15:35+02:00
loge0ac776749f2d5ac3ffd5717ce5208f859d12028
tree64656c6dde72c85b28a142b5ec718da31ebd73d0
parent26d35cc1128c12fe11331915511524550e88bc15
parentebbc50d8be3582cb67baa952ce7a52296a04a3c1
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #21504 from alexrp/android-softfp

`std.Target`: Introduce `Abi.androideabi` to distinguish the soft float case.

10 files changed, 34 insertions(+), 22 deletions(-)

lib/compiler/aro/aro/Compilation.zig+1-1
......@@ -308,7 +308,7 @@ fn generateSystemDefines(comp: *Compilation, w: anytype) !void {
308308 ),
309309 else => {},
310310 }
311 if (comp.target.abi == .android) {
311 if (comp.target.isAndroid()) {
312312 try w.writeAll("#define __ANDROID__ 1\n");
313313 }
314314
lib/compiler/aro/aro/target.zig+1
......@@ -690,6 +690,7 @@ pub fn toLLVMTriple(target: std.Target, buf: []u8) []const u8 {
690690 .eabi => "eabi",
691691 .eabihf => "eabihf",
692692 .android => "android",
693 .androideabi => "androideabi",
693694 .musl => "musl",
694695 .musleabi => "musleabi",
695696 .musleabihf => "musleabihf",
lib/compiler_rt/common.zig+1
......@@ -22,6 +22,7 @@ pub const want_aeabi = switch (builtin.abi) {
2222 .gnueabi,
2323 .gnueabihf,
2424 .android,
25 .androideabi,
2526 => switch (builtin.cpu.arch) {
2627 .arm, .armeb, .thumb, .thumbeb => true,
2728 else => false,
lib/compiler_rt/emutls.zig+1-1
......@@ -18,7 +18,7 @@ const gcc_word = usize;
1818pub const panic = common.panic;
1919
2020comptime {
21 if (builtin.link_libc and (builtin.abi == .android or builtin.os.tag == .openbsd)) {
21 if (builtin.link_libc and (builtin.abi.isAndroid() or builtin.os.tag == .openbsd)) {
2222 @export(&__emutls_get_address, .{ .name = "__emutls_get_address", .linkage = common.linkage, .visibility = common.visibility });
2323 }
2424}
lib/std/Target.zig+13-2
......@@ -664,6 +664,7 @@ pub const Abi = enum {
664664 eabihf,
665665 ilp32,
666666 android,
667 androideabi,
667668 musl,
668669 musleabi,
669670 musleabihf,
......@@ -770,8 +771,16 @@ pub const Abi = enum {
770771 };
771772 }
772773
774 pub inline fn isAndroid(abi: Abi) bool {
775 return switch (abi) {
776 .android, .androideabi => true,
777 else => false,
778 };
779 }
780
773781 pub inline fn floatAbi(abi: Abi) FloatAbi {
774782 return switch (abi) {
783 .androideabi,
775784 .eabi,
776785 .gnueabi,
777786 .musleabi,
......@@ -1617,7 +1626,7 @@ pub inline fn isMusl(target: Target) bool {
16171626}
16181627
16191628pub inline fn isAndroid(target: Target) bool {
1620 return target.abi == .android;
1629 return target.abi.isAndroid();
16211630}
16221631
16231632pub inline fn isWasm(target: Target) bool {
......@@ -1724,7 +1733,7 @@ pub const DynamicLinker = struct {
17241733 }
17251734
17261735 pub fn standard(cpu: Cpu, os_tag: Os.Tag, abi: Abi) DynamicLinker {
1727 return if (abi == .android) initFmt("/system/bin/linker{s}", .{
1736 return if (abi.isAndroid()) initFmt("/system/bin/linker{s}", .{
17281737 if (ptrBitWidth_cpu_abi(cpu, abi) == 64) "64" else "",
17291738 }) catch unreachable else if (abi.isMusl()) return initFmt("/lib/ld-musl-{s}{s}.so.1", .{
17301739 @tagName(switch (cpu.arch) {
......@@ -2391,6 +2400,7 @@ pub fn cTypeAlignment(target: Target, c_type: CType) u16 {
23912400 .eabi,
23922401 .eabihf,
23932402 .android,
2403 .androideabi,
23942404 .musleabi,
23952405 .musleabihf,
23962406 => 8,
......@@ -2463,6 +2473,7 @@ pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 {
24632473 .eabi,
24642474 .eabihf,
24652475 .android,
2476 .androideabi,
24662477 .musleabi,
24672478 .musleabihf,
24682479 => {},
lib/std/Target/Query.zig+1-1
......@@ -374,7 +374,7 @@ pub fn canDetectLibC(self: Query) bool {
374374 if (self.isNativeOs()) return true;
375375 if (self.os_tag) |os| {
376376 if (builtin.os.tag == .macos and os.isDarwin()) return true;
377 if (os == .linux and self.abi == .android) return true;
377 if (os == .linux and self.abi.isAndroid()) return true;
378378 }
379379 return false;
380380}
lib/std/c.zig+3-3
......@@ -5946,7 +5946,7 @@ pub const PR = switch (native_os) {
59465946};
59475947pub const _errno = switch (native_os) {
59485948 .linux => switch (native_abi) {
5949 .android => private.__errno,
5949 .android, .androideabi => private.__errno,
59505950 else => private.__errno_location,
59515951 },
59525952 .emscripten => private.__errno_location,
......@@ -6754,7 +6754,7 @@ pub const pthread_mutex_t = switch (native_os) {
67546754 .mips64, .powerpc64, .powerpc64le, .sparc64 => 40,
67556755 else => if (@sizeOf(usize) == 8) 40 else 24,
67566756 },
6757 .android => if (@sizeOf(usize) == 8) 40 else 4,
6757 .android, .androideabi => if (@sizeOf(usize) == 8) 40 else 4,
67586758 else => @compileError("unsupported ABI"),
67596759 };
67606760 },
......@@ -6848,7 +6848,7 @@ pub const pthread_cond_t = switch (native_os) {
68486848
68496849pub const pthread_rwlock_t = switch (native_os) {
68506850 .linux => switch (native_abi) {
6851 .android => switch (@sizeOf(usize)) {
6851 .android, .androideabi => switch (@sizeOf(usize)) {
68526852 4 => extern struct {
68536853 data: [40]u8 align(@alignOf(usize)) = [_]u8{0} ** 40,
68546854 },
lib/std/zig/LibCDirs.zig+1
......@@ -248,6 +248,7 @@ fn libCGenericName(target: std.Target) [:0]const u8 {
248248 .eabihf,
249249 .ilp32,
250250 .android,
251 .androideabi,
251252 .msvc,
252253 .itanium,
253254 .cygnus,
src/codegen/llvm.zig+1
......@@ -172,6 +172,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
172172 .eabi => "eabi",
173173 .eabihf => "eabihf",
174174 .android => "android",
175 .androideabi => "androideabi",
175176 .musl => "musl",
176177 .musleabi => "musleabi",
177178 .musleabihf => "musleabihf",
src/target.zig+11-14
......@@ -304,20 +304,17 @@ pub fn libcFullLinkFlags(target: std.Target) []const []const u8 {
304304 "-lc",
305305 "-lnetwork",
306306 },
307 else => switch (target.abi) {
308 .android => &[_][]const u8{
309 "-lm",
310 "-lc",
311 "-ldl",
312 },
313 else => &[_][]const u8{
314 "-lm",
315 "-lpthread",
316 "-lc",
317 "-ldl",
318 "-lrt",
319 "-lutil",
320 },
307 else => if (target.isAndroid()) &[_][]const u8{
308 "-lm",
309 "-lc",
310 "-ldl",
311 } else &[_][]const u8{
312 "-lm",
313 "-lpthread",
314 "-lc",
315 "-ldl",
316 "-lrt",
317 "-lutil",
321318 },
322319 };
323320}