japaric / xargo

The sysroot manager that lets you build and customize `std`
Apache License 2.0
1.1k stars 93 forks source link

Description of cross build process #287

Open deliciouslytyped opened 4 years ago

deliciouslytyped commented 4 years ago

Is there a description somewhere, in the rust docs, rfc, something..? that explains what exactly is necessary to do a cross build, or do I have to reverse engineer sysroot.rs?

RalfJung commented 4 years ago

There are a couple of examples in the README, or is that not what you are looking for?

deliciouslytyped commented 4 years ago

Sorry, I'm all over the place right now, I meant the low level operations that would be needed to replicate what xargo does.

I.e. what libraries need to be built to get the minimum functionality to compile rust binaries, how they interrelate, stuff like that.

Everyone says libcore has no dependencies but nothing actually seems to be as simple as "just build libcore". The other half of things is "just use xargo".

RalfJung commented 4 years ago

Oh. For that, no I don't think this is written down anywhere for xargo. But mostly it is preparing an appropriate cargo project and then it lets cargo do the heavy lifting. You can set XARGO_KEEP_TEMP=1 to make xargo not clean up after itself, then you can find the cargo project it creates in your OS temp dir (/tmp on Linux). After that, xargo just copies target/.../.../deps into the sysroot folder.

Moreover, nightly cargo can also build libcore and friends using -Zbuild-std, so you might have some luck by reading the information at https://github.com/rust-lang/wg-cargo-std-aware.

deliciouslytyped commented 4 years ago

Yeah thanks, I found te environment variable by accident when peeking at sysroot.rs. :D That's definitely helpful.

Thanks for mentioning build-std, I'll take a look!

If I saw correctly, most of the logic in sysroot is indeed the toml generation, so then the knowledge necessary to come up with that toml.