[oi-dev] Python 2.7 SPARC build needs an adjusted patch and a new patch

Gary Mills gary_mills at fastmail.fm
Mon Jun 4 00:26:00 UTC 2018


In an attempt to build python2.7 on a T2000 (SPARC), I received this
error:

    /usr/gcc/4.4.4/bin/gcc -m32 -O3 -mno-app-regs -fPIC -DPIC -std=c99 -D_XOPEN_SOURCE=600 -m32 -fPIC -DPIC -R/usr/gnu/lib -L/usr/gnu/lib  -o python \
    		Modules/python.o \
    		-L. -lpython2.7 -lsocket -lnsl -ldl    -lm  
    Undefined			first referenced
     symbol  			    in file
    asm                                 ./libpython2.7.so
    ld: fatal: symbol referencing errors. No output written to python
    collect2: ld returned 1 exit status

This happens because Python/ceval.c contains two instances of code
like this:

      #if defined(__sparc)
    + 	asm("nop");
      #endif

This code was inserted by a patch called 05-dtrace.patch .  The file
dtrace.patch.diff, attached to this message, shows the changes I made
to the patch.  These changes fix the problem.

One of the modules also failed to build, producing these errors:

    /export/home/mills/Downloads/code/oi-userland/components/python/python27/Python-2.7.14/Modules/_ctypes/libffi/src/sparc/ffi.c:526: error: 'asm' undeclared (first use in this function)
    /export/home/mills/Downloads/code/oi-userland/components/python/python27/Python-2.7.14/Modules/_ctypes/libffi/src/sparc/ffi.c:526: error: expected ';' before 'volatile'

The new patch 31-sparc.patch, also attached, fixes this problem.
Finally, I updated COMPONENT_REVISION in the Makefile to signal the
presence of the adjusted patch and the new one as in the file
Makefile.diff, also attached.

These changes only affect the SPARC build.  Later python versions
likely require the same changes, but I haven't checked.

I'd appreciate it if somebody could verify that these changes are
correct.  I assume they are.  The build completes after these changes
are made.


-- 
-Gary Mills-		-refurb-		-Winnipeg, Manitoba, Canada-
-------------- next part --------------
--- ../05-dtrace.patch-orig	   :: 
+++ 05-dtrace.patch	   :: 
@@ -96,7 +96,7 @@
 +	 * Disable the tail call here.
 +	 */
 +#if defined(__sparc)
-+	asm("nop");
++	__asm__ __volatile__("nop");
 +#endif
 +}
 +
@@ -117,7 +117,7 @@
 +	 * Disable the tail call here.
 +	 */
 +#if defined(__sparc)
-+	asm("nop");
++	__asm__ __volatile__("nop");
 +#endif
 +}
 +#else
-------------- next part --------------
--- Makefile-orig	   :: 
+++ Makefile	   :: 
@@ -18,6 +18,7 @@
 #
 # CDDL HEADER END
 #
+# Copyright 2018 Gary Mills
 # Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
 
 #
@@ -25,7 +26,7 @@
 
 COMPONENT_NAME=		Python
 COMPONENT_VERSION=	2.7.14
-COMPONENT_REVISION=	1
+COMPONENT_REVISION=	2
 COMPONENT_PROJECT_URL=	http://python.org/
 COMPONENT_SRC=		$(COMPONENT_NAME)-$(COMPONENT_VERSION)
 COMPONENT_ARCHIVE=	$(COMPONENT_SRC).tar.xz
-------------- next part --------------
--- Python-2.7.14/Modules/_ctypes/libffi/src/sparc/ffi.c-orig	   :: 
+++ Python-2.7.14/Modules/_ctypes/libffi/src/sparc/ffi.c	   :: 
@@ -437,10 +437,10 @@
 	      call_struct[6] = 0x81c7e008;		 /* ret			 */
 	      call_struct[7] = 0xbe100017;		 /* mov   %l7, %i7	 */
 #ifdef __GNUC__
-	      asm volatile ("iflush %0; iflush %0+8; iflush %0+16; iflush %0+24" : :
+	      __asm__ __volatile__ ("iflush %0; iflush %0+8; iflush %0+16; iflush %0+24" : :
 			    "r" (call_struct) : "memory");
 	      /* SPARC v8 requires 5 instructions for flush to be visible */
-	      asm volatile ("nop; nop; nop; nop; nop");
+	      __asm__ __volatile__ ("nop; nop; nop; nop; nop");
 #else
 	      ffi_flush_icache (call_struct, 32);
 #endif
@@ -523,11 +523,11 @@
   /* Flush the Icache.  closure is 8 bytes aligned.  */
 #ifdef __GNUC__
 #ifdef SPARC64
-  asm volatile ("flush	%0; flush %0+8" : : "r" (closure) : "memory");
+  __asm__ __volatile__ ("flush	%0; flush %0+8" : : "r" (closure) : "memory");
 #else
-  asm volatile ("iflush	%0; iflush %0+8" : : "r" (closure) : "memory");
+  __asm__ __volatile__ ("iflush	%0; iflush %0+8" : : "r" (closure) : "memory");
   /* SPARC v8 requires 5 instructions for flush to be visible */
-  asm volatile ("nop; nop; nop; nop; nop");
+  __asm__ __volatile__ ("nop; nop; nop; nop; nop");
 #endif
 #else
   ffi_flush_icache (closure, 16);


More information about the oi-dev mailing list