chcon: link to libfts on musl targets#7863
Conversation
|
GNU testsuite comparison: |
|
i am not sure creating a build.rs is necessary |
|
How else would you conditionally link the |
|
not sure, sorry :) |
This fixes a build failure on aarch64-unknown-linux-musl. On musl‐based targets the fts API is not provided by libc but by a separate libfts library. * src/uu/chcon/build.rs Add a build script (`build.rs`) that detects when `CARGO_CFG_TARGET_OS=linux` && `CARGO_CFG_TARGET_ENV=musl` and emits `rustc-link-lib=fts`, so that `uu-chcon` can link successfully. * src/uu/chcon/src/fts.rs In the glibc version of the header, `level` is `short`, under musl it's `int`; likewise, `pathlen` is `unsigned` on musl but signed on glibc.
|
@ctrlcctrlv Can you please clarify how you are building chcon with musl and selinux? I have tried with alpine linux arm64 docker image, but building selinux with musl is not a typical use-case, and I'm getting build errors because of missing libselinux etc. I've tried this on my ubuntu x86 machine, but it doesn't work: |
|
@ctrlcctrlv ping |
|
Please reopen if you still want to continue working on it. I don't know how to test this, please see my comment above. |
This fixes a build failure on aarch64-unknown-linux-musl.
On musl‐based targets the fts API is not provided by libc but by a separate libfts library.
src/uu/chcon/build.rsAdd a build script (
build.rs) that detects whenCARGO_CFG_TARGET_OS=linux&&CARGO_CFG_TARGET_ENV=musland emitsrustc-link-lib=fts, so thatuu_chconcan link successfully.src/uu/chcon/src/fts.rsIn the glibc version of the header,
levelisshort, under musl it'sint; likewise,pathlenisunsignedon musl but signed on glibc.Note
To test this, I build as:
RUSTFLAGS='-Ctarget-feature=-crt-static' makein Alpine Linux.