rust-lang / rust

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

Rust ppc64 requires AltiVec, which is not available on PowerPC e5500 #59040

Open skydig opened 5 years ago

skydig commented 5 years ago

rustc -Vv rustc 1.35.0-nightly (88f755f8a 2019-03-07) binary: rustc commit-hash: 88f755f8a84df1d9e6b17cf10c96ae8b93481b2e commit-date: 2019-03-07 host: x86_64-unknown-linux-gnu release: 1.35.0-nightly LLVM version: 8.0

strace log: munmap(0x3fffa2913000, 14223) = 0 set_tid_address(0x3fffa290c0d0) = 3111 set_robust_list(0x3fffa290c0e0, 24) = 0 rt_sigaction(SIGRTMIN, {0x3fffa288f1c0, [], SA_SIGINFO}, NULL, 8) = 0 rt_sigaction(SIGRT_1, {0x3fffa288f1d8, [], SA_RESTART|SA_SIGINFO}, NULL, 8) = 0 rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0 ugetrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0 --- SIGILL {si_signo=SIGILL, si_code=ILL_ILLOPC, si_addr=0x37149e34} --- +++ killed by SIGILL (core dumped) +++ Illegal instruction (core dumped)

(gdb) b reset_sigpipe Function "reset_sigpipe" not defined. Make breakpoint pending on future shared library load? (y or [n]) y Breakpoint 1 (reset_sigpipe) pending. (gdb) r Starting program: /root/xx [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGILL, Illegal instruction. 0x0000000020017e34 in reset_sigpipe () at src/libstd/sys/unix/mod.rs:77 77 src/libstd/sys/unix/mod.rs: No such file or directory. (gdb) r The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: /root/xx [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1".

Breakpoint 1, lang_start_internal () at src/libstd/rt.rs:30 30 src/libstd/rt.rs: No such file or directory. (gdb) s init () at src/libstd/rt.rs:30 30 in src/libstd/rt.rs (gdb) disassemble Dump of assembler code for function lang_start_internal: 0x0000000020017dec <+0>: mflr r0 0x0000000020017df0 <+4>: std r0,16(r1) 0x0000000020017df4 <+8>: stdu r1,-512(r1) 0x0000000020017df8 <+12>: li r7,416 0x0000000020017dfc <+16>: std r3,120(r1) => 0x0000000020017e00 <+20>: li r3,13 0x0000000020017e04 <+24>: std r4,128(r1) 0x0000000020017e08 <+28>: li r4,1 0x0000000020017e0c <+32>: std r23,440(r1) 0x0000000020017e10 <+36>: std r24,448(r1) 0x0000000020017e14 <+40>: std r25,456(r1) 0x0000000020017e18 <+44>: std r26,464(r1) 0x0000000020017e1c <+48>: std r27,472(r1) 0x0000000020017e20 <+52>: std r28,480(r1) 0x0000000020017e24 <+56>: std r29,488(r1) 0x0000000020017e28 <+60>: mr r29,r5 0x0000000020017e2c <+64>: std r30,496(r1) 0x0000000020017e30 <+68>: mr r30,r6 0x0000000020017e34 <+72>: stvx v31,r1,r7 0x0000000020017e38 <+76>: bl 0x20008fa0 0000097b.plt_call.signal@@GLIBC_2.3 0x0000000020017e3c <+80>: ld r2,40(r1) ---Type to continue, or q to quit---q Quit (gdb) c Continuing.

Program received signal SIGILL, Illegal instruction. 0x0000000020017e34 in reset_sigpipe () at src/libstd/sys/unix/mod.rs:77 77 src/libstd/sys/unix/mod.rs: No such file or directory.

readelf -V xx

Version symbols section '.gnu.version' contains 89 entries: Addr: 00000000000010f8 Offset: 0x0010f8 Link: 5 (.dynsym) 000: 0 (local) 0 (local) 0 (local) d (GLIBC_2.22) 004: 2 (GLIBC_2.3) 2 (GLIBC_2.3) 2 (GLIBC_2.3) 2 (GLIBC_2.3)
008: 3 (GCC_3.3) 4 (GLIBC_2.3) 4 (GLIBC_2.3) 3 (GCC_3.3)
00c: 2 (GLIBC_2.3) 0 (local) 4 (GLIBC_2.3) 4 (GLIBC_2.3)
010: 2 (GLIBC_2.3) 4 (GLIBC_2.3) 2 (GLIBC_2.3) 2 (GLIBC_2.3)
014: 5 (GLIBC_2.18) 6 (GLIBC_2.3.4) 7 (GCC_3.0) 7 (GCC_3.0)
018: 7 (GCC_3.0) 8 (GLIBC_2.3.2) 2 (GLIBC_2.3) 4 (GLIBC_2.3)
01c: 9 (GLIBC_2.3) 2 (GLIBC_2.3) a (GCC_4.2.0) 7 (GCC_3.0)
020: 8 (GLIBC_2.3.2) 2 (GLIBC_2.3) 2 (GLIBC_2.3) 4 (GLIBC_2.3)
024: 2 (GLIBC_2.3) 4 (GLIBC_2.3) 4 (GLIBC_2.3) 0 (local)
028: 4 (GLIBC_2.3) 2 (GLIBC_2.3) 4 (GLIBC_2.3) 4 (GLIBC_2.3)
02c: 8 (GLIBC_2.3.2) 2 (GLIBC_2.3) 4 (GLIBC_2.3) 2 (GLIBC_2.3)
030: 2 (GLIBC_2.3) 4 (GLIBC_2.3) b (GLIBC_2.4) 4 (GLIBC_2.3)
034: 4 (GLIBC_2.3) 2 (GLIBC_2.3) 4 (GLIBC_2.3) 2 (GLIBC_2.3)
038: c (GLIBC_2.3.3) 4 (GLIBC_2.3) 4 (GLIBC_2.3) 2 (GLIBC_2.3)
03c: 4 (GLIBC_2.3) 4 (GLIBC_2.3) 2 (GLIBC_2.3) 4 (GLIBC_2.3)
040: 2 (GLIBC_2.3) 7 (GCC_3.0) 7 (GCC_3.0) 4 (GLIBC_2.3)
044: 4 (GLIBC_2.3) 2 (GLIBC_2.3) 8 (GLIBC_2.3.2) 2 (GLIBC_2.3)
048: 2 (GLIBC_2.3) 0 (local) 2 (GLIBC_2.3) 0 (local)
04c: 7 (GCC_3.0) 2 (GLIBC_2.3) 2 (GLIBC_2.3) 7 (GCC_3.0)
050: 2 (GLIBC_2.3) 4 (GLIBC_2.3) 2 (GLIBC_2.3) 4 (GLIBC_2.3)
054: 4 (GLIBC_2.3) 7 (GCC_3.0) 1 (global) 1 (global)
058: 1 (global)

Version needs section '.gnu.version_r' contains 5 entries: Addr: 0x00000000000011b0 Offset: 0x0011b0 Link: 6 (.dynstr) 000000: Version: 1 File: ld64.so.1 Cnt: 1 0x0010: Name: GLIBC_2.22 Flags: none Version: 13 0x0020: Version: 1 File: libdl.so.2 Cnt: 1 0x0030: Name: GLIBC_2.3 Flags: none Version: 9 0x0040: Version: 1 File: libpthread.so.0 Cnt: 3 0x0050: Name: GLIBC_2.3.3 Flags: none Version: 12 0x0060: Name: GLIBC_2.3.2 Flags: none Version: 8 0x0070: Name: GLIBC_2.3 Flags: none Version: 4 0x0080: Version: 1 File: libgcc_s.so.1 Cnt: 3 0x0090: Name: GCC_4.2.0 Flags: none Version: 10 0x00a0: Name: GCC_3.0 Flags: none Version: 7 0x00b0: Name: GCC_3.3 Flags: none Version: 3 0x00c0: Version: 1 File: libc.so.6 Cnt: 4 0x00d0: Name: GLIBC_2.4 Flags: none Version: 11 0x00e0: Name: GLIBC_2.3.4 Flags: none Version: 6 0x00f0: Name: GLIBC_2.18 Flags: none Version: 5 0x0100: Name: GLIBC_2.3 Flags: none Version: 2

Version needs section '.gnu.version_r' contains 5 entries: Addr: 0x00000000000011b0 Offset: 0x0011b0 Link: 6 (.dynstr) 000000: Version: 1 File: ld64.so.1 Cnt: 1 0x0010: Name: GLIBC_2.22 Flags: none Version: 13 0x0020: Version: 1 File: libdl.so.2 Cnt: 1 0x0030: Name: GLIBC_2.3 Flags: none Version: 9 0x0040: Version: 1 File: libpthread.so.0 Cnt: 3 0x0050: Name: GLIBC_2.3.3 Flags: none Version: 12 0x0060: Name: GLIBC_2.3.2 Flags: none Version: 8 0x0070: Name: GLIBC_2.3 Flags: none Version: 4 0x0080: Version: 1 File: libgcc_s.so.1 Cnt: 3 0x0090: Name: GCC_4.2.0 Flags: none Version: 10 0x00a0: Name: GCC_3.0 Flags: none Version: 7 0x00b0: Name: GCC_3.3 Flags: none Version: 3 0x00c0: Version: 1 File: libc.so.6 Cnt: 4 0x00d0: Name: GLIBC_2.4 Flags: none Version: 11 0x00e0: Name: GLIBC_2.3.4 Flags: none Version: 6 0x00f0: Name: GLIBC_2.18 Flags: none Version: 5 0x0100: Name: GLIBC_2.3 Flags: none Version: 2

cuviper commented 5 years ago

Program received signal SIGILL, Illegal instruction. 0x0000000020017e34 in reset_sigpipe () at src/libstd/sys/unix/mod.rs:77

0x0000000020017e34 <+72>: stvx v31,r1,r7

STVX is an AltiVec instruction for vector store, which should have broad support.

What is your target CPU model that you ran this on?

skydig commented 5 years ago

powerpc t1042

cuviper commented 5 years ago

OK, assuming you mean this QorIQ T1042, then its e5500 is indeed lacking:

implements most of the core of the Power ISA v.2.06 with hypervisor support, but not AltiVec.

Rust uses the default "ppc64" CPU in LLVM, which is defined with AltiVec. There is also a specific "e5500" CPU, which you could choose with rustc -Ctarget-cpu=e5500. But since std is already built for "ppc64" with AltiVec, you'll need to use something like xargo to customize it.

sanxiyn commented 5 years ago

Maybe we should consider changing ppc64 baseline? Debian ppc64 supports e5500, for example.

DariuszOstolski commented 5 years ago

I've created a template Rust project for cross compiling for E5500 processor using xargo. Hopefully xargo will be integrated in cargo in the future.