rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.58k stars 12.62k forks source link

rust 1.38.0 build fails on NetBSD/powerpc with internal LLVM #65862

Closed he32 closed 4 years ago

he32 commented 4 years ago

The build of rust 1.38.0 natively on NetBSD/powerpc 8.0 fails if the build is instructed to use the internal LLVM. The corresponding build with an external LLVM (version 8.0.1) succeeds.

The failure is fairly similar to what is seen in issue #64903 -- in this case the build stops with and not during the build of ryu:

   Compiling quick-error v1.2.2
   Compiling rustc_driver v0.0.0 (/usr/pkgsrc/lang/rust/work/rustc-1.38.0-src/src/librustc_driver)
   Compiling semver v0.9.0
   Compiling arrayvec v0.4.7
error: failed to run custom build command for `libc v0.2.60`

Caused by:
  process didn't exit successfully: `/usr/pkgsrc/lang/rust/work/rustc-1.38.0-src/build/powerpc-unknown-netbsd/stage1-rustc/release/build/libc-37e397b190d97e24/build-script-build` (signal: 11, SIGSEGV: invalid memory reference)
command did not execute successfully: "/usr/pkgsrc/lang/rust/work/rust-bootstrap/bin/cargo" "build" "--target" "powerpc-unknown-netbsd" "-j" "1" "--release" "--frozen" "--features" "" "--manifest-path" "/usr/pkgsrc/lang/rust/work/rustc-1.38.0-src/src/rustc/Cargo.toml" "--message-format" "json"
expected success, got: exit code: 101
Traceback (most recent call last):
  File "./x.py", line 11, in <module>
    bootstrap.main()

The stack backtrace from GDB is however nearly impossible to make any sense of:

golden-delicious: {4} gdb /usr/pkgsrc/lang/rust/work/rustc-1.38.0-src/build/powerpc-unknown-netbsd/stage1-rustc/release/build/libc-37e397b190d97e24/build-script-build work/rustc-1.38.0-src/vendor/libc/build-script-bui.core
GNU gdb (GDB) 7.12
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "powerpc--netbsd".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/pkgsrc/lang/rust/work/rustc-1.38.0-src/build/powerpc-unknown-netbsd/stage1-rustc/release/build/libc-37e397b190d97e24/build-script-build...(no debugging symbols found)...done.
[New process 1]
Core was generated by `build-script-bui'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000625f0 in ?? ()
(gdb) where
#0  0x000625f0 in ?? ()
#1  0x00030ea0 in __rdos_backtrace_dwarf_add ()
#2  0xffffd83f in ?? ()
#3  0x4f5f4346 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb) 
(gdb) i reg
r0             0x1c844  116804
r1             0xffffca30       4294953520
r2             0xfdeffa08       4260362760
r3             0xd      13
r4             0x1      1
r5             0x1      1
r6             0xffffcb04       4294953732
r7             0xfde8ad04       4259884292
r8             0x0      0
r9             0xfdef8a00       4260334080
r10            0xfdead958       4260026712
r11            0xfdd63f7c       4258676604
r12            0x24000402       603980802
r13            0x9fe60  654944
r14            0x0      0
r15            0x0      0
r16            0x0      0
r17            0x0      0
r18            0x0      0
r19            0x0      0
r20            0x0      0
r21            0x0      0
r22            0x0      0
r23            0x0      0
r24            0x0      0
r25            0x0      0
r26            0x0      0
r27            0x0      0
r28            0x1      1
r29            0xffffcb04       4294953732
r30            0xa67c8  681928
r31            0xffffeff0       4294963184
pc             0x625f0  0x625f0
msr            <unavailable>
cr             0x24000402       603980802
lr             0x30ea0  0x30ea0 <__rdos_backtrace_dwarf_add+320>
ctr            0xfdd63f7c       4258676604
xer            0x0      0
(gdb) x/i 0x625f0
=> 0x625f0:     .long 0x0
(gdb) x/i __rdos_backtrace_dwarf_add+320
   0x30ea0 <__rdos_backtrace_dwarf_add+320>:    lwz     r10,136(r1)
(gdb) 
...
(gdb) 
   0x30e54 <__rdos_backtrace_dwarf_add+244>:    addi    r3,r1,128
   0x30e58 <__rdos_backtrace_dwarf_add+248>:    stw     r8,64(r1)
   0x30e5c <__rdos_backtrace_dwarf_add+252>:    li      r27,0
   0x30e60 <__rdos_backtrace_dwarf_add+256>:    stw     r5,60(r1)
   0x30e64 <__rdos_backtrace_dwarf_add+260>:    bl      0x2da98 <read_uint32>
   0x30e68 <__rdos_backtrace_dwarf_add+264>:    cmpwi   cr7,r3,-1
   0x30e6c <__rdos_backtrace_dwarf_add+268>:    addi    r22,r1,160
   0x30e70 <__rdos_backtrace_dwarf_add+272>:    addi    r31,r1,224
   0x30e74 <__rdos_backtrace_dwarf_add+276>:    addi    r28,r1,192
   0x30e78 <__rdos_backtrace_dwarf_add+280>:    mr      r9,r3
   0x30e7c <__rdos_backtrace_dwarf_add+284>:    li      r19,0
   0x30e80 <__rdos_backtrace_dwarf_add+288>:
    beq     cr7,0x31114 <__rdos_backtrace_dwarf_add+948>
   0x30e84 <__rdos_backtrace_dwarf_add+292>:    lwz     r10,128(r1)
   0x30e88 <__rdos_backtrace_dwarf_add+296>:    mr      r4,r9
   0x30e8c <__rdos_backtrace_dwarf_add+300>:    addi    r3,r1,128
   0x30e90 <__rdos_backtrace_dwarf_add+304>:    stw     r9,172(r1)
   0x30e94 <__rdos_backtrace_dwarf_add+308>:    stw     r10,160(r1)
   0x30e98 <__rdos_backtrace_dwarf_add+312>:    lwz     r10,132(r1)
   0x30e9c <__rdos_backtrace_dwarf_add+316>:    stw     r10,164(r1)
   0x30ea0 <__rdos_backtrace_dwarf_add+320>:    lwz     r10,136(r1)
(gdb) 

When the rust build is instructed to use an external LLVM (version 8.0.1) via --enable-llvm-link-shared and --llvm-root=${LLVM_ROOT} on this platform, the build succeeds.

As an additional data point, a native build of rust 1.38.0 on NetBSD/aarch64 using the internal LLVM succeeds, as does a build on NetBSD/amd64, also using the internal LLVM.

he32 commented 4 years ago

I've re-tried the build by trying to use an updated external LLVM (version 9.0.0), and it fails the same way:

error: failed to run custom build command for `libc v0.2.60`

Caused by:
  process didn't exit successfully: `/usr/pkgsrc/lang/rust/work/rustc-1.38.0-src/build/powerpc-unknown-netbsd/stage1-rustc/release/build/libc-37e397b190d97e24/build-script-build` (signal: 11, SIGSEGV: invalid memory reference)

So ... this, sadly, appears to be a regression for powerpc between LLVM 8 and LLVM 9.

elprans commented 4 years ago

FWIW, I consistently get a similar error when compiling Firefox 71 on Gentoo with Rust 1.39 and LLVM 9 on x86-64. Bundled or system LLVM, does not matter in my case.

nikic commented 4 years ago

@elprans Do you also see a similar back trace for the crash?

elprans commented 4 years ago

@nikic Despite an eerily similar crash, my case seems to have been caused by Gentoo's build sandbox. Sorry for the noise!

he32 commented 4 years ago

I've been continuing to track new rust releases, and now that it's cross-compileable again, I've made a new attempt with 1.41.1 and the internal LLVM, and I can no longer reproduce the problem; the rust build completes successfully, and the cross-built compiler can compile itself natively.

Therefore I'm closing this issue.