This page contained status information about efforts to bring LLVM to PowerPC64 target, using OpenPower ELF v2 ABI. It is now obsolete.
Flag day occurred on Dec 26, 2019, starting from r356111. -- Bdragon28 2019-12-27T05:50:24+0000
Contents
Converting an existing ELFv1 world to ELFv2
Reinstalling from the latest snapshot is highly preferable to doing a source upgrade! You have been warned!
I'm still in the middle of writing this, don't follow these instructions yet! -- Bdragon28 2020-01-08T02:12:58+0000
Step 1: Transition build
Ensure xtoolchain-llvm90 is installed.
Do an initial world build as a cross compile, and force a gcc 4.2.1-compatible bootstrap (Use the GPL DTC, and use prebuilt tblgen files to avoid building any C++11 code during bootstrap.)
make CROSS_TOOLCHAIN=llvm90 TARGET=powerpc TARGET_ARCH=powerpc64 \ WITHOUT_BOOT=yes WITHOUT_LIB32=yes \ LLVM_TBLGEN=/usr/local/llvm90/bin/llvm-tblgen \ CLANG_TBLGEN=/usr/local/llvm90/bin/clang-tblgen \ WITH_GPL_DTC=yes \ WITHOUT_GOOGLETEST=yes \ XCFLAGS="-mabi=elfv2 -mcmodel=medium --sysroot=/usr/obj/usr/src/powerpc.powerpc64/tmp/" \ XCXXFLAGS="-mabi=elfv2 -mcmodel=medium --sysroot=/usr/obj/usr/src/powerpc.powerpc64/tmp/" \ buildworld buildkernel KERNCONF=GENERIC64 -j32
Note: Build is currently failing still.
Step 2: Transition install
make installkernel KERNCONF=GENERIC64
reboot
At this point, you are on a post-flag-day compatible kernel which can execute post-flag-day ELFv2 binaries (This is necessary because of the auxv change.)
DO NOT INSTALL THIS WORLD DIRECTLY! Make will crash during install and leave the system in a broken state!
Prepare a bootable partition of some sort and do a temporary installworld to it.
newfs /dev/nda1p5 mount /dev/nda1p5 /mnt/newtarget cp -a /etc /mnt/newtarget make installkernel installworld DESTDIR=/mnt/newtarget
Reboot into the temporary volume somehow. (override vfs.root.mountfrom, etc.)
Use the temporary volume to install to your normal volume.
mkdir /mnt/target mount (normal root device) /mnt/target rmdir /usr/src rmdir /usr/obj ln -s /mnt/target/usr/src /usr/src ln -s /mnt/target/usr/obj /usr/obj cd /usr/src make installworld DESTDIR=/mnt/target
At this point, you are in a cross elfv2 world. Rebuild the world and kernel natively.
Step 3: Final build
make buildworld buildkernel KERNCONF=GENERIC64 WITHOUT_SYSTEM_COMPILER=yes WITHOUT_SYSTEM_LINKER=yes -j32
Step 4: Final install
make installkernel
reboot again into final kernel
make installworld
Status Tracking for Flag Day
The table bellow sumarizes status of the hard dependencies for the flag day and duplicates information found on other sections of this document. All items on this table must have status "accepted" or "commited" for the flagday be declared.
Description |
Target |
URL |
Status |
Plan |
makes LLVM default compiler |
powerpc, powerpcspe, powerpc64 |
committed r356111 |
commit on flag day |
|
makes ELFv2 default ABI on FreeBSD13.0+ |
powerpc64 |
committed r356112 |
commit on flag day |
|
Flag day parts of D22608 |
powerpc, powerpcspe |
committed r356114 |
commit on flag day |
|
link LIB32 objects with GNU BFD |
powerpc64 |
committed r356054 |
commit BEFORE flag day |
|
LLVM builtin atomics |
powerpc, powerpcspe |
committed r356104 |
commit BEFORE flag day |
|
Switch to Secure-PLT PIC modules, allow MD code to participate in DYNAMIC parsing |
powerpc, powerpcspe |
committed r356053 |
commit BEFORE flag day |
|
Fix predicate handling with SPE |
powerpcspe |
not accepted |
1. merge changes back to FreeBSD base code; 2. commit BEFORE flag |
|
Relax the restrictions on loading doubles with SPE |
powerpcspe |
needs revision |
1. merge changes back to FreeBSD base code; 2. commit BEFORE flag day |
|
Fix SPE f64 VAARG handling. |
powerpcspe |
needs revision |
merge changes back to FreeBSD base code;commit BEFORE flag day |
|
Only use PLT annotations if using PIC relocation model |
powerpc, powerpcspe |
committed, FreeBSD r356100 |
1. merge changes back to FreeBSD base code; 2. commit BEFORE flag |
|
bump FreeBSD OSVERSION |
|
|
TODO ASAP |
to be published on flagday (by jhibbits) |
FreeBSD Ports
Packages are not yet being built for this configuration; for now, you will have to build your own. Expect to find failures as unlike the results with gcc, few ports have really been tested.
Use of the -CURRENT powerpc packages built on FreeBSD.org may or may not work (it has not been tested as of 20200108).
Description |
URL |
Status |
Mk/bsd.port.mk: detect powerpc64 abi |
committed r518658 |
|
llvm-devel on powerpc64: add configure option to select ELFv2 ABI |
committed r515154 |
|
backport of LLVM 9 fixes in preparation for building FreeBSD/PowerPC64 |
abandoned - ports/llvm80 is at 8.0.1, which contains all important changes |
from ppcdevref
There is a more detailed ports summary native-built on an IBM Power8 machine (ppcdevref) on loan to us by OSU.
Patches
FreeBSD Base
Description |
URL |
Status |
makes LLVM default on PowerPC64 |
commited r356111 |
|
LLVM - change default ABI for FreeBSD13.0+ |
commited r356112 |
|
fix incorrect clang target triple computation (Makefile.inc1) |
review |
|
fix emulation name passed to linker when cross compiling |
review |
|
fix LIB32 build (Makefile.libcompat) |
commited r356054 |
|
[PowerPC] enable atomic.c in compiler_rt and makes clang do not emit a call to an external atomic_is_lock_free |
commited r356104 |
|
Enable TLS usage in system libraries on ELFv2 |
committed r355719 |
|
rtld: do not try to mmap a zero-sized PT_LOAD |
committed |
|
Fix broken kernel modules due to LLD 9+ TOC optimization |
committed r354713 |
|
[PowerPC] force applications linked with lib CSU to have .got |
committed r353455 |
|
powerpc: Transition to Secure-PLT, like most other OSs (Toolchain part) |
committed |
|
add ifunc support in libcsu |
committed |
|
don't mark ld.bfd as obsolete |
committed |
|
fix ifunc indirect call crash |
committed |
|
LLVM - backport FreeBSD/PowerPC64 LLVM9 upstream changes |
abandoned (after 8.0.1 was merged) |
|
fix missing powerpc64 in _LLVM_TARGET_FILT |
committed |
|
readelf: print description for 'e_flags' in ELF header (ABI type) |
committed |
|
add ABI flags to 'file' magic |
committed |
|
fix panic when loading if_epair.ko built with modern compiler |
committed r349377 |
|
fix kernel build with lld8 |
committed (r348112) |
|
fix stand/bootloader build |
committed |
|
ship ld.bfd with base |
committed |
|
fix wrong KASSERT in mphyp_pte_insert() |
committed |
|
fix pseries-llan (QEMU) |
committed |
|
silence cast-align warnings from clang on powerpc64 |
committed |
|
fix rtld-elf compilation warning for powerpc64 ELFv2 ABI |
committed |
|
fix compilation error (contrib/binutils/opcodes/ppc-dis.c) |
committed r344791 |
|
fix compilation error (include/pthread.h) |
abandoned after test with r344922 |
|
increase ctfconvert buffer size |
committed |
|
fix kldxref |
committed |
LLVM 9.0
Description |
URL |
Status |
9.x backport |
PowerPC 32-bit - forces 8 byte lock/lock_free decisions at compiled time |
review |
||
change default ABI for FreeBSD13.0+ |
merged in LLVM10 (8edf759ca7e1), backported to 9.0.1 |
|
|
crash when building graphics/mesa-dri |
Fixed in LLVM10 |
merged in LLVM 9.0.1 (52ac914) |
|
Fix openmp on PowerPC64-BE-ELFv2 ABI on FreeBSD |
fixed |
merged into FreeBSD base-LLVM9 (r352763). Merged in LLVM (3a76b8a538c0) |
|
[PowerPC] Do not emit HW loop if the body contains calls to lrint/lround |
Fixed in LLVM 10 |
Merged b9297dc 43967 |
[PPC32] Emit R_PPC_GOT_TPREL16 instead R_PPC_GOT_TPREL16_LO |
Fixed in LLVM 10 |
43178 9.0.0 (r371059) |
|
powerpc 32 bit binary segfault due to secure-plt vs bss-plt conflict |
Fixed in LLVM 9.0.0 |
43148 9.0.0 (r370312, r370313) |
LLVM 8.0.0
This list of patch is for reference only. Efforts are now being focused on LLVM9
Description |
URL |
Status |
8.x backport |
change default ABI for FreeBSD13.0+ |
|
to be released |
|
[PPC32] Fix PLT calls for -msecure-plt -fpic |
committed in LLVM9/head |
|
|
[PowerPC64] lld incorrectly optimizes ifunc TOC relocations |
fixed in LLVM10/head |
Issue doesn't occur on 8.x |
|
Adds ABI parsing when specified on target triple |
committed in LLVM9/head |
41981 unfeasible for 8.0.1 |
|
[libunwind] Fix r2 not properly restored |
committed in LLVM9/head |
41942 8.0.1 (r360861 r364217) |
|
Consider localentry offset when computing branch distance |
committed in LLVM9/head |
42332 8.0.1 (r359094 r364209) |
|
[PPC] Fix 32-bit build of libunwind |
committed in LLVM9/head |
41941 8.0.1 (r360862 r363030) |
|
llvm-objdump: when ELF st_other field is set, print its value before symbol name |
committed in LLVM9/head |
41961 8.0.1 (r360439 r362668) |
|
Implement Thunk Section Spacing |
committed in LLVM9/head |
41959 8.0.1 (r353865 r353866 358975 r360405 r362043 r362273 r362274) |
|
Update LocalEntry from assigned symbols |
committed in LLVM9/head |
41960 8.0.1 (r361237 r362671) |
|
Preserve LocalEntry when linking |
committed in LLVM9/head |
41943 8.0.1 (r354184 r361921) |
|
Fix missing ELF st_other field on versioned symbols |
committed in LLVM9/head |
41968 8.0.1 (r360439 r360442 r362668 r362669) |
Pending Issues
List of currently known pending issues. This list assumes above patches are already applied.
FreeBSD base
Description |
URL |
Workaround |
Status |
LIB32 C++ exception is broken when linked with LLVM LLD 9 |
Use GNU LD v2.17; with clang9, use -fPIC or -fpic |
fixed in LLD 10 D73399 |
|
LIB32 binaries are broken when linked with LLVM LLD 9 |
fixed |
||
LIB32 binaries are broken when linked with LLVM LLD 8 |
|
Use GNU LD v2.17 |
abandoned since support was improved in LLVM9 and FreeBSD 13 will upgrade to LLVM9 |
slof loader is broken when linked with LLVM LLD 8 |
|
Fixed in LLVM LLD |
LLD PowerPC 32-bit support is being improved. See 40888 |
LIB32 build is incompatible with WITH_LLVM_LIBUNWIND=yes |
|
Fixed |
See D61792 |
FreeBSD base compiler
Description |
URL |
Workaround |
Status |
Integrated AS doesn't implement mulldo, addo and subfo instructions |
use GNU AS 2.30+ |
Merged in llvm 10.x Backport to 9.0.1 merge ed3f33f D66902 |
|
Invalid PPC CTR loop when building node (clang900-import branch) |
|
merged in FreeBSD base (r353358) |
|
enable OpenMP on powerpc64 |
|
fix committed r352763 (clang900-import) |
|
LLVM/lld large binaries (like clang itself) may get a wrong/corrupted .init after link |
|||
LLVM/lld doesn't implement dynamic relocations R_PPC_LOCAL24PC and R_PPC_GOT16 used by LIB32 |
link with GNU LD 2.17 |
LLD PowerPC 32-bit support is being improved. See 40888 |
FreeBSD kernel
Description |
URL |
Workaround |
Status |
driver virtio drivers are not working when host is Little-Endian |
Fixed r357596 |
||
'kldload if_epair' causes kernel panic |
|
fixed r349377 |
|
[ppc][pseries] panic: Error evicting page: -7 |
|
Fixed |
FreeBSD ports
Description |
URL |
Workaround |
Status |
cannot build rust package (firefox dependency) |
see D20792 |
fixed rP517954 |
Petitiboot - kexec (bare metal)
Description |
URL |
Workaround |
Status |
kexec can't boot ELFv2 FreeBSD kernel |
On petitboot console, download and use http://drop.rtk0.net/kexec instead |
committed, is in Talos II/Lite/Blackbird PNOR beta firmware. Only affects platforms using kexec-lite containing this commit. Older versions of kexec-lite did not do the erroneous computation and always used the first address of .text as the entry point. There're reports of IBM Power9 and some IBM Power8 machines are affected. |