components/python/python34/patches/16-pic-compile.patch
author John Beck <John.Beck@Oracle.COM>
Mon, 02 Feb 2015 18:48:58 -0800
branchs11-update
changeset 3786 fa9d2da4d216
parent 3778 35735ffdda43
permissions -rw-r--r--
19782913 update Python to 3.4.2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3778
35735ffdda43 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.
35735ffdda43 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     2
3786
fa9d2da4d216 19782913 update Python to 3.4.2
John Beck <John.Beck@Oracle.COM>
parents: 3778
diff changeset
     3
--- Python-3.4.2/Lib/distutils/sysconfig.py.~2~	2014-09-22 14:20:53.466326587 -0700
fa9d2da4d216 19782913 update Python to 3.4.2
John Beck <John.Beck@Oracle.COM>
parents: 3778
diff changeset
     4
+++ Python-3.4.2/Lib/distutils/sysconfig.py	2014-09-22 14:20:53.494063421 -0700
fa9d2da4d216 19782913 update Python to 3.4.2
John Beck <John.Beck@Oracle.COM>
parents: 3778
diff changeset
     5
@@ -219,6 +219,22 @@
3778
35735ffdda43 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     6
         else:
35735ffdda43 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     7
             archiver = ar + ' ' + ar_flags
35735ffdda43 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     8
 
35735ffdda43 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
35735ffdda43 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.
35735ffdda43 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    11
+        if re.search('-.PIC', cflags) == None:
35735ffdda43 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    12
+            try:
35735ffdda43 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')
35735ffdda43 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    14
+                out_string = out.read()
35735ffdda43 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    15
+                out.close()
35735ffdda43 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    16
+                result = re.search(' (\d+\.\d+(\.\d+)*)', out_string)
35735ffdda43 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"
35735ffdda43 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    18
+            except ImportError:
35735ffdda43 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
35735ffdda43 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
35735ffdda43 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    21
+                # yet available.  Assume Studio compiler for that case.
35735ffdda43 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    22
+                kpic_flags = "-KPIC -DPIC"
35735ffdda43 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    23
+            cflags += ' ' + kpic_flags
35735ffdda43 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    24
+
35735ffdda43 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    25
         cc_cmd = cc + ' ' + cflags
35735ffdda43 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    26
         compiler.set_executables(
35735ffdda43 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    27
             preprocessor=cpp,