Update on using LLVM's lld linker in the FreeBSD base system

Mark Millard markmi at dsl-only.net
Tue Aug 2 00:07:09 UTC 2016


Warner Losh imp at bsdimp.com wrote on Aug 1 22:27:19 UTC 2016 :

> On Mon, Aug 1, 2016 at 3:40 PM, Ed Maste <emaste at freebsd.org> wrote:
> 
> > There is (some) support for mips and powerpc in lld, but I'm not sure
> > how well tested it is. RISC-V is not yet supported but there is a
> > desire to have a full LLVM-based RISC-V toolchain. I'm not aware of
> > any plan with respect to sparc64 in lld. In any case, I do not plan to
> > address these architectures in the initial lld work. In the near term
> > they will continue to use GNU ld 2.17.50.
> 
> OK. How does this square up against the gcc 4.2 removal timelines and
> plans? Once gcc is gone, we'll have to use an external toolchain anyway
> to build mips at least (though clang is close, it isn't there yet despite Sean
> Bruno's wonderful work).

This note is about the status for TARGET_ARCH=powerpc and TARGET_ARCH=powerpc64.

clang 3.8.0 is not ready for TARGET_ARCH=powerpc or TARGET_ARCH=powerpc64 yet.
(I do not know about clang/clang++ 3.9 or later.) So this is another external
tool chain family (so far).

clang/clang++ for TARET_ARCH=powerpc does not even generate code for the FreeBSD
specified ABI's stack handling properties: It requires a so-called red-zone for
signal handling because of when the stack pointer is adjusted for both directions.

clang also does not handle some of the assembler notation that is used in the kernel.

Neither TARGET_ARCH variant handles C++ exceptions correctly for things built via
clang++ 3.8.0.

TARGET_ARCH=powerpc64 is missing soft-float support, blocking building libstand as
I remember.

There is more wrong. See https://llvm.org/bugs/show_bug.cgi?id=25780 :

      [META] Using Clang as the FreeBSD/ppc system compiler

And its "Depends on" list. There are about 6 reports pending.


Additional clang related notes:

TARGET_ARCH=powerpc notes: with a kernel modified to have signal handling provide a
red-zone I've been able to use clang for buildworld and run a system that is a
mix of a gcc 4.2.1 based kernel and a clang 3.8.0 based world. But I have to avoid
using things that would use C++ exception handling if built via the system clang++
3.8.0.

TARGET_ARCH=powerpc64 note: I've never got that far with clang 3.8.0.


xtoolchain related notes:

There is no external toolchain in place for TARGET_ARCH=powerpc that I know of.

I do build TARGET_ARCH=powerpc64 via devel/powerpc64-gcc and
devel/powerpc64-xtoolchain-gcc . But I've never gotten lib32 to work
when built from that toolchain so I normally do not build lib32:
crtbeginS code problem(s) from not matching the register usage.




Where my mostly TARGET_ARCH=powerpc and TARGET_ARCH=powerpc64 source changes
are:

# svnlite status /usr/src/
M       /usr/src/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
M       /usr/src/lib/csu/powerpc64/Makefile
?       /usr/src/sys/amd64/conf/GENERIC-NODBG
?       /usr/src/sys/amd64/include/include
?       /usr/src/sys/arm/conf/RPI2-NODBG
?       /usr/src/sys/arm/include/include
M       /usr/src/sys/boot/ofw/Makefile.inc
M       /usr/src/sys/boot/powerpc/Makefile.inc
M       /usr/src/sys/boot/powerpc/kboot/Makefile
M       /usr/src/sys/boot/uboot/Makefile.inc
M       /usr/src/sys/conf/Makefile.powerpc
M       /usr/src/sys/conf/kern.mk
M       /usr/src/sys/conf/kmod.mk
?       /usr/src/sys/powerpc/conf/GENERIC64-NODBG
?       /usr/src/sys/powerpc/conf/GENERIC64vtsc
?       /usr/src/sys/powerpc/conf/GENERIC64vtsc-NODEBUG
?       /usr/src/sys/powerpc/conf/GENERICvtsc
?       /usr/src/sys/powerpc/conf/GENERICvtsc-NODEBUG
?       /usr/src/sys/powerpc/include/include
M       /usr/src/sys/powerpc/ofw/ofw_machdep.c
M       /usr/src/sys/powerpc/powerpc/exec_machdep.c
?       /usr/src/sys/x86/include/include

(Something along the way made the include/include's, with the nested
one pointing to its parent one. I did not explicitly do this.)

Some of the .c source changes are tied to my making PowerMac G5's boot
reliably when they have lots of RAM. (Just experimentally derived and
observed on the G5 examples that I sometimes have access to.)

I build with both vt and sc enabled and PS3 disabled.

===
Mark Millard
markmi at dsl-only.net



More information about the freebsd-toolchain mailing list