Skip to content

Commit 5c5574b

Browse files
[3.13] gh-137056: Fix DTrace build support on NetBSD (GH-137057) (#137445)
(cherry picked from commit 54a5fdf) Co-authored-by: Furkan Onder <[email protected]>
1 parent 1024f1a commit 5c5574b

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

Makefile.pre.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,7 +2004,7 @@ Python/frozen.o: $(FROZEN_FILES_OUT)
20042004
# an include guard, so we can't use a pipeline to transform its output.
20052005
Include/pydtrace_probes.h: $(srcdir)/Include/pydtrace.d
20062006
$(MKDIR_P) Include
2007-
CC="$(CC)" CFLAGS="$(CFLAGS)" $(DTRACE) $(DFLAGS) -o $@ -h -s $<
2007+
CC="$(CC)" CFLAGS="$(CFLAGS)" $(DTRACE) $(DFLAGS) -o $@ -h -s $(srcdir)/Include/pydtrace.d
20082008
: sed in-place edit with POSIX-only tools
20092009
sed 's/PYTHON_/PyDTrace_/' $@ > [email protected]
20102010
@@ -2014,7 +2014,7 @@ Python/gc.o: $(srcdir)/Include/pydtrace.h
20142014
Python/import.o: $(srcdir)/Include/pydtrace.h
20152015

20162016
Python/pydtrace.o: $(srcdir)/Include/pydtrace.d $(DTRACE_DEPS)
2017-
CC="$(CC)" CFLAGS="$(CFLAGS)" $(DTRACE) $(DFLAGS) -o $@ -G -s $< $(DTRACE_DEPS)
2017+
CC="$(CC)" CFLAGS="$(CFLAGS)" $(DTRACE) $(DFLAGS) -o $@ -G -s $(srcdir)/Include/pydtrace.d $(DTRACE_DEPS)
20182018

20192019
Objects/typeobject.o: Objects/typeslots.inc
20202020

configure

Lines changed: 20 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: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5099,16 +5099,33 @@ then
50995099
# linked into the binary. Correspondingly, dtrace(1) is missing the ELF
51005100
# generation flag '-G'. We check for presence of this flag, rather than
51015101
# hardcoding support by OS, in the interest of robustness.
5102+
#
5103+
# NetBSD DTrace requires the -x nolibs flag to avoid system library conflicts
5104+
# and uses header generation for testing instead of object generation.
51025105
AC_CACHE_CHECK([whether DTrace probes require linking],
5103-
[ac_cv_dtrace_link], [dnl
5106+
[ac_cv_dtrace_link], [
51045107
ac_cv_dtrace_link=no
51055108
echo 'BEGIN{}' > conftest.d
5106-
"$DTRACE" $DFLAGS -G -s conftest.d -o conftest.o > /dev/null 2>&1 && \
5109+
case $host in
5110+
*netbsd*)
5111+
DTRACE_TEST_FLAGS="-x nolibs -h"
5112+
;;
5113+
*)
5114+
DTRACE_TEST_FLAGS="-G"
5115+
;;
5116+
esac
5117+
"$DTRACE" $DFLAGS $DTRACE_TEST_FLAGS -s conftest.d -o conftest.o > /dev/null 2>&1 && \
51075118
ac_cv_dtrace_link=yes
51085119
])
51095120
if test "$ac_cv_dtrace_link" = "yes"; then
51105121
DTRACE_OBJS="Python/pydtrace.o"
51115122
fi
5123+
# Set NetBSD-specific DTrace flags in DFLAGS
5124+
case $host in
5125+
*netbsd*)
5126+
DFLAGS="$DFLAGS -x nolibs"
5127+
;;
5128+
esac
51125129
fi
51135130

51145131
dnl Platform-specific C and header files.

0 commit comments

Comments
 (0)