Skip to content

Commit

Permalink
gh-95973: Add a new --with-dsymutil option to link debug information …
Browse files Browse the repository at this point in the history
…in macOS (GH-95974)

Automerge-Triggered-By: GH:pablogsal
  • Loading branch information
pablogsal authored Aug 27, 2022
1 parent 43a6dea commit 5b070c0
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
*.cover
*.iml
*.o
*.lto
*.a
*.so
*.so.*
*.dylib
*.dSYM
*.dll
*.wasm
*.orig
Expand Down
45 changes: 43 additions & 2 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ DTRACE= @DTRACE@
DFLAGS= @DFLAGS@
DTRACE_HEADERS= @DTRACE_HEADERS@
DTRACE_OBJS= @DTRACE_OBJS@
DSYMUTIL= @DSYMUTIL@
DSYMUTIL_PATH= @DSYMUTIL_PATH@

GNULD= @GNULD@

Expand Down Expand Up @@ -576,7 +578,7 @@ LIBEXPAT_HEADERS= \
# Default target
all: @DEF_MAKE_ALL_RULE@
build_all: check-clean-src $(BUILDPYTHON) platform sharedmods \
gdbhooks Programs/_testembed scripts checksharedmods
gdbhooks Programs/_testembed scripts checksharedmods rundsymutil
build_wasm: check-clean-src $(BUILDPYTHON) platform sharedmods \
python-config checksharedmods

Expand Down Expand Up @@ -905,6 +907,22 @@ sharedmods: $(SHAREDMODS) pybuilddir.txt
checksharedmods: sharedmods $(PYTHON_FOR_BUILD_DEPS) $(BUILDPYTHON)
@$(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/scripts/check_extension_modules.py

rundsymutil: sharedmods $(PYTHON_FOR_BUILD_DEPS) $(BUILDPYTHON)
@if [ ! -z $(DSYMUTIL) ] ; then \
echo $(DSYMUTIL_PATH) $(BUILDPYTHON); \
$(DSYMUTIL_PATH) $(BUILDPYTHON); \
if test -f $(LDLIBRARY); then \
echo $(DSYMUTIL_PATH) $(LDLIBRARY); \
$(DSYMUTIL_PATH) $(LDLIBRARY); \
fi; \
for mod in X $(SHAREDMODS); do \
if test $$mod != X; then \
echo $(DSYMUTIL_PATH) $$mod; \
$(DSYMUTIL_PATH) $$mod; \
fi; \
done \
fi

Modules/Setup.local:
@# Create empty Setup.local when file was deleted by user
echo "# Edit this file for local setup changes" > $@
Expand Down Expand Up @@ -1755,9 +1773,14 @@ sharedinstall: $(DESTSHARED) all
if test $$i != X; then \
echo $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \
$(INSTALL_SHARED) $$i $(DESTDIR)$(DESTSHARED)/`basename $$i`; \
if test -d "$$i.dSYM"; then \
echo $(DSYMUTIL_PATH) $(DESTDIR)$(DESTSHARED)/`basename $$i`; \
$(DSYMUTIL_PATH) $(DESTDIR)$(DESTSHARED)/`basename $$i`; \
fi; \
fi; \
done


$(DESTSHARED):
@for i in $(DESTDIRS); \
do \
Expand Down Expand Up @@ -1818,6 +1841,23 @@ altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@
-output $(DESTDIR)$(BINDIR)/python$(VERSION)-intel64$(EXE) \
$(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE); \
fi
# Install macOS debug information (if available)
if test -d "$(BUILDPYTHON).dSYM"; then \
echo $(DSYMUTIL_PATH) $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \
$(DSYMUTIL_PATH) $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \
fi
if test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \
if test -d "$(LDLIBRARY).dSYM"; then \
echo $(DSYMUTIL_PATH) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
$(DSYMUTIL_PATH) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
fi \
else \
if test -d "$(LDLIBRARY).dSYM"; then \
echo $(DSYMUTIL_PATH) $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/$(INSTSONAME); \
$(DSYMUTIL_PATH) $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/$(INSTSONAME); \
fi \
fi


bininstall: altbininstall
if test ! -d $(DESTDIR)$(LIBPC); then \
Expand Down Expand Up @@ -2392,6 +2432,7 @@ clean-retain-profile: pycremoval
find . -name '*.[oa]' -exec rm -f {} ';'
find . -name '*.s[ol]' -exec rm -f {} ';'
find . -name '*.so.[0-9]*.[0-9]*' -exec rm -f {} ';'
find . -name '*.lto' -exec rm -f {} ';'
find . -name '*.wasm' -exec rm -f {} ';'
find . -name '*.lst' -exec rm -f {} ';'
find build -name 'fficonfig.h' -exec rm -f {} ';' || true
Expand Down Expand Up @@ -2508,7 +2549,7 @@ Python/thread.o: @THREADHEADERS@ $(srcdir)/Python/condvar.h

# Declare targets that aren't real files
.PHONY: all build_all build_wasm check-clean-src
.PHONY: sharedmods checksharedmods test quicktest
.PHONY: sharedmods checksharedmods test quicktest rundsymutil
.PHONY: install altinstall sharedinstall bininstall altbininstall
.PHONY: maninstall libinstall inclinstall libainstall
.PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add a new ``--with-dsymutil`` configure option to to link debug information
in macOS. Patch by Pablo Galindo.
86 changes: 83 additions & 3 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 30 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1863,10 +1863,10 @@ if test "$Py_LTO" = 'true' ; then
# Any changes made here should be reflected in the GCC+Darwin case below
if test $Py_LTO_POLICY = default
then
LTOFLAGS="-flto -Wl,-export_dynamic"
LTOFLAGS="-flto -Wl,-export_dynamic -Wl,-object_path_lto,\"\$@\".lto"
LTOCFLAGS="-flto"
else
LTOFLAGS="-flto=${Py_LTO_POLICY} -Wl,-export_dynamic"
LTOFLAGS="-flto=${Py_LTO_POLICY} -Wl,-export_dynamic -Wl,-object_path_lto,\"\$@\".lto"
LTOCFLAGS="-flto=${Py_LTO_POLICY}"
fi
;;
Expand Down Expand Up @@ -1896,7 +1896,7 @@ if test "$Py_LTO" = 'true' ; then
LDFLAGS_NOLTO="-fno-lto"
case $ac_sys_system in
Darwin*)
LTOFLAGS="-flto -Wl,-export_dynamic"
LTOFLAGS="-flto -Wl,-export_dynamic -Wl,-object_path_lto,\"\$@\".lto"
LTOCFLAGS="-flto"
;;
*)
Expand Down Expand Up @@ -3053,6 +3053,33 @@ else
AC_MSG_RESULT(no)
fi

# Check for --with-dsymutil
AC_SUBST(DSYMUTIL)
AC_SUBST(DSYMUTIL_PATH)
DSYMUTIL=
DSYMUTIL_PATH=
AC_MSG_CHECKING(for --with-dsymutil)
AC_ARG_WITH(dsymutil,
AS_HELP_STRING([--with-dsymutil], [link debug information into final executable with dsymutil in macOS (default is no)]),
[
if test "$withval" != no
then
if test "$MACHDEP" != "darwin"; then
AC_MSG_ERROR([dsymutil debug linking is only available in macOS.])
fi
AC_MSG_RESULT(yes);
DSYMUTIL='true'
else AC_MSG_RESULT(no); DSYMUTIL=
fi],
[AC_MSG_RESULT(no)])

if test "$DSYMUTIL"; then
AC_PATH_PROG(DSYMUTIL_PATH, [dsymutil], [not found])
if test "$DSYMUTIL_PATH" = "not found"; then
AC_MSG_ERROR([dsymutil command not found on \$PATH])
fi
fi

AC_MSG_CHECKING(for dyld)
case $ac_sys_system/$ac_sys_release in
Darwin/*)
Expand Down

0 comments on commit 5b070c0

Please sign in to comment.