-
Notifications
You must be signed in to change notification settings - Fork 392
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 linkage and C++ support for musl targets. #1063
Conversation
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.
this is great
bors try --target musl --cpp 1 |
This changes the default linkage, and will increase the executable size of the generated binaries (but only for C++ binaries, which currently don't really work anyway), but ensure maximum portability and allow libraries with C++ dependencies to build and run correctly. The following sizes exist:
|
tryBuild failed: |
The
EDIT: Seems like the known bug: $ rustc --print native-static-libs src/lib.rs
note: Link against the following native artifacts when linking against this static library. The order and any duplication can be significant on some platforms.
note: native-static-libs: -lgcc_s -lutil -lrt -lpthread -lm -ldl -lc
$ rustc --print native-static-libs src/lib.rs --target mips-unknown-linux-musl
note: Link against the following native artifacts when linking against this static library. The order and any duplication can be significant on some platforms.
note: native-static-libs: -lgcc_s -lc
$ rustc --print native-static-libs src/lib.rs --target mips64-unknown-linux-muslabi64
note: Link against the following native artifacts when linking against this static library. The order and any duplication can be significant on some platforms.
note: native-static-libs: -lunwind -lc
$ rustc --print native-static-libs src/lib.rs --target aarch64-unknown-linux-musl
note: Link against the following native artifacts when linking against this static library. The order and any duplication can be significant on some platforms.
note: native-static-libs: -lunwind -lc |
bors try --target mips*musl --cpp 1 |
Changing this to a draft since it breaks if |
tryBuild succeeded: |
Change behavior to use static-pie linkage by default (consistent with Alpine's behavior for pure Rust packages as well as those with external C dependencies), and fix musl targets with C++ dependencies by forcing statie-pie linkage to standard libraries.
bors try --target mips*musl --cpp 1 Whoops this was supposed to be all musl targets. |
@@ -182,6 +182,21 @@ main() { | |||
|
|||
rm -rf "${td}" | |||
fi | |||
|
|||
# special tests for a shared C runtime, since we disable the shared c++ runtime |
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.
This doesn't need a check for C++ support since it's for a shared C runtime. The C++ runtime will always be static, and we've tested that above.
tryBuild succeeded: |
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.
bors r+
Build succeeded: |
Change behavior to use static-pie linkage by default (consistent with Alpine's behavior for pure Rust packages as well as those with external C dependencies), and fix musl targets with C++ dependencies by forcing static-pie linkage to standard libraries.
Closes #902.