configure: Add macOS-specific debug flags for libbacktrace compatibility
What changed, and why it matters
This commit changes the build configuration for macOS so that a debugging helper library (libbacktrace) can correctly read debug information. It does not fix a security vulnerability, change network behavior, or alter how funds or cryptographic operations are handled. It only affects how stack traces are produced during development/debugging on Apple computers.
No security action required; treat as a normal build/compatability improvement. Reviewers may verify that the new flags do not break non-macOS builds and that dsymutil availability is handled gracefully.
Security signals we found
No security-relevant code changes
Build-system-only change
No changes to cryptographic, networking, or transaction-handling code
No memory-safety fixes
Evidence from the diff
The patch adjusts compiler/linker flags on Darwin/macOS: it forces -gdwarf-4 instead of DWARF 5, adds -fno-standalone-debug semantics via -g, and runs dsymutil after linking so libbacktrace can resolve symbols. These are build-time developer-experience changes. No runtime logic, protocol handling, cryptography, or memory-safety code is modified.
Changed components
Makefileconfigure scriptexternal/libbacktrace build integrationInspect captured patch +22 / −2
diff --git a/Makefile b/Makefile
index 55a4ad8b..09a60e3c 100644
--- a/Makefile
+++ b/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
diff --git a/configure b/configure
index c7298161..bdb803be 100755
--- a/configure
+++ b/configure
@@ -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"
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.