Bug 1639485

Summary: corrupted objects in Rust's libstd.rlib on armv7hl
Product: [Fedora] Fedora Reporter: Josh Stone <jistone>
Component: binutilsAssignee: Nick Clifton <nickc>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: aoliva, dvlasenk, fweimer, jakub, nickc, rust-sig
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-22 16:39:33 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Josh Stone 2018-10-15 20:30:49 UTC
Description of problem:
Builds using rust-1.29.2 are failing to find some backtrace symbols on armv7hl only.  This appears to be some corruption of the objects in libstd.rlib (an "ar" archive).  The same Rust version is fine on F29, and the prior 1.29.1 was also fine on rawhide.

I'm not sure where the problem lies, so I'm just starting it on binutils.  The compiler bootstrapped itself fine, and the %check results look typical, so I suspect the problem is something in post-install.

Version-Release number of selected component (if applicable):
A few that seem relevant, different from the prior build:
annobin-8.53-1.fc30.armv7hl
binutils-2.31.1-14.fc30.armv7hl
rpm-4.14.2-7.fc30.armv7hl
rust-1.29.2-3.fc30.armv7hl
cargo-1.29.0-3.fc30.armv7hl

How reproducible:
100%

Steps to Reproduce:
1. cargo new hello
2. cd hello/
3. cargo run

Actual results:
   Compiling hello v0.1.0 (file:///tmp/hello)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-L" "/usr/lib/rustlib/armv7-unknown-linux-gnueabihf/lib" "/tmp/hello/target/debug/deps/hello-7b8f6b0cd67c5190.1y16o1qfye96o7m0.rcgu.o" "/tmp/hello/target/debug/deps/hello-7b8f6b0cd67c5190.3rngp6bm2u2q5z0y.rcgu.o" "/tmp/hello/target/debug/deps/hello-7b8f6b0cd67c5190.4oc10dk278mpk1vy.rcgu.o" "/tmp/hello/target/debug/deps/hello-7b8f6b0cd67c5190.4xq48u46a1pwiqn7.rcgu.o" "/tmp/hello/target/debug/deps/hello-7b8f6b0cd67c5190.544l4wfz89vbhoea.rcgu.o" "/tmp/hello/target/debug/deps/hello-7b8f6b0cd67c5190.oa3rad818d8sgn4.rcgu.o" "-o" "/tmp/hello/target/debug/deps/hello-7b8f6b0cd67c5190" "/tmp/hello/target/debug/deps/hello-7b8f6b0cd67c5190.crate.allocator.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/tmp/hello/target/debug/deps" "-L" "/usr/lib/rustlib/armv7-unknown-linux-gnueabihf/lib" "-Wl,--start-group" "-Wl,-Bstatic" "/usr/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libstd-3c1ac0c18307a26c.rlib" "/usr/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libpanic_unwind-0cd8db65cd5cad8a.rlib" "/usr/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libunwind-af4f624361145583.rlib" "/usr/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/liballoc_system-23381d84007bc683.rlib" "/usr/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/liblibc-3742de2bfa3f3f57.rlib" "/usr/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/liballoc-ec50fb91ce9425e4.rlib" "/usr/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libcore-6957c9e80cf7e5a1.rlib" "-Wl,--end-group" "/usr/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libcompiler_builtins-362a06d915f1aff9.rlib" "-Wl,-Bdynamic" "-ldl" "-lrt" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil"
  = note: /usr/bin/ld: /usr/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libstd-3c1ac0c18307a26c.rlib(std-3c1ac0c18307a26c.std6-dc336450c6219793961ba7e2856ac46a.rs.rcgu.o): in function `std::sys_common::gnu::libbacktrace::foreach_symbol_fileline':
          (.text._ZN3std10sys_common3gnu12libbacktrace23foreach_symbol_fileline17ha2c26b6688d38548E+0x1ac): undefined reference to `backtrace_create_state'
          /usr/bin/ld: (.text._ZN3std10sys_common3gnu12libbacktrace23foreach_symbol_fileline17ha2c26b6688d38548E+0x1f0): undefined reference to `backtrace_pcinfo'
          /usr/bin/ld: /usr/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libstd-3c1ac0c18307a26c.rlib(std-3c1ac0c18307a26c.std6-dc336450c6219793961ba7e2856ac46a.rs.rcgu.o): in function `std::sys_common::gnu::libbacktrace::resolve_symname':
          (.text._ZN3std10sys_common3gnu12libbacktrace15resolve_symname17hb530d56ed4464aa6E+0xa0): undefined reference to `backtrace_create_state'
          /usr/bin/ld: (.text._ZN3std10sys_common3gnu12libbacktrace15resolve_symname17hb530d56ed4464aa6E+0xdc): undefined reference to `backtrace_syminfo'
          /usr/bin/ld: /usr/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libstd-3c1ac0c18307a26c.rlib(std-3c1ac0c18307a26c.std6-dc336450c6219793961ba7e2856ac46a.rs.rcgu.o): in function `std::sys_common::gnu::libbacktrace::resolve_symname':
          (.text._ZN3std10sys_common3gnu12libbacktrace15resolve_symname17hef4dabc6efa56fd3E+0xa0): undefined reference to `backtrace_create_state'
          /usr/bin/ld: (.text._ZN3std10sys_common3gnu12libbacktrace15resolve_symname17hef4dabc6efa56fd3E+0xdc): undefined reference to `backtrace_syminfo'
          collect2: error: ld returned 1 exit status


error: aborting due to previous error

error: Could not compile `hello`.


Expected results:
Hello, world!

Additional info:
Using "nm" on the bad libstd.rlib shows errors that aren't present on the working builds.

$ nm usr/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libstd-3c1ac0c18307a26c.rlib >/dev/null
nm: usr/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libstd-3c1ac0c18307a26c.rlib(alloc.o): no group info for section .ARM.exidx.text.backtrace_alloc
nm: usr/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libstd-3c1ac0c18307a26c.rlib(alloc.o): unknown type [0x70000001] section `.ARM.exidx.text.backtrace_alloc'
nm: alloc.o: Bad value
nm: usr/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libstd-3c1ac0c18307a26c.rlib(backtrace.o): no group info for section .ARM.exidx.text.unwind
nm: usr/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libstd-3c1ac0c18307a26c.rlib(backtrace.o): unknown type [0x70000001] section `.ARM.exidx.text.unwind'
nm: backtrace.o: Bad value
...

Here are the Rust builds:
GOOD rust-1.29.1-2.fc30: https://koji.fedoraproject.org/koji/buildinfo?buildID=1147651
BAD  rust-1.29.2-3.fc30: https://koji.fedoraproject.org/koji/buildinfo?buildID=1152959
GOOD rust-1.29.2-3.fc29: https://koji.fedoraproject.org/koji/buildinfo?buildID=1153010

Buildroot differences that look significant:
binutils 2.31.1-13.fc30 -> 2.31.1-14.fc30
annobin 8.41-1.fc30 -> 8.53-1.fc30
rpm 4.14.2-1.fc30 -> 4.14.2-7.fc30

Build that failed to use rustc on armv7hl:
rust-syn-0.15.11-1.fc30: https://koji.fedoraproject.org/koji/taskinfo?taskID=30252014

Comment 1 Nick Clifton 2018-10-19 12:15:36 UTC
Hi Josh,

  I have updated the rawhide binutils so that nm will no longer complain
  about unknown section types.  This patch *might* also fix the link
  problems, although I am having difficulty finding a machine to test this.

  Anyway, you may find that a scratch rebuild now works.  Please give it
  a try if you have the time.

Cheers
  Nick

PS. The patched binutils is binutils-2.31.1-15.fc30

Comment 2 Josh Stone 2018-10-20 00:03:32 UTC
The new binutils can read the existing rlib without error, so I was hoping this would mean we're all set, but that rlib still doesn't link properly.  Then I bootstrapped a whole new rust build (scratch), and this seems to be working!
https://koji.fedoraproject.org/koji/taskinfo?taskID=30333239

Comment 4 Josh Stone 2018-10-22 16:39:33 UTC
I bootstrapped armv7hl in rust-1.29.2-4.fc30, and 5.fc30 is building now without bootstrap binaries.  A few rust crates have since been built fine with 4.fc30, including a scratch build I just did of rust-syn which had first triggered the original problem.

Thanks for the quick response, Nick!