-
Notifications
You must be signed in to change notification settings - Fork 944
"rustup target [add, install]" should guide towards successful compilation. #1483
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
Comments
Finally I found what I was missing! So yes, I agree that this guide should be given somewhere. |
Unfortunately the specific requirements change from platform to platform and over time. If you were to spearhead a page (e.g. on the rust forge or nursery sites) where you explain how to handle toolchains for various targets, then we could possibly add a "you may want to read " message to some of these targets. |
Isn't the purpose of rustup to provide a working toolchain? I'm eager to replace all my Go projects with Rust, but I regularly need to compile on Windows for Linux and Linux ARM and on Linux for Windows. With Go everything works out of the box, but with Rust I haven't managed to get anything to compile that isn't the host platform. If rustup can't (for licensing reasons or whatever) download a working toolchain itself, it should at least point to the exact project that is needed for the specific case. For example "you need to install GCC" can mean at least 6 different things (4 different mingw-w64 projects, TDM-GCC or Cygwin). They might all work, but I don't want to try them all and I only need one, so I would really like rustup to tell me exactly what it needs. By the way (from #1483 (comment)):
I actually did read that part when I first started my experiments with Rust. But that doesn't help me at all, it's near impossible to google reliable information what needs to be done to get Rust to cross-compile. |
Not per-se no. The purpose is to allow the installation of Rust toolchains. It's a combinatorial explosion for us to expect to understand how to tell everyone how to deal with cross-compilers.
This is exactly why I requested someone spearhead an effort to document what they can on the forge.
My exact goal is that rustup will direct you to the above document where someone who actually knows what the right answer is can document it. |
@kinnison I am trying to figure out how to package toolchain for cross-compilation. I followed the documentation. I get the below error. The error is looking for link.exe on the ubuntu platform. Do I have to package the tools on the windows machine and ship to the ubuntu? |
I don't think the In addition to switching the toolchain you might have to set |
In the documentation, there is a mention of https://doc.rust-lang.org/nightly/rustc/platform-support.html x86_64-px-windows-msvc . Why do you think it is mentioned in the cross-compilation doc? How were you able to figure out that x86_64-pc-windows-msvc don't cross-compile? Is it some naming convention, hit, and trial, through the official website, etc that you did? It becomes so confusing to figure out which tool needs which dependency and the google search does not provide much information. I am trying to setup distributed sccache and was going through the documentation I am unable to understand How the executable of one platform will help in the compilation on the remote build server with different os? Do let me know if you have any idea about it. |
I think we should steer folk to the cross project actually and keep rustup focused on an excellent installation mechanism. if we can ever get to the point of installing all the dependencies to merely compile for the same host automatically, then we can talk about cross-compilations dependencies. @rahulbansal16 we mention the platform support URL in the cross compilation doc of rustup to help make that documentation visible; not to claim that any particular combination is supported to a particular level - that is up to rustc and cargo's behaviour. I think making the x86_64-pc-windows-msvc target cross-compile successfully would be a great idea; you may be able to do that using qemu binary emulation; but there may be more requirements than that- possibly even code changes to rustc. |
As far as I know cross needs to be able to run Docker containers and since a lot of build jobs already run inside Docker containers themselves, the cross project is of very limited use.
I strongly believe that should be a goal, and it seems we're actually getting closer to that? Sure, there are exceptions because of licensing issues (msvc), but the other targets already bring their necessary dependencies. There is even now the bundled LLD, so cross-compiling for Linux on Windows now works fine (as long as all crates use only Rust). By the way, it might be a bin unorthodox but I recently came across an idea (here for Go, but works the same for Rust). The language Zig includes a self-contained LLVM-based C++ compiler for a variety of targets and apparently can easily be used to cross compile C++ sources on any system. Personally I value "building just works" much higher than "you can pick and choose your own toolchain", so bundling the Zig executable to make cross-compilation "just work" seems quite attractive. (And you could still pick and choose your toolchain by fiddling with your Cargo config.) |
My understanding is that cross supports running within docker as long as you give it the docker socket. So, no problem. I agree that bringing in all the compile pre-reqs is a goal, but Rustup hasn't moved on that at all since I've been contributing to it: we don't install debs, rpms, etc. Having copies of the platforms preferring components that the Rust-lang project is allowed to distribute is I guess one route forward, but one that redistributors like Redhat and Canonical will not embrace easily. That said zig is super interesting and teaching rustc to use zig would be very interesting, and Rustup can certainly manage to install zig tarballs, as we install other ones. We may want to teach rustup how to tell versions of zig separate to versions of rustc to save peoples bandwidth, since I suspect zig is not so small. Thats something that would require some cross-team design and implementation work. Its a bit sad that zig implements the windows-gnu toolchain not windows-msvc though; we've had performance problems in the past in the compiled binaries on Windows, and for 'just works' avoiding those cases is probably pretty important. |
Giving a container the Docker socket (or running a
👍 |
Regarding the state of things concerning "successful compilation" I'd like to link to this issue I recently opened. I eventually resolved it myself by finding the one obscure working toolchain, and this isn't even about cross compiling, this is just about building a Rust application with SQLite on Windows. |
We should probably split this bug out into some related facets. Cross compilation is a different case to regular builds. That said, I think the diagnostic label on that bug is appropriate - rust itself does get to see the the original error, so is best placed to steer folk towards diagnostic guides, even though this is an error below the layers Rust itself owns. |
This is fixed by doing Macbook Pro M2 |
The
README
says:Witnessing myself and my colleagues, most users will:
rustup target [add, install] arm-linux-xxx
and see what happens.~/.cargo/config
.Having everything work out of the box would obviously be the best case.
In lack of that, since the steps for a given
host
xtarget
combination are similar, there should be clear and simple instructions printed right at the end of anrustup
installation, at least for the most common combinations.What I would have liked (simplified):
Other
host
xtarget
combinations should have these steps modified accordingly.If the steps for a given
host
xtarget
are unclear / ambiguous,rustup
should print exactly that as part of theINSTALL TOOLCHAIN
andCONFIGURE TOOLCHAIN
instructions.The text was updated successfully, but these errors were encountered: