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

LLVM ERROR: Unexpected anonymous function when writing summary #51947

Closed
japaric opened this issue Jun 30, 2018 · 8 comments
Closed

LLVM ERROR: Unexpected anonymous function when writing summary #51947

japaric opened this issue Jun 30, 2018 · 8 comments
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. WG-embedded Working group: Embedded systems

Comments

@japaric
Copy link
Member

japaric commented Jun 30, 2018

When compiling the compiler_builtins crate for any of the thumb targets in release mode and with debuginfo enabled. Without debuginfo the build succeeds (we are testing this by building rust-std for the thumb targets). This doesn't affect the ARM Linux targets.

STR

$ cp -r $(rustc --print sysroot)/lib/rustlib/src/rust/src/ src && cd $_

$ cd libcompiler_builtins

$ cat >>Cargo.toml <<'EOF'
[profile.release]
debug = true
EOF

$ cargo build --target thumbv7m-none-eabi --release
LLVM ERROR: Unexpected anonymous function when writing summary

Metadata

$ rustc -V
rustc 1.28.0-nightly (e3bf634e0 2018-06-28)

Needs bisecting

cc @alexcrichton

@japaric japaric added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Jun 30, 2018
@Mark-Simulacrum
Copy link
Member

$ cargo-bisect-rustc --start 56714acc5eb0687ed9a7566fdebe5528657fc5b3 --target thumbv7m-none-eabi --prompt --test-dir case/src/libcompiler_builtins --by-commit  -- build --target thumbv7m-none-eabi --release

searched toolchains 56714acc5eb0687ed9a7566fdebe5528657fc5b3 through 96b47337d9deebdb9cbca909e7772672062021e5
regression in e1151c9819cca90e511f60757297629177272d16

e1151c9 - #49479 - cc @nagisa @nox

@Mark-Simulacrum Mark-Simulacrum added the WG-embedded Working group: Embedded systems label Jun 30, 2018
@nikic
Copy link
Contributor

nikic commented Jun 30, 2018

Could this be hitting the case where linking is performed without thinlto, but bitcode is still being written through thinlto buffers? It might be worth trying to apply these changes and see if it fixes the issue: https://github.com/rust-lang/rust/pull/51007/files#diff-a3c60982b42eac1d2e3fd67f4d562ae8R550

@nagisa
Copy link
Member

nagisa commented Jun 30, 2018

Yeah, the error message definitely sounds related to thinlto. At least "summary" is a thinlto concept.

That being said, it doesn’t seem like thinlto is disabled anywhere in the original report, so…

@agalakhov
Copy link

I just tried it with "-Z thinlto=no", and it does NOT help.

@aribeironovaes
Copy link

Hi @japaric ,

Did you figure our how to fix this issue?
I'm trying to run cortex-m-quickstart on a STM32L475 and I'm getting Stuck on the LLVM ERROR: Unexpected anonymous function when writing summary error if debug = true.

Can you let me know if you could successfully run the sample on this version of Cortex M4?

Thanks lot in advance,

Angelo Ribeiro.

@maximevince
Copy link

Same problem here! Any solution or workaround known?

@nikic
Copy link
Contributor

nikic commented Nov 1, 2018

Running with -C lto=thin worked for me, so I think my general guess in #51947 (comment) was right -- unfortunately the linked patch has landed in the meantime and has not fixed the issue. rustc is being run with --crate-type lib --emit=dep-info,link here, I'll have to check what exactly that means for bitcode emission.

@nikic
Copy link
Contributor

nikic commented Nov 1, 2018

Here is a reproducer without the compiler_builtins/thumb dependency:

#![feature(linkage)]
  
#[linkage = "weak"]
pub fn fn1(a: u32, b: u32, c: u32) -> u32 {
    a + b + c
}

#[linkage = "weak"]
pub fn fn2(a: u32, b: u32, c: u32) -> u32 {
    a + b + c
}

Compiled with --crate-type=rlib -O this produces the anon function error.

nikic added a commit to nikic/rust that referenced this issue Nov 6, 2018
If we're going to emit bitcode (through ThinLTOBuffer), then we
need to ensure that anon globals are named. This was already done
after optimization passes, but also has to happen after LTO passes,
as we always emit the final result in a ThinLTO-compatible manner.

Fixes rust-lang#51947.
kennytm added a commit to kennytm/rust that referenced this issue Nov 7, 2018
Run name-anon-globals after LTO passes as well

If we're going to emit bitcode (through ThinLTOBuffer), then we need to ensure that anon globals are named. This was already done after optimization passes, but also has to happen after LTO passes, as we always emit the final result in a ThinLTO-compatible manner.

I added the test as `run-make`. The important bit is that we emit bitcode in some way (e.g. `--crate-type rlib` or `--emit=llvm-bc`). Please tell me if there is a better way to test for that.

Fixes rust-lang#51947
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. WG-embedded Working group: Embedded systems
Projects
None yet
Development

No branches or pull requests

7 participants