https://github.com/python/cpython/commit/cbd532f2e86442f61f35bb978430d1eb6fc5daed
commit: cbd532f2e86442f61f35bb978430d1eb6fc5daed
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: encukou <[email protected]>
date: 2025-10-08T14:31:26+02:00
summary:

[3.14] gh-137056: Fix DTrace build support on NetBSD (GH-137057) (GH-137444)

(cherry picked from commit 54a5fdffc8e20f111e7a7d2df352e8be057177ff)

Co-authored-by: Furkan Onder <[email protected]>

files:
M Makefile.pre.in
M configure
M configure.ac

diff --git a/Makefile.pre.in b/Makefile.pre.in
index 34a270ab31167a..711628a4c22242 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -2230,7 +2230,7 @@ Python/frozen.o: $(FROZEN_FILES_OUT)
 # an include guard, so we can't use a pipeline to transform its output.
 Include/pydtrace_probes.h: $(srcdir)/Include/pydtrace.d
        $(MKDIR_P) Include
-       CC="$(CC)" CFLAGS="$(CFLAGS)" $(DTRACE) $(DFLAGS) -o $@ -h -s $<
+       CC="$(CC)" CFLAGS="$(CFLAGS)" $(DTRACE) $(DFLAGS) -o $@ -h -s 
$(srcdir)/Include/pydtrace.d
        : sed in-place edit with POSIX-only tools
        sed 's/PYTHON_/PyDTrace_/' $@ > [email protected]
        mv [email protected] $@
@@ -2240,7 +2240,7 @@ Python/gc.o: $(srcdir)/Include/pydtrace.h
 Python/import.o: $(srcdir)/Include/pydtrace.h
 
 Python/pydtrace.o: $(srcdir)/Include/pydtrace.d $(DTRACE_DEPS)
-       CC="$(CC)" CFLAGS="$(CFLAGS)" $(DTRACE) $(DFLAGS) -o $@ -G -s $< 
$(DTRACE_DEPS)
+       CC="$(CC)" CFLAGS="$(CFLAGS)" $(DTRACE) $(DFLAGS) -o $@ -G -s 
$(srcdir)/Include/pydtrace.d $(DTRACE_DEPS)
 
 Objects/typeobject.o: Objects/typeslots.inc
 
diff --git a/configure b/configure
index dc66ea068ebc1f..2c403f4965ddfe 100755
--- a/configure
+++ b/configure
@@ -19051,15 +19051,27 @@ printf "%s\n" "#define WITH_DTRACE 1" >>confdefs.h
     # linked into the binary. Correspondingly, dtrace(1) is missing the ELF
     # generation flag '-G'. We check for presence of this flag, rather than
     # hardcoding support by OS, in the interest of robustness.
+    #
+    # NetBSD DTrace requires the -x nolibs flag to avoid system library 
conflicts
+    # and uses header generation for testing instead of object generation.
     { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether DTrace 
probes require linking" >&5
 printf %s "checking whether DTrace probes require linking... " >&6; }
 if test ${ac_cv_dtrace_link+y}
 then :
   printf %s "(cached) " >&6
 else case e in #(
-  e)             ac_cv_dtrace_link=no
+  e)
+            ac_cv_dtrace_link=no
             echo 'BEGIN{}' > conftest.d
-            "$DTRACE" $DFLAGS -G -s conftest.d -o conftest.o > /dev/null 2>&1 
&& \
+            case $host in
+                *netbsd*)
+                    DTRACE_TEST_FLAGS="-x nolibs -h"
+                    ;;
+                *)
+                    DTRACE_TEST_FLAGS="-G"
+                    ;;
+            esac
+            "$DTRACE" $DFLAGS $DTRACE_TEST_FLAGS -s conftest.d -o conftest.o > 
/dev/null 2>&1 && \
                 ac_cv_dtrace_link=yes
        ;;
 esac
@@ -19069,6 +19081,12 @@ printf "%s\n" "$ac_cv_dtrace_link" >&6; }
     if test "$ac_cv_dtrace_link" = "yes"; then
         DTRACE_OBJS="Python/pydtrace.o"
     fi
+    # Set NetBSD-specific DTrace flags in DFLAGS
+    case $host in
+        *netbsd*)
+            DFLAGS="$DFLAGS -x nolibs"
+            ;;
+    esac
 fi
 
 PLATFORM_HEADERS=
diff --git a/configure.ac b/configure.ac
index 9412e3614c4206..07b005bacaf279 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5113,16 +5113,33 @@ then
     # linked into the binary. Correspondingly, dtrace(1) is missing the ELF
     # generation flag '-G'. We check for presence of this flag, rather than
     # hardcoding support by OS, in the interest of robustness.
+    #
+    # NetBSD DTrace requires the -x nolibs flag to avoid system library 
conflicts
+    # and uses header generation for testing instead of object generation.
     AC_CACHE_CHECK([whether DTrace probes require linking],
-        [ac_cv_dtrace_link], [dnl
+        [ac_cv_dtrace_link], [
             ac_cv_dtrace_link=no
             echo 'BEGIN{}' > conftest.d
-            "$DTRACE" $DFLAGS -G -s conftest.d -o conftest.o > /dev/null 2>&1 
&& \
+            case $host in
+                *netbsd*)
+                    DTRACE_TEST_FLAGS="-x nolibs -h"
+                    ;;
+                *)
+                    DTRACE_TEST_FLAGS="-G"
+                    ;;
+            esac
+            "$DTRACE" $DFLAGS $DTRACE_TEST_FLAGS -s conftest.d -o conftest.o > 
/dev/null 2>&1 && \
                 ac_cv_dtrace_link=yes
       ])
     if test "$ac_cv_dtrace_link" = "yes"; then
         DTRACE_OBJS="Python/pydtrace.o"
     fi
+    # Set NetBSD-specific DTrace flags in DFLAGS
+    case $host in
+        *netbsd*)
+            DFLAGS="$DFLAGS -x nolibs"
+            ;;
+    esac
 fi
 
 dnl Platform-specific C and header files.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to