Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Mar 2015 19:40:34 -0700
From:      Mark Millard <markmi@dsl-only.net>
To:        freebsd-toolchain@freebsd.org
Cc:        freebsd-ports@freebsd.org, FreeBSD PowerPC ML <freebsd-ppc@freebsd.org>
Subject:   Re: powerpc64 11.0-CURRENT: CROSS_TOOLCHAIN=powerpc64-gcc rejects -m elf32ppc_fbsd for linking boot1.elf
Message-ID:  <62E9089D-AF22-49F2-A20B-8719C1922EC7@dsl-only.net>
In-Reply-To: <122C9C88-24F9-4FA7-BCAC-293ED0DB946A@dsl-only.net>
References:  <122C9C88-24F9-4FA7-BCAC-293ED0DB946A@dsl-only.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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/inclu=
de/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=20
> -m32 -mcpu=3Dpowerpc -m32 -mcpu=3Dpowerpc -std=3Dgnu99     -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=3D (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=3D
WITHOUT_BOOT=3D

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

=3D=3D=3D
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@FBSDG4C0:/usr/obj/powerpc.powerpc64/usr/srcC/sys/GENERIC64vtsc-NODEBU=
G  powerpc powerpc64 1100062 1100062

No clang is built or installed.



The problem:

> make -j 8 CROSS_TOOLCHAIN=3Dpowerpc64-gcc WITHOUT_CLANG_BOOTSTRAP=3D =
WITHOUT_CLANG_IS_CC=3D WITHOUT_CLANG=3D WITHOUT_CLANG_EXTRAS=3D =
WITHOUT_CLANG_FULL=3D WITHOUT_LLDB=3D WITHOUT_GCC_BOOTSTRAP=3D =
WITHOUT_GCC=3D buildworld buildkernel KERNCONF=3DGENERIC64vtsc-NODEBUG =
TARGET=3Dpowerpc TARGET_ARCH=3Dpowerpc64


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=20
> -m32 -mcpu=3Dpowerpc -m32 -mcpu=3Dpowerpc -std=3Dgnu99     -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'
>=20
> *** [boot1.elf] Error code 1
>=20
> 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 $
>=20
> .if ${MACHINE_ARCH} =3D=3D "powerpc64"
> CFLAGS+=3D        -m32 -mcpu=3Dpowerpc
> LDFLAGS+=3D       -m elf32ppc_fbsd
> .endif
>=20
> .include "../Makefile.inc"


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

> LDFLAGS+=3D       -m elf32ppc_fbsd
> /usr/srcC/sys/boot/ofw/Makefile.inc
> LDFLAGS+=3D       -m elf32ppc_fbsd
> /usr/srcC/sys/boot/uboot/Makefile.inc
>               LD=3D"${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=3D (bootstrap too) is important to getting this far in my =
context. (It was in the make command shown earlier.)

# more /etc/src.conf
CC=3D/usr/local/bin/powerpc64-portbld-freebsd11.0-gcc
CXX=3D/usr/local/bin/powerpc64-portbld-freebsd11.0-g++
CPP=3D/usr/local/bin/powerpc64-portbld-freebsd11.0-cpp
CROSS_BINUTILS_PREFIX=3D/usr/local/powerpc64-freebsd/bin/
X_COMPILER_TYPE=3Dgcc
CXXFLAGS+=3D-I/usr/obj/usr/srcC/tmp/usr/include/c++/v1
LDADD+=3D-L/usr/obj/usr/srcC/usr/lib/libc++ -lc++
NO_WERROR=3D

The CC=3D, CXX=3D, CPP=3D assignments matching the XCC, XCXX, and XCPP =
assignments for CROSS_TOOLCHAIN=3Dpowerpc64-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+=3D and LDADD+=3D. If there had been a CXX =
specific LDADDCXX I would have used it instead.

NO_WERROR=3D 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.


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





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?62E9089D-AF22-49F2-A20B-8719C1922EC7>