-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Various Rumprun fixes #200
Conversation
@@ -143,6 +143,9 @@ cfg_if! { | |||
} else if #[cfg(target_os = "emscripten")] { | |||
#[link(name = "c")] | |||
extern {} | |||
} else if #[cfg(all(target_vendor = "rumprun", target_os = "netbsd"))] { | |||
#[link(name = "m")] |
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.
We pass a few flags to the linker to say that default system libraries shouldn't be included by default, so shouldn't we link both libc and libm like the block just below this one?
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.
Do you mean -nodefaultlibs
? That flag is actually not used in Rust's Rumprun target, since the Rumprun linker always pulls its own libc. So not passing -lc
explicitly should be fine.
The reason why I removed the explicit -lc
is however due to a bug in binutils (as invoked by the Rumprun linker). I haven't really been able to track it down, but for some reason it crashes with an assertion failure if -lc
is passed to ld
twice (once explicitly by Rust, and once by Rumprun's linker).
I can try to get a workaround in the Rumprun linker, so it removes the superfluous -lc
passed to it, but opted for removing it here, I hope that's okay. Having a redundant -lc
is not a problem when linking C programs, so I'm not really sure what's going on here.
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.
Whoa, weird! If we're triggering bugs I guess it seems fine to leave this here. Could you add some comments to this effect though?
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.
Rebased and added a comment to clarify why we omit -lc
. Note that while I only observed the assertion failure when linking Rust, I don't think the crash is Rust's fault. It probably is caused by Rumprun's use of ld -r
which has triggered bugs in binutils before, see rumpkernel/rumprun-packages#19
fef0ad9
to
a46ae76
Compare
Since #[cfg] attributes are short-circuting, cfg_if! should not change the order in which the predicates are listed. This enables the use of unstable cfg attributes in cfg_if!, which is useful when building libstd.
The Rumprun linker wrapper already includes -lc when linking. Passing it twice unfortunately causes binutils to crash with an assertion failure. Rumprun does currently not provide librt.
These functions were never available on NetBSD, they belong to OpenBSD/Bitrig.
a46ae76
to
35420e2
Compare
This moves some pthread_*_np definitions that ended up in the wrong BSD modules. Additionally, it avoids linking against libc and librt on Rumprun when building libstd. librt is not available on Rumprun, and libc is pulled in automatically by Rumpruns own linker.
Because conditional compilation for Rumprun is using the unstable
target_vendor
attribute, I'm relying on the fact that#[cfg]
evaluation is short-circuiting regarding feature gate checks.I had to change thecfg_if!
macro to support this. Now, if theif #[cfg(..)]
clause is true, then theelse if #[cfg(..)]
clause will not be evaluated, allowing me to use unstable attributes for libstd builds.