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

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

D20378

committed r356111

commit on flag day

makes ELFv2 default ABI on FreeBSD13.0+

powerpc64

D20383

committed r356112

commit on flag day

Flag day parts of D22608

powerpc, powerpcspe

D22798

committed r356114

commit on flag day

link LIB32 objects with GNU BFD

powerpc64

D20261

committed r356054

commit BEFORE flag day

LLVM builtin atomics

powerpc, powerpcspe

D22549

committed r356104

commit BEFORE flag day

Switch to Secure-PLT PIC modules, allow MD code to participate in DYNAMIC parsing

powerpc, powerpcspe

D22608

committed r356053

commit BEFORE flag day

Fix predicate handling with SPE

powerpcspe

D69483

not accepted

1. merge changes back to FreeBSD base code; 2. commit BEFORE flag

Relax the restrictions on loading doubles with SPE

powerpcspe

D69484

needs revision

1. merge changes back to FreeBSD base code; 2. commit BEFORE flag day

Fix SPE f64 VAARG handling.

powerpcspe

D69486

needs revision

merge changes back to FreeBSD base code;commit BEFORE flag day

Only use PLT annotations if using PIC relocation model

powerpc, powerpcspe

D70570

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

D22039

committed r518658

llvm-devel on powerpc64: add configure option to select ELFv2 ABI

D22100

committed r515154

backport of LLVM 9 fixes in preparation for building FreeBSD/PowerPC64

D20375

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

D20378

commited r356111

LLVM - change default ABI for FreeBSD13.0+

D20383

commited r356112

fix incorrect clang target triple computation (Makefile.inc1)

D19237

review

fix emulation name passed to linker when cross compiling

D21800

review

fix LIB32 build (Makefile.libcompat)

D20261

commited r356054

[PowerPC] enable atomic.c in compiler_rt and makes clang do not emit a call to an external atomic_is_lock_free

D22549

commited r356104

Enable TLS usage in system libraries on ELFv2

D22524

committed r355719

rtld: do not try to mmap a zero-sized PT_LOAD

D22634

committed

Fix broken kernel modules due to LLD 9+ TOC optimization

D22317

committed r354713

[PowerPC] force applications linked with lib CSU to have .got

43148 D21476

committed r353455

powerpc: Transition to Secure-PLT, like most other OSs (Toolchain part)

rS349351

committed

add ifunc support in libcsu

D21070

committed

don't mark ld.bfd as obsolete

D21136

committed

fix ifunc indirect call crash

D21102

committed

LLVM - backport FreeBSD/PowerPC64 LLVM9 upstream changes

D20337

abandoned (after 8.0.1 was merged)

fix missing powerpc64 in _LLVM_TARGET_FILT

D20756

committed

readelf: print description for 'e_flags' in ELF header (ABI type)

D20782

committed

add ABI flags to 'file' magic

D20771

committed

fix panic when loading if_epair.ko built with modern compiler

D20461

committed r349377

fix kernel build with lld8

D19352

committed (r348112)

fix stand/bootloader build

D20026

committed

ship ld.bfd with base

D20259

committed

fix wrong KASSERT in mphyp_pte_insert()

D20012

committed

fix pseries-llan (QEMU)

D20008

committed

silence cast-align warnings from clang on powerpc64

D18807

committed

fix rtld-elf compilation warning for powerpc64 ELFv2 ABI

D18808

committed

fix compilation error (contrib/binutils/opcodes/ppc-dis.c)

D19235

committed r344791

fix compilation error (include/pthread.h)

D19236

abandoned after test with r344922

increase ctfconvert buffer size

D19353

committed

fix kldxref

D19370

committed

LLVM 9.0

Description

URL

Status

9.x backport

PowerPC 32-bit - forces 8 byte lock/lock_free decisions at compiled time

D71600

review

change default ABI for FreeBSD13.0+

D72306 D72352

merged in LLVM10 (8edf759ca7e1), backported to 9.0.1

crash when building graphics/mesa-dri

44183

Fixed in LLVM10

merged in LLVM 9.0.1 (52ac914)

Fix openmp on PowerPC64-BE-ELFv2 ABI on FreeBSD

D67190

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

43527

Fixed in LLVM 10

Merged b9297dc 43967

[PPC32] Emit R_PPC_GOT_TPREL16 instead R_PPC_GOT_TPREL16_LO

43150 D66925

Fixed in LLVM 10

43178 9.0.0 (r371059)

powerpc 32 bit binary segfault due to secure-plt vs bss-plt conflict

43116

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

D63563

committed in LLVM9/head

[PowerPC64] lld incorrectly optimizes ifunc TOC relocations

42759

fixed in LLVM10/head

Issue doesn't occur on 8.x

Adds ABI parsing when specified on target triple

D61950

committed in LLVM9/head

41981 unfeasible for 8.0.1

[libunwind] Fix r2 not properly restored

41050, D59694

committed in LLVM9/head

41942 8.0.1 (r360861 r364217)

Consider localentry offset when computing branch distance

D61058

committed in LLVM9/head

42332 8.0.1 (r359094 r364209)

[PPC] Fix 32-bit build of libunwind

D61792

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

D61647 D61718

committed in LLVM9/head

41961 8.0.1 (r360439 r362668)

Implement Thunk Section Spacing

D61610 D61720

committed in LLVM9/head

41959 8.0.1 (r353865 r353866 358975 r360405 r362043 r362273 r362274)

Update LocalEntry from assigned symbols

D56586

committed in LLVM9/head

41960 8.0.1 (r361237 r362671)

Preserve LocalEntry when linking

D56782

committed in LLVM9/head

41943 8.0.1 (r354184 r361921)

Fix missing ELF st_other field on versioned symbols

41048, D59436

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

43350

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

43116

43148

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

42541

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)

43527

merged in FreeBSD base (r353358)

enable OpenMP on powerpc64

D21532

fix committed r352763 (clang900-import)

LLVM/lld large binaries (like clang itself) may get a wrong/corrupted .init after link

40740

21690

D61610D61720 Fix available

LLVM/lld doesn't implement dynamic relocations R_PPC_LOCAL24PC and R_PPC_GOT16 used by LIB32

40888

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

D23401

D19815 msg01496.html

Fixed r357596

'kldload if_epair' causes kernel panic

232387 D20461

fixed r349377

[ppc][pseries] panic: Error evicting page: -7

237470

Fixed

FreeBSD ports

Description

URL

Workaround

Status

cannot build rust package (firefox dependency)

D20792

see D20792

fixed rP517954

Petitiboot - kexec (bare metal)

Description

URL

Workaround

Status

kexec can't boot ELFv2 FreeBSD kernel

https://github.com/antonblanchard/kexec-lite/pull/9

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.

Contact

FreeBSD IRC Channels


CategoryHistorical

powerpc/llvm-elfv2 (last edited 2020-06-09T16:49:38+0000 by MarkLinimon)