freebsd-dev/sys/modules/cloudabi32/Makefile
Alex Richardson 2b6ee34cf6 Pass -fuse-ld=/path/to/ld if ${LD} != "ld"
This is needed so that setting LD/XLD is not ignored when linking with $CC
instead of directly using $LD. Currently only clang accepts an absolute
path for -fuse-ld= (Clang 12+ will add a new --ld-path flag), so we now
warn when building with GCC and $LD != "ld" since that might result in the
wrong linker being used.

We have been setting XLD=/path/to/cheri/ld.lld in CheriBSD for a long time and
used a similar version of this patch to avoid linking with /usr/bin/ld.
This change is also required when building FreeBSD on an Ubuntu with Clang:
In that case we set XCC=/usr/lib/llvm-10/bin/clang and since
/usr/lib/llvm-10/bin/ does not contain a "ld" binary the build fails with
`clang: error: unable to execute command: Executable "ld" doesn't exist!`
unless we pass -fuse-ld=/usr/lib/llvm-10/bin/ld.lld.

This change passes -fuse-ld instead of copying ${XLD} to WOLRDTMP/bin/ld
since then we would have to ensure that this file does not exist while
building the bootstrap tools. The cross-linker might not be compatible with
the host linker (e.g. when building on macos: host-linker= Mach-O /usr/bin/ld,
cross-linker=LLVM ld.lld).

Reviewed By:	brooks, emaste
Differential Revision: https://reviews.freebsd.org/D26055
2020-08-25 13:30:03 +00:00

47 lines
1.4 KiB
Makefile

# $FreeBSD$
SYSDIR?=${SRCTOP}/sys
.PATH: ${SYSDIR}/compat/cloudabi32
.PATH: ${SYSDIR}/${MACHINE_CPUARCH}/cloudabi32
.PATH: ${SYSDIR}/${MACHINE}/cloudabi32
KMOD= cloudabi32
SRCS= cloudabi32_fd.c cloudabi32_module.c cloudabi32_poll.c \
cloudabi32_sock.c cloudabi32_syscalls.c cloudabi32_sysent.c \
cloudabi32_sysvec.c cloudabi32_thread.c
OBJS= cloudabi32_vdso_blob.o
CLEANFILES=cloudabi32_vdso.o
.if ${MACHINE_CPUARCH} == "aarch64"
VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_armv6_on_64bit.S
OUTPUT_TARGET=elf64-littleaarch64
BINARY_ARCHITECTURE=aarch64
.elif ${MACHINE_CPUARCH} == "amd64"
VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S
OUTPUT_TARGET=elf64-x86-64-freebsd
BINARY_ARCHITECTURE=i386
.elif ${MACHINE_ARCH:Marmv[67]*} != ""
VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_armv6.S
OUTPUT_TARGET=elf32-littlearm
BINARY_ARCHITECTURE=arm
.elif ${MACHINE_CPUARCH} == "i386"
VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_i686.S
OUTPUT_TARGET=elf32-i386-freebsd
BINARY_ARCHITECTURE=i386
.endif
cloudabi32_vdso.o: ${VDSO_SRCS}
${CC} ${CCLDFLAGS} -x assembler-with-cpp -m32 -shared -nostdinc -nostdlib \
-Wl,-T${SYSDIR}/compat/cloudabi/cloudabi_vdso.lds \
${VDSO_SRCS} -o ${.TARGET}
cloudabi32_vdso_blob.o: cloudabi32_vdso.o
${OBJCOPY} --input-target binary \
--output-target ${OUTPUT_TARGET} \
--binary-architecture ${BINARY_ARCHITECTURE} \
cloudabi32_vdso.o ${.TARGET}
.include <bsd.kmod.mk>