at 23.05-pre 4.0 kB view raw
1From ba458f33f335b217d078fdce56e9c6f9f93adb49 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 | 78 ++-------------------------------------------- 8 1 file changed, 2 insertions(+), 76 deletions(-) 9 10diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py 11index 0c2510e..79635a8 100644 12--- a/Lib/ctypes/util.py 13+++ b/Lib/ctypes/util.py 14@@ -100,54 +100,7 @@ elif os.name == "posix": 15 return thefile.read(4) == elf_header 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.findall(expr, trace) 55- if not res: 56- return None 57- 58- for file in res: 59- # Check if the given file is an elf file: gcc can report 60- # some files that are linker scripts and not actual 61- # shared objects. See bpo-41976 for more details 62- if not _is_elf(file): 63- continue 64- return os.fsdecode(file) 65- 66+ return None 67 68 if sys.platform == "sunos5": 69 # use /usr/ccs/bin/dump on solaris 70@@ -268,34 +221,7 @@ elif os.name == "posix": 71 else: 72 73 def _findSoname_ldconfig(name): 74- import struct 75- if struct.calcsize('l') == 4: 76- machine = os.uname().machine + '-32' 77- else: 78- machine = os.uname().machine + '-64' 79- mach_map = { 80- 'x86_64-64': 'libc6,x86-64', 81- 'ppc64-64': 'libc6,64bit', 82- 'sparc64-64': 'libc6,64bit', 83- 's390x-64': 'libc6,64bit', 84- 'ia64-64': 'libc6,IA-64', 85- } 86- abi_type = mach_map.get(machine, 'libc6') 87- 88- # XXX assuming GLIBC's ldconfig (with option -p) 89- regex = r'\s+(lib%s\.[^\s]+)\s+\(%s' 90- regex = os.fsencode(regex % (re.escape(name), abi_type)) 91- try: 92- with subprocess.Popen(['/sbin/ldconfig', '-p'], 93- stdin=subprocess.DEVNULL, 94- stderr=subprocess.DEVNULL, 95- stdout=subprocess.PIPE, 96- env={'LC_ALL': 'C', 'LANG': 'C'}) as p: 97- res = re.search(regex, p.stdout.read()) 98- if res: 99- return os.fsdecode(res.group(1)) 100- except OSError: 101- pass 102+ return None 103 104 def _findLib_ld(name): 105 # See issue #9998 for why this is needed 106-- 1072.30.0 108