git: f5fca73651a3 - stable/13 - Optionally create full debuginfo for llvm-related executables

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Fri, 08 Mar 2024 08:19:47 UTC
The branch stable/13 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=f5fca73651a39dd75683c0f2374ac2cb0d11e670

commit f5fca73651a39dd75683c0f2374ac2cb0d11e670
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-02-11 19:02:51 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2024-03-08 08:19:05 +0000

    Optionally create full debuginfo for llvm-related executables
    
    Commit de6feefdb7cfd limited the amount of debuginfo generated for clang
    and other llvm-related executables. This was done to save disk space and
    memory during building, but it makes debugging any of these executables
    much harder.
    
    Add a new src.conf(5) setting, WITH_LLVM_FULL_DEBUGINFO, to generate
    full debuginfo instead. This is off by default, but could for example be
    enabled for release builds or snapshots, so llvm executables are easier
    to debug.
    
    Reviewed by:    emaste
    MFC after:      1 week
    Differential Revision: https://reviews.freebsd.org/D43839
    
    (cherry picked from commit 73ff7384e025033abc98fd5437a48beb8077a90b)
---
 lib/clang/Makefile.inc                       | 4 +++-
 lib/clang/headers/Makefile                   | 1 +
 lib/clang/libclang/Makefile                  | 2 +-
 lib/clang/libclangminimal/Makefile           | 1 +
 lib/clang/liblldb/Makefile                   | 1 +
 lib/clang/libllvm/Makefile                   | 2 +-
 lib/clang/libllvmminimal/Makefile            | 1 +
 share/man/man5/src.conf.5                    | 5 ++++-
 share/mk/src.opts.mk                         | 1 +
 tools/build/options/WITH_LLVM_FULL_DEBUGINFO | 2 ++
 usr.bin/clang/Makefile.inc                   | 8 +++++---
 11 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/lib/clang/Makefile.inc b/lib/clang/Makefile.inc
index 0a2ae8f6b802..75d3b7c14507 100644
--- a/lib/clang/Makefile.inc
+++ b/lib/clang/Makefile.inc
@@ -1,12 +1,14 @@
 
-.include <bsd.compiler.mk>
+.include <src.opts.mk>
 
 MK_PIE:=	no	# Explicit libXXX.a references
 
+.if ${MK_LLVM_FULL_DEBUGINFO} == "no"
 .if ${COMPILER_TYPE} == "clang"
 DEBUG_FILES_CFLAGS= -gline-tables-only
 .else
 DEBUG_FILES_CFLAGS= -g1
 .endif
+.endif
 
 WARNS?=		0
diff --git a/lib/clang/headers/Makefile b/lib/clang/headers/Makefile
index 49f78b0a4d97..f72567514f20 100644
--- a/lib/clang/headers/Makefile
+++ b/lib/clang/headers/Makefile
@@ -1,4 +1,5 @@
 
+.include <bsd.init.mk>
 .include "../clang.pre.mk"
 
 .PATH:		${CLANG_SRCS}/lib/Headers
diff --git a/lib/clang/libclang/Makefile b/lib/clang/libclang/Makefile
index 51c209d879f1..8d911905808d 100644
--- a/lib/clang/libclang/Makefile
+++ b/lib/clang/libclang/Makefile
@@ -1,5 +1,5 @@
 
-.include <src.opts.mk>
+.include <bsd.init.mk>
 .include "../clang.pre.mk"
 
 LIB=		clang
diff --git a/lib/clang/libclangminimal/Makefile b/lib/clang/libclangminimal/Makefile
index 744e1a835f90..22faa7b98aeb 100644
--- a/lib/clang/libclangminimal/Makefile
+++ b/lib/clang/libclangminimal/Makefile
@@ -1,4 +1,5 @@
 
+.include <bsd.init.mk>
 .include "../clang.pre.mk"
 
 LIB=		clangminimal
diff --git a/lib/clang/liblldb/Makefile b/lib/clang/liblldb/Makefile
index c32e4a387b2e..e6e1e638abce 100644
--- a/lib/clang/liblldb/Makefile
+++ b/lib/clang/liblldb/Makefile
@@ -1,4 +1,5 @@
 
+.include <bsd.init.mk>
 .include "../lldb.pre.mk"
 
 LIB=		lldb
diff --git a/lib/clang/libllvm/Makefile b/lib/clang/libllvm/Makefile
index df39f2eb212e..b59d881ad99a 100644
--- a/lib/clang/libllvm/Makefile
+++ b/lib/clang/libllvm/Makefile
@@ -1,5 +1,5 @@
 
-.include <src.opts.mk>
+.include <bsd.init.mk>
 .include "../llvm.pre.mk"
 
 LIB=		llvm
diff --git a/lib/clang/libllvmminimal/Makefile b/lib/clang/libllvmminimal/Makefile
index 83c7101b04f5..ce5535a59072 100644
--- a/lib/clang/libllvmminimal/Makefile
+++ b/lib/clang/libllvmminimal/Makefile
@@ -1,4 +1,5 @@
 
+.include <bsd.init.mk>
 .include "../llvm.pre.mk"
 
 LIB=		llvmminimal
diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5
index 9aab6fc459c1..181b4fea466d 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 24, 2023
+.Dd March 8, 2024
 .Dt SRC.CONF 5
 .Os
 .Sh NAME
@@ -916,6 +916,9 @@ Do not build the
 tool.
 .It Va WITHOUT_LLVM_CXXFILT
 Install ELF Tool Chain's cxxfilt as c++filt, instead of LLVM's llvm-cxxfilt.
+.It Va WITH_LLVM_FULL_DEBUGINFO
+Generate full debug information for LLVM libraries and tools, which uses
+more disk space and build resources, but allows for easier debugging.
 .It Va WITHOUT_LLVM_TARGET_AARCH64
 Do not build LLVM target support for AArch64.
 The
diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk
index 3add35bc07c3..811b0a493d50 100644
--- a/share/mk/src.opts.mk
+++ b/share/mk/src.opts.mk
@@ -210,6 +210,7 @@ __DEFAULT_NO_OPTIONS = \
     LOADER_FIREWIRE \
     LOADER_VERBOSE \
     LOADER_VERIEXEC_PASS_MANIFEST \
+    LLVM_FULL_DEBUGINFO \
     OFED_EXTRA \
     OPENLDAP \
     RPCBIND_WARMSTART_SUPPORT \
diff --git a/tools/build/options/WITH_LLVM_FULL_DEBUGINFO b/tools/build/options/WITH_LLVM_FULL_DEBUGINFO
new file mode 100644
index 000000000000..4362de9eb762
--- /dev/null
+++ b/tools/build/options/WITH_LLVM_FULL_DEBUGINFO
@@ -0,0 +1,2 @@
+Generate full debug information for LLVM libraries and tools, which uses
+more disk space and build resources, but allows for easier debugging.
diff --git a/usr.bin/clang/Makefile.inc b/usr.bin/clang/Makefile.inc
index 8fb62b876678..8f6b098de2d4 100644
--- a/usr.bin/clang/Makefile.inc
+++ b/usr.bin/clang/Makefile.inc
@@ -1,15 +1,17 @@
 
-WARNS?=		0
-
-.include <bsd.compiler.mk>
+.include <src.opts.mk>
 
 MK_PIE:=	no	# Explicit libXXX.a references
 
+.if ${MK_LLVM_FULL_DEBUGINFO} == "no"
 .if ${COMPILER_TYPE} == "clang"
 DEBUG_FILES_CFLAGS= -gline-tables-only
 .else
 DEBUG_FILES_CFLAGS= -g1
 .endif
+.endif
+
+WARNS?=		0
 
 .if ${MACHINE_ARCH:Mmips*} && ${MACHINE_ARCH:Mmips64*} == ""
 CFLAGS+= -mxgot