sunfishcode / eyra

Rust programs written entirely in Rust
Other
765 stars 12 forks source link

`coreutils` with `--features unix` and Eyra fails to build due to undefined reference `gethostid` #30

Closed polarathene closed 11 months ago

polarathene commented 11 months ago

I recently ran into a build failure using --features unix with uutils coreutils.

The Eyra README seems to imply it should be supported though?:

coreutils, including the "unix" feature set

$ mkdir /tmp/uutils && cd /tmp/uutils
$ git clone https://github.com/uutils/coreutils .

# Modify to build with Eyra:
$ cargo add eyra
$ echo 'extern crate eyra;' | cat - src/bin/coreutils.rs | sponge src/bin/coreutils.rs

# Build fails with `--features unix`:
$ RUSTFLAGS="-C link-arg=-nostartfiles -Z location-detail=none -C relocation-model=static -C target-feature=+crt-static" cargo +nightly build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target x86_64-unknown-linux-gnu --profile release-small --features unix

error: linking with `cc` failed: exit status: 1

...

  = note: /usr/bin/ld: /tmp/uutils/target/x86_64-unknown-linux-gnu/release-small/deps/coreutils-cc427e4838ea7f5f.coreutils.d13cef3019b35159-cgu.05.rcgu.o: in function `uu_hostid::uumain':
          coreutils.d13cef3019b35159-cgu.05:(.text._ZN9uu_hostid6uumain17hfa9e9797012ec5f4E+0x38): undefined reference to `gethostid'
          collect2: error: ld returned 1 exit status

  = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link

# Same error with `cargo add eyra --rename=std` approach:
$ RUSTFLAGS="-C link-arg=-nostartfiles -Z location-detail=none -C relocation-model=static -C target-feature=+crt-static" cargo +nightly build --target x86_64-unknown-linux-gnu --profile release-small --features unix

It does build fine without --features unix though 👍

So perhaps something changed in that project since Sep 2023, when the README for Eyra made that claim. Or I misunderstood given it's the section comparing to Mustang?

EDIT: I just realized the link in the README quote above points to a patched fork (changes).

Either way I understand that Eyra is still very much WIP, and that will work in future 👍

sunfishcode commented 11 months ago

I'm not sure what changed, but I didn't see an undefined reference to gethostid last time I tried coreutils, but I do see it now. It's now fixed in c-scape 0.15.26.

I do also see one additional issue; the test_ls_perm_io_errors test is failing; I've now filed https://github.com/sunfishcode/eyra/issues/31 to track this.