-
Notifications
You must be signed in to change notification settings - Fork 13.3k
#![no_std] seems quite difficult to use in practice #18172
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
Comments
Note that for the second point you don't actually need to define any lang items so long as your'e compiled as an rlib. If you compile as a dylib, staticlib, or an executable you'll be required to provide an impl for all the lang items. |
Ahh, that helps a lot. I worry more about the first point though. If no_std is a recommended practice for "crates that support use from other languages", will that end up creating a sort of split where some (probably large) percentage of rust crates - the one that do use std - can't be used as dependencies? |
I'm not sure I would classify no_std as "recommended practice" per se. Currently no_std serves as a way to disable |
/cc me |
There should be an option to make |
@arielb1: There is absolutely no guarantee of a segfault when dereferencing a null pointer. It only causes that on a subset of platforms due to the zero page being mapped as PROT_NONE. The use case for |
Weak symbols also don't work properly with static linking. |
Would it be possible for the compiler to provide these functions in a hosted environment with a sane default behavior? E.g., if the the programmer doesn't provide his own functions, they simply abort the process. |
@mahkoh: It can provide the abort behaviour everywhere, because it's provided by an LLVM intrinsic mapping down to a single instruction. |
Kernels will of course have to supply their own version of the failure function, which should be something like linux's panic. I was worried about libraries, which don't want to export a non-weak |
This ticket isn't really actionable, and with changes to the runtime, the details are (somewhat) different overall anyway. |
…vidbarsky fix: Support expect in attribute completion and hover Fixes rust-lang#18171
I've had a few conversations on IRC about using
#![no_std]
in Rust libraries. There are comments around (such as here in html5ever) that using#![no_std]
should be used if one wants to write a Rust library that is going to be used from other languages. It's not really clear to me how accurate that recommendation still is currently / will be at 1.0 with the changes to std that have happened over the past months; however, assuming it's still true, I think there are a couple of problems that don't seem to have easy solutions:#![no_std]
needs to define a few lang_items likestack_exhausted
. If two independently-developed crates both define the lang items, you get duplicate name errors when trying to use both simultaneously.The text was updated successfully, but these errors were encountered: