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

libcore fails to compile for thumbv6m-none-eabi #62932

Closed
gnzlbg opened this issue Jul 24, 2019 · 19 comments · Fixed by #63302
Closed

libcore fails to compile for thumbv6m-none-eabi #62932

gnzlbg opened this issue Jul 24, 2019 · 19 comments · Fixed by #63302
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Jul 24, 2019

The libc crate cron job has started failing to build on master for the target thumbv6m-none-eabi. To reproduce:

cargo install xargo
rustup target add thumbv6m-none-eabi
git clone git@github.com:rust-lang/libc.git
cd libc
xargo +nightly build -vv --no-default-features --target thumbv6m-none-eabi

errors with

Compiling core v0.0.0 (/home/travis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore)
     Running `rustc --edition=2018 --crate-name core /home/travis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/lib.rs --color never --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C metadata=60fcc652106674f6 -C extra-filename=-60fcc652106674f6 --out-dir /tmp/xargo.t1IUdReqtxLM/target/thumbv6m-none-eabi/release/deps --target thumbv6m-none-eabi -L dependency=/tmp/xargo.t1IUdReqtxLM/target/thumbv6m-none-eabi/release/deps -L dependency=/tmp/xargo.t1IUdReqtxLM/target/release/deps --sysroot /home/travis/.xargo -Z force-unstable-if-unmarked`
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
  --> /home/travis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/lib.rs:77:37
   |
77 | #![cfg_attr(not(bootstrap), feature(const_generics))]
   |                                     ^^^^^^^^^^^^^^
LLVM ERROR: invalid symbol redefinition
error: Could not compile `core`.

libcore failing to build for the target is bad - that it prevents to build the libc crate for the target is a sideeffect of that.

@gnzlbg gnzlbg changed the title [regression] libc crate no longer builds on master libcore fails to compile for thumbv6m-none-eabi Jul 24, 2019
@jonas-schievink jonas-schievink added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-nominated O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 24, 2019
@nikic
Copy link
Contributor

nikic commented Jul 24, 2019

I wasn't able to reproduce this based on your instructions. Though for me there is no attempt to even build core, it just builds libc.

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Jul 24, 2019

Though for me there is no attempt to even build core, it just builds libc.

Weird. The first thing xargo does is build a sysroot for the target, and the first step of doing that is building libcore.

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Jul 24, 2019

See the exact build failure in libc's CI which mentions the exact same xargo invocation and how the first thing xargo does is building libcore: https://travis-ci.com/rust-lang/libc/jobs/219031083#L5403

@nikic
Copy link
Contributor

nikic commented Jul 24, 2019

I suspect that it doesn't build libcore because it's already distributed by rustup (and removing the rustup target makes compilation fail with libcore not found). Maybe something needs to be done to force building of libcore even for a non-custom target?

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Jul 24, 2019

I don't really follow. xargo and cargo-xbuild ignore anything distributed by rustup, except for the rust-src component, which include libcore sources, and as can be seen in the logs, the first thing they do is compiling the core crate, which fails with an LLVM error since the LLVM upgrade.

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Jul 24, 2019

AFAIK, we do not ship a rust-std component for this particular target.

@jonas-schievink
Copy link
Contributor

thumbv6m-none-eabi has a rust-std component that contains just libcore (it's the only target we ship that works on Cortex-M0 chips, so it's quite important for embedded)

@nikomatsakis
Copy link
Contributor

@gnzlbg can you try to bisect the regression -- ideally to a specific PR? The https://github.com/rust-lang-nursery/cargo-bisect-rustc tool may be of use! I'm marking this as P-high so that we check in on it but it seems like it's not yet clear whether this is a compiler bug exactly or what.

@nikomatsakis nikomatsakis added P-high High priority E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc and removed I-nominated labels Jul 25, 2019
@gnzlbg
Copy link
Contributor Author

gnzlbg commented Jul 25, 2019

I think it would be helpful if somebody else can reproduce this issue first. Following the instructions that I posted in the OP, I can reproduce this both on a x86_64-unknown-linux-gnu and a x86_64-apple-darwin host, with the current nightly (rustc 1.38.0-nightly (03f19f7 2019-07-24)).

@nikic which host are you on ?

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Jul 25, 2019

@nikomatsakis PR wise we started seeing this right after #62592 was merged. I'm afraid that on my home laptop compiling rustc twice to test will take me... days.

@jonas-schievink

This comment has been minimized.

@nikic
Copy link
Contributor

nikic commented Jul 25, 2019

@gnzlbg I was able to reproduce after doing a rustup default nightly. I'm not sure why that works while xargo +nightly doesn't. Now I get the LLVM error.

@jonas-schievink
Copy link
Contributor

Ah, indeed! rustup override add nightly makes the error appear.

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Jul 25, 2019

I'm not sure why that works while xargo +nightly doesn't.

So I do indeed have nightly as my default Rust toolchain, and on libc's CI this is the case as well for that build job. I'll report this to xargo upstream.

@nikic
Copy link
Contributor

nikic commented Jul 25, 2019

There's a couple of places that can throw this error, the one we hit is https://github.com/llvm/llvm-project/blob/930df11a0d00c467b17c76f2b782a96bf721599b/llvm/lib/MC/MCStreamer.cpp#L354-L355.

The symbol in question is .LJTI27_0, a jump-table label.

@nikic
Copy link
Contributor

nikic commented Jul 25, 2019

Finally managed to get a reproducer (turns out this only crashes llc at -O3): https://gist.github.com/nikic/1fa40bc972e815f9606518c5b2218699

@nikic
Copy link
Contributor

nikic commented Jul 25, 2019

I've opened an LLVM bug at https://bugs.llvm.org/show_bug.cgi?id=42760.

@nikic nikic removed the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Jul 25, 2019
@gnzlbg
Copy link
Contributor Author

gnzlbg commented Aug 1, 2019

FYI rust-lang/stdarch game boy advance build job is affected by this as well.

@nikic
Copy link
Contributor

nikic commented Aug 5, 2019

Fixed upstream in llvm/llvm-project@4f8259b and backported to LLVM 9 in llvm/llvm-project@4e21661.

LLVM submodule update pending in #63302.

Centril added a commit to Centril/rust that referenced this issue Aug 9, 2019
Update LLVM submodule

This pulls in a newer version of the LLVM 9 release branch.

Fixes rust-lang#62932.

r? @alexcrichton
bors added a commit that referenced this issue Aug 9, 2019
Update LLVM submodule

This pulls in a newer version of the LLVM 9 release branch.

Fixes #62932.

r? @alexcrichton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants