taiki-e / upload-rust-binary-action

GitHub Action for building and uploading Rust binary to GitHub Releases.
Apache License 2.0
227 stars 19 forks source link

Undefined reference to `memfd_create' #62

Closed wangeguo closed 7 months ago

wangeguo commented 7 months ago

Hello, My workflow is not working properly for the last 3 days, it is reporting the following error on Linux aarch64 platform:

linking with `aarch64-linux-gnu-gcc` failed: exit status: 1
...
= note: /target/aarch64-unknown-linux-gnu/release/deps/libnix-523dc21357cd5d32.rlib(nix-523dc21357cd5d32.nix.8194b51de9eb2c73-cgu.11.rcgu.o): In function `nix::sys::memfd::memfd_create::h06992278f46e2685':
        nix.8194b51de9eb2c73-cgu.11:(.text._ZN3nix3sys5memfd12memfd_create17h06992278f46e2685E+0x8): undefined reference to `memfd_create'
        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
= note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

error: could not compile `desktop` (bin "amphitheatre-desktop") due to previous error
Error: Process completed with exit code 101.

Instance link: https://github.com/amphitheatre-app/desktop/actions/runs/7343335491/job/19995843592

I'm not sure what's wrong, can you help me out? Thank you.

taiki-e commented 7 months ago

This is due to memfd_create requires glibc 2.27, but it is not available on the latest cross (0.2.5)'s default image.
Upstream bug report: https://github.com/nix-rust/nix/issues/1972

One workaround is to use the edge image of cross, another is to use a way other than cross, which is the default.

# Cross.toml
[target.aarch64-unknown-linux-gnu]
image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:edge"
wangeguo commented 7 months ago

Thanks, I switched to taiki-e/setup-cross-toolchain-action and it works fine.

  - name: Install cross-compilation tools
    uses: taiki-e/setup-cross-toolchain-action@v1
    with:
      target: ${{ matrix.target }}

Instance link: https://github.com/amphitheatre-app/desktop/actions/runs/7344765234 Commit: https://github.com/amphitheatre-app/desktop/commit/14fd0387da43de11cde4173579560e364ef4309c