lol

python{39,310,311,312,313}: Allow using cc to resolve dynamic libraries

This patch hasn't been complete since an alternate case was added to
cpython which allows using ld(1) to resolve libraries. In addition to
this, the stated reason for the patch, to improve startup times by
preventing cpython from invoking gcc to resolve libuuid, has not been an
issue since that logic was removed in cpython 3.9. Finally, this patch
creates a disparity between Linux and other operating systems (I am
working on FreeBSD right now) since the ld(1) case is system gated.

Since it no longer accomplishes its stated purpose, is no longer needed,
and creates platform disparities, we should remove it.

I've left the half of this patch which prevents /sbin/ldconfig from
being invoked, since no nix-compiled program should ever be invoking
absolute paths like this.

-275
-55
pkgs/development/interpreters/python/cpython/3.10/no-ldconfig.patch
··· 11 11 index 0c2510e..7fb98af 100644 12 12 --- a/Lib/ctypes/util.py 13 13 +++ b/Lib/ctypes/util.py 14 - @@ -100,53 +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 - + return None 66 - 67 - 68 - if sys.platform == "sunos5": 69 14 @@ -268,34 +222,7 @@ elif os.name == "posix": 70 15 else: 71 16
-55
pkgs/development/interpreters/python/cpython/3.11/no-ldconfig.patch
··· 11 11 index 0c2510e161..7fb98af308 100644 12 12 --- a/Lib/ctypes/util.py 13 13 +++ b/Lib/ctypes/util.py 14 - @@ -100,53 +100,7 @@ def _is_elf(filename): 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 - + return None 66 - 67 - 68 - if sys.platform == "sunos5": 69 14 @@ -268,34 +222,7 @@ def find_library(name, is64 = False): 70 15 else: 71 16
-55
pkgs/development/interpreters/python/cpython/3.12/no-ldconfig.patch
··· 11 11 index 0c2510e161..7fb98af308 100644 12 12 --- a/Lib/ctypes/util.py 13 13 +++ b/Lib/ctypes/util.py 14 - @@ -100,53 +100,7 @@ def _is_elf(filename): 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 - + return None 66 - 67 - 68 - if sys.platform == "sunos5": 69 14 @@ -268,34 +222,7 @@ def find_library(name, is64 = False): 70 15 else: 71 16
-55
pkgs/development/interpreters/python/cpython/3.13/no-ldconfig.patch
··· 11 11 index 0c2510e161..7fb98af308 100644 12 12 --- a/Lib/ctypes/util.py 13 13 +++ b/Lib/ctypes/util.py 14 - @@ -100,53 +100,7 @@ def _is_elf(filename): 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 - + return None 66 - 67 - 68 - if sys.platform == "sunos5": 69 14 @@ -268,34 +222,7 @@ def find_library(name, is64 = False): 70 15 else: 71 16
-55
pkgs/development/interpreters/python/cpython/3.9/no-ldconfig.patch
··· 11 11 index 0c2510e161..7fb98af308 100644 12 12 --- a/Lib/ctypes/util.py 13 13 +++ b/Lib/ctypes/util.py 14 - @@ -100,53 +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 - + return None 66 - 67 - 68 - if sys.platform == "sunos5": 69 14 @@ -268,34 +222,7 @@ elif os.name == "posix": 70 15 else: 71 16