diff --git a/Makefile.inc1 b/Makefile.inc1 index 3399e469ea02..542121976333 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -629,6 +629,18 @@ MKTEMP=${WORLDTMP}/legacy/usr/bin/mktemp MKTEMP=mktemp .endif INSTALLTMP!= ${MKTEMP} -d -u -t install + +.if ${.MAKE.OS} == "FreeBSD" +# When building on FreeBSD we always copy the host tools instead of linking +# into INSTALLTMP to avoid issues with incompatible libraries (see r364030). +# Note: we could create links if we don't intend to update the current machine. +INSTALLTMP_COPY_HOST_TOOL=cp +.else +# However, this is not necessary on Linux/macOS. Additionally, copying the host +# tools to another directory with cp results in AMFI Launch Constraint +# Violations on macOS Ventura as part of its System Integrity Protection. +INSTALLTMP_COPY_HOST_TOOL=ln -s +.endif .endif .if make(stagekernel) || make(distributekernel) @@ -1388,7 +1400,7 @@ distributeworld installworld stageworld: _installcheck_world .PHONY fi; \ done); \ fi; \ - cp $$libs $$progs ${INSTALLTMP} + ${INSTALLTMP_COPY_HOST_TOOL} $$libs $$progs ${INSTALLTMP} cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale .if defined(NO_ROOT) -mkdir -p ${METALOG:H}