Conversation
| "target_env": "gnu", | ||
| "target_vendor": "unknown", | ||
| "target_has_atomic": ["8", "16", "32", "64"], // any of #[cfg(target_has_atomic={"8", "16", "32", "64")] work. | ||
| "target_has_atomic_ptr": null, |
There was a problem hiding this comment.
I would prefer the previous system where you only need to specify a single value for atomic support: just the maximum atomic bit width supported by the target. It's much simpler and gives the same information.
|
If we're going to change the target format anyway (by moving around json keys as proposed here), I'm not sure what the downside of switching to toml would be (and at that point we'll get comments natively, and have the same config format as cargo) |
| values, though. | ||
|
|
||
| # Alternatives | ||
| [alternatives]: #alternatives |
There was a problem hiding this comment.
Seems like an alternative (in some sense) would be to have a rustc --print target-spec option that spit out more info.
There was a problem hiding this comment.
Its not an alternative at all, because that option does not help creating and distributing custom targets.
There was a problem hiding this comment.
It's a solution to the issue of being able to determine information about a target externally (which I saw as one of the motivations for moving all targets to json), but you're right that it doesn't have anything to do with creating & distributing custom targets.
There was a problem hiding this comment.
I've got the code for rustc --print target-spec at https://github.com/cardoe/rust/tree/target-spec I'll gladly resubmit it.
|
@Amanieu commented on the line 128 (about
GitHub really needs a way to mark comments as not-outdated. |
|
Speaking of cross compiling, I think rustc should support separate Also, while I'd like to do this ASAP, I don't think it should be stabilized ASAP as there is some interaction with scenarios. |
|
Also, Now more than ever, it should be clear that that the target triple does not determine the target. So that we still by default name build directories by the target triple is prone for errors. I think there should at least be an option (if not the default) to instead normalize the config JSON, hash it, and use the hash instead. |
+1 to that (now we just need to get rustbuild to stop trying to parse them...)
As long as this can be overridden in cargo via a flag or env var (so higher level build systems can know where files end up without hashing things themselves) that would work for me. |
Quickly glancing over |
There is a env var to change the |
|
I'd also like to chime in supporting the idea of using TOML rather than JSON, if we make incompatible changes. IMO, it'd make it considerably easier to work with targets - in particular, the built-in targets, well-commented, could themselves serve as half-decent documentation. |
text/0000-target-bundles.md
Outdated
| ```js | ||
| { | ||
| // REQUIRED | ||
| "llvm-target": "x86_64-unknown-linux-gnu", // LLVM target triple (does not need to match with rustc triple) |
There was a problem hiding this comment.
Don't use dashes and instead use underscores so that you can just use #[derive(RustcEncodable, RustcDecodable)]. The dashes are the problem as I pointed out in rust-lang/rust#32988
|
Actually, there might be a use for all 3 autoconfig-style platforms after all. "host" for the project becomes "target" for build scripts and procedural macros. |
|
@Ericson2314: Moreover, build scripts and procedural macros probably should be aware of |
It might even be possible to provide a migration path for this: Support both |
Target specs have gotten members added (some mandatory) and removed as a regular occurrence, without warnings. I don't think there is really stability with the specs yet. I don't see it as a big deal to just remove the json spec support (presuming we switch toml). That said, I say this as someone using target specs with release versions, not with nightlies, so adjusting to changes here isn't so bad for me. |
| than the built-in targets rustc knows about, therefore distributing targets built-in into rustc is | ||
| providing no benefits. | ||
|
|
||
| Native libraries and linkers aside, it is obvious there’s little sense in distributing targets |
There was a problem hiding this comment.
I don't agree with this. Once "on the fly compilation of std" becomes a thing, it actually makes sense to provide all the target specifications "upfront" with rustc. Then people, specially the ones working with/on embedded systems, can choose which std features to enable/disable (e.g. remove RUST_BACKTRACE support) (*) and/or compile std with CPU specific optimizations for maximum performance (**). In this scenario, rust-std becomes a convenience to avoid the compile time required to build std the first time.
(*) This actually makes more sense for final deployments/releases.
(**) This makes sense for both development (slightly faster execution of test suites but the savings add up quickly) and for deployment to embedded systems. For releases that must work everywhere, one should instead not enable any CPU-specific optimization -- this would be the default, zero-configuration option, which is also how rust-std is compiled.
Instead of what's proposed here, I propose adding a new targets component that will be installed by rustup once regardless of which or how many toolchains (rustc components) one installs. After all, target specifications are indepedent of the host system. This also means one less step (rustup target add foo) in the initial cross compilation setup (once "on the fly compilation of std" is here).
There was a problem hiding this comment.
Getting rid of precompiled std altogether isn't something I had considered in my other comments here. If we're sure that is going to happen (and as a result ${libdir}/rustlib/<target>/* is going to go away as most places that isn't writable) then it definitely makes sense to distribute specs for all supported targets at once rather than requiring them to each be downloaded separately because the size of a target will just be the size of it's spec.
There was a problem hiding this comment.
After all, target specifications are indepedent of the host system.
They aren't independent of the compiler however, as the fields will probably be subject to change for a while.
There was a problem hiding this comment.
You are right. Then we could use the same "channel" policy that the toolchain uses. If you do rustup update nightly, you get an updated targets-nightly; If you do rustup default stable, you get targets-stable; and so for.
There was a problem hiding this comment.
I do not disagree with any points raised here, but I feel like solving this concern should become a part of eventual “custom std on demand” RFC, which AFAICT not even feasible at the moment due to stability concerns.
cc @japaric @alexcrichton