Skip to content

build on chimera linux fails: 1. dynamic build has missing libgcc dependency, 2. static build fails due to clap_derive needing dynamic linking #965

@matu3ba

Description

@matu3ba

Context
Background on what is broken in rustc (besides language features like proc macros depending on linking mode): rust-lang/rust#135244 and rust-lang/rust#95926
System: Chimera Linux with network installation.

  1. dynamic build problem
# alternative 1
set -x RUSTFLAGS "-C target-feature=+crt-static"
cargo install stylua --features lua52 --target x86_64-unknown-linux-musl
# alternative 2
set -x RUSTFLAGS "-C target-feature=-crt-static"
cargo install stylua --features lua52

Output

error: linking with `cc` failed: exit status: 1
[...]
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: ld: error: unable to find library -lgcc_s
          cc: error: linker command failed with exit code 1 (use -v to see invocation)
  1. static build problem
set -x RUSTFLAGS "-C target-feature=+crt-static"
cargo install stylua --features lua52

Output

cargo install stylua --features lua52
    Updating crates.io index
  Installing stylua v2.0.2
    Updating crates.io index
     Locking 97 packages to latest compatible versions
      Adding clap v3.2.25 (available: v4.5.32)
      Adding env_logger v0.10.2 (available: v0.11.7)
      Adding thiserror v1.0.69 (available: v2.0.12)
error: failed to compile `stylua v2.0.2`, intermediate artifacts can be found at `/tmp/cargo-installlGgsiF`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

Caused by:
  cannot produce proc-macro for `clap_derive v3.2.25` as the target `x86_64-unknown-linux-musl` does not support these crate types

Solution 1
Describe in README correct flags to disable clap_derive for static builds to just work on any host system.

Solution 2
Explain how to set musl dynamic linking.

Solution 3
Explain that musl host systems are not supported.

Solution 4
Link to gcc based cross-compiler setup with rustc and cargo for proc-macro to "just work".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions