Index: Makefile.inc1 =================================================================== --- Makefile.inc1 +++ Makefile.inc1 @@ -802,6 +802,7 @@ ${TARGET_ARCH} == "powerpc64" || ${TARGET_ARCH:Mmips64*} != "") LIBCOMPAT= 32 .include "Makefile.libcompat" +CROSSENV+=LIB32LD=${LIB32LD} .elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH:Marmv[67]*} != "" LIBCOMPAT= SOFT .include "Makefile.libcompat" Index: Makefile.libcompat =================================================================== --- Makefile.libcompat +++ Makefile.libcompat @@ -8,6 +8,41 @@ # ------------------------------------------------------------------- # 32 bit world + + +# Determines linker used for 32-bit compatibility +# Currently LLD support for PowerPC 32-bit is not complete, +# so falling back to ld.bfd. +.if "${TARGET_ARCH}" == "powerpc64" && "${LINKER_TYPE}" == "lld" + +.if "${_HOST_ARCH}" != "${TARGET_ARCH}" # cross build + +.if defined(CROSS_TOOLCHAIN) # with toolchain file + +.if defined(CROSS_BINUTILS_PREFIX) +LIB32LD?=${LOCALBASE}/bin/${CROSS_BINUTILS_PREFIX}-ld.bfd +.else +# Binutils prefix must be defined +# Note: Just warn because this is required for 32-bit stuff only +.warning 32-bit binaries on PowerPC64 requires binutils linker ld.bfd.\ +Please set CROSS_BINUTILS_PREFIX. +.endif + +.else # without toolchain file +LIB32LD?=${WORLDTMP}/usr/bin/ld.bfd +.endif + +.else # native build +LIB32LD?=/usr/bin/ld.bfd +.endif + +.info LIB32: using ${LIB32LD} as linker for LIB32 +.endif + +# for other platforms (or when LIB32LD is not set), just use the main linker +LIB32LD?=${XLD} + + .if ${TARGET_ARCH} == "amd64" .if empty(TARGET_CPUTYPE) LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2 @@ -33,10 +68,17 @@ .else LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE} .endif + +.if ${WANT_COMPILER_TYPE} == gcc || \ + (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc) LIB32CPUFLAGS+= -m32 +.else +LIB32CPUFLAGS+= -target powerpc-unknown-freebsd13.0 -fuse-ld=${LIB32LD} +.endif + LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc LIB32WMAKEFLAGS= \ - LD="${XLD} -m elf32ppc_fbsd" \ + LD="${LIB32LD} -m elf32ppc_fbsd" \ OBJCOPY="${XOBJCOPY}" .elif ${TARGET_ARCH:Mmips64*} != "" Index: stand/defs.mk =================================================================== --- stand/defs.mk +++ stand/defs.mk @@ -93,6 +93,13 @@ # or powerpc64. .if ${MACHINE_ARCH} == "powerpc64" CFLAGS+= -m32 -mcpu=powerpc +# Use same linker used to link 32 bit binaries +.if "${COMPILER_TYPE}" == "clang" +.if !defined(LIB32LD) +.error LIB32LD must be defined when building stand. +.endif +CFLAGS+= -fuse-ld=${LIB32LD} +.endif .endif # For amd64, there's a bit of mixed bag. Some of the tree (i386, lib*32) is