From 07bab4417d0e08bed86f48dea6d0c68f496b456c Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Tue, 3 Nov 2020 19:57:28 +0000 Subject: [PATCH] Add WITH_LLVM_CXXFILT option to install llvm-cxxfilt as c++filt Since elftoolchain's cxxfilt is rather far behind on features, and we ran into several bugs, add an option to use llvm-cxxfilt as an drop-in replacement. It supports the same options as elftoolchain cxxfilt, though it doesn't have support for old ARM (C++ Annotated Reference Manual, not the CPU) and GNU v2 manglings. But these are irrelevant in 2020. Note: as we already compile the required libraries as part of libllvm, this will not add any significant build time either. PR: 250702 Reviewed by: emaste, yuri Differential Revision: https://reviews.freebsd.org/D27071 MFC after: 2 weeks --- share/man/man5/src.conf.5 | 4 +++- share/mk/src.opts.mk | 1 + tools/build/options/WITHOUT_LLVM_CXXFILT | 2 ++ tools/build/options/WITH_LLVM_CXXFILT | 2 ++ usr.bin/Makefile | 2 ++ usr.bin/clang/Makefile | 5 ++++- usr.bin/clang/llvm-cxxfilt/Makefile | 7 +++++++ 7 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 tools/build/options/WITHOUT_LLVM_CXXFILT create mode 100644 tools/build/options/WITH_LLVM_CXXFILT diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5 index 90f6a4886bf5..96224e220c1f 100644 --- a/share/man/man5/src.conf.5 +++ b/share/man/man5/src.conf.5 @@ -1,6 +1,6 @@ .\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman. .\" $FreeBSD$ -.Dd September 15, 2020 +.Dd November 3, 2020 .Dt SRC.CONF 5 .Os .Sh NAME @@ -919,6 +919,8 @@ Set to disable debugging assertions in LLVM. Set to not build the .Xr llvm-cov 1 tool. +.It Va WITH_LLVM_CXXFILT +Install LLVM's llvm-cxxfilt as c++filt, instead of ELF Tool Chain's cxxfilt. .It Va WITHOUT_LLVM_TARGET_AARCH64 Set to not build LLVM target support for AArch64. The diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index d71b05d3ec99..5601b56165f5 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -210,6 +210,7 @@ __DEFAULT_NO_OPTIONS = \ GNU_GREP_COMPAT \ HESIOD \ LIBSOFT \ + LLVM_CXXFILT \ LOADER_FIREWIRE \ LOADER_VERBOSE \ LOADER_VERIEXEC_PASS_MANIFEST \ diff --git a/tools/build/options/WITHOUT_LLVM_CXXFILT b/tools/build/options/WITHOUT_LLVM_CXXFILT new file mode 100644 index 000000000000..e729f6c4c8e0 --- /dev/null +++ b/tools/build/options/WITHOUT_LLVM_CXXFILT @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Install ELF Tool Chain's cxxfilt as c++filt, instead of LLVM's llvm-cxxfilt. diff --git a/tools/build/options/WITH_LLVM_CXXFILT b/tools/build/options/WITH_LLVM_CXXFILT new file mode 100644 index 000000000000..e80c0e9c1f35 --- /dev/null +++ b/tools/build/options/WITH_LLVM_CXXFILT @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Install LLVM's llvm-cxxfilt as c++filt, instead of ELF Tool Chain's cxxfilt. diff --git a/usr.bin/Makefile b/usr.bin/Makefile index 85ffce06e496..8ea3b1c2bfe3 100644 --- a/usr.bin/Makefile +++ b/usr.bin/Makefile @@ -260,7 +260,9 @@ SUBDIR.${MK_TOOLCHAIN}+= ar 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 diff --git a/usr.bin/clang/Makefile b/usr.bin/clang/Makefile index 68b3c1537d90..6f5a065b9ae7 100644 --- a/usr.bin/clang/Makefile +++ b/usr.bin/clang/Makefile @@ -16,6 +16,10 @@ SUBDIR+= llvm-nm SUBDIR+= llvm-objdump SUBDIR+= llvm-symbolizer +.if ${MK_CLANG_EXTRAS} != "no" || ${MK_LLVM_CXXFILT} != "no" +SUBDIR+= llvm-cxxfilt +.endif + .if ${MK_CLANG_EXTRAS} != "no" SUBDIR+= bugpoint SUBDIR+= llc @@ -23,7 +27,6 @@ SUBDIR+= lli SUBDIR+= llvm-as SUBDIR+= llvm-bcanalyzer SUBDIR+= llvm-cxxdump -SUBDIR+= llvm-cxxfilt SUBDIR+= llvm-diff SUBDIR+= llvm-dis SUBDIR+= llvm-dwarfdump diff --git a/usr.bin/clang/llvm-cxxfilt/Makefile b/usr.bin/clang/llvm-cxxfilt/Makefile index b5aa8b34b8e2..3b452a1f8e12 100644 --- a/usr.bin/clang/llvm-cxxfilt/Makefile +++ b/usr.bin/clang/llvm-cxxfilt/Makefile @@ -1,8 +1,15 @@ # $FreeBSD$ +.include + PROG_CXX= llvm-cxxfilt SRCDIR= llvm/tools/llvm-cxxfilt SRCS+= llvm-cxxfilt.cpp +.if ${MK_LLVM_CXXFILT} != "no" +LINKS= ${BINDIR}/llvm-cxxfilt ${BINDIR}/c++filt +MLINKS= llvm-cxxfilt.1 c++filt.1 +.endif + .include "../llvm.prog.mk"