coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

chcon: link to libfts on musl targets

Open ctrlcctrlv opened this issue 9 months ago • 4 comments

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.

ctrlcctrlv avatar Apr 30 '25 20:04 ctrlcctrlv

GNU testsuite comparison:

Skip an intermittent issue tests/misc/stdbuf (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar May 01 '25 05:05 github-actions[bot]

i am not sure creating a build.rs is necessary

sylvestre avatar May 04 '25 07:05 sylvestre

How else would you conditionally link the -lfts library?

ctrlcctrlv avatar May 05 '25 00:05 ctrlcctrlv