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

Linking liblibc using musl target fails ("unrecognized relocation") with the new nightlies #39979

Closed
golddranks opened this issue Feb 20, 2017 · 12 comments
Labels
A-linkage Area: linking into static, shared libraries and binaries regression-from-stable-to-nightly Performance or correctness regression from stable to nightly.

Comments

@golddranks
Copy link
Contributor

golddranks commented Feb 20, 2017

Here's a dockerized test case: https://github.com/golddranks/libc_regression_test/ (run with docker build .)

Here's the error:

  = note: /usr/bin/ld: /root/.rustup/toolchains/nightly-2017-02-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/liblibc-95af4192ed69a1c8.rlib(exit.lo): unrecognized relocation (0x2a) in section `.text.libc_exit_fini'
          /usr/bin/ld: final link failed: Bad value
          collect2: error: ld returned 1 exit status

The linking error seems to happen only with the musl target. I originally posted this as rust-lang/libc#529, but because the breaking is dependent on the nightly, it seems that this is an rustc issue rather than an issue of the libc crate.

After testing with various nightlies, it seems that the nightly nightly-2017-02-16 installed - rustc 1.17.0-nightly (62eb6056d 2017-02-15) is the first one that breaks. The nightly before that, nightly-2017-02-13 installed - rustc 1.17.0-nightly (956e2bcba 2017-02-12) is the last one that works.

So that seems to imply that the commit that introduced this regression is in the range 956e2bcba..62eb6056d. Any thoughts about which one it might be?

@TimNN
Copy link
Contributor

TimNN commented Feb 20, 2017

I can reproduce this with the docker image (by the way @golddranks, there's no need to build musl yourself).

Diff for 956e2bcba..62eb6056d.

This works fine on stable, thus tagging as a regression.

@TimNN TimNN added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-tools A-linkage Area: linking into static, shared libraries and binaries labels Feb 20, 2017
@TimNN
Copy link
Contributor

TimNN commented Feb 20, 2017

I cannot reproduce this with a current ubuntu release. After some looking around, I believe that the problem could be that the binutils version used by the buildbots / travis is to new.

During the time this was introduced, the nightlies were switched from buildbot to travis so I guess this may have caused this problem (cc @alexcrichton).

@golddranks
Copy link
Contributor Author

@TimNN, thanks for the pointer, the Dockerfile uses now the distro-provided musl. (But errors nevertheless, so it isn't just the self-built musl that has this problem.)

@TimNN
Copy link
Contributor

TimNN commented Feb 20, 2017

@golddranks: I actually meant to say, that you don't need to get any kind of musl yourself: musl is linked statically into the rust stdlib (unless I am misremembering something).

@golddranks
Copy link
Contributor Author

Ah, really? I've been building musl stuff with native dependencies, which I have had to build by hand, so I've always needed the musl build environment anyway, so I didn't know this :D

@alexcrichton
Copy link
Member

alexcrichton commented Feb 21, 2017

This looks like #34978 and agreed this is likely a regression in switching nightlies to Travis/AppVeyor. The fix last time was to pass -Wa,-mrelax-relocations=no when compiling C code, but we should be doing that. This may just erroneously not be ferrying along those arguments?

Another possible bug, although I forget if it has this exact signature, is that when we compile binaries with a very new binutils it ends up being incompatible with older binutils (for whatever reason). There's typically flags we can pass, though, to disable the "new binutils behavior incompatible with older binutils".

Also FWIW this is how we build nightlies

Oh.... maybe it's because we don't pass the flag when building musl itself.

alexcrichton added a commit to alexcrichton/rust that referenced this issue Feb 21, 2017
The mitigations for rust-lang#34978 involve passing `-Wa,-mrelax-relocations=no` to all C
code we compile, and we just forgot to pass it when compiling musl itself.

Closes rust-lang#39979
@alexcrichton
Copy link
Member

Ok, I've got a fix at #40019

eddyb added a commit to eddyb/rust that referenced this issue Feb 25, 2017
travis: Compile a more compatible libc.a for musl

The mitigations for rust-lang#34978 involve passing `-Wa,-mrelax-relocations=no` to all C
code we compile, and we just forgot to pass it when compiling musl itself.

Closes rust-lang#39979
eddyb added a commit to eddyb/rust that referenced this issue Feb 25, 2017
travis: Compile a more compatible libc.a for musl

The mitigations for rust-lang#34978 involve passing `-Wa,-mrelax-relocations=no` to all C
code we compile, and we just forgot to pass it when compiling musl itself.

Closes rust-lang#39979
@golddranks
Copy link
Contributor Author

The fix landed on the commit 1572bf1, but the same error occurs even on the latest nightly (60a0edc6c 2017-02-26), which is based on a commit that landed after 1572bf1.

So the problem isn't solved yet.

@golddranks
Copy link
Contributor Author

Ah, but this times the error is:

  = note: /usr/bin/ld: /root/.rustup/toolchains/nightly-2017-02-27-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/liballoc_jemalloc-4b74d6f2808677d3.rlib(jemalloc.pic.o): unrecognized relocation (0x2a) in section `.text.malloc_conf_init'
          /usr/bin/ld: final link failed: Bad value
          collect2: error: ld returned 1 exit status

So it seems that jemalloc needs the same treatment?

alexcrichton added a commit to alexcrichton/rust that referenced this issue Feb 27, 2017
These flags were supposed to be relevant for musl, not for gnu

cc rust-lang#39979
@alexcrichton
Copy link
Member

@golddranks oh I think that's #40130 (an accidental typo)

steveklabnik added a commit to steveklabnik/rust that referenced this issue Feb 28, 2017
…matsakis

travis: Fix typos in linux-tested-targets

These flags were supposed to be relevant for musl, not for gnu

cc rust-lang#39979
@BurntSushi
Copy link
Member

Whatever it was, this is fixed for me now in the 2017-03-02 nightly: https://travis-ci.org/BurntSushi/ripgrep/jobs/206572974

@BurntSushi
Copy link
Member

Thanks @alexcrichton! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries regression-from-stable-to-nightly Performance or correctness regression from stable to nightly.
Projects
None yet
Development

No branches or pull requests

4 participants