Build cross-compiler without shared libraries for std

I'm trying to build rustc with prebuilt std for a foreign target (sparcv9-sun-solaris). With cargo build -Zbuild-std, I can cross compile static libraries for this target using a regular toolchain from rustup, without having a sysroot or cross-linker available. (I later link them with native tools on the target platform in a separate build step.)

However when I try to prebuild this std with x.py, it seems to want to build a shared library libstd-534e64715d8c4043.so, which fails because I have no cross-linker/sysroot. How can I disable this? Clearly it's not needed as demonstrated by cargo build -Zbuild-std working.

Alternatively, I would be happy to get -Zbuild-std working offline with vendored sources. However this seems to be broken. I guess -Zbuild-std just assumes you will never do a sandboxed build.

You can edit library/std/Cargo.toml and library/test/Cargo.toml to remove the dylib crate type, but this will affect the compiler itself too. You can also edit the target spec to disable dylib support, which will cause cargo to stop building as dylib.

2 Likes

Thanks! This worked for me.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.