Skip to content
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

cross-built compiler doesn't have the standard library for the target in its sysroot #77352

Open
glandium opened this issue Sep 30, 2020 · 6 comments
Labels
A-cross Area: Cross compilation C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@glandium
Copy link
Contributor

This is actually a followup to #76733, because somehow I overlooked that when checking the fix for that issue worked.

After building the compiler with the following config.toml:

[build]
build = "x86_64-apple-darwin"
host = ["aarch64-apple-darwin"]
target = ["aarch64-apple-darwin"]

you end up with a compiler without any of the libstd, etc. rlibs, meaning that using the compiler fails with:

error[E0463]: can't find crate for `std`

The same is true when building with the following config.toml on linux:

[build]
build = "x86_64-unknown-linux-gnu"
host = ["i686-unknown-linux-gnu"]
target = ["i686-unknown-linux-gnu"]

Cc @Mark-Simulacrum

@jyn514 jyn514 added A-cross Area: Cross compilation T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Sep 30, 2020
@jyn514
Copy link
Member

jyn514 commented Sep 30, 2020

How are you building the compiler, what x.py command?

@jyn514
Copy link
Member

jyn514 commented Sep 30, 2020

It sounds like you're using build --stage 1 compiler/rustc; to get the standard library you need build --stage 2.

@Mark-Simulacrum
Copy link
Member

I know what the problem here is, currently thinking/working on a solution.

@Mark-Simulacrum
Copy link
Member

I think this is the same underlying problem as I noted in #76799 (comment) -- for now, I think x.py dist library/std src/librustc should build just std + rustc tarballs and put them in the build/dist directory, and if those are unpacked they will contain the expected contents.

The reason this isn't fully working today is because rustbuild has no reason to populate the (internal) stage2/ compiler directory with a standard library and compiler for i686-unknown-linux-gnu; you're not able to run that locally (or so it assumes, since it could be the case).

The proper fix is quite involved -- we'd need to rework rustbuild to support the notion that while we only need to build std for each target once, we need to promote it into multiple places. Which places to copy to is not entirely obvious; I think the right answer is every host compiler in that stage, but it would potentially create awkward artifacts in e.g. i686/stage1/lib/rustlib where they don't really need to be.

I am still thinking -- there might be a targeted fix here that we can apply. For now my recommendation is that if you want to cross-compile, you use x.py dist which is likely always going to be the more stable command (since it gives you closer to "what I asked for" instead of trying to be smart and failing).

@glandium
Copy link
Contributor Author

glandium commented Oct 1, 2020

x.py dist doesn't leave you with a working compiler in some directory. You need to x.py install for that, which puts things in /usr/local, which you may or may not want.

@jyn514 jyn514 added the C-bug Category: This is a bug. label Oct 1, 2020
@Mark-Simulacrum
Copy link
Member

That seems easily solvable, though: [install] prefix = "/my/own/directory" in config.toml.

@jyn514 jyn514 changed the title cross-built compiler can't compile cross-built compiler doesn't have the standard library for the target in its sysroot Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cross Area: Cross compilation C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

3 participants