-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix(build): don't statically link against the "musl" C standard library #4818
Conversation
This shouldn't be the default for all targets, just musl. |
We should check what the alpine package does since that does build against musl and seems to work fine |
I met the same problem today, by (manually) building helix on alpine linux. And I solved it using the same technique you provided here. i.e.
I suggest this be mentioned in the installation chapter of the documentation. |
I don't know who to ping. Guess pinging the author is not a bad idea. @archseer |
I already added a note to the docs about this a while ago. You need to look at the master docs |
42eec8a
to
3c8f60e
Compare
Sorry for the delay, I nearly forgot about the existence of this PR, until I wanted to deploy a new Helix built from source on my raspberry pi nodes... I changed the configuration file such that the compile flags apply to musl targets only, as suggested by @archseer .
If someone knows how to configure this in a more elegant way: Be my guest. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this kind of hard coding is fine. RISCV would be nice to add tough.
Therer are probably very few people compiling for weird architectures and musl and those that do probably know how to add these flags themselves. I think you could actually remove the note about musl from the dos with this PR. It has been confusing some windows people that don't know what musl or glibc are
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comes with the downside of having to hardcode different musl targets
If someone knows how to configure this in a more elegant way: Be my guest. :)
Just a suggestion for a simpler representation :)
8e9fc06
to
f554a0c
Compare
I simplified the configuration as per @polarathene 's suggestion. Also wanted to remove the note from the docs as suggested by @pascalkuthe , but it seems that was done in the meanwhile already. |
Those docs moved here: Lines 185 to 189 in 585402d
|
this pr is stale and I actually included it with #8021 as I had to touch the config anyway (which would have made it impossible to configure this manually). Thanks for contributing! |
By default, rustc always statically links against musl (*), unlike on glibc systems where the resulting binary is dynamically linked against glibc.
This has a very problematic side effect: Binaries which statically link against musl do not support the
dlopen()
call (which we do through the "libloading" crate) (**). This in turn makes it impossible to load treesitter grammars.The result is an error in the log and the user is left without syntax highlighting, among others:
This PR ensures the resulting binary is never statically linked against a C standard library. This configuration should have no impact in environments where the resulting binary would be dynamically linked by default.
(*) Tested with v1.65.0. See also: rust-lang/rust#34987 / rust-lang/compiler-team#422
(**) I found it out by testing a call to
Library::new(...).unwrap()
in a statically and dynamically linked application. I couldn't find much information regarding my claim, but I found these:https://www.openwall.com/lists/musl/2012/12/08/4
https://www.openwall.com/lists/musl/2014/08/27/14
I tested it with the following code:
Output (when built on musl with default options):