Page MenuHomeFreeBSD

bsd.lib.mk: apply DEBUG_FILES_CFLAGS only to shared objs
Needs ReviewPublic

Authored by emaste on Aug 16 2021, 2:55 PM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 22 2024, 4:55 PM
Unknown Object (File)
Nov 19 2024, 5:58 PM
Unknown Object (File)
Nov 16 2024, 1:12 PM
Unknown Object (File)
Oct 3 2024, 9:54 AM
Unknown Object (File)
Sep 20 2024, 6:48 AM
Unknown Object (File)
Sep 14 2024, 11:58 AM
Unknown Object (File)
Sep 14 2024, 8:52 AM
Unknown Object (File)
Sep 14 2024, 8:38 AM
Subscribers

Details

Reviewers
jrtc27
imp
Summary
DEBUG_FILES_CFLAGS contains the compiler debugging flag(s) used when
standlone debug files (/usr/lib/debug/...) are enabled.  However,
archives for static linking (.a files) do not use standalone debug, and
should not have these flag(s) applied.

Archives were previously built with debug info, but that was an
unintentional side effect of the WITH_DEBUG_FILES knob.  With this
change they will no longer be built with debug info by default.

We may want to revisit default debug info for archives, but it should 
not be controlled by WITH_DEBUG_FILES.

Sponsored by:   The FreeBSD Foundation

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Hmm, I suppose it we need to apply it to INTERNALLIBs too.

Possibly this:

diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
index 28c159689e71..d0bd8bb97c15 100644
--- a/share/mk/bsd.lib.mk
+++ b/share/mk/bsd.lib.mk
@@ -114,11 +114,18 @@ CXXFLAGS+= -ftrivial-auto-var-init=pattern
 .if ${MK_DEBUG_FILES} != "no" && empty(DEBUG_FLAGS:M-g) && \
     empty(DEBUG_FLAGS:M-gdwarf*)
 .if !${COMPILER_FEATURES:Mcompressed-debug}
-CFLAGS+= ${DEBUG_FILES_CFLAGS:N-gz*}
-CXXFLAGS+= ${DEBUG_FILES_CFLAGS:N-gz*}
+_DEBUG_FILES_CFLAGS=${DEBUG_FILES_CFLAGS:N-gz*}
 .else
-CFLAGS+= ${DEBUG_FILES_CFLAGS}
-CXXFLAGS+= ${DEBUG_FILES_CFLAGS}
+_DEBUG_FILES_CFLAGS=${DEBUG_FILES_CFLAGS}
+.endif
+.if defined(INTERNALLIB)
+# INTERNALLIB archives have debug flags applied to support standalone debug
+# files for binaries using those libraries.
+CFLAGS+= ${_DEBUG_FILES_CFLAGS}
+CXXFLAGS+= ${_DEBUG_FILES_CFLAGS}
+.else
+SHARED_CFLAGS+= ${_DEBUG_FILES_CFLAGS}
+SHARED_CXXFLAGS+= ${_DEBUG_FILES_CFLAGS}
 .endif
 CTFFLAGS+= -g
 .endif

What did we do by default before WITH_DEBUG_FILES was added? Was debuginfo always stripped?

What did we do by default before WITH_DEBUG_FILES was added? Was debuginfo always stripped?

It just wasn't generated at all.

Hmm, I do find it useful that static libraries have debug info, but it's true that it bloats the .a files. I think I did changes to enable them on static libraries intentionally:

commit de6feefdb7cfd0779277a6c451ce19d60b1d2b4d
Author: John Baldwin <jhb@FreeBSD.org>
Date:   Wed Aug 23 23:30:25 2017 +0000

    Improve the coverage of debug symbols for MK_DEBUG_FILES.
    
    - Include debug symbols in static libraries.  This permits binaries
      to include debug symbols for functions obtained from static libraries.
    - Permit the C/C++ compiler flags added for MK_DEBUG_FILES to be
      overridden by setting DEBUG_FILES_CFLAGS.  Use this to limit the debug
      information for llvm libraries and binaries.
    
    Reviewed by:    emaste
    Sponsored by:   DARPA / AFRL
    Differential Revision:  https://reviews.freebsd.org/D12025

It does treat 'WITH_DEBUG_FILES' as meaning "I want base system debug info"

I think I did changes to enable them on static libraries intentionally:

Ah, indeed -- it was SHARED_CFLAGS and SHARED_CXXFLAGS prior to your change.
OK, I will abandon this change, and perhaps leave a note in the DEBUG_FILES description that it controls debug info in static library archives as well.