-
Notifications
You must be signed in to change notification settings - Fork 8
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
Remove requirement for --target
#25
Comments
We should check with the compiler team what exactly the bootstrapping requirements are. For example, ideally Rust can be bootstrapped from a plain compiler with no prebuilt libraries if one has the source for the bootstrapping compiler. CC #19 |
I'm less certain that we'll be able to do this in the long term myself. Morally you're right in that we can auto-switch to "as if If we preserve the same output structure (as if @Ericson2314 the requirement that proc-macros and build scripts use the host compiler's sysroot isn't going to change any time soon. That should be in a dedicated separate issue if you'd like to see that pursued. |
#42 opened |
Can you talk more about this? Why must host dependencies use the sysroot? My understanding of this is something like "in cross-compile mode, RUSTFLAGS is not passed to build scripts, but in host mode it is", but I'm not sure why that's related to the sysroot? |
I don't remember the reasoning. Perhaps there were issues with dylib loading or ABI compatibility (particularly in the face of any RUSTFLAGS)? One possibility was to avoid building the standard library twice when cross-compiling. Another possibility is that this was an issue when cargo used It may be possible to remove this requirement if we're willing to take the hit of building it twice, and we can convince ourselves that the proc-macro crate doesn't have any weird ABI issues. I think with global caching, that might not be as bad. |
Has there been any update on this since May 2023? I've been looking into it, and so far haven't found any issues with removing this requirement. I've tried playing around with proc_macro's, build scripts and some RUSTFLAGS, but things seem to build fine. Any ideas of anything else to look at? |
Some additional info: I've been looking into this issue. I have removed the requirement for Having tested a few things to see if this causes issues, such as using proc_macros (both in the crate, and the build script), as well as passing some RUSTFLAGS:
I'm unable to observe any issues when building. If there are any particular edge cases that i may have missed, please let me know. Additionally, I haven't observed std being built twice with this change (running cargo with |
…r=ehuss Remove requirement for --target when invoking Cargo with -Zbuild-std This PR addresses [this issue](rust-lang/wg-cargo-std-aware#25) re: build-std stabilization. We believe the requirement for --target to be specified when invoking cargo with -Zbuild-std, from our testing, is no longer needed. Now, with this change, by default Cargo will use the Host CompileKind, rather than a manually specified CompileTarget. We propose removing this restriction in order to test this more widely. Our own testing is detailed below. This change has been tested in the following manner: * Building crates depending on proc_macro, std, and build scripts (which themselves depend on proc_macro) * Various RUSTFLAGS, such as `-Zsanitizer=cfi`, `-Cembed-bitcode=yes`, `-Cforce-frame-pointers`, `-Cforce-unwind-tables=yes`, `-Csoft-float=yes`, `-Zbranch-protection=pac-ret`.
As the PR has been merged, we can close this issue now? @ehuss |
Indeed, thanks! |
The current implementation requires
--target
to be specified. Building in "cross compile mode" is required because host dependencies (proc macro especially) must use the sysroot from the compiler.I don't think this can be changed, but we should infer the
--target
flag if it is not specified. The problem is that the decision to enable "cross compile mode" is done too early (before it is known that the standard library will be built). We'll need to figure out some way to work around this.The crux of the issue is that
BuildConfig::requested_target
needs to be set, butBuildConfig
is constructed extremely early. Decisions like this will need to know if the standard library is being built.I'm not sure how to deal with this.
The text was updated successfully, but these errors were encountered: