Index: Makefile.inc1 =================================================================== --- Makefile.inc1 +++ Makefile.inc1 @@ -720,8 +720,8 @@ MK_ASAN=${BOOTSTRAP_TOOLS_ASAN:Uno} \ MK_UBSAN=${BOOTSTRAP_TOOLS_UBSAN:Uno} \ MK_CLANG_EXTRAS=no MK_CLANG_FORMAT=no MK_CLANG_FULL=no \ - MK_LLDB=no MK_RETPOLINE=no MK_TESTS=no \ - MK_INCLUDES=yes + MK_LLDB=no MK_LLVM_BINUTILS=${MK_LLVM_BINUTILS} \ + MK_RETPOLINE=no MK_TESTS=no MK_INCLUDES=yes BMAKE= \ ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \ @@ -2301,15 +2301,19 @@ # We need to build tblgen when we're building clang or lld, either as # bootstrap tools, or as the part of the normal build. +# llvm-tblgen is also needed for various llvm binutils (e.g. objcopy). .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \ - ${MK_LLD_BOOTSTRAP} != "no" || ${MK_LLD} != "no" + ${MK_LLD_BOOTSTRAP} != "no" || ${MK_LLD} != "no" || \ + ${MK_LLDB} != "no" || ${MK_LLVM_BINUTILS} != "no" _clang_tblgen= \ lib/clang/libllvmminimal \ - usr.bin/clang/llvm-tblgen \ - usr.bin/clang/clang-tblgen \ - usr.bin/clang/lldb-tblgen -# XXX: lldb-tblgen is not needed, if top-level MK_LLDB=no - + usr.bin/clang/llvm-tblgen +.if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" +_clang_tblgen+= usr.bin/clang/clang-tblgen +.endif +.if ${MK_LLDB} != "no" +_clang_tblgen+= usr.bin/clang/lldb-tblgen +.endif ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmminimal ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmminimal ${_bt}-usr.bin/clang/lldb-tblgen: ${_bt}-lib/clang/libllvmminimal Index: lib/Makefile =================================================================== --- lib/Makefile +++ lib/Makefile @@ -157,7 +157,9 @@ SUBDIR.${MK_BSNMP}+= libbsnmp .if !defined(COMPAT_32BIT) && !defined(COMPAT_SOFTFP) -SUBDIR.${MK_CLANG}+= clang +.if ${MK_CLANG} != "no" || ${MK_LLVM_BINUTILS} != "no" +SUBDIR+= clang +.endif .endif SUBDIR.${MK_CUSE}+= libcuse Index: lib/clang/Makefile =================================================================== --- lib/clang/Makefile +++ lib/clang/Makefile @@ -4,10 +4,12 @@ # These have to be built in order. SUBDIR= libllvm +.if ${MK_CLANG} != "no" SUBDIR+= libclang +SUBDIR+= headers +.endif .if ${MK_LLDB} != "no" SUBDIR+= liblldb .endif -SUBDIR+= headers .include Index: lib/clang/libllvm/Makefile =================================================================== --- lib/clang/libllvm/Makefile +++ lib/clang/libllvm/Makefile @@ -829,7 +829,7 @@ SRCS_MIN+= Object/IRSymtab.cpp SRCS_MIN+= Object/MachOObjectFile.cpp SRCS_MIW+= Object/MachOUniversal.cpp -SRCS_EXT+= Object/MachOUniversalWriter.cpp +SRCS_MIW+= Object/MachOUniversalWriter.cpp SRCS_MIW+= Object/Minidump.cpp SRCS_MIN+= Object/ModuleSymbolTable.cpp SRCS_EXT+= Object/Object.cpp @@ -919,7 +919,7 @@ SRCS_MIN+= Support/Error.cpp SRCS_MIN+= Support/ErrorHandling.cpp SRCS_MIN+= Support/FileCollector.cpp -SRCS_EXL+= Support/FileOutputBuffer.cpp +SRCS_MIW+= Support/FileOutputBuffer.cpp SRCS_MIN+= Support/FileUtilities.cpp SRCS_MIN+= Support/FoldingSet.cpp SRCS_MIN+= Support/FormatVariadic.cpp @@ -944,7 +944,7 @@ SRCS_MIN+= Support/ManagedStatic.cpp SRCS_MIN+= Support/MathExtras.cpp SRCS_MIN+= Support/MemAlloc.cpp -SRCS_XDL+= Support/Memory.cpp +SRCS_MIW+= Support/Memory.cpp SRCS_MIN+= Support/MemoryBuffer.cpp SRCS_MIN+= Support/MemoryBufferRef.cpp SRCS_MIN+= Support/NativeFormatting.cpp Index: share/mk/src.opts.mk =================================================================== --- share/mk/src.opts.mk +++ share/mk/src.opts.mk @@ -205,6 +205,7 @@ LOADER_FIREWIRE \ LOADER_VERBOSE \ LOADER_VERIEXEC_PASS_MANIFEST \ + LLVM_BINUTILS \ MALLOC_PRODUCTION \ OFED_EXTRA \ OPENLDAP \ @@ -468,6 +469,7 @@ MK_INCLUDES:= no MK_LLD:= no MK_LLDB:= no +MK_LLVM_BINUTILS:= no .endif .if ${MK_CLANG} == "no" @@ -477,6 +479,12 @@ MK_LLVM_COV:= no .endif +.if ${MK_LLVM_BINUTILS} == "yes" +# MK_LLVM_CXXFILT is a subset of MK_LLVM_BINUTILS and should therefore be +# enabled if MK_LLVM_BINUTILS is set. +MK_LLVM_CXXFILT:= yes +.endif + .if ${MK_LOADER_VERIEXEC} == "no" MK_LOADER_VERIEXEC_PASS_MANIFEST := no .endif Index: tools/build/options/WITH_LLVM_BINUTILS =================================================================== --- /dev/null +++ tools/build/options/WITH_LLVM_BINUTILS @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Install LLVM's binutils (ar, addr2line, nm, etc.) instead of ELF Tool Chain's. Index: usr.bin/Makefile =================================================================== --- usr.bin/Makefile +++ usr.bin/Makefile @@ -144,7 +144,6 @@ split \ stat \ stdbuf \ - strings \ su \ systat \ tail \ @@ -195,7 +194,10 @@ SUBDIR.${MK_BLUETOOTH}+= bluetooth SUBDIR.${MK_BSD_CPIO}+= cpio SUBDIR.${MK_CALENDAR}+= calendar -SUBDIR.${MK_CLANG}+= clang +.if ${MK_CLANG} != "no" || ${MK_LLVM_BINUTILS} != "no" || \ + ${MK_LLD} != "no" || ${MK_LLDB} != "no" +SUBDIR+= clang +.endif SUBDIR.${MK_DIALOG}+= dpv SUBDIR.${MK_EE}+= ee SUBDIR.${MK_FILE}+= file @@ -251,25 +253,29 @@ SUBDIR.${MK_TESTS}+= tests SUBDIR.${MK_TEXTPROC}+= ul SUBDIR.${MK_TFTP}+= tftp +.if ${MK_LLVM_BINUTILS} == "no" +# Only build the elftoolchain tools if we aren't using the LLVM ones. SUBDIR.${MK_TOOLCHAIN}+= addr2line SUBDIR.${MK_TOOLCHAIN}+= ar +SUBDIR.${MK_TOOLCHAIN}+= nm +SUBDIR.${MK_TOOLCHAIN}+= objcopy +SUBDIR.${MK_TOOLCHAIN}+= readelf +SUBDIR.${MK_TOOLCHAIN}+= size +SUBDIR+= strings +.endif SUBDIR.${MK_TOOLCHAIN}+= c89 SUBDIR.${MK_TOOLCHAIN}+= c99 SUBDIR.${MK_TOOLCHAIN}+= ctags .if ${MK_LLVM_CXXFILT} == "no" SUBDIR.${MK_TOOLCHAIN}+= cxxfilt .endif -SUBDIR.${MK_TOOLCHAIN}+= objcopy SUBDIR.${MK_TOOLCHAIN}+= file2c SUBDIR.${MK_TOOLCHAIN}+= gprof SUBDIR.${MK_TOOLCHAIN}+= indent SUBDIR.${MK_TOOLCHAIN}+= lex SUBDIR.${MK_TOOLCHAIN}+= mkstr -SUBDIR.${MK_TOOLCHAIN}+= nm -SUBDIR.${MK_TOOLCHAIN}+= readelf SUBDIR.${MK_TOOLCHAIN}+= rpcgen SUBDIR.${MK_TOOLCHAIN}+= unifdef -SUBDIR.${MK_TOOLCHAIN}+= size SUBDIR.${MK_TOOLCHAIN}+= xstr SUBDIR.${MK_TOOLCHAIN}+= yacc SUBDIR.${MK_VI}+= vi Index: usr.bin/clang/Makefile =================================================================== --- usr.bin/clang/Makefile +++ usr.bin/clang/Makefile @@ -17,12 +17,20 @@ .endif .if !defined(TOOLS_PREFIX) +# LLVM binutils are needed to support features such as LTO, so we build them +# by default if clang is enabled. If MK_LLVM_BINUTILS is set, we also use them +# as the default binutils (ar,nm,addr2line, etc.). +.if ${MK_CLANG} != "no" || ${MK_LLVM_BINUTILS} != "no" SUBDIR+= llvm-ar SUBDIR+= llvm-nm +SUBDIR+= llvm-objcopy SUBDIR+= llvm-objdump +SUBDIR+= llvm-size +SUBDIR+= llvm-strings SUBDIR+= llvm-symbolizer +.endif -.if ${MK_CLANG_EXTRAS} != "no" || ${MK_LLVM_CXXFILT} != "no" +.if ${MK_LLVM_BINUTILS} != "no" || ${MK_LLVM_CXXFILT} != "no" SUBDIR+= llvm-cxxfilt .endif @@ -44,11 +52,8 @@ SUBDIR+= llvm-mc SUBDIR+= llvm-mca SUBDIR+= llvm-modextract -SUBDIR+= llvm-objcopy SUBDIR+= llvm-pdbutil SUBDIR+= llvm-rtdyld -SUBDIR+= llvm-size -SUBDIR+= llvm-strings SUBDIR+= llvm-xray SUBDIR+= opt .endif Index: usr.bin/clang/llvm-ar/Makefile =================================================================== --- usr.bin/clang/llvm-ar/Makefile +++ usr.bin/clang/llvm-ar/Makefile @@ -1,5 +1,7 @@ # $FreeBSD$ +.include + PROG_CXX= llvm-ar MAN= llvm-ar.1 llvm-ranlib.1 @@ -10,4 +12,9 @@ LINKS+= ${BINDIR}/llvm-ar ${BINDIR}/llvm-ranlib +.if ${MK_LLVM_BINUTILS} != "no" +LINKS= ${BINDIR}/llvm-ar ${BINDIR}/ar ${BINDIR}/llvm-ar ${BINDIR}/ranlib +MLINKS= llvm-ar.1 ar.1 llvm-ar.1 ranlib.1 +.endif + .include "../llvm.prog.mk" Index: usr.bin/clang/llvm-nm/Makefile =================================================================== --- usr.bin/clang/llvm-nm/Makefile +++ usr.bin/clang/llvm-nm/Makefile @@ -1,5 +1,7 @@ # $FreeBSD$ +.include + PROG_CXX= llvm-nm SRCDIR= llvm/tools/llvm-nm @@ -7,4 +9,9 @@ LIBADD+= z +.if ${MK_LLVM_BINUTILS} != "no" +LINKS= ${BINDIR}/llvm-nm ${BINDIR}/nm +MLINKS= llvm-nm.1 nm.1 +.endif + .include "../llvm.prog.mk" Index: usr.bin/clang/llvm-objcopy/Makefile =================================================================== --- usr.bin/clang/llvm-objcopy/Makefile +++ usr.bin/clang/llvm-objcopy/Makefile @@ -1,5 +1,7 @@ # $FreeBSD$ +.include + PROG_CXX= llvm-objcopy SRCDIR= llvm/tools/llvm-objcopy @@ -42,4 +44,9 @@ LIBADD+= z +.if ${MK_LLVM_BINUTILS} != "no" +LINKS= ${BINDIR}/llvm-objcopy ${BINDIR}/objcopy +MLINKS= llvm-objcopy.1 objcopy.1 +.endif + .include "../llvm.prog.mk" Index: usr.bin/clang/llvm-objdump/Makefile =================================================================== --- usr.bin/clang/llvm-objdump/Makefile +++ usr.bin/clang/llvm-objdump/Makefile @@ -1,5 +1,7 @@ # $FreeBSD$ +.include + PROG_CXX= llvm-objdump SRCDIR= llvm/tools/llvm-objdump @@ -12,4 +14,9 @@ LIBADD+= z +.if ${MK_LLVM_BINUTILS} != "no" +LINKS= ${BINDIR}/llvm-objdump ${BINDIR}/objdump +MLINKS= llvm-objdump.1 objdump.1 +.endif + .include "../llvm.prog.mk" Index: usr.bin/clang/llvm-size/Makefile =================================================================== --- usr.bin/clang/llvm-size/Makefile +++ usr.bin/clang/llvm-size/Makefile @@ -1,8 +1,15 @@ # $FreeBSD$ +.include + PROG_CXX= llvm-size SRCDIR= llvm/tools/llvm-size SRCS+= llvm-size.cpp +.if ${MK_LLVM_BINUTILS} != "no" +LINKS= ${BINDIR}/llvm-size ${BINDIR}/size +MLINKS= llvm-size.1 size.1 +.endif + .include "../llvm.prog.mk" Index: usr.bin/clang/llvm-strings/Makefile =================================================================== --- usr.bin/clang/llvm-strings/Makefile +++ usr.bin/clang/llvm-strings/Makefile @@ -1,8 +1,15 @@ # $FreeBSD$ +.include + PROG_CXX= llvm-strings SRCDIR= llvm/tools/llvm-strings SRCS+= llvm-strings.cpp +.if ${MK_LLVM_BINUTILS} != "no" +LINKS= ${BINDIR}/llvm-strings ${BINDIR}/strings +MLINKS= llvm-strings.1 strings.1 +.endif + .include "../llvm.prog.mk" Index: usr.bin/clang/llvm-symbolizer/Makefile =================================================================== --- usr.bin/clang/llvm-symbolizer/Makefile +++ usr.bin/clang/llvm-symbolizer/Makefile @@ -1,5 +1,7 @@ # $FreeBSD$ +.include + PROG_CXX= llvm-symbolizer MAN= llvm-symbolizer.1 llvm-addr2line.1 @@ -26,4 +28,9 @@ LINKS+= ${BINDIR}/llvm-symbolizer ${BINDIR}/llvm-addr2line +.if ${MK_LLVM_BINUTILS} != "no" +LINKS= ${BINDIR}/llvm-symbolizer ${BINDIR}/addr2line +MLINKS= llvm-addr2line.1 addr2line.1 +.endif + .include "../llvm.prog.mk"