Enable compressed debug on little-endian targets

Compressed debug was enabled by default in commit c910570e75, but
broke the build on big-endian targets, and so was disabled in
89ed2ecb14.

Older versions of LLD fail with big-endian compressed debug sections.
This was fixed in LLD upstream (commit c6ebc651b6fa) and merged to
FreeBSD main (commit d69d07569e) by dim.

External toolchains (e.g. the llvm12 package) will not yet have the fix.
These may be used to link against base system .a archives, so compressed
debug sections would cause trouble even though the base system is fixed.

Enable compressed debug sections again, for little-endian targets only.
As discussed on freebsd-hackers[1] I expect to undo this in the future
(using compressed debug everywhere), once fixed versions of lld are
widely available.

Note that to be pedantically correct we should check both the compiler
and the linker for compressed debug support, but given the external
toolchain constraint the extra complexity does not seem worthwhile.

[1] https://lists.freebsd.org/archives/freebsd-hackers/2021-August/000188.html

PR:		257638
Reported by:	jrtc27 [impact of .a archives]
Discussed with:	imp
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31454

Revert "Disable compressed debug by default"

This reverts commit 89ed2ecb14.
This commit is contained in:
Ed Maste 2021-08-07 10:46:07 -04:00
parent 9feff969a0
commit 47363e99d3
2 changed files with 9 additions and 2 deletions

View File

@ -235,7 +235,14 @@ ${X_}COMPILER_FEATURES+= c++11 c++14
${X_}COMPILER_FEATURES+= c++17
.endif
.if ${${X_}COMPILER_TYPE} == "clang"
${X_}COMPILER_FEATURES+= compressed-debug retpoline init-all
${X_}COMPILER_FEATURES+= retpoline init-all
# PR257638 lld fails with BE compressed debug. Fixed in main but external tool
# chains will initially not have the fix. For now limit the feature to LE
# targets.
.include <bsd.endian.mk>
.if ${TARGET_ENDIANNESS} == "1234"
${X_}COMPILER_FEATURES+= compressed-debug
.endif
.endif
.if ${${X_}COMPILER_TYPE} == "clang" && ${${X_}COMPILER_VERSION} >= 100000 || \
(${${X_}COMPILER_TYPE} == "gcc" && ${${X_}COMPILER_VERSION} >= 80100)

View File

@ -247,7 +247,7 @@ CFLAGS+= ${SSP_CFLAGS}
# Additional flags passed in CFLAGS and CXXFLAGS when MK_DEBUG_FILES is
# enabled.
DEBUG_FILES_CFLAGS?= -g
DEBUG_FILES_CFLAGS?= -g -gz=zlib
# Allow user-specified additional warning flags, plus compiler and file
# specific flag overrides, unless we've overridden this...