Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Aug 2018 00:01:01 -0700
From:      Mark Millard <marklmi@yahoo.com>
To:        Warner Losh <imp@bsdimp.com>, FreeBSD Toolchain <freebsd-toolchain@freebsd.org>, FreeBSD PowerPC ML <freebsd-ppc@freebsd.org>
Subject:   head -r337868 's stand/defs.mk "CFLAGS.gcc+=    -Os" breaks powerpc64's boot1.elf amd64 -> powerpc64 cross build via devel/powerpc64-binutils and devel/powerpc64-gcc
Message-ID:  <6EAD7607-1FD5-4282-B082-F5FD0087B6C5@yahoo.com>

next in thread | raw e-mail | index | archive | help
[My previous build was based on head -r337400 and did not have
this problem. I experiment with powerpc64 and powerpc builds
via fairly modern compilers and toolchains, although I currently
do nto have access to such hardware.]

Despite the amd64 and i386 focused comment in:

QUOTE
# Slim down the image. This saves about 15% in size with clang 6 on x86
# Our most constrained /boot/loader env is BIOS booting on x86, where
# our text + data + BTX have to fit into 640k below the ISA hole.
# Experience has shown that problems arise between ~520k to ~530k.
CFLAGS.clang+=3D  -Oz
CFLAGS.gcc+=3D    -Os
ENDQUOTE

the code is not conditional on such a context being involved.
This changes the powerpc64 to fail for a devel/powerpc64-gcc and
devel/powerpc64-binutil based build when boot1.elf is attempted:

--- boot1.elf ---
Using built-in specs.
COLLECT_GCC=3D/usr/local/bin/powerpc64-unknown-freebsd12.0-gcc
=
COLLECT_LTO_WRAPPER=3D/usr/local/libexec/gcc/powerpc64-unknown-freebsd12.0=
/6.4.0/lto-wrapper
Target: powerpc64-unknown-freebsd12.0
Configured with: =
/wrkdirs/usr/ports/devel/powerpc64-gcc/work/gcc-6.4.0/configure =
--target=3Dpowerpc64-unknown-freebsd12.0 --disable-nls =
--enable-languages=3Dc,c++ --enable-gnu-indirect-function =
--without-headers --with-gmp=3D/usr/local --with-pkgversion=3D'FreeBSD =
Ports Collection for powerpc64' --with-system-zlib =
--with-gxx-include-dir=3D/usr/include/c++/v1/ --with-sysroot=3D/ =
--with-as=3D/usr/local/bin/powerpc64-unknown-freebsd12.0-as =
--with-ld=3D/usr/local/bin/powerpc64-unknown-freebsd12.0-ld =
--enable-initfini-array --prefix=3D/usr/local --localstatedir=3D/var =
--mandir=3D/usr/local/man --infodir=3D/usr/local/info/ =
--build=3Dx86_64-unknown-freebsd12.0
Thread model: posix
gcc version 6.4.0 (FreeBSD Ports Collection for powerpc64)=20
=
COMPILER_PATH=3D/usr/local/powerpc64-unknown-freebsd12.0/bin/:/usr/local/l=
ibexec/gcc/powerpc64-unknown-freebsd12.0/6.4.0/:/usr/local/libexec/gcc/pow=
erpc64-unknown-freebsd12.0/6.4.0/:/usr/local/libexec/gcc/powerpc64-unknown=
-freebsd12.0/:/usr/local/lib/gcc/powerpc64-unknown-freebsd12.0/6.4.0/:/usr=
/local/lib/gcc/powerpc64-unknown-freebsd12.0/:/usr/local/lib/gcc/powerpc64=
-unknown-freebsd12.0/6.4.0/../../../../powerpc64-unknown-freebsd12.0/bin/
=
LIBRARY_PATH=3D/usr/local/powerpc64-unknown-freebsd12.0/bin/:/usr/local/li=
b/gcc/powerpc64-unknown-freebsd12.0/6.4.0/:/usr/local/lib/gcc/powerpc64-un=
known-freebsd12.0/6.4.0/../../../../powerpc64-unknown-freebsd12.0/lib/:/us=
r/obj/powerpc64vtsc_xtoolchain-gcc-no_toolchain/powerpc.powerpc64/usr/src/=
powerpc.powerpc64/tmp/lib/:/usr/obj/powerpc64vtsc_xtoolchain-gcc-no_toolch=
ain/powerpc.powerpc64/usr/src/powerpc.powerpc64/tmp/usr/lib/
COLLECT_GCC_OPTIONS=3D'-B' =
'/usr/local/powerpc64-unknown-freebsd12.0/bin/' '-O2' '-pipe' =
'-nostdinc' '-I' =
'/usr/obj/powerpc64vtsc_xtoolchain-gcc-no_toolchain/powerpc.powerpc64/usr/=
src/powerpc.powerpc64/stand/libsa' '-I' '/usr/src/stand/libsa' '-D' =
'_STANDALONE' '-I' '/usr/src/sys' '-D' 'double=3Djagged-little-pill' =
'-D' 'float=3Dfloaty-mcfloatface' '-D' 'LOADER_GELI_SUPPORT' '-I' =
'/usr/src/stand/libsa/geli' '-D' 'LOADER_DISK_SUPPORT' '-m32' =
'-mcpu=3Dpowerpc' '-ffreestanding' '-msoft-float' '-I' '.' '-I' =
'/usr/src/stand/common' '-std=3Dgnu99' '-Wsystem-headers' =
'-Wno-pointer-sign' '-Wno-error=3Daddress' '-Wno-error=3Darray-bounds' =
'-Wno-error=3Dattributes' '-Wno-error=3Dbool-compare' =
'-Wno-error=3Dcast-align' '-Wno-error=3Dclobbered' =
'-Wno-error=3Denum-compare' '-Wno-error=3Dextra' '-Wno-error=3Dinline' =
'-Wno-error=3Dlogical-not-parentheses' '-Wno-error=3Dstrict-aliasing' =
'-Wno-error=3Duninitialized' '-Wno-error=3Dunused-but-set-variable' =
'-Wno-error=3Dunused-function' '-Wno-error=3Dunused-value' =
'-Wno-error=3Dmisleading-indentation' '-Wno-error=3Dnonnull-compare' =
'-Wno-error=3Dshift-negative-value' '-Wno-error=3Dtautological-compare' =
'-Wno-error=3Dunused-const-variable' '-v' '-Os' '-nostdlib' '-static' =
'-o' 'boot1.elf'
 /usr/local/libexec/gcc/powerpc64-unknown-freebsd12.0/6.4.0/collect2 =
-plugin =
/usr/local/libexec/gcc/powerpc64-unknown-freebsd12.0/6.4.0/liblto_plugin.s=
o =
-plugin-opt=3D/usr/local/libexec/gcc/powerpc64-unknown-freebsd12.0/6.4.0/l=
to-wrapper -plugin-opt=3D-fresolution=3D/tmp//cco6MSov.res =
--sysroot=3D/usr/obj/powerpc64vtsc_xtoolchain-gcc-no_toolchain/powerpc.pow=
erpc64/usr/src/powerpc.powerpc64/tmp -V -static -melf32ppc_fbsd -V =
-Bstatic -o boot1.elf -L/usr/local/powerpc64-unknown-freebsd12.0/bin =
-L/usr/local/lib/gcc/powerpc64-unknown-freebsd12.0/6.4.0 =
-L/usr/local/lib/gcc/powerpc64-unknown-freebsd12.0/6.4.0/../../../../power=
pc64-unknown-freebsd12.0/lib =
-L/usr/obj/powerpc64vtsc_xtoolchain-gcc-no_toolchain/powerpc.powerpc64/usr=
/src/powerpc.powerpc64/tmp/lib =
-L/usr/obj/powerpc64vtsc_xtoolchain-gcc-no_toolchain/powerpc.powerpc64/usr=
/src/powerpc.powerpc64/tmp/usr/lib -N boot1.o qdivrem.o udivdi3.o =
ashldi3.o syncicache.o
GNU ld (GNU Binutils) 2.30
  Supported emulations:
   elf64ppc_fbsd
   elf64ppc
   elf32ppc_fbsd
   elf32ppc
GNU ld (GNU Binutils) 2.30
  Supported emulations:
   elf64ppc_fbsd
   elf64ppc
   elf32ppc_fbsd
   elf32ppcboot1.o: In function `__puts':
boot1.c:(.text+0xe0): undefined reference to `_restgpr_28_x'
boot1.o: In function `__printf':
boot1.c:(.text+0x1a0): undefined reference to `_restgpr_24_x'
boot1.o: In function `ofw_getprop':
boot1.c:(.text+0x5fc): undefined reference to `_restgpr_31_x'
boot1.o: In function `ofw_close':
boot1.c:(.text+0x668): undefined reference to `_restgpr_31_x'
boot1.o: In function `dskread':
boot1.c:(.text+0x76c): undefined reference to `_restgpr_25_x'
boot1.o: In function `ofw_write.constprop.2':
boot1.c:(.text+0x7f4): undefined reference to `_restgpr_30_x'
boot1.o: In function `putchar':
boot1.c:(.text+0x844): undefined reference to `_restgpr_30_x'
boot1.o: In function `fsread_size.constprop.11':
boot1.c:(.text+0x904): undefined reference to `_restgpr_17_x'
boot1.o: In function `domount.constprop.4':
boot1.c:(.text+0xe98): undefined reference to `_restgpr_30_x'
boot1.o: In function `main':
boot1.c:(.text.startup+0x3c0): undefined reference to `_restgpr_19_x'
qdivrem.o: In function `__qdivrem':
qdivrem.c:(.text+0xb8): undefined reference to `_restgpr_25_x'
collect2: error: ld returned 1 exit status
*** [boot1.elf] Error code 1

make[5]: stopped in /usr/src/stand/powerpc/boot1.chrp
.ERROR_TARGET=3D'boot1.elf'
=
.ERROR_META_FILE=3D'/usr/obj/powerpc64vtsc_xtoolchain-gcc-no_toolchain/pow=
erpc.powerpc64/usr/src/powerpc.powerpc64/stand/powerpc/boot1.chrp/boot1.el=
f.meta'
.MAKE.LEVEL=3D'5'
MAKEFILE=3D''
.MAKE.MODE=3D'meta missing-filemon=3Dyes missing-meta=3Dyes silent=3Dyes =
verbose'
_ERROR_CMD=3D'/usr/local/bin/powerpc64-unknown-freebsd12.0-gcc =
--sysroot=3D/usr/obj/powerpc64vtsc_xtoolchain-gcc-no_toolchain/powerpc.pow=
erpc64/usr/src/powerpc.powerpc64/tmp =
-B/usr/local/powerpc64-unknown-freebsd12.0/bin/ -O2 -pipe -nostdinc =
-I/usr/obj/powerpc64vtsc_xtoolchain-gcc-no_toolchain/powerpc.powerpc64/usr=
/src/powerpc.powerpc64/stand/libsa -I/usr/src/stand/libsa -D_STANDALONE =
-I/usr/src/sys -Ddouble=3Djagged-little-pill -Dfloat=3Dfloaty-mcfloatface =
-DLOADER_GELI_SUPPORT -I/usr/src/stand/libsa/geli -DLOADER_DISK_SUPPORT =
-m32 -mcpu=3Dpowerpc -ffreestanding -msoft-float -I. =
-I/usr/src/stand/common -std=3Dgnu99 -Wsystem-headers -Wno-pointer-sign =
-Wno-error=3Daddress -Wno-error=3Darray-bounds -Wno-error=3Dattributes =
-Wno-error=3Dbool-compare -Wno-error=3Dcast-align -Wno-error=3Dclobbered =
-Wno-error=3Denum-compare -Wno-error=3Dextra -Wno-error=3Dinline =
-Wno-error=3Dlogical-not-parentheses -Wno-error=3Dstrict-aliasing =
-Wno-error=3Duninitialized -Wno-error=3Dunused-but-set-variable =
-Wno-error=3Dunused-function -Wno-error=3Dunused-value =
-Wno-error=3Dmisleading-indentation -Wno-error=3Dnonnull-compare =
-Wno-error=3Dshift-negative-value -Wno-error=3Dtautological-compare =
-Wno-error=3Dunused-const-variable -v -Os -nostdlib -static -Wl,-N  -o =
boot1.elf boot1.o qdivrem.o udivdi3.o ashldi3.o syncicache.o  ;'
.CURDIR=3D'/usr/src/stand/powerpc/boot1.chrp'
.MAKE=3D'make'
=
.OBJDIR=3D'/usr/obj/powerpc64vtsc_xtoolchain-gcc-no_toolchain/powerpc.powe=
rpc64/usr/src/powerpc.powerpc64/stand/powerpc/boot1.chrp'
.TARGETS=3D'all'
=
DESTDIR=3D'/usr/obj/powerpc64vtsc_xtoolchain-gcc-no_toolchain/powerpc.powe=
rpc64/usr/src/powerpc.powerpc64/tmp'
LD_LIBRARY_PATH=3D''
MACHINE=3D'powerpc'
MACHINE_ARCH=3D'powerpc64'
MAKEOBJDIRPREFIX=3D''
MAKESYSPATH=3D'/usr/src/share/mk'
MAKE_VERSION=3D'20180512'
=
PATH=3D'/usr/obj/powerpc64vtsc_xtoolchain-gcc-no_toolchain/powerpc.powerpc=
64/usr/src/powerpc.powerpc64/tmp/legacy/usr/sbin:/usr/obj/powerpc64vtsc_xt=
oolchain-gcc-no_toolchain/powerpc.powerpc64/usr/src/powerpc.powerpc64/tmp/=
legacy/usr/bin:/usr/obj/powerpc64vtsc_xtoolchain-gcc-no_toolchain/powerpc.=
powerpc64/usr/src/powerpc.powerpc64/tmp/legacy/bin:/usr/obj/powerpc64vtsc_=
xtoolchain-gcc-no_toolchain/powerpc.powerpc64/usr/src/powerpc.powerpc64/tm=
p/usr/sbin:/usr/obj/powerpc64vtsc_xtoolchain-gcc-no_toolchain/powerpc.powe=
rpc64/usr/src/powerpc.powerpc64/tmp/usr/bin:/sbin:/bin:/usr/sbin:/usr/bin'=

SRCTOP=3D'/usr/src'
=
OBJTOP=3D'/usr/obj/powerpc64vtsc_xtoolchain-gcc-no_toolchain/powerpc.power=
pc64/usr/src/powerpc.powerpc64'
.MAKE.MAKEFILES=3D'/usr/src/share/mk/sys.mk =
/usr/src/share/mk/local.sys.env.mk /usr/src/share/mk/src.sys.env.mk =
/root/src.configs/src.conf.powerpc64-xtoolchain-gcc-no_toolchain.amd64-hos=
t /usr/src/share/mk/bsd.mkopt.mk /usr/src/share/mk/src.sys.obj.mk =
/usr/src/share/mk/auto.obj.mk /usr/src/share/mk/bsd.suffixes.mk =
/root/src.configs/make.conf /usr/src/share/mk/local.sys.mk =
/usr/src/share/mk/src.sys.mk /dev/null =
/usr/src/stand/powerpc/boot1.chrp/Makefile /usr/src/share/mk/bsd.init.mk =
/usr/src/share/mk/bsd.opts.mk /usr/src/share/mk/bsd.cpu.mk =
/usr/src/share/mk/local.init.mk /usr/src/share/mk/src.init.mk =
/usr/src/stand/powerpc/boot1.chrp/../Makefile.inc =
/usr/src/stand/powerpc/boot1.chrp/../../Makefile.inc =
/usr/src/stand/powerpc/boot1.chrp/../../defs.mk =
/usr/src/share/mk/src.opts.mk /usr/src/share/mk/bsd.own.mk =
/usr/src/share/mk/bsd.compiler.mk /usr/src/share/mk/bsd.linker.mk =
/usr/src/stand/powerpc/boot1.chrp/Makefile.hfs =
/usr/src/share/mk/bsd.prog.mk /usr/src/share/mk/bsd.libnames.mk =
/usr/src/share/mk/src.libnames.mk /usr/src/share/mk/bsd.nls.mk =
/usr/src/share/mk/bsd.confs.mk /usr/src/share/mk/bsd.files.mk =
/usr/src/share/mk/bsd.dirs.mk /usr/src/share/mk/bsd.incs.mk =
/usr/src/share/mk/bsd.links.mk /usr/src/share/mk/bsd.man.mk =
/usr/src/share/mk/bsd.dep.mk /usr/src/share/mk/bsd.clang-analyze.mk =
/usr/src/share/mk/bsd.obj.mk /usr/src/share/mk/bsd.subdir.mk =
/usr/src/share/mk/bsd.sys.mk'
.PATH=3D'. /usr/src/stand/powerpc/boot1.chrp /usr/src/sys/libkern =
/usr/src/lib/libc/powerpc/gen /usr/src/stand/powerpc/boot1.chrp'
1 error


The following patch was sufficient to show that the
-Os use made the difference (but I do not know about
other TARGET_ARCH=3D alternatives so it may not be
appropriate overall).

# svnlite diff /usr/src/stand/defs.mk
Index: /usr/src/stand/defs.mk
=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/src/stand/defs.mk	(revision 338319)
+++ /usr/src/stand/defs.mk	(working copy)
@@ -53,6 +53,7 @@
 CFLAGS+=3D	-I${SYSDIR}
 # Spike the floating point interfaces
 CFLAGS+=3D	-Ddouble=3Djagged-little-pill -Dfloat=3Dfloaty-mcfloatface=

+.if ${MACHINE_ARCH} =3D=3D "amd64" || ${MACHINE_ARCH} =3D=3D "i386"
 # Slim down the image. This saves about 15% in size with clang 6 on x86
 # Our most constrained /boot/loader env is BIOS booting on x86, where
 # our text + data + BTX have to fit into 640k below the ISA hole.
@@ -59,6 +60,7 @@
 # Experience has shown that problems arise between ~520k to ~530k.
 CFLAGS.clang+=3D	-Oz
 CFLAGS.gcc+=3D	-Os
+.endif
=20
 # GELI Support, with backward compat hooks (mostly)
 .if defined(LOADER_NO_GELI_SUPPORT)
@@ -87,6 +89,7 @@
 # or powerpc64.
 .if ${MACHINE_ARCH} =3D=3D "powerpc64"
 CFLAGS+=3D	-m32 -mcpu=3Dpowerpc
+LFLAGS+=3D	-Wl,-m -Wl,elf32ppc_fbsd
 .endif
=20
 # For amd64, there's a bit of mixed bag. Some of the tree (i386, =
lib*32) is


Note: The "LFLAGS+=3D	-Wl,-m -Wl,elf32ppc_fbsd" is a long-standing =
item
in my powerpc64 experimental environment and is not the point here.


For reference:

# more =
~/src.configs/src.conf.powerpc64-xtoolchain-gcc-no_toolchain.amd64-host
TO_TYPE=3Dpowerpc64
TOOLS_TO_TYPE=3D${TO_TYPE}
VERSION_CONTEXT=3D12.0
#
KERNCONF=3DGENERIC64vtsc-NODBG
TARGET=3Dpowerpc
.if ${.MAKE.LEVEL} =3D=3D 0
TARGET_ARCH=3D${TO_TYPE}
.export TARGET_ARCH
.endif
#
WITHOUT_CROSS_COMPILER=3D
WITHOUT_SYSTEM_COMPILER=3D
WITHOUT_SYSTEM_LINKER=3D
#
WITH_LIBCPLUSPLUS=3D
WITHOUT_LLD_BOOTSTRAP=3D
WITHOUT_BINUTILS_BOOTSTRAP=3D
WITHOUT_ELFTOOLCHAIN_BOOTSTRAP=3D
WITHOUT_CLANG_BOOTSTRAP=3D
WITHOUT_CLANG_IS_CC=3D
WITHOUT_CLANG=3D
WITHOUT_CLANG_FULL=3D
WITHOUT_CLANG_EXTRAS=3D
WITHOUT_LLD=3D
WITHOUT_BINUTILS=3D
WITHOUT_LLDB=3D
#
WITH_BOOT=3D
# powerpc64 LIB32 builds via gcc 4.9 or later variants that I've tried
# but the LIB32 does not work [crtbeginS code problem(s): bad R30 use]
#WITHOUT_LIB32=3D
WITH_LIB32=3D
#
WITHOUT_GCC_BOOTSTRAP=3D
WITHOUT_GCC=3D
WITHOUT_GCC_IS_CC=3D
WITHOUT_GNUCXX=3D
#
NO_WERROR=3D
#
# Avoid db_trace.o getting:
#   calling '__builtin_frame_address' with a nonzero argument is unsafe
# as an error? Other such points as well.
#WERROR=3D
MALLOC_PRODUCTION=3D
#
WITH_REPRODUCIBLE_BUILD=3D
WITH_DEBUG_FILES=3D
#
#
# For TO (so-called "cross") stages . . .
# So-called-cross via ${TO_TYPE}-xtoolchain-gcc/${TO_TYPE}-gcc. . .
# TOOLS_TO_TYPE based on ${TO_TYPE}-xtoolchain-gcc related binutils. . .
#
CROSS_TOOLCHAIN=3D${TO_TYPE}-gcc
X_COMPILER_TYPE=3Dgcc
=
CROSS_BINUTILS_PREFIX=3D/usr/local/${TOOLS_TO_TYPE}-unknown-freebsd${VERSI=
ON_CONTEXT}/bin/
.if ${.MAKE.LEVEL} =3D=3D 0
=
XCC=3D/usr/local/bin/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}-gc=
c
=
XCXX=3D/usr/local/bin/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}-g=
++
=
XCPP=3D/usr/local/bin/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}-c=
pp
.export XCC
.export XCXX
.export XCPP
XAS=3D/usr/local/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}/bin/as=

XAR=3D/usr/local/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}/bin/ar=

XLD=3D/usr/local/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}/bin/ld=

XNM=3D/usr/local/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}/bin/nm=

=
XOBJCOPY=3D/usr/local/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}/b=
in/objcopy
=
XOBJDUMP=3D/usr/local/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}/b=
in/objdump
=
XRANLIB=3D/usr/local/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}/bi=
n/ranlib
=
XSIZE=3D/usr/local/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}/bin/=
size
#NO-SUCH: =
XSTRINGS=3D/usr/local/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEXT}/b=
in/strings
=
XSTRINGS=3D/usr/local/bin/${TOOLS_TO_TYPE}-unknown-freebsd${VERSION_CONTEX=
T}-strings
.export XAS
.export XAR
.export XLD
.export XNM
.export XOBJCOPY
.export XOBJDUMP
.export XRANLIB
.export XSIZE
.export XSTRINGS
.endif
#
#
# =46rom based on clang (via system). . .
#
.if ${.MAKE.LEVEL} =3D=3D 0
CC=3D/usr/bin/clang
CXX=3D/usr/bin/clang++
CPP=3D/usr/bin/clang-cpp
.export CC
.export CXX
.export CPP
.endif


=3D=3D=3D
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6EAD7607-1FD5-4282-B082-F5FD0087B6C5>