powerpc64 11.0-CURRENT: CROSS_TOOLCHAIN=powerpc64-gcc rejects -m elf32ppc_fbsd for linking boot1.elf

Mark Millard markmi at dsl-only.net
Wed Mar 18 21:39:09 UTC 2015

Basic context (more details given later):

> # freebsd-version -ku; uname -apKU
> 11.0-CURRENT
> 11.0-CURRENT
> FreeBSD FBSDG5C0 11.0-CURRENT FreeBSD 11.0-CURRENT #0 r279514M: Wed Mar 11 19:23:14 PDT 2015     root at FBSDG4C0:/usr/obj/powerpc.powerpc64/usr/srcC/sys/GENERIC64vtsc-NODEBUG  powerpc powerpc64 1100062 1100062

No clang is built or installed.

The problem:


processes up to:

> /usr/local/bin/powerpc64-portbld-freebsd11.0-gcc -ffreestanding -msoft-float -Os  -I/usr/srcC/sys/boot/powerpc/boot1.chrp/../../common -I/usr/srcC/sys/boot/powerpc/boot1.chrp/../../../  -D_STANDALONE 
> -m32 -mcpu=powerpc -m32 -mcpu=powerpc -std=gnu99     -nostdlib -static -Wl,-N -m elf32ppc_fbsd -m elf32ppc_fbsd -o boot1.elf boot1.o ashldi3.o syncicache.o -L/usr/obj/usr/srcC/usr/lib/libc++ -lc++

and then gets for the above command...

> powerpc64-portbld-freebsd11.0-gcc: error: elf32ppc_fbsd: No such file or directory
> powerpc64-portbld-freebsd11.0-gcc: error: elf32ppc_fbsd: No such file or directory
> powerpc64-portbld-freebsd11.0-gcc: error: unrecognized command line option '-m'
> powerpc64-portbld-freebsd11.0-gcc: error: unrecognized command line option '-m'
> *** [boot1.elf] Error code 1
> make[6]: stopped in /usr/srcC/sys/boot/powerpc/boot1.chrp
> 1 error

The -m options seems to be from the likes of...

> # $FreeBSD: head/sys/boot/powerpc/Makefile.inc 227739 2011-11-19 19:25:57Z andreast $
> .if ${MACHINE_ARCH} == "powerpc64"
> CFLAGS+=        -m32 -mcpu=powerpc
> LDFLAGS+=       -m elf32ppc_fbsd
> .endif
> .include "../Makefile.inc"

and (extracted from using find ... -print):

> LDFLAGS+=       -m elf32ppc_fbsd
> /usr/srcC/sys/boot/ofw/Makefile.inc
> LDFLAGS+=       -m elf32ppc_fbsd
> /usr/srcC/sys/boot/uboot/Makefile.inc
>                LD="${LD} -m elf32ppc_fbsd"

> /usr/srcC/Makefile.inc1

When I looked at "man gcc" I did not find any "-m <space> text" options or any -melf32ppc_fbsd option. It would suggest that "-m elf32ppc_fbsd" is not normally valid --matching the complaints by powerpc64-portbld-freebsd11.0-gcc.

Is there a FreeBSD-specific addition to gcc missing in powerpc64-gcc?

Context details:

WITHOUT_CLANG= (bootstrap too) is important to getting this far in my context. (It was in the make command shown earlier.)

# more /etc/src.conf
LDADD+=-L/usr/obj/usr/srcC/usr/lib/libc++ -lc++

The CC=, CXX=, CPP= assignments matching the XCC, XCXX, and XCPP assignments for CROSS_TOOLCHAIN=powerpc64-gcc are important to getting this far: otherwise gcc 4.2.1 is used for some things. I also listed CROSS_BINUTILS_PREFIX and X_COMPILER_TYPE when I added the assignments. I do not know if they are needed.

libc++ include and library path handling did not automatically work so I added the explicit CXXFLAGS+= and LDADD+=. If there had been a CXX specific LDADDCXX I would have used it instead.

NO_WERROR= is for avoiding stopping for the warnings: I'm not trying to clean up the status relative to compiler warnings.

# svnlite info /usr/srcC/
Path: /usr/srcC
Working Copy Root Path: /usr/srcC
URL: https://svn0.us-west.freebsd.org/base/head
Relative URL: ^/head
Repository Root: https://svn0.us-west.freebsd.org/base
Repository UUID: ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Revision: 279514
Node Kind: directory
Schedule: normal
Last Changed Author: adrian
Last Changed Rev: 279514
Last Changed Date: 2015-03-01 18:27:25 -0800 (Sun, 01 Mar 2015)

# svnlite status /usr/srcC/ --no-ignore
?       /usr/srcC/.snap
M       /usr/srcC/Makefile
M       /usr/srcC/contrib/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
?       /usr/srcC/restoresymtable
M       /usr/srcC/sys/ddb/db_main.c
M       /usr/srcC/sys/ddb/db_script.c
?       /usr/srcC/sys/powerpc/conf/GENERIC64vtsc
?       /usr/srcC/sys/powerpc/conf/GENERIC64vtsc-NODEBUG
?       /usr/srcC/sys/powerpc/conf/GENERICvtsc
?       /usr/srcC/sys/powerpc/conf/GENERICvtsc-NODEBUG
M       /usr/srcC/sys/powerpc/ofw/ofw_machdep.c
M       /usr/srcC/sys/powerpc/ofw/ofwcall64.S

IntrusiveRefCntPtr.h needed an internal friend status established across typename parameters in order to compile.

I have a PowerMac G5 specific change to make booting reliable and some changes for getting information from early boot failures in case I get any more of them. I build without ps3 in order to allow having both vt and sc in the build.

# ls -FPal /usr/local/include/iconv*
-rw-r--r--  1 root  wheel  9348 Mar 12 02:47 /usr/local/include/iconv.h_alt

powerpc64-gcc automatically finds files in /usr/local/include/ such that they can be used when others with different content but the same name are appropriate. I renamed /usr/local/include/iconv.h to avoid it being an example of that.

I will not list how I got powerpc64-xtoolchain-gcc (and so powerpc64-gcc) to finish installing on a powerpc64 11.0-CURRENT.

Mark Millard
markmi at dsl-only.net

More information about the freebsd-ports mailing list