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

[beta] rustc_const_math: undefined reference to `rust_eh_personality' #40251

Closed
cuviper opened this issue Mar 4, 2017 · 6 comments
Closed

[beta] rustc_const_math: undefined reference to `rust_eh_personality' #40251

cuviper opened this issue Mar 4, 2017 · 6 comments

Comments

@cuviper
Copy link
Member

cuviper commented Mar 4, 2017

While testing 1.16.0-beta.3 builds on Fedora, I'm getting a link error for rust_eh_personality on i686 and armv7hl, but not on the rest of arches which are all 64-bit. I'm also seeing this only on Fedora 24/25 with LLVM-3.8, not on Fedora rawhide with LLVM-3.9.

   Compiling rustc_const_math v0.0.0 (file:///builddir/build/BUILD/rustc-beta-src/src/librustc_const_math)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m32" "-L" "/builddir/build/BUILD/rustc-beta-src/build/i686-unknown-linux-gnu/stage1/lib/rustlib/i686-unknown-linux-gnu/lib" "/builddir/build/BUILD/rustc-beta-src/build/i686-unknown-linux-gnu/stage1-rustc/i686-unknown-linux-gnu/release/deps/rustc_const_math-3eb308102ead4d97.0.o" "-o" "/builddir/build/BUILD/rustc-beta-src/build/i686-unknown-linux-gnu/stage1-rustc/i686-unknown-linux-gnu/release/deps/librustc_const_math-3eb308102ead4d97.so" "/builddir/build/BUILD/rustc-beta-src/build/i686-unknown-linux-gnu/stage1-rustc/i686-unknown-linux-gnu/release/deps/rustc_const_math-3eb308102ead4d97.metadata.o" "-Wl,-O1" "-nodefaultlibs" "-L" "/builddir/build/BUILD/rustc-beta-src/build/i686-unknown-linux-gnu/stage1-rustc/i686-unknown-linux-gnu/release/deps" "-L" "/builddir/build/BUILD/rustc-beta-src/build/i686-unknown-linux-gnu/stage1-rustc/release/deps" "-L" "/builddir/build/BUILD/rustc-beta-src/build/i686-unknown-linux-gnu/stage1/lib/rustlib/i686-unknown-linux-gnu/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "-L" "/builddir/build/BUILD/rustc-beta-src/build/i686-unknown-linux-gnu/stage1-rustc/i686-unknown-linux-gnu/release/deps" "-l" "syntax-361284d4f5fb5940" "-L" "/builddir/build/BUILD/rustc-beta-src/build/i686-unknown-linux-gnu/stage1-rustc/i686-unknown-linux-gnu/release/deps" "-l" "rustc_data_structures-b6582de1b9706e19" "-L" "/builddir/build/BUILD/rustc-beta-src/build/i686-unknown-linux-gnu/stage1-rustc/i686-unknown-linux-gnu/release/deps" "-l" "rustc_errors-11fbf09a24007839" "-L" "/builddir/build/BUILD/rustc-beta-src/build/i686-unknown-linux-gnu/stage1-rustc/i686-unknown-linux-gnu/release/deps" "-l" "log-15b4e8336a0a4a4a" "-L" "/builddir/build/BUILD/rustc-beta-src/build/i686-unknown-linux-gnu/stage1/lib/rustlib/i686-unknown-linux-gnu/lib" "-l" "term-1f8b28580ffa517e" "-L" "/builddir/build/BUILD/rustc-beta-src/build/i686-unknown-linux-gnu/stage1-rustc/i686-unknown-linux-gnu/release/deps" "-l" "syntax_pos-091c6cfef6161c2c" "-L" "/builddir/build/BUILD/rustc-beta-src/build/i686-unknown-linux-gnu/stage1-rustc/i686-unknown-linux-gnu/release/deps" "-l" "serialize-41fa6f76166d8a6e" "-L" "/builddir/build/BUILD/rustc-beta-src/build/i686-unknown-linux-gnu/stage1/lib/rustlib/i686-unknown-linux-gnu/lib" "-l" "std-675d08ed24b25a61" "/tmp/rustc.QQnGwqNawKRQ/libcompiler_builtins-55bf5e5eafc786cf.rlib" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "util" "-shared" "-Wl,-z,relro,-z,now"
  = note: /builddir/build/BUILD/rustc-beta-src/build/i686-unknown-linux-gnu/stage1-rustc/i686-unknown-linux-gnu/release/deps/rustc_const_math-3eb308102ead4d97.0.o:(.data.DW.ref.rust_eh_personality[DW.ref.rust_eh_personality]+0x0): undefined reference to `rust_eh_personality'
          collect2: error: ld returned 1 exit status


error: aborting due to previous error

error: Could not compile `rustc_const_math`.

The problem seems exactly like that described in commit 92e6c53, part of #38482. On the F25 system, the stage1 libcompiler_builtins.rlib contains undefined references to rust_eh_personality, and the working rawhide system does not. I don't know how they identified where the reference is coming from, but since this seems dependent on the LLVM version, I guess there's still some missing optimization or analysis that needs to be cleaned up.

cc @est31 @nagisa

@cuviper
Copy link
Member Author

cuviper commented Mar 4, 2017

Here are the two libraries, where llvm38 fails and llvm39 works:
rust40251-libcompiler_builtins.zip

@cuviper
Copy link
Member Author

cuviper commented Mar 4, 2017

That commit describes this only happening with optimizations turned off, but I do have optimization on. I also have debuginfo on, in case that matters. I also see a DW.ref.rust_eh_personality, but I'm not sure if that's relevant.

@est31
Copy link
Member

est31 commented Mar 4, 2017

@cuviper can you upload the binary somewhere? EDIT: oh, seems you did. Debuginfo turned on is really great, it can help us nail down the offender.

Also, have you turned debug assertions on? If yes, maybe try turning them off.

@cuviper
Copy link
Member Author

cuviper commented Mar 4, 2017

I don't think I have debug assertions - at least not in config.mk, just CFG_ENABLE_DEBUGINFO := 1.

@nagisa
Copy link
Member

nagisa commented Mar 4, 2017

I also see a DW.ref.rust_eh_personality, but I'm not sure if that's relevant.

It is. That’s the thing which preserves the only reference to rust_eh_personality. I’m not sure why it remanins, but it shouldn’t be present in the first place.

arielb1 pushed a commit to arielb1/rust that referenced this issue Mar 8, 2017
…=alexcrichton

Fix personality_fn within the compiler_builtins

compiler_builtins may not have any unwinding within it to link correctly. This is notoriously
finicky, and this small piece of change removes yet another case where personality function
happens to get introduced.

Side note: I do remember solving the exact same thing before. I wonder why it has reappered...

@cuviper, could you please try building beta with this patch applied? It should apply cleanly. If it works, I’ll nominate to land this into beta.

Fixes(?) rust-lang#40251
@Mark-Simulacrum
Copy link
Member

@cuviper confirmed fixed in #40254.

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

No branches or pull requests

4 participants