Skip to content

install-deps.py: add x86_64-unknown-linux-musl target #2532

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

Merged
merged 1 commit into from
Mar 30, 2016

Conversation

japaric
Copy link
Member

@japaric japaric commented Mar 30, 2016

This lets me build a statically linked cargo on our linux-cross Docker image with the following
commands:

$ apt-get install musl-tools # for musl-gcc, which is needed to build openssl
$ ./.travis.install.deps.sh
$ ./configure --local-rust-root=$(pwd)/rustc --enable-nightly --target=x86_64-unknown-linux-musl
$ make
$ file target/x86_64-unknown-linux-musl/release/cargo
cargo: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked (..)


r? @alexcrichton -- If we want start building cargo for this target on the bots, we'll have to modify the linux-cross Dockerfile to install musl-tools.
cc @eddyb

This lets me build a statically linked cargo on our linux-cross Docker image with the following
commands:

$ apt-get install musl-tools # for musl-gcc, which is needed to build openssl
$ ./.travis.install.deps.sh
$ ./configure --local-rust-root=$(pwd)/rustc --enable-nightly --target=x86_64-unknown-linux-musl
$ make
$ file target/x86_64-unknown-linux-musl/release/cargo
cargo: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked (..)
@alexcrichton
Copy link
Member

Out of curiosity, what's the rationale for a MUSL build of Cargo? We certainly can produce one, but I'm not entirely sure what the use case would be.

@eddyb
Copy link
Member

eddyb commented Mar 30, 2016

@alexcrichton This came up in IRC: we can provide binaries that can be built on non-ancient distributions and work on any Linux system (unless musl is using new syscalls, I guess), and they can work on NixOS out of the box.

@brson seemed to be okay with running patchelf from rustup to set the interpreter (which isn't in /lib on NixOS), and it can also be done in the NixOS packaging of rustup, but it's a fragile hack which can break with glibc version changes, whereas musl would keep working pretty much forever.

@alexcrichton
Copy link
Member

Hm I may still be a bit confused. You can build Cargo binaries on any Linux distribution, right? Not using MUSL doesn't gate out newer ones, right? Does Cargo not work on NixOS out of the box? If so, how come?

I also believe that MUSL claims to support Linux 2.6+ so even though it does try to use newer syscalls in some situations I believe there's always a fallback if the kernel is too old (I recall seeing an instance or two of this at least).

Also what's up with patchelf? Is the dynamic interpreter different on NixOS than it is on other Linux distributions, which is why Cargo might be failing on NixOS?

@japaric
Copy link
Member Author

japaric commented Mar 30, 2016

@alexcrichton another reason is that this cargo would work on musl-based linux distros like alpine. Now they just need a rustc that works over there...

@alexcrichton
Copy link
Member

Ok, after some more discussion with @eddyb on IRC seems reasonable to at least have a build of Cargo for this to me!

@japaric this'll actually probably use the rust-slave-linux container as that's got MUSL installed already and doesn't have all the cross compiler weight. We'll also probably tweak it slightly to actually run tests as we can in the case of MUSL. Could you make sure that this build also works and passes tests inside that container?

@japaric
Copy link
Member Author

japaric commented Mar 30, 2016

@alexcrichton tested this on the rust-slave-linux container, and both make and make test passed. I had to do two modifications to the container:

  • Install a newer cmake because of this bug
  • Put /musl-x86_64/bin in PATH, because musl-gcc is required to compile OpenSSL

@alexcrichton
Copy link
Member

Nice! Are you sure you didn't need to add more variables to compile OpenSSL for MUSL though? Seems like we should at least inform OpenSSL that the compiler is musl-gcc instead of gcc.

Those seem like reasonable changes to the container, however.

@japaric
Copy link
Member Author

japaric commented Mar 30, 2016

Are you sure you didn't need to add more variables to compile OpenSSL for MUSL though?

I didn't have to.

Seems like we should at least inform OpenSSL that the compiler is musl-gcc instead of gcc.

You did that already. 😃

@alexcrichton
Copy link
Member

As @alexcrichton from the future descends...

@bors: r+ d382d6a

Thanks @japaric! If you want to send the updates to the linux container I'll upload a new version and we can configure buildbot to produce a new Cargo

@bors
Copy link
Contributor

bors commented Mar 30, 2016

⌛ Testing commit d382d6a with merge 1a6a32e...

bors added a commit that referenced this pull request Mar 30, 2016
install-deps.py: add x86_64-unknown-linux-musl target

This lets me build a statically linked cargo on our linux-cross Docker image with the following
commands:

$ apt-get install musl-tools # for musl-gcc, which is needed to build openssl
$ ./.travis.install.deps.sh
$ ./configure --local-rust-root=$(pwd)/rustc --enable-nightly --target=x86_64-unknown-linux-musl
$ make
$ file target/x86_64-unknown-linux-musl/release/cargo
cargo: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked (..)

---

r? @alexcrichton -- If we want start building cargo for this target on the bots, we'll have to modify the linux-cross Dockerfile to install musl-tools.
cc @eddyb
@bors
Copy link
Contributor

bors commented Mar 30, 2016

💔 Test failed - cargo-win-gnu-64

@alexcrichton
Copy link
Member

@bors: retry

good ol' high quality MSYS make

On Wed, Mar 30, 2016 at 9:32 AM, bors [email protected] wrote:

[image: 💔] Test failed - cargo-win-gnu-64
http://buildbot.rust-lang.org/builders/cargo-win-gnu-64/builds/433


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#2532 (comment)

@bors
Copy link
Contributor

bors commented Mar 30, 2016

⚡ Previous build results for cargo-cross-linux, cargo-linux-32, cargo-linux-64, cargo-mac-32, cargo-mac-64, cargo-win-gnu-32, cargo-win-msvc-32, cargo-win-msvc-64 are reusable. Rebuilding only cargo-win-gnu-64...

@bors
Copy link
Contributor

bors commented Mar 30, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants