Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd target_has_floating_point property and make floats optional in libcore #32651
Conversation
rust-highfive
assigned
alexcrichton
Mar 31, 2016
This comment has been minimized.
This comment has been minimized.
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
phil-opp
referenced this pull request
Mar 31, 2016
Open
Float-free libcore (for embedded systems and kernel drivers, among other things) #1364
This comment has been minimized.
This comment has been minimized.
|
I think the The documentation should also be updated to say that only libcore is supported in a float-free configuration, and not any of the other standard Rust libraries. |
phil-opp
force-pushed the
phil-opp:cfg-has-floating-point
branch
from
7dd2e34
to
1f611c5
Mar 31, 2016
This comment has been minimized.
This comment has been minimized.
|
@Amanieu That's going a step too far given the use case (OS development) this PR is intended to solve. There's nothing intrinsically wrong with values of type |
This comment has been minimized.
This comment has been minimized.
|
Thanks for the PR @phil-opp! Working with and/or changing the behavior of the primitive types in Rust is a pretty serious PR, though, so this may be breaching requires-an-RFC territory in terms of proposing such a change. (in terms of a formal document rather than an issue itself). cc @rust-lang/lang I would personally also expect that this sort of option would disable the floating point types entirely. The problem is that the ABI of floats requires the use of SSE registers, right? (and the purpose of this is to disable use of SSE register?) |
alexcrichton
added
T-lang
T-libs
labels
Apr 1, 2016
This comment has been minimized.
This comment has been minimized.
Agreed. The design was proposed by @emk in rust-lang/rfcs#1364 (comment). It should only change the behavior for targets that set the new I could try to create a RFC if it's needed. However, it seems like there are some issues with the current design:
Yes, I just tried it. A simple function returning a f32 triggers the LLVM SSE error again: fn foo() -> f32 {
32.0
}So I agree that it would be better to disable f32 and f64 completely. But is it even possible to disable primitive types? |
This comment has been minimized.
This comment has been minimized.
I though so, too. But it seems like a simple float return already uses SSE registers… |
This comment has been minimized.
This comment has been minimized.
|
@phil-opp I stand corrected—I thought it'd happily store an |
This comment has been minimized.
This comment has been minimized.
In principle, yeah, although it may be kinda hard in practice. If the compiler just removed the names from the default namespace, there's no way to import them, so you can be pretty sure that nothing uses them. That being said you'd also probably want to verify that dependencies don't use floats as well, but that's just a minor complication. |
This comment has been minimized.
This comment has been minimized.
|
I just wanted to make a general point that we have a strong need for vision in the area of arch/OS/config/...-dependent APIs. Examples include:
The common thread among all these problems is that we want to expose, in libraries like But this clearly doesn't scale to other kinds of distinctions. Now, it's not obvious that all of the above examples can be solved by a single mechanism. But I am really eager to see some basic vision for how to approach these questions in Rust, before we go too far down the road of adding specific ad hoc APIs. If @phil-opp or anyone else is interested in this topic, I'd love to work together toward an RFC! |
phil-opp commentedMar 31, 2016
See rust-lang/rfcs#1364
The first commit adds an optional
has_floating_pointproperty (defaulting to true), which can be used for conditional compilation. It's feature gated ascfg_target_has_floating_point.The second commit uses the new
has_floating_pointflag to make all floating point uses in libcore optional. This makes it possible to compile a float-free libcore by adding the following entries to thecustom-target.json:TODO:
libcorefor a float-free target and ensures that the“LLVM ERROR: SSE register return with SSE disabled”error does not occur. What's the best way to add this test?