Skip to content

Commit 54a5fdf

Browse files
authored
gh-137056: Fix DTrace build support on NetBSD (GH-137057)
1 parent c2428ca commit 54a5fdf

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
@@ -2230,7 +2230,7 @@ Python/frozen.o: $(FROZEN_FILES_OUT)
22302230
# an include guard, so we can't use a pipeline to transform its output.
22312231
Include/pydtrace_probes.h: $(srcdir)/Include/pydtrace.d
22322232
$(MKDIR_P) Include
2233-
CC="$(CC)" CFLAGS="$(CFLAGS)" $(DTRACE) $(DFLAGS) -o $@ -h -s $<
2233+
CC="$(CC)" CFLAGS="$(CFLAGS)" $(DTRACE) $(DFLAGS) -o $@ -h -s $(srcdir)/Include/pydtrace.d
22342234
: sed in-place edit with POSIX-only tools
22352235
sed 's/PYTHON_/PyDTrace_/' $@ > [email protected]
22362236
@@ -2240,7 +2240,7 @@ Python/gc.o: $(srcdir)/Include/pydtrace.h
22402240
Python/import.o: $(srcdir)/Include/pydtrace.h
22412241

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

22452245
Objects/typeobject.o: Objects/typeslots.inc
22462246

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
@@ -5104,16 +5104,33 @@ then
51045104
# linked into the binary. Correspondingly, dtrace(1) is missing the ELF
51055105
# generation flag '-G'. We check for presence of this flag, rather than
51065106
# hardcoding support by OS, in the interest of robustness.
5107+
#
5108+
# NetBSD DTrace requires the -x nolibs flag to avoid system library conflicts
5109+
# and uses header generation for testing instead of object generation.
51075110
AC_CACHE_CHECK([whether DTrace probes require linking],
5108-
[ac_cv_dtrace_link], [dnl
5111+
[ac_cv_dtrace_link], [
51095112
ac_cv_dtrace_link=no
51105113
echo 'BEGIN{}' > conftest.d
5111-
"$DTRACE" $DFLAGS -G -s conftest.d -o conftest.o > /dev/null 2>&1 && \
5114+
case $host in
5115+
*netbsd*)
5116+
DTRACE_TEST_FLAGS="-x nolibs -h"
5117+
;;
5118+
*)
5119+
DTRACE_TEST_FLAGS="-G"
5120+
;;
5121+
esac
5122+
"$DTRACE" $DFLAGS $DTRACE_TEST_FLAGS -s conftest.d -o conftest.o > /dev/null 2>&1 && \
51125123
ac_cv_dtrace_link=yes
51135124
])
51145125
if test "$ac_cv_dtrace_link" = "yes"; then
51155126
DTRACE_OBJS="Python/pydtrace.o"
51165127
fi
5128+
# Set NetBSD-specific DTrace flags in DFLAGS
5129+
case $host in
5130+
*netbsd*)
5131+
DFLAGS="$DFLAGS -x nolibs"
5132+
;;
5133+
esac
51175134
fi
51185135

51195136
dnl Platform-specific C and header files.

0 commit comments

Comments
 (0)