Fix paths for cross-built versions of lib/libclang_rt and hardfloat arm variants

- Define TARGET_CPUARCH and use in libclang_rt as the basis for CRTARCH

  When cross-compiling, the wrong architecture was being embedded in the
  libclang_rt binary filenames. It should be based on TARGET_ARCH (target), not
  MACHINE_ARCH (host).

  If TARGET_ARCH isn't defined (host-builds), fallback to MACHINE_ARCH.

- Define CRTARCH to armhf when TARGET/TARGET_ARCH are set to arm/armv[67]

  TARGET_ABI/TARGET_CPU in Makefile.inc1 sets the ABI to gnueabihf, which
  affects the clang lookup path per `getArchNameForCompilerRTLib(..)` in
  contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp, so chase clang and
  Linux's assumed naming convention for hard-float arm architectures.

  CROSSENV (in Makefile.inc1) sets CPUTYPE/MACHINE(_ARCH)? to the
  TARGET*-relevant values when building the `libraries` target, so test
  those variables instead.

- Add OLD_FILES/OLD_LIBS entries for TARGET/TARGET_ARCH == arm/armv[67]. This
  impacts only arm/armv6 and arm/armv7.

PR:	222925
This commit is contained in:
Enji Cooper 2017-11-05 19:38:51 +00:00
commit 571e134eea
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=325443
3 changed files with 28 additions and 1 deletions

View File

@ -38,6 +38,21 @@
# xargs -n1 | sort | uniq -d;
# done
# 20171105: fixing lib/libclang_rt CRTARCH for arm:armv[67].
.if ${MACHINE} == "arm"
.if ${MACHINE_ARCH:Marmv[67]*} != "" && ${CPUTYPE:M*soft*} == ""
OLD_FILES+=usr/lib/clang/5.0.0/lib/freebsd/libclang_rt.asan-preinit-arm.a
OLD_FILES+=usr/lib/clang/5.0.0/lib/freebsd/libclang_rt.asan-arm.a
OLD_LIBS+=usr/lib/clang/5.0.0/lib/freebsd/libclang_rt.asan-arm.so
OLD_FILES+=usr/lib/clang/5.0.0/lib/freebsd/libclang_rt.asan_cxx-arm.a
OLD_FILES+=usr/lib/clang/5.0.0/lib/freebsd/libclang_rt.profile-arm.a
OLD_FILES+=usr/lib/clang/5.0.0/lib/freebsd/libclang_rt.safestack-arm.a
OLD_FILES+=usr/lib/clang/5.0.0/lib/freebsd/libclang_rt.stats-arm.a
OLD_FILES+=usr/lib/clang/5.0.0/lib/freebsd/libclang_rt.stats_client-arm.a
OLD_FILES+=usr/lib/clang/5.0.0/lib/freebsd/libclang_rt.ubsan_standalone-arm.a
OLD_FILES+=usr/lib/clang/5.0.0/lib/freebsd/libclang_rt.ubsan_standalone_cxx-arm.a
.endif
.endif
# 20171104: libcap_random should be in /lib not in /usr/lib
OLD_LIBS+=usr/lib/libcap_random.so.0
# 20171104: Casper can work only as shared library

View File

@ -2,7 +2,14 @@
.include <src.opts.mk>
CRTARCH= ${MACHINE_CPUARCH:C/amd64/x86_64/}
# NOTE: based on TARGET_ABI/TARGET_CPUTYPE, set in Makefile.inc1 .
.if ${MACHINE} == "arm"
.if ${MACHINE_ARCH:Marmv[67]*} != "" && ${CPUTYPE:M*soft*} == ""
CRTARCH= armhf
.endif
.endif
CRTARCH?= ${TARGET_CPUARCH:C/amd64/x86_64/}
CRTSRC= ${SRCTOP}/contrib/compiler-rt
.PATH: ${CRTSRC}/lib

View File

@ -15,6 +15,11 @@ unix ?= We run FreeBSD, not UNIX.
#
__TO_CPUARCH=C/mips(n32|64)?(el)?(hf)?/mips/:C/arm(v[67])?(eb)?/arm/:C/powerpc(64|spe)/powerpc/:C/riscv64(sf)?/riscv/
MACHINE_CPUARCH=${MACHINE_ARCH:${__TO_CPUARCH}}
.ifdef TARGET_ARCH
TARGET_CPUARCH=${TARGET_ARCH:${__TO_CPUARCH}}
.else
TARGET_CPUARCH=${MACHINE_CPUARCH}
.endif
.endif
__DEFAULT_YES_OPTIONS+= \