-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
change musl linker to /lib/ld-musl-x86_64.so.1 or support -dynamic-linker option #40049
Comments
Ok I've managed to build libseccomp.so without bringing in libc:
This .so is not readable by ldd but i can see what it wants using the interpreter directly
After building the binary with the new version I cannot run it, nor ldd it
but I can run it with the musl ld:
and it runs just fine if i force the new interpreter:
Essentially I have reached the same conclusion, which is If I want to dynamically link to musl libraries, I have to be able to change the dynamic-interpreter somehow. I think this comes down to one of the following: 1) supporting the -dynamic-linker LDFLAG |
A bit more progress: I've found the invocation to actually pass link-arg to the linker: RUSTFLAGS="-L native=/path/to/libseccomp/src/.libs -C link-arg=-dynamic-linker -C link-arg=/lib/ld-musl-x86_64.so.1" Unfortunately, while this is adding a dependency on /lib/ld-musl-x86_64.so.1, it isn't properly setting it for the interpreter. I'm not sure what is missing to make it actually set the interpreter properly. |
Looks like the people building on alpine ran into a similar problem here: #31322 That said, I don't see anything there that would allow me to change the interpreter that rustc is sticking into my elf header for the binaries it produces for the musl target. |
Thanks for the report! Some things I might recommend:
|
Thanks for taking a look at this.
I think the proper solution here is to get rust to set the .interp header properly when writing out the ELF file. I have not yet figured out what component is responsible for generating the elf, but I suspect that if -dynamic-linker is specified then it should be set in the header like ld does. The fact dynamic-linker causes a dependency to be added but not included in the elf header makes me think that rust is doing some post-processing before writing out the ELF and not setting .interp. Any tips for where I should look for that? |
Typically when you compile for musl but the resulting binary wants ld-linux-* it means that something went wrong along the way (e.g. cross compilers weren't set up or something like that). I don't think that Do you have some logs I could perhaps take a look at and help with? |
|
@jmesmon that is exactly what I just discovered. I had assumed it was defaulting to musl-gcc. It woks fine without passing in dynamic-library with -C linker=musl-gcc. I guess the default wasn't changed becasue for static linking cc works just fine. It should probably be documented somewhere that dynamic linking requires changing the linker. Thanks for the help @alexcrichton and @jmesmon Feel free to close this if there are no further comments. |
Ok, glad it worked out! |
What if cross-compilation to another platform? On |
So i am making a own server with some other people and when we finally were done this popped up. dont know what it is, dont know what it does, just need some help on how to fix it. [Pterodactyl Daemon] Server marked as STARTING |
I've been attempting to build libraries for the x86_64-unknown-linux-musl target. I've managed to get static linking working. Dynamic linking is very close. Consider the following steps.
Any ideas why the -dynamic-linker arg is getting ignored when building my binary?
The text was updated successfully, but these errors were encountered: