uutils / uutils/coreutils

Compilation fails when cross-compiling for Linux

Open
#12,394 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
24.1k
Forks
2k
Avg merge
1d 5h
Merged PRs (30d)
365

Description

Summary

Running cargo check --target x86_64-unknown-linux-gnu in the project directory results in a build failure.

This also breaks development workflows using rust-analyzer when targeting Linux from a non-Linux host with:

"rust-analyzer.cargo.target": "x86_64-unknown-linux-gnu"

because rust-analyzer triggers the same Cargo check internally.

Steps to Reproduce

From a non-Linux host system, run:

cargo check --workspace --all-targets --features unix --target x86_64-unknown-linux-gnu --quiet --keep-going
Error Output
Click to expand the error output
error: failed to run custom build command for `selinux-sys v0.7.0`

Caused by:
  process didn't exit successfully: `~/coreutils/target/debug/build/selinux-sys-4027e8a3e2fee4d2/build-script-build` (exit status: 101)
  --- stdout
  cargo:root=~/coreutils/target/x86_64-unknown-linux-gnu/debug/build/selinux-sys-cf102dfccbfa8af1/out
  cargo:rerun-if-env-changed=SYSROOT_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=SYSROOT_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_SYSROOT
  cargo:rerun-if-env-changed=SYSROOT
  cargo:rerun-if-env-changed=SELINUX_STATIC_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=SELINUX_STATIC_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_SELINUX_STATIC
  cargo:rerun-if-env-changed=SELINUX_STATIC
  cargo:rerun-if-env-changed=SELINUX_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=SELINUX_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_SELINUX_PATH
  cargo:rerun-if-env-changed=SELINUX_PATH
  cargo:rerun-if-env-changed=SELINUX_INCLUDE_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=SELINUX_INCLUDE_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_SELINUX_INCLUDE_DIR
  cargo:rerun-if-env-changed=SELINUX_INCLUDE_DIR
  cargo:rerun-if-env-changed=SELINUX_LIB_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=SELINUX_LIB_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_SELINUX_LIB_DIR
  cargo:rerun-if-env-changed=SELINUX_LIB_DIR
  cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_CC
  cargo:rerun-if-env-changed=CC
  cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  cargo:rerun-if-env-changed=CFLAGS
  cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-gnu
  CC_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_gnu
  CC_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CROSS_COMPILE
  CROSS_COMPILE = None
  PATH = ✂
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:warning=Compiler family detection failed due to error: ToolNotFound: failed to find tool "x86_64-linux-gnu-gcc": No such file or directory (os error 2)
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_gnu
  CFLAGS_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-gnu
  CFLAGS_x86_64-unknown-linux-gnu = None

  --- stderr

  thread 'main' (1386865) panicked at ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/selinux-sys-0.7.0/build.rs:88:14:
  selinux-sys: Failed to discover default compiler search paths: Os { code: 2, kind: NotFound, message: "No such file or directory" }
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: failed to run custom build command for `onig_sys v69.9.3`

Caused by:
  process didn't exit successfully: `~/coreutils/target/debug/build/onig_sys-fb747dccb6654421/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=RUSTONIG_DYNAMIC_LIBONIG
  cargo:rerun-if-env-changed=RUSTONIG_STATIC_LIBONIG
  cargo:rerun-if-env-changed=RUSTONIG_SYSTEM_LIBONIG
  cargo:rerun-if-env-changed=CC_FORCE_DISABLE
  CC_FORCE_DISABLE = None
  cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-gnu
  CC_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_gnu
  CC_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CROSS_COMPILE
  CROSS_COMPILE = None
  PATH = ✂
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:warning=Compiler family detection failed due to error: ToolNotFound: failed to find tool "x86_64-linux-gnu-gcc": No such file or directory (os error 2)
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_gnu
  CFLAGS_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-gnu
  CFLAGS_x86_64-unknown-linux-gnu = None

  --- stderr


  error occurred in cc-rs: failed to find tool "x86_64-linux-gnu-gcc": No such file or directory (os error 2)


error: failed to run custom build command for `uu_stdbuf v0.8.0 (~/coreutils/src/uu/stdbuf)`

Caused by:
  process didn't exit successfully: `~/coreutils/target/debug/build/uu_stdbuf-a43706012c284a3f/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=build.rs
  cargo:rerun-if-changed=src/libstdbuf/src/libstdbuf.rs

  --- stderr
     Compiling uu_stdbuf_libstdbuf v0.8.0 (~/coreutils/src/uu/stdbuf/src/libstdbuf)
  error: linking with `cc` failed: exit status: 1
    |
    = note:  "cc" "-Wl,--version-script=~/coreutils/target/x86_64-unknown-linux-gnu/debug/build/uu_stdbuf-a67e640426c1213a/out/libstdbuf-build/x86_64-unknown-linux-gnu/debug/deps/rustcvAlvq9/list" "-Wl,--no-undefined-version" "-m64" "~/coreutils/target/x86_64-unknown-linux-gnu/debug/build/uu_stdbuf-a67e640426c1213a/out/libstdbuf-build/x86_64-unknown-linux-gnu/debug/deps/rustcvAlvq9/symbols.o" "<23 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "~/coreutils/target/x86_64-unknown-linux-gnu/debug/build/uu_stdbuf-a67e640426c1213a/out/libstdbuf-build/x86_64-unknown-linux-gnu/debug/deps/{liblibc-a70cf24ab1c661a8,libctor-40eeff0499a5867e}.rlib" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,libcfg_if-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "~/coreutils/target/x86_64-unknown-linux-gnu/debug/build/uu_stdbuf-a67e640426c1213a/out/libstdbuf-build/x86_64-unknown-linux-gnu/debug/deps/rustcvAlvq9/raw-dylibs" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "~/coreutils/target/x86_64-unknown-linux-gnu/debug/build/uu_stdbuf-a67e640426c1213a/out/libstdbuf-build/x86_64-unknown-linux-gnu/debug/deps/libstdbuf.so" "-Wl,--gc-sections" "-shared" "-Wl,-z,relro,-z,now" "-Wl,--strip-debug" "-nodefaultlibs" "-fPIC" "-z" "defs"
    = note: some arguments are omitted. use `--verbose` to show all linker arguments
    = note: ld: unknown options: --version-script=~/coreutils/target/x86_64-unknown-linux-gnu/debug/build/uu_stdbuf-a67e640426c1213a/out/libstdbuf-build/x86_64-unknown-linux-gnu/debug/deps/rustcvAlvq9/list --no-undefined-version --as-needed -Bstatic -Bdynamic --eh-frame-hdr -z --gc-sections -z -z --strip-debug -z
            clang: error: linker command failed with exit code 1 (use -v to see invocation)


  error: could not compile `uu_stdbuf_libstdbuf` (lib) due to 1 previous error

  thread 'main' (1386871) panicked at src/uu/stdbuf/build.rs:101:5:
  Failed to build libstdbuf
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: failed to run custom build command for `fts-sys v0.2.17`

Caused by:
  process didn't exit successfully: `~/coreutils/target/debug/build/fts-sys-5ef819fc9985db4e/build-script-build` (exit status: 101)
  --- stdout
  cargo:root=~/coreutils/target/x86_64-unknown-linux-gnu/debug/build/fts-sys-f4d491a04ac5d67f/out
  cargo:rerun-if-env-changed=SYSROOT_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=SYSROOT_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_SYSROOT
  cargo:rerun-if-env-changed=SYSROOT
  cargo:rerun-if-env-changed=TARGET
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS
  cargo:rerun-if-changed=src/fts-sys.h

  --- stderr
  src/fts-sys.h:1:10: fatal error: 'sys/types.h' file not found

  thread 'main' (1386877) panicked at ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/fts-sys-0.2.17/build.rs:123:10:
  fts-sys: Failed to generate Rust bindings for 'fts.h'.: ClangDiagnostic("src/fts-sys.h:1:10: fatal error: 'sys/types.h' file not found\n")
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Related Issues

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reported cargo check command from a non-Linux host and compare the failures from selinux-sys, onig_sys, uu_stdbuf, and fts-sys. Read src/uu/stdbuf/build.rs and the reported target and linker diagnostics first. Done means the workspace check succeeds for x86_64-unknown-linux-gnu and the same target works through rust-analyzer.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.