Skip to content

Commit 0d464d2

Browse files
committed
gh-95973: Add a new --with-dsymutil option to link debug information in MacOS
Signed-off-by: Pablo Galindo <[email protected]>
1 parent 4a7f5a5 commit 0d464d2

File tree

5 files changed

+129
-6
lines changed

5 files changed

+129
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*.cover
66
*.iml
77
*.o
8+
*.lto
89
*.a
910
*.so
1011
*.so.*

Makefile.pre.in

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ DTRACE= @DTRACE@
5454
DFLAGS= @DFLAGS@
5555
DTRACE_HEADERS= @DTRACE_HEADERS@
5656
DTRACE_OBJS= @DTRACE_OBJS@
57+
DSYMUTIL= @DSYMUTIL@
58+
DSYMUTIL_PATH= @DSYMUTIL_PATH@
5759

5860
GNULD= @GNULD@
5961

@@ -575,7 +577,7 @@ LIBEXPAT_HEADERS= \
575577
# Default target
576578
all: @DEF_MAKE_ALL_RULE@
577579
build_all: check-clean-src $(BUILDPYTHON) platform sharedmods \
578-
gdbhooks Programs/_testembed scripts checksharedmods
580+
gdbhooks Programs/_testembed scripts checksharedmods rundsymutil
579581
build_wasm: check-clean-src $(BUILDPYTHON) platform sharedmods \
580582
python-config checksharedmods
581583

@@ -893,6 +895,16 @@ sharedmods: $(SHAREDMODS) pybuilddir.txt
893895
checksharedmods: sharedmods $(PYTHON_FOR_BUILD_DEPS) $(BUILDPYTHON)
894896
@$(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/scripts/check_extension_modules.py
895897

898+
rundsymutil: sharedmods $(PYTHON_FOR_BUILD_DEPS) $(BUILDPYTHON)
899+
@if [ ! -z $(DSYMUTIL) ] ; then \
900+
$(DSYMUTIL_PATH) $(BUILDPYTHON); \
901+
for mod in X $(SHAREDMODS); do \
902+
if test $$mod != X; then \
903+
$(DSYMUTIL_PATH) $$mod; \
904+
fi; \
905+
done \
906+
fi
907+
896908
Modules/Setup.local:
897909
@# Create empty Setup.local when file was deleted by user
898910
echo "# Edit this file for local setup changes" > $@
@@ -2381,6 +2393,7 @@ clean-retain-profile: pycremoval
23812393
find . -name '*.[oa]' -exec rm -f {} ';'
23822394
find . -name '*.s[ol]' -exec rm -f {} ';'
23832395
find . -name '*.so.[0-9]*.[0-9]*' -exec rm -f {} ';'
2396+
find . -name '*.lto' -exec rm -f {} ';'
23842397
find . -name '*.wasm' -exec rm -f {} ';'
23852398
find . -name '*.lst' -exec rm -f {} ';'
23862399
find build -name 'fficonfig.h' -exec rm -f {} ';' || true
@@ -2497,7 +2510,7 @@ Python/thread.o: @THREADHEADERS@ $(srcdir)/Python/condvar.h
24972510

24982511
# Declare targets that aren't real files
24992512
.PHONY: all build_all build_wasm check-clean-src
2500-
.PHONY: sharedmods checksharedmods test quicktest
2513+
.PHONY: sharedmods checksharedmods test quicktest rundsymutil
25012514
.PHONY: install altinstall sharedinstall bininstall altbininstall
25022515
.PHONY: maninstall libinstall inclinstall libainstall
25032516
.PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add a new ``--with-dsymutil`` configure option to to link debug information
2+
in MacOS. Patch by Pablo Galindo.

configure

Lines changed: 82 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,7 +1866,7 @@ if test "$Py_LTO" = 'true' ; then
18661866
LTOFLAGS="-flto -Wl,-export_dynamic"
18671867
LTOCFLAGS="-flto"
18681868
else
1869-
LTOFLAGS="-flto=${Py_LTO_POLICY} -Wl,-export_dynamic"
1869+
LTOFLAGS="-flto=${Py_LTO_POLICY} -Wl,-export_dynamic -Wl,-object_path_lto,\"\$@\".lto"
18701870
LTOCFLAGS="-flto=${Py_LTO_POLICY}"
18711871
fi
18721872
;;
@@ -1896,7 +1896,7 @@ if test "$Py_LTO" = 'true' ; then
18961896
LDFLAGS_NOLTO="-fno-lto"
18971897
case $ac_sys_system in
18981898
Darwin*)
1899-
LTOFLAGS="-flto -Wl,-export_dynamic"
1899+
LTOFLAGS="-flto -Wl,-export_dynamic -Wl,-object_path_lto,\"\$@\".lto"
19001900
LTOCFLAGS="-flto"
19011901
;;
19021902
*)
@@ -3000,6 +3000,33 @@ else
30003000
AC_MSG_RESULT(no)
30013001
fi
30023002

3003+
# Check for --with-dsymutil
3004+
AC_SUBST(DSYMUTIL)
3005+
AC_SUBST(DSYMUTIL_PATH)
3006+
DSYMUTIL=
3007+
DSYMUTIL_PATH=
3008+
AC_MSG_CHECKING(for --with-dsymutil)
3009+
AC_ARG_WITH(dsymutil,
3010+
AS_HELP_STRING([--with-dsymutil], [link debug information into final executable with dsymutil in MacOS (default is no)]),
3011+
[
3012+
if test "$withval" != no
3013+
then
3014+
if test "$MACHDEP" != "darwin"; then
3015+
AC_MSG_ERROR([dsymutil debug linking is only available in MacOS.])
3016+
fi
3017+
AC_MSG_RESULT(yes);
3018+
DSYMUTIL='true'
3019+
else AC_MSG_RESULT(no); DSYMUTIL=
3020+
fi],
3021+
[AC_MSG_RESULT(no)])
3022+
3023+
if test "$DSYMUTIL"; then
3024+
AC_PATH_PROG(DSYMUTIL_PATH, [dsymutil], [not found])
3025+
if test "$DSYMUTIL_PATH" = "not found"; then
3026+
AC_MSG_ERROR([dsymutil command not found on \$PATH])
3027+
fi
3028+
fi
3029+
30033030
AC_MSG_CHECKING(for dyld)
30043031
case $ac_sys_system/$ac_sys_release in
30053032
Darwin/*)

0 commit comments

Comments
 (0)