Skip to content

Can't build executables for musl #59

Closed
rust-lang/rust
#77086
@vi

Description

@vi

Usual target works:

$ grep panic Cargo.toml
panic = 'abort'

$ cargo build --release -Zbuild-std=panic_abort,std -Zbuild-std-features=panic_immediate_abort --target=x86_64-unknown-linux-gnu
...

$ strip target/x86_64-unknown-linux-gnu/release/koo -o koo
$ ls -lh koo
-rwxrwxr-x 1 vi vi 35K Sep 18 00:57 koo
$ ./koo
Hello, world!

But musl don't:

$ cargo build --release -Zbuild-std=panic_abort,std -Zbuild-std-features=panic_immediate_abort --target=x86_64-unknown-linux-musl
   Compiling compiler_builtins v0.1.35
   Compiling libc v0.2.77
   Compiling unwind v0.0.0 (/nix/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/unwind)
The following warnings were emitted during compilation:

warning: cc: error: ../../src/llvm-project/libunwind/src/Unwind-EHABI.cpp: No such file or directory
warning: cc: fatal error: no input files
warning: compilation terminated.

error: failed to run custom build command for `unwind v0.0.0 (/nix/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/unwind)`

Caused by:
  process didn't exit successfully: `/tmp/rustexp/koo/target/release/build/unwind-3ba23c349fd7fbd4/build-script-build` (exit code: 1)
  --- stdout
  cargo:rerun-if-changed=build.rs
  cargo:rustc-link-search=native=/tmp/rustexp/koo/target/x86_64-unknown-linux-musl/release/build/unwind-030b776e200555ef/out
  CC_x86_64-unknown-linux-musl = None
  CC_x86_64_unknown_linux_musl = None
  TARGET_CC = None
  CC = None
  CROSS_COMPILE = None
  CFLAGS_x86_64-unknown-linux-musl = None
  CFLAGS_x86_64_unknown_linux_musl = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,mmx,sse,sse2")
  running: "musl-gcc" "-Os" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "../../src/llvm-project/libunwind/include" "-std=c99" "-std=c++11" "-nostdinc++" "-fno-exceptions" "-fno-rtti" "-fstrict-aliasing" "-funwind-tables" "-fvisibility=hidden" "-D__LITTLE_ENDIAN__=1" "-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS" "-o" "/tmp/rustexp/koo/target/x86_64-unknown-linux-musl/release/build/unwind-030b776e200555ef/out/../../src/llvm-project/libunwind/src/Unwind-EHABI.o" "-c" "../../src/llvm-project/libunwind/src/Unwind-EHABI.cpp"
  cargo:warning=cc: error: ../../src/llvm-project/libunwind/src/Unwind-EHABI.cpp: No such file or directory
  cargo:warning=cc: fatal error: no input files
  cargo:warning=compilation terminated.
  exit code: 1

  --- stderr


  error occurred: Command "musl-gcc" "-Os" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "../../src/llvm-project/libunwind/include" "-std=c99" "-std=c++11" "-nostdinc++" "-fno-exceptions" "-fno-rtti" "-fstrict-aliasing" "-funwind-tables" "-fvisibility=hidden" "-D__LITTLE_ENDIAN__=1" "-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS" "-o" "/tmp/rustexp/koo/target/x86_64-unknown-linux-musl/release/build/unwind-030b776e200555ef/out/../../src/llvm-project/libunwind/src/Unwind-EHABI.o" "-c" "../../src/llvm-project/libunwind/src/Unwind-EHABI.cpp" with args "musl-gcc" did not execute successfully (status code exit code: 1).


warning: build failed, waiting for other jobs to finish...
error: could not find native static library `c`, perhaps an -L flag is missing?

error: aborting due to previous error

error: build failed

Why unwind? I specified that panic aborts. Can all the stack trickery be completely opted out?

$ rustc --version
rustc 1.48.0-nightly (285fc7d70 2020-09-16)
$ cargo --version
cargo 1.48.0-nightly (8777a6b1e 2020-09-15)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions