jenkins-core-weekly: update to 2.491
[oi-userland.git] / components / python / python39 / patches / 11-pic-compile.patch
blobefd1a7f9a1948eb01dc00f26a5c056952f02f149
1 Python should always build modules pic. Bug 15780280
3 This patch is a Solaris-specific hack; it will not be submitted upstream.
5 --- Python-3.9.0/Lib/distutils/sysconfig.py
6 +++ Python-3.9.0/Lib/distutils/sysconfig.py
7 @@ -230,6 +230,22 @@ def customize_compiler(compiler):
8 else:
9 archiver = ar + ' ' + ar_flags
11 + # Force PIC compilation. Determine if GNU compiler or otherwise
12 + # and set the PIC flag(s) accordingly. Defaults to Studio compiler.
13 + if re.search('-.PIC', cflags) == None:
14 + try:
15 + out = os.popen(cc + ' --version 2>/dev/null', 'r')
16 + out_string = out.read()
17 + out.close()
18 + result = re.search(' (\d+\.\d+(\.\d+)*)', out_string)
19 + kpic_flags = "-fPIC -DPIC" if result else "-KPIC -DPIC"
20 + except ImportError:
21 + # The only time the above should fail is during boot-strapping
22 + # when time (os imports subprocess which imports time) is not
23 + # yet available. Assume Studio compiler for that case.
24 + kpic_flags = "-KPIC -DPIC"
25 + cflags += ' ' + kpic_flags
27 cc_cmd = cc + ' ' + cflags
28 compiler.set_executables(
29 preprocessor=cpp,
30 --- Python-3.9.0/Lib/distutils/tests/test_sysconfig.py
31 +++ Python-3.9.0/Lib/distutils/tests/test_sysconfig.py
32 @@ -127,10 +127,10 @@ class SysconfigTestCase(support.EnvironG
33 self.assertEqual(comp.exes['preprocessor'],
34 'env_cpp --env-cppflags')
35 self.assertEqual(comp.exes['compiler'],
36 - 'env_cc --sc-cflags --env-cflags --env-cppflags')
37 + 'env_cc --sc-cflags --env-cflags --env-cppflags -KPIC -DPIC')
38 self.assertEqual(comp.exes['compiler_so'],
39 ('env_cc --sc-cflags '
40 - '--env-cflags ''--env-cppflags --sc-ccshared'))
41 + '--env-cflags ''--env-cppflags -KPIC -DPIC --sc-ccshared'))
42 self.assertEqual(comp.exes['compiler_cxx'],
43 'env_cxx --env-cxx-flags')
44 self.assertEqual(comp.exes['linker_exe'],
45 @@ -156,9 +156,9 @@ class SysconfigTestCase(support.EnvironG
46 self.assertEqual(comp.exes['preprocessor'],
47 'sc_cc -E')
48 self.assertEqual(comp.exes['compiler'],
49 - 'sc_cc --sc-cflags')
50 + 'sc_cc --sc-cflags -KPIC -DPIC')
51 self.assertEqual(comp.exes['compiler_so'],
52 - 'sc_cc --sc-cflags --sc-ccshared')
53 + 'sc_cc --sc-cflags -KPIC -DPIC --sc-ccshared')
54 self.assertEqual(comp.exes['compiler_cxx'],
55 'sc_cxx')
56 self.assertEqual(comp.exes['linker_exe'],