1From 597e73f2a4b2f0b508127931b36d5540d6941823 Mon Sep 17 00:00:00 2001
2From: Frederik Rietdijk <fridh@fridh.nl>
3Date: Mon, 28 Aug 2017 09:24:06 +0200
4Subject: [PATCH] Don't use ldconfig
5
6---
7 Lib/ctypes/util.py | 70 ++----------------------------------------------------
8 1 file changed, 2 insertions(+), 68 deletions(-)
9
10diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
11index 5e8b31a854..7b45ce6c15 100644
12--- a/Lib/ctypes/util.py
13+++ b/Lib/ctypes/util.py
14@@ -94,46 +94,7 @@ elif os.name == "posix":
15 import re, tempfile
16
17 def _findLib_gcc(name):
18- # Run GCC's linker with the -t (aka --trace) option and examine the
19- # library name it prints out. The GCC command will fail because we
20- # haven't supplied a proper program with main(), but that does not
21- # matter.
22- expr = os.fsencode(r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name))
23-
24- c_compiler = shutil.which('gcc')
25- if not c_compiler:
26- c_compiler = shutil.which('cc')
27- if not c_compiler:
28- # No C compiler available, give up
29- return None
30-
31- temp = tempfile.NamedTemporaryFile()
32- try:
33- args = [c_compiler, '-Wl,-t', '-o', temp.name, '-l' + name]
34-
35- env = dict(os.environ)
36- env['LC_ALL'] = 'C'
37- env['LANG'] = 'C'
38- try:
39- proc = subprocess.Popen(args,
40- stdout=subprocess.PIPE,
41- stderr=subprocess.STDOUT,
42- env=env)
43- except OSError: # E.g. bad executable
44- return None
45- with proc:
46- trace = proc.stdout.read()
47- finally:
48- try:
49- temp.close()
50- except FileNotFoundError:
51- # Raised if the file was already removed, which is the normal
52- # behaviour of GCC if linking fails
53- pass
54- res = re.search(expr, trace)
55- if not res:
56- return None
57- return os.fsdecode(res.group(0))
58+ return None
59
60
61 if sys.platform == "sunos5":
62@@ -255,34 +216,7 @@ elif os.name == "posix":
63 else:
64
65 def _findSoname_ldconfig(name):
66- import struct
67- if struct.calcsize('l') == 4:
68- machine = os.uname().machine + '-32'
69- else:
70- machine = os.uname().machine + '-64'
71- mach_map = {
72- 'x86_64-64': 'libc6,x86-64',
73- 'ppc64-64': 'libc6,64bit',
74- 'sparc64-64': 'libc6,64bit',
75- 's390x-64': 'libc6,64bit',
76- 'ia64-64': 'libc6,IA-64',
77- }
78- abi_type = mach_map.get(machine, 'libc6')
79-
80- # XXX assuming GLIBC's ldconfig (with option -p)
81- regex = r'\s+(lib%s\.[^\s]+)\s+\(%s'
82- regex = os.fsencode(regex % (re.escape(name), abi_type))
83- try:
84- with subprocess.Popen(['/sbin/ldconfig', '-p'],
85- stdin=subprocess.DEVNULL,
86- stderr=subprocess.DEVNULL,
87- stdout=subprocess.PIPE,
88- env={'LC_ALL': 'C', 'LANG': 'C'}) as p:
89- res = re.search(regex, p.stdout.read())
90- if res:
91- return os.fsdecode(res.group(1))
92- except OSError:
93- pass
94+ return None
95
96 def _findLib_ld(name):
97 # See issue #9998 for why this is needed
98--
992.15.0
100