-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
De-stabilize target spec JSON #71009
Comments
@rustbot prioritize Let's try this out! |
Error: The feature Please let |
There seems to be some concern (raised on #rust-embedded:matrix.org) that this might negatively impact some tier 3 ports unless there're some guarantees along the lines of rust-lang/rfcs#2803 to provide a miniscule bar of entry as internal target specification. |
Can you clarify how those tier 3 targets are currently working on stable? |
They don't work on stable, there was just some confusion about what this means for eg. Rust forks using custom LLVM backends. I believe we've resolved all of that though. |
I've no idea whether and how/whether they could work on stable. All I know is that there are some target specifications around which might potentially work with a stable compiler (at least if they were included) and some people raised that concern that this would limit the ability to achieve support in the future. |
Ah, okay. I would love to know what those use cases are. I think I missed it in my first post - was thinking about it though - but I meant to also say that if we do move ahead with this I would want to do so very slowly; we'd land some warning on stable telling people that if they are using these today, to comment here, and let that sit for several cycles before actually removing the ability from stable users. I hope that can help alleviate your concern that there might be unknown use cases that people are using today. |
I think de-stabilizing target JSON files is a good idea, given that they are effectively unstable already and only sparsely documented. However, I'm a bit worried about the user-experience for people that want to continue working with custom target specifications on nightly. I think we should provide some sort of file-based opt-in (e.g. a This is especially important because |
cc #71769 (a PR that breaks custom target specifications that specify CRT objects) |
Looks like this has some interaction with #38338. |
So @Mark-Simulacrum, if I'm working on targets for compiling code as bare metal Xen targets and I have those as JSON files is the suggestion that I have to build a custom rustc to get that support if the JSON files go away or get them added into the compiler? |
Also interacts with #32819. |
No, the suggestion is that you use a nightly compiler when using such targets (or, yes, get them added to the compiler, as tier 3 to start). |
#80838 is an example of an unstable change to JSON targets. |
We are using target spec files in Rust for Linux. I don't think it is reasonable to expect all users to use only pre-defined targets. It also creates a cyclic dependency between Having said that, a certain degree of instability can be accommodated. That is to say, I think kernels, embedded & freestanding projects can handle a few changes here and there in the beginning. Nevertheless, I'm sure some degree of stability, even if it is not a perfect 100%, would be appreciated. What about providing compiler flags instead? This would also allow
I'd assume most projects that build |
It should also be noted that many target JSON options have accidentally been renamed in Rust 1.49.0, the current stable release. This was fixed 4 days later in dd682cb. Unfortunately, the fix didn't make it into Rust 1.49.0. As a result, I'm currently required to apply ugly workarounds just for Rust 1.49.0 when building a cross-compiler: ColinFinck/meta-rust@c746ab6 |
I haven't seen it noted, and I'm not sure where to mention this, but one thing I've experienced is that the target spec files break periodically. I'm a little concerned about if we ever do "stabilize" target specs for real, that they cannot be reliably stable over time, particularly due to changes in LLVM. The issue we've hit the most often is changes in the data-layout. Occasionally when LLVM is updated, we get errors like:
which forces us to update the spec file. I don't know if it is possible to better deal with it, or to not be as tied to the backend. |
Maybe it would make sense to remove the |
GCC and Cranelift are backends for rustc too. Cranelift doesn't have any knowledge about type alignments and I don't know if libgccjit allows querying it. In any case the data layout needs to be independent of the backend for the abi to match between backends, which is very important for the Cranelift backend as it uses an LLVM compiled standard library when you use it from the rustc-codegen-cranelift-preview component. |
But isn't the issue here that it has to match LLVM exactly, so it's not truly backend independent? It's de-facto specified by LLVM, no? |
Yes, but Cranelift doesn't care about the alignments. It just has to match what LLVM does for ABI compatibility, which putting the data layout in the target spec solves. |
In a recent Zulip discussion, it was noted that we currently consider JSON target specifications unstable, in the sense that options are relatively freely added and removed.
Currently, the compiler will load target specifications from three places.
If a triple is passed without trailing ".json":
$RUST_TARGET_PATH
, split like PATH on the system we're running on, or, if not set, the current directory.$triple.json
from the directories listedIf a triple is passed with .json, then we directly attempt to load that file path (relative or absolute).
This is the history as best as I can tell:
--target
support, including RUST_TARGET_PATH, was implemented in Implement flexible target specification #16156.I cannot currently find any explicit discussion around stability, but presumably that discussion did happen at some time, happy to receive links to it. I would like to propose that we de-stabilize the RUST_TARGET_PATH and file-path loading, making only built-in targets usable. To my knowledge, this essentially is already the status quo: you need to build core/std to actually use a target, and that's not possible on beta/stable without intentional stability holes like RUSTC_BOOTSTRAP.
The text was updated successfully, but these errors were encountered: