Skip to content

configure: Add macOS-specific debug flags for libbacktrace compatibility #8431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -819,6 +825,12 @@ install-program: installdirs $(BIN_PROGRAMS) $(PKGLIBEXEC_PROGRAMS) $(PLUGINS) $
@if [ -d "$(DESTDIR)$(plugindir)/wss-proxy" ]; then rm -rf $(DESTDIR)$(plugindir)/wss-proxy; fi
[ -z "$(PLUGINS)" ] || $(INSTALL_PROGRAM) $(PLUGINS) $(DESTDIR)$(plugindir)
for PY in $(PY_PLUGINS); do DIR=`dirname $$PY`; DST=$(DESTDIR)$(plugindir)/`basename $$DIR`; if [ -d $$DST ]; then rm -rf $$DST; fi; $(INSTALL_PROGRAM) -d $$DIR; cp -a $$DIR $$DST ; done
ifeq ($(OS),Darwin)
# Install dSYM bundles alongside binaries on macOS
for BIN in $(BIN_PROGRAMS); do if [ -d $$BIN.dSYM ]; then cp -a $$BIN.dSYM $(DESTDIR)$(bindir)/; fi; done
for BIN in $(PKGLIBEXEC_PROGRAMS); do if [ -d $$BIN.dSYM ]; then cp -a $$BIN.dSYM $(DESTDIR)$(pkglibexecdir)/; fi; done
for PLUGIN in $(PLUGINS); do if [ -d $$PLUGIN.dSYM ]; then cp -a $$PLUGIN.dSYM $(DESTDIR)$(plugindir)/; fi; done
endif

MAN1PAGES = $(filter %.1,$(MANPAGES))
MAN5PAGES = $(filter %.5,$(MANPAGES))
Expand Down
16 changes: 15 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -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 -fno-standalone-debug -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}
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion external/libbacktrace
Submodule libbacktrace updated 51 files
+155 −31 Makefile.am
+438 −157 Makefile.in
+11 −1 README.md
+1 −1 alloc.c
+1 −1 allocfail.c
+1 −1 allocfail.sh
+2 −2 atomic.c
+1 −1 backtrace-supported.h.in
+1 −1 backtrace.c
+1 −1 backtrace.h
+24 −8 btest.c
+16 −0 config.h.in
+162 −53 config/libtool.m4
+471 −75 configure
+82 −13 configure.ac
+279 −88 dwarf.c
+2 −2 edtest.c
+1 −1 edtest2.c
+2,823 −271 elf.c
+103 −8 fileline.c
+2 −2 install-debuginfo-for-buildid.sh.in
+1 −1 instrumented_alloc.c
+50 −2 internal.h
+0 −7,436 libtool.m4
+0 −369 ltoptions.m4
+0 −123 ltsugar.m4
+0 −23 ltversion.m4
+0 −98 lt~obsolete.m4
+28 −22 macho.c
+1 −1 mmap.c
+1 −1 mmapio.c
+4 −4 mtest.c
+1 −1 nounwind.c
+208 −20 pecoff.c
+1 −1 posix.c
+41 −16 print.c
+1 −1 read.c
+1 −1 simple.c
+1 −1 sort.c
+1 −1 state.c
+1 −1 stest.c
+1 −1 test_format.c
+1 −1 testlib.c
+1 −1 testlib.h
+1 −1 ttest.c
+1 −1 unittest.c
+1 −1 unknown.c
+43 −32 xcoff.c
+2 −2 xztest.c
+523 −0 zstdtest.c
+1 −1 ztest.c