Because MK_LLDB=no is in BSARGS, the bootstrap-tools recursive make does
not add lldb-tblgen to _clang_tblgen, causing it to not be built. This
means that the build currently always uses the host's lldb-tblgen
(which, whilst currently it appears to work, could in future break if
TableGen backends are added or altered) and, if it doesn't exist (either
because the current FreeBSD system was built with it disabled, or you're
building on macOS/Linux), fails. Linux and macOS cross-builds used to
work simply because LLDB was previously in BROKEN_OPTIONS when building
on non-FreeBSD.
Instead, move MK_LLDB=no from BSARGS to XMAKE. This ensures that the
lib/clang build in cross-tools continues to not build LLDB parts for the
bootstrap toolchain (both to save time/space on FreeBSD, and because our
vendored LLDB does not include the macOS and Linux host files so those
would fail to build).
The DIRDEPS target is updated to move MK_LLDB=no from the BSARGS block
that mirrors Makefile.inc1 to the line that disables additional
toolchain components. The DIRDEPS build likely suffers from the same
issue currently, but having never used it and not being familiar with
how it works I am leaving that as-is. If it does suffer from the same
issue it should be easily reproducible by renaming /usr/bin/lldb-tblgen
or moving it to a directory not in PATH.
Fixes: 31ba4ce889
("Allow bootstrapping llvm-tblgen on macOS and Linux")
MFC after: 1 week
Reviewed by: dim, emaste, imp
Differential Revision: https://reviews.freebsd.org/D31531
104 lines
2.9 KiB
Makefile
104 lines
2.9 KiB
Makefile
# $FreeBSD$
|
|
|
|
# building clang is particularly tedious - so avoid re-inventing wheels
|
|
|
|
all: bootstrap-toolchain
|
|
|
|
UPDATE_DEPENDFILE= no
|
|
.export UPDATE_DEPENDFILE
|
|
|
|
# we build for the pseudo machine "host"
|
|
TARGET_MACHINE= host
|
|
|
|
HOST_MACHINE!= uname -m
|
|
HOST_MACHINE_ARCH!= uname -p
|
|
BTOOLSDIR?= ${HOST_OBJTOP}/tools
|
|
WORLDTMP= ${BTOOLSDIR}
|
|
LEGACY_TOOLS?= ${BTOOLSDIR}/legacy
|
|
|
|
BSENV= \
|
|
MAKESYSPATH=${SRCTOP}/tools/build/mk:${SRCTOP}/share/mk \
|
|
TARGET=${HOST_MACHINE} TARGET_ARCH=${HOST_MACHINE_ARCH} \
|
|
WITHOUT_STAGING=1 STAGE_ROOT= BOOTSTRAPPING_TOOLS=1 \
|
|
WORLDTMP=${BTOOLSDIR} \
|
|
INSTALL="sh ${SRCTOP}/tools/install.sh" \
|
|
PATH=${LEGACY_TOOLS}/usr/sbin:${LEGACY_TOOLS}/usr/bin:${LEGACY_TOOLS}/bin:${PATH}
|
|
|
|
.if !defined(OSRELDATE)
|
|
ord_h= /usr/include/osreldate.h
|
|
.if exists(${ord_h})
|
|
OSRELDATE!= sed -n '/define.*__FreeBSD_version/{s,^[^0-9]*,,p;q;}' ${ord_h}
|
|
.endif
|
|
OSRELDATE?= 0
|
|
.endif
|
|
|
|
# need to keep this in sync with src/Makefile.inc1
|
|
BSARGS= DESTDIR= \
|
|
OBJTOP='${WORLDTMP}/obj-tools' \
|
|
OBJROOT='$${OBJTOP}/' \
|
|
MAKEOBJDIRPREFIX= \
|
|
BOOTSTRAPPING=${OSRELDATE} \
|
|
BWPHASE=${.TARGET} \
|
|
-DNO_CPU_CFLAGS \
|
|
-DNO_LINT \
|
|
-DNO_PIC \
|
|
-DNO_SHARED \
|
|
MK_CTF=no \
|
|
MK_CLANG_EXTRAS=no \
|
|
MK_CLANG_FORMAT=no \
|
|
MK_CLANG_FULL=no \
|
|
MK_HTML=no \
|
|
MK_MAN=no \
|
|
MK_PROFILE=no \
|
|
MK_RETPOLINE=no \
|
|
MK_SSP=no \
|
|
MK_TESTS=no \
|
|
MK_WERROR=no \
|
|
MK_INCLUDES=yes \
|
|
MK_MAN_UTILS=yes
|
|
|
|
# We will handle building the toolchain and cross-compiler.
|
|
BSARGS+= MK_CROSS_COMPILER=no MK_CLANG=no MK_LLDB=no
|
|
|
|
DISTRIB_ENV= INSTALL="sh ${SRCTOP}/tools/install.sh" NO_FSCHG=1 MK_TESTS=no
|
|
legacy: .MAKE ${META_DEPS}
|
|
mkdir -p ${LEGACY_TOOLS}
|
|
${DISTRIB_ENV} ${MAKE} -C ${SRCTOP}/etc distrib-dirs \
|
|
DESTDIR=${BTOOLSDIR} > $@.distrib-dirs_btoolsdir
|
|
${DISTRIB_ENV} ${MAKE} -C ${SRCTOP}/etc distrib-dirs \
|
|
DESTDIR=${LEGACY_TOOLS} > $@.distrib-dirs_legacy_tools
|
|
${BSENV} ${MAKE} -C ${SRCTOP} -f Makefile.inc1 ${BSARGS} $@
|
|
|
|
bootstrap-tools: legacy
|
|
build-tools: bootstrap-tools
|
|
cross-tools: build-tools
|
|
|
|
cross-tools build-tools bootstrap-tools: .MAKE ${META_DEPS}
|
|
${BSENV} ${MAKE} -C ${SRCTOP} -f Makefile.inc1 ${BSARGS} $@
|
|
|
|
# MAKELEVEL=0 so that dirdeps.mk does its thing
|
|
# BSENV:MPATH=* lets us use the bootstrapped stuff in LEGACY_TOOLS above.
|
|
# TARGET* is so that MK_CLANG gets set correctly.
|
|
BSTCENV= \
|
|
MAKELEVEL=0 \
|
|
MACHINE=host \
|
|
BOOTSTRAPPING_TOOLS=1 \
|
|
TARGET=${HOST_MACHINE} \
|
|
TARGET_ARCH=${HOST_MACHINE_ARCH} \
|
|
${BSENV:MPATH=*}
|
|
|
|
BSTCARGS= \
|
|
${BSARGS:NDESTDIR=*:NOBJTOP=*:NOBJROOT=*:NMK_CROSS_COMPILER=*:NMK_CLANG=*} \
|
|
BUILD_DIRDEPS=yes \
|
|
LLVM_TBLGEN=${TOOLSDIR}/usr/bin/llvm-tblgen \
|
|
CLANG_TBLGEN=${TOOLSDIR}/usr/bin/clang-tblgen \
|
|
-DWITH_STAGING \
|
|
-DWITH_TOOLSDIR
|
|
|
|
# finally we build toolchain leveraging the above.
|
|
bootstrap-toolchain: .MAKE cross-tools
|
|
${BSTCENV} ${MAKE} -C ${SRCTOP} ${BSTCARGS} toolchain
|
|
|
|
# Ensure CCACHE_DIR is ignored since we are processing .meta files here.
|
|
.include <bsd.compiler.mk>
|