rust-lang / libc

Raw bindings to platform APIs for Rust
https://docs.rs/libc
Apache License 2.0
2.09k stars 1.04k forks source link

`get`/`setpwent` is missing on aarch64 android #3014

Open Z-snails opened 1 year ago

Z-snails commented 1 year ago

The get/setpwent functions are not available on the aarch64-linux-android target, however libc on this platform (at least on my phone) does have this symbol in the libc library. I'm happy to add this api, but it would be my first PR, so I wanted to first check there wasn't some reason not to include it.

Also I don't know if I'd need to add some more functions/types? A dependency of a package I'm using doesn't compile because of this issue, I don't actually know the api at all, so any help would be appreciated.

This api is available in this package for x86_64 linux, so would it just be a case of porting that code over?

Takashiidobe commented 10 months ago

I decided to take a stab at this, so I took https://github.com/devnexen/libc/commit/942d622b8a18d5018c10af51dbd6cbafb3c63035, fixed it up and pushed it to my Samsung S10 phone running termux, and tried to run cargo test in the libc-test directory, using rust 1.73:

I got these logs that indicate that set/get/endpwent aren't defined, but I'm also on android 12.

The source code seems to indicate that getpwent, setpwent, and endpwent are all "introduced in the future", which I take to mean someday they'll be part of android? (Maybe z-snails phone is newer than mine).

On the flip side, at least the group side is defined, so these can be defined for android.

Edit: I was looking at a really old version of the source tree, the current version indicates these were implemented in API 26: https://android.googlesource.com/platform/bionic/+/b28d496/libc/include/pwd.h#120. I guess its time to upgrade the emulator to make sure CI passes.

Log File ``` Compiling libc v0.2.151 (/data/data/com.termux/files/home/rust-libc) Compiling libc-test v0.2.151 (/data/data/com.termux/files/home/rust-libc/libc-test) warning: hard linking files in the incremental compilation cache failed. copying files instead. consider moving the cache directory to a file system which supports hard linking in session dir `/data/data/com.termux/files/home/rust-libc/target/debug/incremental/libc-2st6ihx3zyot/s-grtswerui5-1d2d10a-working` warning: `libc` (lib) generated 1 warning The following warnings were emitted during compilation: warning: /data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/main.c:36460:24: error: use of undeclared identifier 'setpwent' warning: 36460 | return setpwent; warning: | ^ warning: /data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/main.c:36470:24: error: use of undeclared identifier 'getpwent' warning: 36470 | return getpwent; warning: | ^ warning: 2 errors generated. error: failed to run custom build command for `libc-test v0.2.151 (/data/data/com.termux/files/home/rust-libc/libc-test)` Caused by: process didn't exit successfully: `/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-949e8b75353ea557/build-script-build` (exit status: 1) --- stdout TARGET = Some("aarch64-linux-android") OPT_LEVEL = Some("0") HOST = Some("aarch64-linux-android") cargo:rerun-if-env-changed=CC_aarch64-linux-android CC_aarch64-linux-android = None cargo:rerun-if-env-changed=CC_aarch64_linux_android CC_aarch64_linux_android = None cargo:rerun-if-env-changed=HOST_CC HOST_CC = None cargo:rerun-if-env-changed=CC CC = None cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS CRATE_CC_NO_DEFAULTS = None DEBUG = Some("true") CARGO_CFG_TARGET_FEATURE = Some("neon") cargo:rerun-if-env-changed=CFLAGS_aarch64-linux-android CFLAGS_aarch64-linux-android = None cargo:rerun-if-env-changed=CFLAGS_aarch64_linux_android CFLAGS_aarch64_linux_android = None cargo:rerun-if-env-changed=HOST_CFLAGS HOST_CFLAGS = None cargo:rerun-if-env-changed=CFLAGS CFLAGS = None running: "/data/data/com.termux/files/home/.cargo/bin/sccache" "aarch64-linux-android-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "-Wall" "-Wextra" "-o" "/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/src/cmsg.o" "-c" "src/cmsg.c" exit status: 0 cargo:rerun-if-env-changed=AR_aarch64-linux-android AR_aarch64-linux-android = None cargo:rerun-if-env-changed=AR_aarch64_linux_android AR_aarch64_linux_android = None cargo:rerun-if-env-changed=HOST_AR HOST_AR = None cargo:rerun-if-env-changed=AR AR = None cargo:rerun-if-env-changed=ARFLAGS_aarch64-linux-android ARFLAGS_aarch64-linux-android = None cargo:rerun-if-env-changed=ARFLAGS_aarch64_linux_android ARFLAGS_aarch64_linux_android = None cargo:rerun-if-env-changed=HOST_ARFLAGS HOST_ARFLAGS = None cargo:rerun-if-env-changed=ARFLAGS ARFLAGS = None running: ZERO_AR_DATE="1" "aarch64-linux-android-ar" "cq" "/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/libcmsg.a" "/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/src/cmsg.o" exit status: 0 running: "aarch64-linux-android-ar" "s" "/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/libcmsg.a" exit status: 0 cargo:rustc-link-lib=static=cmsg cargo:rustc-link-search=native=/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out TARGET = Some("aarch64-linux-android") OPT_LEVEL = Some("0") HOST = Some("aarch64-linux-android") cargo:rerun-if-env-changed=CC_aarch64-linux-android CC_aarch64-linux-android = None cargo:rerun-if-env-changed=CC_aarch64_linux_android CC_aarch64_linux_android = None cargo:rerun-if-env-changed=HOST_CC HOST_CC = None cargo:rerun-if-env-changed=CC CC = None cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS CRATE_CC_NO_DEFAULTS = None DEBUG = Some("true") CARGO_CFG_TARGET_FEATURE = Some("neon") cargo:rerun-if-env-changed=CFLAGS_aarch64-linux-android CFLAGS_aarch64-linux-android = None cargo:rerun-if-env-changed=CFLAGS_aarch64_linux_android CFLAGS_aarch64_linux_android = None cargo:rerun-if-env-changed=HOST_CFLAGS HOST_CFLAGS = None cargo:rerun-if-env-changed=CFLAGS CFLAGS = None running: "/data/data/com.termux/files/home/.cargo/bin/sccache" "aarch64-linux-android-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "-Wall" "-Wextra" "-o" "/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/src/makedev.o" "-c" "src/makedev.c" exit status: 0 cargo:rerun-if-env-changed=AR_aarch64-linux-android AR_aarch64-linux-android = None cargo:rerun-if-env-changed=AR_aarch64_linux_android AR_aarch64_linux_android = None cargo:rerun-if-env-changed=HOST_AR HOST_AR = None cargo:rerun-if-env-changed=AR AR = None cargo:rerun-if-env-changed=ARFLAGS_aarch64-linux-android ARFLAGS_aarch64-linux-android = None cargo:rerun-if-env-changed=ARFLAGS_aarch64_linux_android ARFLAGS_aarch64_linux_android = None cargo:rerun-if-env-changed=HOST_ARFLAGS HOST_ARFLAGS = None cargo:rerun-if-env-changed=ARFLAGS ARFLAGS = None running: ZERO_AR_DATE="1" "aarch64-linux-android-ar" "cq" "/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/libmakedev.a" "/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/src/makedev.o" exit status: 0 running: "aarch64-linux-android-ar" "s" "/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/libmakedev.a" exit status: 0 cargo:rustc-link-lib=static=makedev cargo:rustc-link-search=native=/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out TARGET = Some("aarch64-linux-android") OPT_LEVEL = Some("0") HOST = Some("aarch64-linux-android") cargo:rerun-if-env-changed=CC_aarch64-linux-android CC_aarch64-linux-android = None cargo:rerun-if-env-changed=CC_aarch64_linux_android CC_aarch64_linux_android = None cargo:rerun-if-env-changed=HOST_CC HOST_CC = None cargo:rerun-if-env-changed=CC CC = None cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS CRATE_CC_NO_DEFAULTS = None DEBUG = Some("true") CARGO_CFG_TARGET_FEATURE = Some("neon") cargo:rerun-if-env-changed=CFLAGS_aarch64-linux-android CFLAGS_aarch64-linux-android = None cargo:rerun-if-env-changed=CFLAGS_aarch64_linux_android CFLAGS_aarch64_linux_android = None cargo:rerun-if-env-changed=HOST_CFLAGS HOST_CFLAGS = None cargo:rerun-if-env-changed=CFLAGS CFLAGS = None running: "/data/data/com.termux/files/home/.cargo/bin/sccache" "aarch64-linux-android-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "-Wall" "-Wextra" "-o" "/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/src/errqueue.o" "-c" "src/errqueue.c" exit status: 0 cargo:rerun-if-env-changed=AR_aarch64-linux-android AR_aarch64-linux-android = None cargo:rerun-if-env-changed=AR_aarch64_linux_android AR_aarch64_linux_android = None cargo:rerun-if-env-changed=HOST_AR HOST_AR = None cargo:rerun-if-env-changed=AR AR = None cargo:rerun-if-env-changed=ARFLAGS_aarch64-linux-android ARFLAGS_aarch64-linux-android = None cargo:rerun-if-env-changed=ARFLAGS_aarch64_linux_android ARFLAGS_aarch64_linux_android = None cargo:rerun-if-env-changed=HOST_ARFLAGS HOST_ARFLAGS = None cargo:rerun-if-env-changed=ARFLAGS ARFLAGS = None running: ZERO_AR_DATE="1" "aarch64-linux-android-ar" "cq" "/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/liberrqueue.a" "/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/src/errqueue.o" exit status: 0 running: "aarch64-linux-android-ar" "s" "/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/liberrqueue.a" exit status: 0 cargo:rustc-link-lib=static=errqueue cargo:rustc-link-search=native=/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out TARGET = Some("aarch64-linux-android") OPT_LEVEL = Some("0") HOST = Some("aarch64-linux-android") cargo:rerun-if-env-changed=CC_aarch64-linux-android CC_aarch64-linux-android = None cargo:rerun-if-env-changed=CC_aarch64_linux_android CC_aarch64_linux_android = None cargo:rerun-if-env-changed=HOST_CC HOST_CC = None cargo:rerun-if-env-changed=CC CC = None cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS CRATE_CC_NO_DEFAULTS = None DEBUG = Some("true") CARGO_CFG_TARGET_FEATURE = Some("neon") cargo:rerun-if-env-changed=CFLAGS_aarch64-linux-android CFLAGS_aarch64-linux-android = None cargo:rerun-if-env-changed=CFLAGS_aarch64_linux_android CFLAGS_aarch64_linux_android = None cargo:rerun-if-env-changed=HOST_CFLAGS HOST_CFLAGS = None cargo:rerun-if-env-changed=CFLAGS CFLAGS = None running: "/data/data/com.termux/files/home/.cargo/bin/sccache" "aarch64-linux-android-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "-Wall" "-Wextra" "-o" "/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/src/sigrt.o" "-c" "src/sigrt.c" exit status: 0 cargo:rerun-if-env-changed=AR_aarch64-linux-android AR_aarch64-linux-android = None cargo:rerun-if-env-changed=AR_aarch64_linux_android AR_aarch64_linux_android = None cargo:rerun-if-env-changed=HOST_AR HOST_AR = None cargo:rerun-if-env-changed=AR AR = None cargo:rerun-if-env-changed=ARFLAGS_aarch64-linux-android ARFLAGS_aarch64-linux-android = None cargo:rerun-if-env-changed=ARFLAGS_aarch64_linux_android ARFLAGS_aarch64_linux_android = None cargo:rerun-if-env-changed=HOST_ARFLAGS HOST_ARFLAGS = None cargo:rerun-if-env-changed=ARFLAGS ARFLAGS = None running: ZERO_AR_DATE="1" "aarch64-linux-android-ar" "cq" "/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/libsigrt.a" "/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/src/sigrt.o" exit status: 0 running: "aarch64-linux-android-ar" "s" "/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/libsigrt.a" exit status: 0 cargo:rustc-link-lib=static=sigrt cargo:rustc-link-search=native=/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out ----------------------------------------- cargo:rerun-if-changed=../src/lib.rs cargo:rerun-if-changed=../src/macros.rs cargo:rerun-if-changed=../src/fixed_width_ints.rs cargo:rerun-if-changed=../src/unix/mod.rs cargo:rerun-if-changed=../src/unix/linux_like/mod.rs cargo:rerun-if-changed=../src/unix/linux_like/android/mod.rs cargo:rerun-if-changed=../src/unix/linux_like/android/b64/mod.rs cargo:rerun-if-changed=../src/unix/linux_like/android/b64/aarch64/mod.rs OPT_LEVEL = Some("0") HOST = Some("aarch64-linux-android") cargo:rerun-if-env-changed=CC_aarch64-linux-android CC_aarch64-linux-android = None cargo:rerun-if-env-changed=CC_aarch64_linux_android CC_aarch64_linux_android = None cargo:rerun-if-env-changed=HOST_CC HOST_CC = None cargo:rerun-if-env-changed=CC CC = None cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS CRATE_CC_NO_DEFAULTS = None DEBUG = Some("true") CARGO_CFG_TARGET_FEATURE = Some("neon") cargo:rerun-if-env-changed=CFLAGS_aarch64-linux-android CFLAGS_aarch64-linux-android = None cargo:rerun-if-env-changed=CFLAGS_aarch64_linux_android CFLAGS_aarch64_linux_android = None cargo:rerun-if-env-changed=HOST_CFLAGS HOST_CFLAGS = None cargo:rerun-if-env-changed=CFLAGS CFLAGS = None running: "/data/data/com.termux/files/home/.cargo/bin/sccache" "aarch64-linux-android-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "-Wall" "-Wextra" "-Wall" "-Wextra" "-Werror" "-Wno-unused-parameter" "-Wno-type-limits" "-Wno-address-of-packed-member" "-Wno-unknown-warning-option" "-Wno-deprecated-declarations" "-D_GNU_SOURCE" "-o" "/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/1a37abadb208aa97-main.o" "-c" "/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/main.c" cargo:warning=/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/main.c:36460:24: error: use of undeclared identifier 'setpwent' cargo:warning= 36460 | return setpwent; cargo:warning= | ^ cargo:warning=/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/main.c:36470:24: error: use of undeclared identifier 'getpwent' cargo:warning= 36470 | return getpwent; cargo:warning= | ^ cargo:warning=2 errors generated. exit status: 1 --- stderr rust version: 1.73.0 error occurred: Command "/data/data/com.termux/files/home/.cargo/bin/sccache" "aarch64-linux-android-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "-Wall" "-Wextra" "-Wall" "-Wextra" "-Werror" "-Wno-unused-parameter" "-Wno-type-limits" "-Wno-address-of-packed-member" "-Wno-unknown-warning-option" "-Wno-deprecated-declarations" "-D_GNU_SOURCE" "-o" "/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/1a37abadb208aa97-main.o" "-c" "/data/data/com.termux/files/home/rust-libc/target/debug/build/libc-test-9905dcbe0cbbbccf/out/main.c" with args "aarch64-linux-android-gcc" did not execute successfully (status code exit status: 1). ```
tgross35 commented 2 months ago

@Takashiidobe I think our Android CI may be improved at this point, if you want to try reapplying your PR