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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
matu3ba opened this issue Mar 20, 2025 · 4 comments

Comments

@matu3ba
Copy link

matu3ba commented Mar 20, 2025

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".

@q66
Copy link

q66 commented Mar 21, 2025

none of this is related to stylua so why are you opening that here

it works fine with the distro's toolchain: https://pkgs.chimera-linux.org/packages?name=stylua&origin=

@JohnnyMorganz
Copy link
Owner

I don't know much about chimera linux, but we do already publish a stylua-linux-x86_64-musl.zip release artifact that is based on musl, so I believe it should be working. As also seen by the link above

@q66
Copy link

q66 commented Apr 21, 2025

the issue they are facing is most likely due to upstream rust compilers not handling systems that are clang-native well (due to those having no libgcc/libgcc_s and instead using libclang_rt.builtins staticlib and libunwind) but this is patched in distro toolchain

@JohnnyMorganz
Copy link
Owner

Gotcha. I will close this issue then as I see no further action needed on StyLua side

@JohnnyMorganz JohnnyMorganz closed this as not planned Won't fix, can't repro, duplicate, stale Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants