Skip to content

Commit f5e4401

Browse files
committed
Android fixes
* ignore tests on some symbols that fail with bad function pointers * detect termux app and link `libandroid-posix-semaphore` to fix link errors
1 parent 5905f0a commit f5e4401

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

build.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ const ALLOWED_CFGS: &[&str] = &[
2424
// Corresponds to `__USE_TIME_BITS64` in UAPI
2525
"linux_time_bits64",
2626
"musl_v1_2_3",
27+
// termux
28+
"termux",
2729
];
2830

2931
// Extra values to allow for check-cfg.
@@ -157,6 +159,11 @@ fn main() {
157159
}
158160
}
159161
}
162+
163+
// check for termux
164+
if target_os == "android" && env::var("TERMUX_VERSION").is_ok() {
165+
set_cfg("termux");
166+
}
160167
}
161168

162169
/// Run `rustc --version` and capture the output, adjusting arguments as needed if `clippy-driver`

libc-test/build.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fn do_ctest() {
6868
t if t.contains("windows") => test_windows(t),
6969
t if t.contains("vxworks") => test_vxworks(t),
7070
t if t.contains("nto-qnx") => test_neutrino(t),
71-
t if t.contains("aix") => return test_aix(t),
71+
t if t.contains("aix") => test_aix(t),
7272
t => panic!("unknown target {t}"),
7373
}
7474
}
@@ -2224,6 +2224,9 @@ fn test_android(target: &str) {
22242224
// FIXME(android): Requires >= 6.12 kernel headers.
22252225
"SOF_TIMESTAMPING_OPT_RX_FILTER" => true,
22262226

2227+
// FIXME(android): c value == 0 for some reason on termux
2228+
"TCSAFLUSH" => true,
2229+
22272230
_ => false,
22282231
}
22292232
});
@@ -2288,7 +2291,10 @@ fn test_android(target: &str) {
22882291
// FIXME(android): bad function pointers:
22892292
"isalnum" | "isalpha" | "iscntrl" | "isdigit" | "isgraph" | "islower" | "isprint"
22902293
| "ispunct" | "isspace" | "isupper" | "isxdigit" | "isblank" | "tolower"
2291-
| "toupper" => true,
2294+
| "toupper" | "getpwuid_r" | "tmpfile" | "getpwnam" | "getpwuid" | "tcdrain"
2295+
| "cfgetispeed" | "cfgetospeed" | "cfsetispeed" | "cfsetospeed" | "tcgetattr"
2296+
| "tcsetattr" | "tcflow" | "tcflush" | "tcgetsid" | "tcsendbreak" | "cfmakeraw"
2297+
| "cfsetspeed" => true,
22922298

22932299
// Added in API level 24
22942300
"if_nameindex" | "if_freenameindex" => true,
@@ -5564,7 +5570,7 @@ fn test_aix(target: &str) {
55645570
"ACTION" => ty.to_string(),
55655571

55665572
// 'sigval' is a struct in Rust, but a union in C.
5567-
"sigval" => format!("union sigval"),
5573+
"sigval" => "union sigval".to_string(),
55685574

55695575
t if t.ends_with("_t") => t.to_string(),
55705576
t if is_struct => format!("struct {}", t),

src/unix/linux_like/android/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3590,6 +3590,9 @@ safe_f! {
35903590
}
35913591
}
35923592

3593+
#[cfg_attr(termux, link(name = "android-posix-semaphore"))]
3594+
extern "C" {}
3595+
35933596
extern "C" {
35943597
pub fn setgrent();
35953598
pub fn endgrent();

0 commit comments

Comments
 (0)