configure: Add macOS-specific debug flags for libbacktrace compatibility
On macOS, libbacktrace was failing to find debug information due to: 1. Debug symbols not being properly linked with dsymutil 2. Apple Clang 17.0.0 generating DWARF 5 which libbacktrace couldn't parse In this commit we address both issues: Debug symbol accessibility: - Add dsymutil integration in Makefile to properly link debug symbols - Use -fno-standalone-debug to embed debug info inline in executable DWARF format compatibility: - Force -gdwarf-4 instead of default DWARF 5 to avoid "DW_FORM_addrx value out of range" errors Changelog-added: libbacktrace works with macOS
This commit is contained in:
committed by
Rusty Russell
parent
ed2b0eff9a
commit
92020ac31f
6
Makefile
6
Makefile
@@ -684,12 +684,18 @@ $(ALL_TEST_PROGRAMS) $(ALL_FUZZ_TARGETS): %: %.o
|
||||
# (as per EXTERNAL_LDLIBS) so we filter them out here.
|
||||
$(ALL_PROGRAMS) $(ALL_TEST_PROGRAMS):
|
||||
@$(call VERBOSE, "ld $@", $(LINK.o) $(filter-out %.a,$^) $(LOADLIBES) $(EXTERNAL_LDLIBS) $(LDLIBS) libccan.a $($(@)_LDLIBS) -o $@)
|
||||
ifeq ($(OS),Darwin)
|
||||
@$(call VERBOSE, "dsymutil $@", dsymutil $@)
|
||||
endif
|
||||
|
||||
# We special case the fuzzing target binaries, as they need to link against libfuzzer,
|
||||
# which brings its own main().
|
||||
FUZZ_LDFLAGS = -fsanitize=fuzzer
|
||||
$(ALL_FUZZ_TARGETS):
|
||||
@$(call VERBOSE, "ld $@", $(LINK.o) $(filter-out %.a,$^) $(LOADLIBES) $(EXTERNAL_LDLIBS) $(LDLIBS) libccan.a $(FUZZ_LDFLAGS) -o $@)
|
||||
ifeq ($(OS),Darwin)
|
||||
@$(call VERBOSE, "dsymutil $@", dsymutil $@)
|
||||
endif
|
||||
|
||||
|
||||
# Everything depends on the CCAN headers, and Makefile
|
||||
|
||||
16
configure
vendored
16
configure
vendored
@@ -148,7 +148,18 @@ set_defaults()
|
||||
# which matters since you might explicitly set of these blank.
|
||||
PREFIX=${PREFIX:-/usr/local}
|
||||
CC=${CC:-cc}
|
||||
CDEBUGFLAGS=${CDEBUGFLAGS--std=gnu11 -g -fstack-protector-strong}
|
||||
# Detect macOS and use appropriate debug flags for libbacktrace compatibility
|
||||
if [ "$(uname -s)" = "Darwin" ]; then
|
||||
# Always override to avoid DWARF 5
|
||||
CDEBUGFLAGS="-std=gnu11 -g -gdwarf-4 -fstack-protector-strong"
|
||||
|
||||
# Optional: confirm dsymutil is available
|
||||
if ! command -v dsymutil >/dev/null 2>&1; then
|
||||
echo "Warning: dsymutil not found. Install Xcode Command Line Tools for better debug support."
|
||||
fi
|
||||
else
|
||||
CDEBUGFLAGS=${CDEBUGFLAGS--std=gnu11 -g -fstack-protector-strong}
|
||||
fi
|
||||
DEBUGBUILD=${DEBUGBUILD:-0}
|
||||
COMPAT=${COMPAT:-1}
|
||||
STATIC=${STATIC:-0}
|
||||
@@ -194,6 +205,9 @@ usage()
|
||||
usage_with_default "CWARNFLAGS" "$DEFAULT_CWARNFLAGS"
|
||||
usage_with_default "COPTFLAGS" "$DEFAULT_COPTFLAGS"
|
||||
usage_with_default "CDEBUGFLAGS" "$CDEBUGFLAGS"
|
||||
if [ "$(uname -s)" = "Darwin" ]; then
|
||||
echo " Note: On macOS, -g is used instead of -g3 for libbacktrace compatibility"
|
||||
fi
|
||||
usage_with_default "CONFIGURATOR_CC" "${CONFIGURATOR_CC:-$CC}"
|
||||
echo " To override compile line for configurator itself"
|
||||
usage_with_default "PYTEST" "$PYTEST"
|
||||
|
||||
2
external/libbacktrace
vendored
2
external/libbacktrace
vendored
Submodule external/libbacktrace updated: 2446c66076...793921876c
Reference in New Issue
Block a user