diff --git a/Makefile b/Makefile index 55a4ad8bb..09a60e3c2 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 c72981610..bdb803beb 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" diff --git a/external/libbacktrace b/external/libbacktrace index 2446c6607..793921876 160000 --- a/external/libbacktrace +++ b/external/libbacktrace @@ -1 +1 @@ -Subproject commit 2446c66076480ce07a6bd868badcbceb3eeecc2e +Subproject commit 793921876c981ce49759114d7bb89bb89b2d3a2d