-
Notifications
You must be signed in to change notification settings - Fork 13.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
Building no_std
binary fails with link error "undefined reference to `__rust_probestack"
#43264
Comments
@ranweiler as a If you follow these instructions does that solve your problem? |
@alexcrichton, yes, the instructions at your link resolved the link error. Thank you! Also, looks like it is sufficient to add For the reference of others, I've found (indirect) documentation for the reported situation here: https://doc.rust-lang.org/unstable-book/library-features/compiler-builtins-lib.html The documentation I was working from included this section of the Unstable Book: "Writing an executable without stdlib", which doesn't mention this feature at all.
|
Ok cool, glad that worked out! This is an interesting case though in terms of documentation and embedding and whatnot. In the limit it's true that all binaries should use this crate unconditionally, but for specific really tiny embedded projects it may want to be avoided for one reason or another. My recommendation though would be that we should definitely update the docs to mention this! |
@alexcrichton, great, and thanks so much for the help! I'm happy to open a PR for the docs, too. |
That'd be awesome, thanks! Feel free to r? me on the PR and I can take a look |
…ichton Document use of `compiler_builtins` with `no_std` binaries See discussion in rust-lang#43264. The docs for the `compiler_builtins_lib` feature were removed in PR rust-lang#42899. But, though the `compiler_builtins` library has been migrated out-of-tree, the language feature remains, and is needed to use the stand-alone crate. So, we reintroduce the docs for the feature, and add a reference to them when describing how to create a `no_std` executable.
FWIW, this (along with #38281) is very hard to discover when trying to just make a simple no_std staticlib, partially because it's unclear what the entry point docs are for no_std (I ended up starting from an old version of the book). |
Triage: Closing as fixed since the originally reported issue was fixed by improving docs. If there is still (6 years later) something that should be done, it is better to file a new issue for that issue with up to date information. |
Platform
rustc 1.20.0-nightly (086eaa78e 2017-07-15)
Linux 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u2 (2017-06-26) x86_64 GNU/Linux
Summary
Compilation of a
no_std
binary on nightly fails with a linking error about the new stack probe feature.Expected: The binary builds successfully, and
rustc
links to the new__rust_probestack
implementation for my platform.Observed: Building fails with a link error:
undefined reference to `__rust_probestack'
Comments
I poked around the Rust source and recent PRs around stack probes, and the feature didn't seem to be configurable. Things that would be nice: the ability to toggle stack probes with a
-C
flag, or to have a configurable language item, like we do foreh_personality
andpanic_fmt
. I have not yet tried to work around this with linker arguments, as it is more of a weird edge case I ran into in some throwaway example code.Question
Is there a reason this behavior is expected, and linking shouldn't just work?
Test case
The issue can be reproduced using the following project:
Cargo.toml
:and
src/main.rs
:Output
Full error from
cargo build
:The text was updated successfully, but these errors were encountered: