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

Mark Millard markmi at dsl-only.net
Thu Mar 19 02:40:39 UTC 2015


It looks to me like the space between -m and elf32ppc_fbsd in "-m elf32ppc_fbsd" is likely not allowed for powerpc64-gcc (gcc 4.9.1):
(shown ignoring binary file matches)

> # pwd
> /usr/obj/portswork/usr/ports/devel/powerpc64-gcc/work
> # find . -type f -exec grep elf32ppc_fbsd {} \; -print | more
> #define LINK_OS_FREEBSD_SPEC32 "-melf32ppc_fbsd " LINK_OS_FREEBSD_SPEC_DEF32
> ./gcc-4.9.1/gcc/config/rs6000/freebsd64.h
> -melf32ppc_fbsd   %{p:%nconsider using `-pg' instead of `-p' with gprof(1)}   %{v:-V}   %{assert*} %{R*} %{rpath*} %{defsym*}   %{shared:-Bshareable %{h*} %{soname*}}   %{!shared:     %{!static:       %{rdynamic: -export-dynamic}       %{!dynamic-linker:-dynamic-linker /libexec/ld-elf32.so.1}}     %{static:-Bstatic}}   %{symbolic:-Bsymbolic}
> ./build-gcc/gcc/specs
> #define LINK_OS_FREEBSD_SPEC32 "-melf32ppc_fbsd " LINK_OS_FREEBSD_SPEC_DEF32
> ./stage/usr/local/lib/gcc/powerpc64-portbld-freebsd11.0/4.9.1/plugin/include/config/rs6000/freebsd64.h

This might explain the elf32gcc_fbsd file missing notices that I reported before.


However when I removed the spaces from the Makefile.inc*'s that use "-m elf..." (see later) powerpc64-gcc produced:

> /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 -melf32ppc_fbsd -melf32ppc_fbsd -o boot1.elf boot1.o ashldi3.o syncicache.o -L/usr/obj/usr/srcC/usr/lib/libc++ -lc++
> powerpc64-portbld-freebsd11.0-gcc: error: unrecognized command line option '-melf32ppc_fbsd'
> powerpc64-portbld-freebsd11.0-gcc: error: unrecognized command line option '-melf32ppc_fbsd'


It looks like elf32ppc_fbsd mode usage with such -m notation is disallowed in powerpc64-gcc.

[I tried a few experimental, manual gcc5 command lines and got the same results there. So it may not be just powerpc64-gcc.]

Being disallowed overall would imply that WITH_GCC_BOOTSTRAP= (4.2.1 or some alternative) is required for such use and /usr/srcC/Makefile.inc1 would need to make use of the alternative that allows elf32ppc_fbsd where it is used.

So for my purposes

WITHOUT_LIB32=
WITHOUT_BOOT=

relative to seeing what can be done with powerpc64-xtoolchain-gcc: I'm not checking if there is a different way to do an equivalent of -melf32ppc_fbsd.


The -m elf...'s that I tried changing were as below. I only tried elf32ppc_fbsd contexts.

> # svnlite diff /usr/srcC/Makefile.inc1 /usr/srcC/sys/boot | more
> Index: /usr/srcC/Makefile.inc1
> ===================================================================
> --- /usr/srcC/Makefile.inc1     (revision 279514)
> +++ /usr/srcC/Makefile.inc1     (working copy)
> @@ -396,7 +396,7 @@
>                 MACHINE_CPU="i686 mmx sse sse2"
>  LIB32WMAKEFLAGS=       \
>                 AS="${AS} --32" \
> -               LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32"
> +               LD="${LD} -melf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32"
>  
>  .elif ${TARGET_ARCH} == "powerpc64"
>  .if empty(TARGET_CPUTYPE)
> @@ -406,7 +406,7 @@
>  .endif
>  LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc
>  LIB32WMAKEFLAGS=       \
> -               LD="${LD} -m elf32ppc_fbsd"
> +               LD="${LD} -melf32ppc_fbsd"
>  .endif
>  
>  
> Index: /usr/srcC/sys/boot/i386/Makefile.inc
> ===================================================================
> --- /usr/srcC/sys/boot/i386/Makefile.inc        (revision 279514)
> +++ /usr/srcC/sys/boot/i386/Makefile.inc        (working copy)
> @@ -14,7 +14,7 @@
>  CFLAGS+=       -m32
>  ACFLAGS+=      -m32
>  # LD_FLAGS is passed directly to ${LD}, not via ${CC}:
> -LD_FLAGS+=     -m elf_i386_fbsd
> +LD_FLAGS+=     -melf_i386_fbsd
>  AFLAGS+=       --32
>  .endif
>  
> Index: /usr/srcC/sys/boot/ofw/Makefile.inc
> ===================================================================
> --- /usr/srcC/sys/boot/ofw/Makefile.inc (revision 279514)
> +++ /usr/srcC/sys/boot/ofw/Makefile.inc (working copy)
> @@ -2,7 +2,7 @@
>  
>  .if ${MACHINE_ARCH} == "powerpc64"
>  CFLAGS+=       -m32 -mcpu=powerpc
> -LDFLAGS+=      -m elf32ppc_fbsd
> +LDFLAGS+=      -melf32ppc_fbsd
>  .endif
>  
>  .include "../Makefile.inc"
> Index: /usr/srcC/sys/boot/powerpc/Makefile.inc
> ===================================================================
> --- /usr/srcC/sys/boot/powerpc/Makefile.inc     (revision 279514)
> +++ /usr/srcC/sys/boot/powerpc/Makefile.inc     (working copy)
> @@ -2,7 +2,7 @@
>  
>  .if ${MACHINE_ARCH} == "powerpc64"
>  CFLAGS+=       -m32 -mcpu=powerpc
> -LDFLAGS+=      -m elf32ppc_fbsd
> +LDFLAGS+=      -melf32ppc_fbsd
>  .endif
>  
>  .include "../Makefile.inc"
> Index: /usr/srcC/sys/boot/uboot/Makefile.inc
> ===================================================================
> --- /usr/srcC/sys/boot/uboot/Makefile.inc       (revision 279514)
> +++ /usr/srcC/sys/boot/uboot/Makefile.inc       (working copy)
> @@ -2,7 +2,7 @@
>  
>  .if ${MACHINE_ARCH} == "powerpc64"
>  CFLAGS+=       -m32 -mcpu=powerpc
> -LDFLAGS+=      -m elf32ppc_fbsd
> +LDFLAGS+=      -melf32ppc_fbsd
>  .endif
>  
>  .include "../Makefile.inc"

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

On 2015-Mar-18, at 02:38 PM, Mark Millard <markmi at dsl-only.net> wrote:

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:

> make -j 8 CROSS_TOOLCHAIN=powerpc64-gcc WITHOUT_CLANG_BOOTSTRAP= WITHOUT_CLANG_IS_CC= WITHOUT_CLANG= WITHOUT_CLANG_EXTRAS= WITHOUT_CLANG_FULL= WITHOUT_LLDB= WITHOUT_GCC_BOOTSTRAP= WITHOUT_GCC= buildworld buildkernel KERNCONF=GENERIC64vtsc-NODEBUG TARGET=powerpc TARGET_ARCH=powerpc64


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
CC=/usr/local/bin/powerpc64-portbld-freebsd11.0-gcc
CXX=/usr/local/bin/powerpc64-portbld-freebsd11.0-g++
CPP=/usr/local/bin/powerpc64-portbld-freebsd11.0-cpp
CROSS_BINUTILS_PREFIX=/usr/local/powerpc64-freebsd/bin/
X_COMPILER_TYPE=gcc
CXXFLAGS+=-I/usr/obj/usr/srcC/tmp/usr/include/c++/v1
LDADD+=-L/usr/obj/usr/srcC/usr/lib/libc++ -lc++
NO_WERROR=

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