Skip to content

chcon: link to libfts on musl targets #7863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ctrlcctrlv
Copy link

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.

Note

To test this, I build as: RUSTFLAGS='-Ctarget-feature=-crt-static' make in Alpine Linux.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant