freebsd-dev/sys/modules/cloudabi64/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

39 lines
1.1 KiB
Makefile

# $FreeBSD$
SYSDIR?=${SRCTOP}/sys
.PATH: ${SYSDIR}/compat/cloudabi64
.PATH: ${SYSDIR}/${MACHINE_CPUARCH}/cloudabi64
.PATH: ${SYSDIR}/${MACHINE}/cloudabi64
KMOD= cloudabi64
SRCS= cloudabi64_fd.c cloudabi64_module.c cloudabi64_poll.c \
cloudabi64_sock.c cloudabi64_syscalls.c cloudabi64_sysent.c \
cloudabi64_sysvec.c cloudabi64_thread.c
OBJS= cloudabi64_vdso_blob.o
CLEANFILES=cloudabi64_vdso.o
.if ${MACHINE_CPUARCH} == "aarch64"
VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_aarch64.S
OUTPUT_TARGET=elf64-littleaarch64
BINARY_ARCHITECTURE=aarch64
.elif ${MACHINE_CPUARCH} == "amd64"
VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_x86_64.S
OUTPUT_TARGET=elf64-x86-64-freebsd
BINARY_ARCHITECTURE=i386
.endif
cloudabi64_vdso.o: ${VDSO_SRCS}
${CC} ${CCLDFLAGS} -x assembler-with-cpp -shared -nostdinc -nostdlib \
-Wl,-T${SYSDIR}/compat/cloudabi/cloudabi_vdso.lds \
${VDSO_SRCS} -o ${.TARGET}
cloudabi64_vdso_blob.o: cloudabi64_vdso.o
${OBJCOPY} --input-target binary \
--output-target ${OUTPUT_TARGET} \
--binary-architecture ${BINARY_ARCHITECTURE} \
cloudabi64_vdso.o ${.TARGET}
.include <bsd.kmod.mk>