From nobody Sun Dec 05 20:42:58 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 989D418BBCA0; Sun, 5 Dec 2021 20:42:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J6dmf26h1z3Dq7; Sun, 5 Dec 2021 20:42:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 282291EE06; Sun, 5 Dec 2021 20:42:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1B5KgwGH090131; Sun, 5 Dec 2021 20:42:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B5Kgw2M090130; Sun, 5 Dec 2021 20:42:58 GMT (envelope-from git) Date: Sun, 5 Dec 2021 20:42:58 GMT Message-Id: <202112052042.1B5Kgw2M090130@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: a5186406aced - stable/13 - Add WITH_LLVM_BINUTILS to install LLVM binutils instead of Elftoolchain List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a5186406aced401de7984f8b338675da650d0e25 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638736978; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=UCLN7ToHQdmNeR+iS7RhQtqwgFZT1SlvdWofOm9ZHpg=; b=fGNggu0KOqFNsJ3q53XMU4EQPNWXfsQCIsJkg2u7+GQwFrxYiHRZChcQ9s6Fv+qZDEe1Bm aoXXmdVxwZMT3vYknqwyt8YqV96cdatOdNAmAB/kL2Kp5oIIQ36ud9cYYSMrny9px9VKbs 5pdKF600kP7b3JJqj/7UGgO+JOeIpLZUpFrT60/y7+XPfLs2XVuvMo3m/U6nccOM1D8d1I EcdLs9eDqPWKSYvLb1rhHuEj3cttAgzYtsWfPlR0LXgCsxEDgxv+w1Z0FH/Yx6jjQNx5xc uuRtqdRDyUS9oUVgYUkDf6HZJNoM2vc+pYGDlZ+nr4InZObuY9BzEUjvatAzMw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638736978; a=rsa-sha256; cv=none; b=SJMG1DxzqcHSbLdbtOgaikQ0oKfue4WA6bn+GC37FEansTX2jpMUasDP6E2ZTR7rIP3RbN YQzThvC6iTKwajzBNleta85GlsJUbGb5zO4CT4985ZZNnY1USNoDNGzRGzS062YJpOvGMt rW1FPFPb08p+KxqyMGZC/Z9e3x/YyJnyI+fLwxl1ur2844KKg5aBujqy0P1Jp7jLuoTZ3f 8q+IRHfdtPUtQkIBJdN9ozYXWqIB0uMjCbakU11JH1boZOAgEVwEy4ZO2j3zkhk94fFtGb 8xcTtNpsp0eEVS2LJ9JOA0N9Fv/suYte2DZTcrEHiAk8OUntks22sgKDOHOaZA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=a5186406aced401de7984f8b338675da650d0e25 commit a5186406aced401de7984f8b338675da650d0e25 Author: Alex Richardson AuthorDate: 2021-09-06 08:49:49 +0000 Commit: Dimitry Andric CommitDate: 2021-12-05 20:42:14 +0000 Add WITH_LLVM_BINUTILS to install LLVM binutils instead of Elftoolchain When WITH_LLVM_BINUTILS is set, we will install the LLVM binutils as ar/ranlib/nm/objcopy/etc. instead of the elftoolchain ones. Having the LLVM binutils instead of the elftoolchain ones allows us to use features such as LTO that depend on binutils that understand LLVM IR. Another benefit will be an improved user-experience when compiling with AddressSanitizer, since ASAN does not symbolize backtraces correctly if addr2line is elftoolchain addr2line instead of llvm-symbolizer. See https://lists.freebsd.org/archives/freebsd-toolchain/2021-July/000062.html for more details. This is currently off by default but will be turned on by default at some point in the near future. Reviewed By: emaste Differential Revision: https://reviews.freebsd.org/D31060 (cherry picked from commit 021385aba56279febcfdcc64d23673a0106ae45d) --- Makefile.inc1 | 4 +++- lib/Makefile | 5 ++++- lib/clang/Makefile | 4 +++- lib/clang/libllvm/Makefile | 6 +++--- share/mk/src.opts.mk | 8 ++++++++ tools/build/options/WITH_LLVM_BINUTILS | 2 ++ usr.bin/Makefile | 16 +++++++++++----- usr.bin/clang/Makefile | 13 +++++++++---- usr.bin/clang/llvm-ar/Makefile | 7 +++++++ usr.bin/clang/llvm-nm/Makefile | 7 +++++++ usr.bin/clang/llvm-objcopy/Makefile | 8 ++++++++ usr.bin/clang/llvm-objdump/Makefile | 7 +++++++ usr.bin/clang/llvm-size/Makefile | 7 +++++++ usr.bin/clang/llvm-symbolizer/Makefile | 7 +++++++ 14 files changed, 86 insertions(+), 15 deletions(-) diff --git a/Makefile.inc1 b/Makefile.inc1 index 995ed7af3e4b..6829c3c962fd 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -765,6 +765,7 @@ XMAKE= ${BMAKE} \ TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ MK_CLANG_IS_CC=${MK_CLANG_BOOTSTRAP} \ MK_LLDB=no \ + MK_LLVM_BINUTILS=no \ MK_TESTS=no # kernel-tools stage @@ -2331,9 +2332,10 @@ _gensnmptree= usr.sbin/bsnmpd/gensnmptree # 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_LLDB} != "no" + ${MK_LLDB} != "no" || ${MK_LLVM_BINUTILS} != "no" _clang_tblgen= \ lib/clang/libllvmminimal \ usr.bin/clang/llvm-tblgen diff --git a/lib/Makefile b/lib/Makefile index f42909ec0b09..dbf5182f50a5 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -157,7 +157,10 @@ SUBDIR.${MK_BLUETOOTH}+=libbluetooth libsdp SUBDIR.${MK_BSNMP}+= libbsnmp .if !defined(COMPAT_32BIT) && !defined(COMPAT_SOFTFP) -SUBDIR.${MK_CLANG}+= clang +.if ${MK_CLANG} != "no" || ${MK_LLD} != "no" || \ + ${MK_LLDB} != "no" || ${MK_LLVM_BINUTILS} != "no" +SUBDIR+= clang +.endif .endif SUBDIR.${MK_CUSE}+= libcuse diff --git a/lib/clang/Makefile b/lib/clang/Makefile index bc09ea62dc67..df4aa01a2653 100644 --- a/lib/clang/Makefile +++ b/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 diff --git a/lib/clang/libllvm/Makefile b/lib/clang/libllvm/Makefile index caca02399c42..a17ba63a91ba 100644 --- a/lib/clang/libllvm/Makefile +++ b/lib/clang/libllvm/Makefile @@ -830,7 +830,7 @@ SRCS_MIN+= Object/IRObjectFile.cpp 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 @@ -920,7 +920,7 @@ SRCS_MIN+= Support/Errno.cpp 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 @@ -945,7 +945,7 @@ SRCS_MIN+= Support/MD5.cpp 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 diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index d692b7efe58b..467f1f445fa8 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -205,6 +205,7 @@ __DEFAULT_NO_OPTIONS = \ HESIOD \ LIBSOFT \ LLVM_ASSERTIONS \ + LLVM_BINUTILS \ LOADER_FIREWIRE \ LOADER_VERBOSE \ LOADER_VERIEXEC_PASS_MANIFEST \ @@ -473,6 +474,7 @@ MK_CLANG:= no MK_INCLUDES:= no MK_LLD:= no MK_LLDB:= no +MK_LLVM_BINUTILS:= no .endif .if ${MK_CLANG} == "no" @@ -482,6 +484,12 @@ MK_CLANG_FULL:= no 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 diff --git a/tools/build/options/WITH_LLVM_BINUTILS b/tools/build/options/WITH_LLVM_BINUTILS new file mode 100644 index 000000000000..8fa2c55f31a9 --- /dev/null +++ b/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. diff --git a/usr.bin/Makefile b/usr.bin/Makefile index 6126e93b28a8..fc6b94adf4c2 100644 --- a/usr.bin/Makefile +++ b/usr.bin/Makefile @@ -198,7 +198,10 @@ SUBDIR.${MK_ATM}+= atm 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 @@ -254,25 +257,28 @@ SUBDIR.${MK_TESTS_SUPPORT}.${MK_CXX}+= kyua 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 +.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 diff --git a/usr.bin/clang/Makefile b/usr.bin/clang/Makefile index ca68c37b51c1..349788ec5d3c 100644 --- a/usr.bin/clang/Makefile +++ b/usr.bin/clang/Makefile @@ -11,12 +11,20 @@ SUBDIR+= lldb-tblgen .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 @@ -38,11 +46,8 @@ SUBDIR+= llvm-lto2 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 diff --git a/usr.bin/clang/llvm-ar/Makefile b/usr.bin/clang/llvm-ar/Makefile index 86d4538271a1..bd43194153d7 100644 --- a/usr.bin/clang/llvm-ar/Makefile +++ b/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 @@ LIBADD+= z 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" diff --git a/usr.bin/clang/llvm-nm/Makefile b/usr.bin/clang/llvm-nm/Makefile index 02f16887a7cf..4a6990cfa22d 100644 --- a/usr.bin/clang/llvm-nm/Makefile +++ b/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 @@ SRCS+= llvm-nm.cpp LIBADD+= z +.if ${MK_LLVM_BINUTILS} != "no" +LINKS= ${BINDIR}/llvm-nm ${BINDIR}/nm +MLINKS= llvm-nm.1 nm.1 +.endif + .include "../llvm.prog.mk" diff --git a/usr.bin/clang/llvm-objcopy/Makefile b/usr.bin/clang/llvm-objcopy/Makefile index f9b146f4bbfa..afd03b848b19 100644 --- a/usr.bin/clang/llvm-objcopy/Makefile +++ b/usr.bin/clang/llvm-objcopy/Makefile @@ -1,5 +1,7 @@ # $FreeBSD$ +.include + PROG_CXX= llvm-objcopy SRCDIR= llvm/tools/llvm-objcopy @@ -44,4 +46,10 @@ LIBADD+= z LINKS= ${BINDIR}/llvm-objcopy ${BINDIR}/llvm-strip +.if ${MK_LLVM_BINUTILS} != "no" +LINKS+= ${BINDIR}/llvm-objcopy ${BINDIR}/objcopy \ + ${BINDIR}/llvm-strip ${BINDIR}/strip +MLINKS= llvm-objcopy.1 objcopy.1 +.endif + .include "../llvm.prog.mk" diff --git a/usr.bin/clang/llvm-objdump/Makefile b/usr.bin/clang/llvm-objdump/Makefile index 34b015042718..53b63bd7200e 100644 --- a/usr.bin/clang/llvm-objdump/Makefile +++ b/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 @@ SRCS+= llvm-objdump.cpp LIBADD+= z +.if ${MK_LLVM_BINUTILS} != "no" +LINKS= ${BINDIR}/llvm-objdump ${BINDIR}/objdump +MLINKS= llvm-objdump.1 objdump.1 +.endif + .include "../llvm.prog.mk" diff --git a/usr.bin/clang/llvm-size/Makefile b/usr.bin/clang/llvm-size/Makefile index a4a387aabf6f..4ddaaf86dca3 100644 --- a/usr.bin/clang/llvm-size/Makefile +++ b/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" diff --git a/usr.bin/clang/llvm-symbolizer/Makefile b/usr.bin/clang/llvm-symbolizer/Makefile index 6352d6a67b94..52a48d428600 100644 --- a/usr.bin/clang/llvm-symbolizer/Makefile +++ b/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 @@ LIBADD+= z 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"