Skip to content
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

dylib for target -musl #44991

Closed
pashinin opened this issue Oct 3, 2017 · 4 comments
Closed

dylib for target -musl #44991

pashinin opened this issue Oct 3, 2017 · 4 comments

Comments

@pashinin
Copy link

pashinin commented Oct 3, 2017

As it was said here #34987, we should have support for targets that use a dynamic musl (like alpine linux) in nightly rust.

I want to build .so file to use on Alpine (musl).

[lib]
crate-type = ["dylib"]   # with staticlib it compiles OK
cargo build --target=x86_64-unknown-linux-musl --release --manifest-path ./Cargo.toml
error: cannot produce dylib for ... as the target `x86_64-unknown-linux-musl` does not support these crate types
rustc -V
rustc 1.22.0-nightly (f1b5225e8 2017-10-01)
@aidanhs
Copy link
Member

aidanhs commented Oct 3, 2017

Can you try passing -C target-feature=-crt-static? See second subpoint of point 5 of #40113 (comment)

@pashinin
Copy link
Author

pashinin commented Oct 3, 2017

Magic, thank you. But I thought rustc or cargo will set what it needs to be able to compile.

@pashinin pashinin closed this as completed Oct 3, 2017
@aidanhs
Copy link
Member

aidanhs commented Oct 3, 2017

There are still some rough edges with dynamic musl - it's essentially a tier 3 platform and there are possible issues with backwards compatibility (since it's historically unconditionally meant static linking).

That said, I'd (cautiously) say that I see no reason why a dylib can't default to dynamic linking given it just errors out at the moment - we'd welcome a PR to start a discussion about it!

@brucify
Copy link

brucify commented Dec 13, 2022

For me, adding this to .cargo/config made dylib work for x86_64-unknown-linux-musl

# Cargo.toml

[lib]
crate-type = ["dylib"]
# .cargo/config

[target.x86_64-unknown-linux-musl]
rustflags = [
    "-C", "target-feature=-crt-static",
]

Then this worked

cargo build --target=x86_64-unknown-linux-musl

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