23311386 python2.7 dumps core on SPARC when DTrace on Python is running
authorJohn Beck <John.Beck@Oracle.COM>
Wed, 25 May 2016 12:05:26 -0800
changeset 6058 dd8b0bdd3859
parent 6057 9c3b25fa4b99
child 6059 740b50e8e65f
23311386 python2.7 dumps core on SPARC when DTrace on Python is running
components/python/python27/Makefile
components/python/python27/patches/05-dtrace.patch
--- a/components/python/python27/Makefile	Tue May 24 06:37:50 2016 -0700
+++ b/components/python/python27/Makefile	Wed May 25 12:05:26 2016 -0800
@@ -52,10 +52,6 @@
 # We patch auto* files, so regenerate headers and configure
 COMPONENT_PREP_ACTION = (cd $(@D) ; autoheader ; autoconf -f)
 
-# we don't want to leak $(CC_BITS) into BASECFLAGS as it causes problems with
-# python-config
-CC +=	$(CFLAGS)
-
 C99MODE=
 CPPFLAGS +=	-IPython
 
@@ -78,10 +74,22 @@
 # Use of xprofile requires that the same options be used during compilation and
 # linking.  The targets chosen are based on Solaris 11 minimum supported system
 # requirements.
+#
+# We bypass the profile build for one file (ceval.c; see the DTrace patch)
+# and reduce the optimization level for that same file to work around a
+# problem (see bug 23467236) where Python would core dump on sparc when
+# run under DTrace.
 COMPONENT_BUILD_TARGETS = profile-opt
 XPROFILE_DIR = $(BUILD_DIR_$(BITS))/.profile
 PYFLAGS.i386 = -xtarget=opteron -xarch=sse2 -xcache=generic
 PYFLAGS.sparc =
+CEVAL_PATSUBST.i386 =	
+CEVAL_PATSUBST.sparc =	"-xprofile=\%"
+CEVAL_PATSUBST =	$(CEVAL_PATSUBST.$(MACH))
+CEVAL_CFLAGS.i386 =	$(CFLAGS)
+CEVAL_CFLAGS.sparc =	$(subst -xO5,-xO4,$(CFLAGS))
+CEVAL_CFLAGS =		$(CEVAL_CFLAGS.$(MACH))
+
 CFLAGS += -xO5 $(PYFLAGS.$(MACH))
 LDFLAGS += -xO5 $(PYFLAGS.$(MACH))
 
@@ -114,6 +122,8 @@
 COMPONENT_BUILD_ENV  +=		PATH="$(PATH)"
 COMPONENT_BUILD_ENV  +=		DFLAGS="-$(BITS)"
 COMPONENT_BUILD_ENV  +=		XPROFILE_DIR="$(XPROFILE_DIR)"
+COMPONENT_BUILD_ENV  +=		CEVAL_CFLAGS="$(CEVAL_CFLAGS)"
+COMPONENT_BUILD_ENV  +=		CEVAL_PATSUBST="$(CEVAL_PATSUBST)"
 
 # 64 bit shared objects need to go in a 64-bit directory
 COMPONENT_INSTALL_ARGS.64 += DESTSHARED=$(CONFIGURE_PREFIX)/lib/python2.7/lib-dynload
--- a/components/python/python27/patches/05-dtrace.patch	Tue May 24 06:37:50 2016 -0700
+++ b/components/python/python27/patches/05-dtrace.patch	Wed May 25 12:05:26 2016 -0800
@@ -36,7 +36,7 @@
 +	dtrace -o $@ $(DFLAGS) -C -h -s $(srcdir)/Python/python.d
 +
 +Python/ceval.o: Python/ceval.c Python/python.h
-+	$(CC) -c -I. -IPython $(BASECFLAGS) $(EXTRA_CFLAGS) $(CPPFLAGS) $(CFLAGSFORSHARED) $(CFLAGS) -DPy_BUILD_CORE -o $@ $<
++	$(patsubst $(CEVAL_PATSUBST),,$(CC) -c -I. -IPython $(BASECFLAGS) $(EXTRA_CFLAGS) $(CPPFLAGS) $(CFLAGSFORSHARED) $(CEVAL_CFLAGS)) -DPy_BUILD_CORE -o $@ $<
 +
 +Python/dtrace.o: $(srcdir)/Python/python.d Python/ceval.o
 +	dtrace -o $@ $(DFLAGS) -C -G -s $(srcdir)/Python/python.d Python/ceval.o