components/python/python34/patches/16-pic-compile.patch
author John Beck <John.Beck@Oracle.COM>
Wed, 29 Oct 2014 14:12:28 -0700
changeset 2183 5d00686e81da
parent 1907 446472de62e9
permissions -rw-r--r--
19782913 update Python to 3.4.2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1907
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     1
This patch is a Solaris-specific hack; it will not be submitted upstream.
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     2
2183
5d00686e81da 19782913 update Python to 3.4.2
John Beck <John.Beck@Oracle.COM>
parents: 1907
diff changeset
     3
--- Python-3.4.2/Lib/distutils/sysconfig.py.~2~	2014-09-22 14:20:53.466326587 -0700
5d00686e81da 19782913 update Python to 3.4.2
John Beck <John.Beck@Oracle.COM>
parents: 1907
diff changeset
     4
+++ Python-3.4.2/Lib/distutils/sysconfig.py	2014-09-22 14:20:53.494063421 -0700
5d00686e81da 19782913 update Python to 3.4.2
John Beck <John.Beck@Oracle.COM>
parents: 1907
diff changeset
     5
@@ -219,6 +219,22 @@
1907
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     6
         else:
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     7
             archiver = ar + ' ' + ar_flags
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     8
 
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     9
+        # Force PIC compilation. Determine if GNU compiler or otherwise
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    10
+        # and set the PIC flag(s) accordingly. Defaults to Studio compiler.
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    11
+        if re.search('-.PIC', cflags) == None:
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    12
+            try:
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    13
+                out = os.popen(cc + ' --version 2>/dev/null', 'r')
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    14
+                out_string = out.read()
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    15
+                out.close()
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    16
+                result = re.search(' (\d+\.\d+(\.\d+)*)', out_string)
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    17
+                kpic_flags = "-fPIC -DPIC" if result else "-KPIC -DPIC"
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    18
+            except ImportError:
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    19
+                # The only time the above should fail is during boot-strapping
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    20
+                # when time (os imports subprocess which imports time) is not
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    21
+                # yet available.  Assume Studio compiler for that case.
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    22
+                kpic_flags = "-KPIC -DPIC"
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    23
+            cflags += ' ' + kpic_flags
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    24
+
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    25
         cc_cmd = cc + ' ' + cflags
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    26
         compiler.set_executables(
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    27
             preprocessor=cpp,