-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
core: add unstable no_fp_fmt_parse to disable float formatting code #86048
Conversation
r? @scottmcm (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
69152fe
to
55bcf71
Compare
This comment has been minimized.
This comment has been minimized.
They are used by integer formatting as well and is not exclusive to float.
55bcf71
to
0e8c41d
Compare
I think this is bigger than my lib-impl hat's purview, so I've nominated it for libs team discussion. |
I am also preparing a patch that adds a The goal is not to remove the type |
Consider using Cargo's feature infrastructure for the implementation of this. Furthermore, features should ideally be additive (i.e. in this case you'd add an enabled-by-default (as another nit: since these don't remove the types, but just the formatting code, perhaps this should be reflected in the name?) |
I followed a previous PR that adds a cfg to remove OOM handling code, see #84266 (comment). It seems that libs team is not comfortable with enable-by-default features.
Well, this removes both parsing and formatting code. What would be a better name, |
Two cfgs do definitely seem to make naming these easier: |
I don't understand why this is needed: if you don't use |
For context this cfg is wanted by Rust-for-Linux project. A few reasons that we need to remove them instead of relying on LTO:
|
LTO is not needed for this: rustc performs the equivalent of The reason excluding the formatting code works at all in your case is because most of I'm a bit conflicted about this PR. Fundamentally, the This leaves two arguments for removing float formatting support:
|
Well, given that we disallow usage of
This PR also removes float parsing. |
Hmm I think we can provisionally accept this but with the reservation that we may remove this cfg in the future and replace it with some other mechanism for disabling float support. @bors r+ |
📌 Commit 0e8c41dfd748517b55bfd6ad96d2d7e43b6352f2 has been approved by |
I still had to rename the feature gate, please r- for now |
An option to completely disable floating point would actually be even better for us. However that change seems very big and not trivial to make, so in the short term we want at least to remove the parsing/formatting. |
As requested in #86048 (comment) (If I'm misunderstanding the request, please ping me and I'll re-r.) |
In some projects (e.g. kernel), floating point is forbidden. They can disable hardware floating point support and use `+soft-float` to avoid fp instructions from being generated, but as libcore contains the formatting code for `f32` and `f64`, some fp intrinsics are depended. One could define stubs for these intrinsics that just panic [1], but it means that if any formatting functions are accidentally used, mistake can only be caught during the runtime rather than during compile-time or link-time, and they consume a lot of space without LTO. This patch provides an unstable cfg `no_fp_fmt_parse` to disable these. A panicking stub is still provided for the `Debug` implementation (unfortunately) because there are some SIMD types that use `#[derive(Debug)]`. [1]: https://lkml.org/lkml/2021/4/14/1028
0e8c41d
to
ec7292a
Compare
@nagisa it seems that parsing and formatting code are quite intertwined and it's not very easy to split the two. Currently I rename the flag to |
That is fine, thank you. We do not mind having to change the mechanism later on if needed (at least until things mature quite a bit more on our side). |
Something that might be worth exploring is having each kernel module bundle a separate copy of @bors r+ |
📌 Commit ec7292a has been approved by |
☀️ Test successful - checks-actions |
`alloc`: add unstable cfg features `no_rc` and `no_sync` In Rust for Linux we are using these to make `alloc` a bit more modular. See rust-lang#86048 and rust-lang#84266 for similar requests. Of course, the particular names are not important.
`alloc`: add unstable cfg features `no_rc` and `no_sync` In Rust for Linux we are using these to make `alloc` a bit more modular. See rust-lang#86048 and rust-lang#84266 for similar requests. Of course, the particular names are not important.
`alloc`: add unstable cfg features `no_rc` and `no_sync` In Rust for Linux we are using these to make `alloc` a bit more modular. See rust-lang/rust#86048 and rust-lang/rust#84266 for similar requests. Of course, the particular names are not important.
In some projects (e.g. kernel), floating point is forbidden. They can disable
hardware floating point support and use
+soft-float
to avoid fp instructionsfrom being generated, but as libcore contains the formatting code for
f32
and
f64
, some fp intrinsics are depended. One could define stubs for theseintrinsics that just panic 1, but it means that if any formatting functions
are accidentally used, mistake can only be caught during the runtime rather
than during compile-time or link-time, and they consume a lot of space without
LTO.
This patch provides an unstable cfg
no_fp_fmt_parse
to disable these.A panicking stub is still provided for the
Debug
implementation (unfortunately)because there are some SIMD types that use
#[derive(Debug)]
.