FreeBSD/powerpc and FreeBSD/powerpcspe toolchain update

Mark Millard marklmi at yahoo.com
Fri Jun 28 01:35:52 UTC 2019


[I retried, adjusting src.conf.powerpc-clang-bootstrap.amd64-host to
be lld based this time. It is a different failure: ld rejects the
attempted use of --secure-plt .]

On 2019-Jun-27, at 16:19, Mark Millard <marklmi at yahoo.com> wrote:

> [I used src.conf.powerpc-clang-bootstrap.amd64-host which uses
> WITHOUT_LLD_BOOTSTRAP= and  WITH_BINUTILS_BOOTSTRAP= and so
> LLD was not in use.] 
> 
> On 2019-Jun-27, at 15:03, Mark Millard <marklmi at yahoo.com> wrote:
> 
>> 
>> 
>> On 2019-Jun-27, at 14:53, Mark Millard <marklmi at yahoo.com> wrote:
>> 
>> 
>> 
>>> On 2019-Jun-27, at 12:53, Justin Hibbits <jrh29 at alumni.cwru.edu> wrote:
>>> 
>>>> On Thu, 27 Jun 2019 12:03:05 -0700
>>>> Mark Millard <marklmi at yahoo.com> wrote:
>>>> 
>>>>> On 2019-Jun-24, at 19:40, Justin Hibbits <jrh29 at alumni.cwru.edu>
>>>>> wrote:
>>>>> 
>>>>>> As of r349351 32-bit powerpc toolchains need to be rebuilt as part
>>>>>> of buildworld, in order to take advantage of the new Secure
>>>>>> Procedure Linkage Table (Secure-PLT) format.  This can be done by
>>>>>> passing "WITHOUT_SYSTEM_TOOLCHAIN=" on the 'make buildworld'
>>>>>> command line.
>>>>>> 
>>>>>> Cross-building should work fine with no changes, as that already
>>>>>> builds a new toolchain.  If building with an external toolchain,
>>>>>> such as gcc8, add 'CFLAGS+= -msecure-plt' to /etc/src.conf to
>>>>>> ensure the new PLT is used, otherwise it will default to BSS-PLT,
>>>>>> which is fully compatible, but not as secure.  There is breakage
>>>>>> intended at all, so please let me know if there are any problems.  
>>>>> 
>>>>> My attempt to amd64->powerpc (32-bit) cross build from/to head
>>>>> -r349444 via system clang and lld got the following. This may not be
>>>>> a recent change.
> 
> 
> Gack: Looking at the src.conf.powerpc-clang-bootstrap.amd64-host
> text I'd originally included but has been dropped later in this
> exchange, there is:
> 
> WITHOUT_SYSTEM_LINKER=
> . . .
> WITHOUT_LLD_BOOTSTRAP=
> WITH_BINUTILS_BOOTSTRAP=
> WITH_ELFTOOLCHAIN_BOOTSTRAP=
> 
> So lld was not in use as I intended: wrong src.conf.* file.
> I did not end up testing what I intended to test.
> 
> So this is actually about ld from WITH_BINUTILS_BOOTSTRAP :
> 
> # /usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/powerpc.powerpc/tmp/usr/bin/ld -v
> GNU ld 2.17.50 [FreeBSD] 2007-07-03
> 
> Sorry for the misdirection.
> 
>> . . .

# uname -apKU
FreeBSD FBSDFSSD 13.0-CURRENT FreeBSD 13.0-CURRENT #22 r349444M: Wed Jun 26 16:00:44 PDT 2019     markmi at FBSDFSSD:/usr/obj/amd64_clang/amd64.amd64/usr/src/amd64.amd64/sys/GENERIC-NODBG  amd64 amd64 1300034 1300034

Is:

QUOTE
SYSTEM_LINKER: Determined that LD=ld matches the source tree.  Not bootstrapping a cross-linker
END QUOTE

a problem for amd64->powerpc (32-bit) cross builds?

The different failing result for actual lld use for head -349444
amd64->powerpc cross build is that it rejects the use of --secure-plt :

# Meta data file /usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/powerpc.powerpc/lib/libc/libc.so.7.full.meta
CMD @echo building shared library libc.so.7
CMD @rm -f libc.so.7 libc.so
CMD cc -target powerpc-unknown-freebsd13.0 \
--sysroot=/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/powerpc.powerpc/tmp \
-B/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/powerpc.powerpc/tmp/usr/bin  \
-Wl,--secure-plt -nodefaultlibs -Wl,--version-script=Version.map -Wl,--no-threads   \
-shared -Wl,-x -Wl,--fatal-warnings -Wl,--warn-shared-textrel  \
-o libc.so.7.full -Wl,-soname,libc.so.7  \
`NM='nm' NMFLAGS='' lorder  . . . wmemset.pico |  tsort -q`  -lcompiler_rt  -lssp_nonshared
CWD /usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/powerpc.powerpc/lib/libc
TARGET libc.so.7.full
-- command output --
building shared library libc.so.7
ld: error: unknown argument: --secure-plt
cc: error: linker command failed with exit code 1 (use -v to see invocation)

*** Error code 1

-- filemon acquired metadata --
. . .



Looking at the -Wl,--secure-plt use via:

# cc -### -target powerpc-unknown-freebsd13.0 -Wl,--secure-plt 
FreeBSD clang version 8.0.1 (branches/release_80 363030) (based on LLVM 8.0.1)
Target: powerpc-unknown-freebsd13.0
Thread model: posix
InstalledDir: /usr/bin
 "/usr/bin/ld" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld-elf.so.1" "--enable-new-dtags" "-m" "elf32ppc_fbsd" "-o" "a.out" "/usr/lib32/crt1.o" "/usr/lib32/crti.o" "/usr/lib32/crtbegin.o" "-L/usr/lib32" "--secure-plt" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "/usr/lib32/crtend.o" "/usr/lib32/crtn.o"

Then trying the ld command it reported:

# "/usr/bin/ld" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld-elf.so.1" "--enable-new-dtags" "-m" "elf32ppc_fbsd" "-o" "a.out" "/usr/lib32/crt1.o" "/usr/lib32/crti.o" "/usr/lib32/crtbegin.o" "-L/usr/lib32" "--secure-plt" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "/usr/lib32/crtend.o" "/usr/lib32/crtn.o"
ld: error: unknown argument: --secure-plt



The buildworld log report of the failure looks like:

--- libc.so.7.full ---
ld: error: unknown argument: --secure-plt
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** [libc.so.7.full] Error code 1

make[4]: stopped in /usr/src/lib/libc
.ERROR_TARGET='libc.so.7.full'
.ERROR_META_FILE='/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/powerpc.powerpc/lib/libc/libc.so.7.full.meta'
.MAKE.LEVEL='4'
MAKEFILE=''
.MAKE.MODE='meta missing-filemon=yes missing-meta=yes silent=yes verbose'
_ERROR_CMD='@echo building shared library libc.so.7; @rm -f libc.so.7 libc.so; cc -target powerpc-unknown-freebsd13.0 --sysroot=/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/powerpc.powerpc/tmp -B/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/powerpc.powerpc/tmp/usr/bin  -Wl,--secure-plt -nodefaultlibs -Wl,--version-script=Version.map -Wl,--no-threads   -shared -Wl,-x -Wl,--fatal-warnings -Wl,--warn-shared-textrel  -o libc.so.7.full -Wl,-soname,libc.so.7  `NM='nm' NMFLAGS='' lorder trivial-vdso_tc.pico
. . .
.CURDIR='/usr/src/lib/libc'
.MAKE='make'
.OBJDIR='/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/powerpc.powerpc/lib/libc'
.TARGETS='all'
DESTDIR='/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/powerpc.powerpc/tmp'
LD_LIBRARY_PATH=''
MACHINE='powerpc'
MACHINE_ARCH='powerpc'
MAKEOBJDIRPREFIX=''
MAKESYSPATH='/usr/src/share/mk'
MAKE_VERSION='20181221'
PATH='/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/powerpc.powerpc/tmp/usr/sbin:/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/powerpc.powerpc/tmp/usr/bin:/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/powerpc.powerpc/tmp/legacy/usr/sbin:/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/powerpc.powerpc/tmp/legacy/usr/bin:/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/powerpc.powerpc/tmp/legacy/bin::/sbin:/bin:/usr/sbin:/usr/bin'
SRCTOP='/usr/src'
OBJTOP='/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/powerpc.powerpc'
.MAKE.MAKEFILES='/usr/src/share/mk/sys.mk /usr/src/share/mk/local.sys.env.mk /usr/src/share/mk/src.sys.env.mk
. . .
1 error


This report is based on the following that does use lld:

TO_TYPE=powerpc
#
KERNCONF=GENERICvtsc-NODBG
TARGET=${TO_TYPE}
.if ${.MAKE.LEVEL} == 0
TARGET_ARCH=${TO_TYPE}
.export TARGET_ARCH
.endif
#
WITH_CROSS_COMPILER=
WITH_SYSTEM_COMPILER=
WITH_SYSTEM_LINKER=
#
# llvm's libunwind for 32-bit powerpc:
# Two of its .S files get tons of error reports.
# So avoid llvm's libunwind for now.
#WITHOUT_LLVM_LIBUNWIND=
WITH_LIBCPLUSPLUS=
WITH_LLD_BOOTSTRAP=
WITHOUT_BINUTILS_BOOTSTRAP=
WITH_ELFTOOLCHAIN_BOOTSTRAP=
#Disables avoiding bootstrap: WITHOUT_LLVM_TARGET_ALL=
WITHOUT_LLVM_TARGET_AARCH64=
WITHOUT_LLVM_TARGET_ARM=
WITHOUT_LLVM_TARGET_MIPS=
WITH_LLVM_TARGET_POWERPC=
WITHOUT_LLVM_TARGET_SPARC=
WITHOUT_LLVM_TARGET_X86=
WITH_CLANG_BOOTSTRAP=
WITH_CLANG=
WITH_CLANG_IS_CC=
WITH_CLANG_FULL=
WITH_CLANG_EXTRAS=
WITH_LLD=
WITH_LLD_IS_LD=
WITHOUT_BINTUILS=
# lldb requires missing atomic 8-byte operations for powerpc (non-64)
WITHOUT_LLDB=
#
WITH_BOOT=
WITHOUT_LIB32=
#
LOADER_DEFAULT_INTERP=4th
#
WITHOUT_GCC_BOOTSTRAP=
WITHOUT_GCC=
WITHOUT_GCC_IS_CC=
WITHOUT_GNUCXX=
#
NO_WERROR=
#
# Use WERROR to avoid stopping at the likes of:
# error: implicit conversion from 'int' to 'int8_t' (aka 'signed char') changes value from 128 to -128 [-Werror,-Wconstant-conversion]
WERROR=
MALLOC_PRODUCTION=
#
# Avoid stripping but do not control host -g status as well:
DEBUG_FLAGS+=
#
WITH_REPRODUCIBLE_BUILD=
WITH_DEBUG_FILES=

Note:

--- buildworld ---
make[1]: "/usr/src/Makefile.inc1" line 347: SYSTEM_COMPILER: Determined that CC=cc matches the source tree.  Not bootstrapping a cross-compiler.
make[1]: "/usr/src/Makefile.inc1" line 352: SYSTEM_LINKER: Determined that LD=ld matches the source tree.  Not bootstrapping a cross-linker.



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



More information about the freebsd-ppc mailing list