From 66d41e75e89aa7cf3484c97b5c006c36da5fc56f Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Sat, 20 Jul 2024 23:56:40 -0700 Subject: [PATCH] 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. --- .../python/cpython/3.10/no-ldconfig.patch | 55 ------------------- .../python/cpython/3.11/no-ldconfig.patch | 55 ------------------- .../python/cpython/3.12/no-ldconfig.patch | 55 ------------------- .../python/cpython/3.13/no-ldconfig.patch | 55 ------------------- .../python/cpython/3.9/no-ldconfig.patch | 55 ------------------- 5 files changed, 275 deletions(-) diff --git a/pkgs/development/interpreters/python/cpython/3.10/no-ldconfig.patch b/pkgs/development/interpreters/python/cpython/3.10/no-ldconfig.patch index c259aed72b990..e65883ab895a4 100644 --- a/pkgs/development/interpreters/python/cpython/3.10/no-ldconfig.patch +++ b/pkgs/development/interpreters/python/cpython/3.10/no-ldconfig.patch @@ -11,61 +11,6 @@ diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py index 0c2510e..7fb98af 100644 --- a/Lib/ctypes/util.py +++ b/Lib/ctypes/util.py -@@ -100,53 +100,7 @@ elif os.name == "posix": - return thefile.read(4) == elf_header - - def _findLib_gcc(name): -- # Run GCC's linker with the -t (aka --trace) option and examine the -- # library name it prints out. The GCC command will fail because we -- # haven't supplied a proper program with main(), but that does not -- # matter. -- expr = os.fsencode(r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name)) -- -- c_compiler = shutil.which('gcc') -- if not c_compiler: -- c_compiler = shutil.which('cc') -- if not c_compiler: -- # No C compiler available, give up -- return None -- -- temp = tempfile.NamedTemporaryFile() -- try: -- args = [c_compiler, '-Wl,-t', '-o', temp.name, '-l' + name] -- -- env = dict(os.environ) -- env['LC_ALL'] = 'C' -- env['LANG'] = 'C' -- try: -- proc = subprocess.Popen(args, -- stdout=subprocess.PIPE, -- stderr=subprocess.STDOUT, -- env=env) -- except OSError: # E.g. bad executable -- return None -- with proc: -- trace = proc.stdout.read() -- finally: -- try: -- temp.close() -- except FileNotFoundError: -- # Raised if the file was already removed, which is the normal -- # behaviour of GCC if linking fails -- pass -- res = re.findall(expr, trace) -- if not res: -- return None -- -- for file in res: -- # Check if the given file is an elf file: gcc can report -- # some files that are linker scripts and not actual -- # shared objects. See bpo-41976 for more details -- if not _is_elf(file): -- continue -- return os.fsdecode(file) -+ return None - - - if sys.platform == "sunos5": @@ -268,34 +222,7 @@ elif os.name == "posix": else: diff --git a/pkgs/development/interpreters/python/cpython/3.11/no-ldconfig.patch b/pkgs/development/interpreters/python/cpython/3.11/no-ldconfig.patch index ca6a76d0ffd98..bafcaee7c980e 100644 --- a/pkgs/development/interpreters/python/cpython/3.11/no-ldconfig.patch +++ b/pkgs/development/interpreters/python/cpython/3.11/no-ldconfig.patch @@ -11,61 +11,6 @@ diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py index 0c2510e161..7fb98af308 100644 --- a/Lib/ctypes/util.py +++ b/Lib/ctypes/util.py -@@ -100,53 +100,7 @@ def _is_elf(filename): - return thefile.read(4) == elf_header - - def _findLib_gcc(name): -- # Run GCC's linker with the -t (aka --trace) option and examine the -- # library name it prints out. The GCC command will fail because we -- # haven't supplied a proper program with main(), but that does not -- # matter. -- expr = os.fsencode(r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name)) -- -- c_compiler = shutil.which('gcc') -- if not c_compiler: -- c_compiler = shutil.which('cc') -- if not c_compiler: -- # No C compiler available, give up -- return None -- -- temp = tempfile.NamedTemporaryFile() -- try: -- args = [c_compiler, '-Wl,-t', '-o', temp.name, '-l' + name] -- -- env = dict(os.environ) -- env['LC_ALL'] = 'C' -- env['LANG'] = 'C' -- try: -- proc = subprocess.Popen(args, -- stdout=subprocess.PIPE, -- stderr=subprocess.STDOUT, -- env=env) -- except OSError: # E.g. bad executable -- return None -- with proc: -- trace = proc.stdout.read() -- finally: -- try: -- temp.close() -- except FileNotFoundError: -- # Raised if the file was already removed, which is the normal -- # behaviour of GCC if linking fails -- pass -- res = re.findall(expr, trace) -- if not res: -- return None -- -- for file in res: -- # Check if the given file is an elf file: gcc can report -- # some files that are linker scripts and not actual -- # shared objects. See bpo-41976 for more details -- if not _is_elf(file): -- continue -- return os.fsdecode(file) -+ return None - - - if sys.platform == "sunos5": @@ -268,34 +222,7 @@ def find_library(name, is64 = False): else: diff --git a/pkgs/development/interpreters/python/cpython/3.12/no-ldconfig.patch b/pkgs/development/interpreters/python/cpython/3.12/no-ldconfig.patch index ca6a76d0ffd98..bafcaee7c980e 100644 --- a/pkgs/development/interpreters/python/cpython/3.12/no-ldconfig.patch +++ b/pkgs/development/interpreters/python/cpython/3.12/no-ldconfig.patch @@ -11,61 +11,6 @@ diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py index 0c2510e161..7fb98af308 100644 --- a/Lib/ctypes/util.py +++ b/Lib/ctypes/util.py -@@ -100,53 +100,7 @@ def _is_elf(filename): - return thefile.read(4) == elf_header - - def _findLib_gcc(name): -- # Run GCC's linker with the -t (aka --trace) option and examine the -- # library name it prints out. The GCC command will fail because we -- # haven't supplied a proper program with main(), but that does not -- # matter. -- expr = os.fsencode(r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name)) -- -- c_compiler = shutil.which('gcc') -- if not c_compiler: -- c_compiler = shutil.which('cc') -- if not c_compiler: -- # No C compiler available, give up -- return None -- -- temp = tempfile.NamedTemporaryFile() -- try: -- args = [c_compiler, '-Wl,-t', '-o', temp.name, '-l' + name] -- -- env = dict(os.environ) -- env['LC_ALL'] = 'C' -- env['LANG'] = 'C' -- try: -- proc = subprocess.Popen(args, -- stdout=subprocess.PIPE, -- stderr=subprocess.STDOUT, -- env=env) -- except OSError: # E.g. bad executable -- return None -- with proc: -- trace = proc.stdout.read() -- finally: -- try: -- temp.close() -- except FileNotFoundError: -- # Raised if the file was already removed, which is the normal -- # behaviour of GCC if linking fails -- pass -- res = re.findall(expr, trace) -- if not res: -- return None -- -- for file in res: -- # Check if the given file is an elf file: gcc can report -- # some files that are linker scripts and not actual -- # shared objects. See bpo-41976 for more details -- if not _is_elf(file): -- continue -- return os.fsdecode(file) -+ return None - - - if sys.platform == "sunos5": @@ -268,34 +222,7 @@ def find_library(name, is64 = False): else: diff --git a/pkgs/development/interpreters/python/cpython/3.13/no-ldconfig.patch b/pkgs/development/interpreters/python/cpython/3.13/no-ldconfig.patch index ca6a76d0ffd98..bafcaee7c980e 100644 --- a/pkgs/development/interpreters/python/cpython/3.13/no-ldconfig.patch +++ b/pkgs/development/interpreters/python/cpython/3.13/no-ldconfig.patch @@ -11,61 +11,6 @@ diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py index 0c2510e161..7fb98af308 100644 --- a/Lib/ctypes/util.py +++ b/Lib/ctypes/util.py -@@ -100,53 +100,7 @@ def _is_elf(filename): - return thefile.read(4) == elf_header - - def _findLib_gcc(name): -- # Run GCC's linker with the -t (aka --trace) option and examine the -- # library name it prints out. The GCC command will fail because we -- # haven't supplied a proper program with main(), but that does not -- # matter. -- expr = os.fsencode(r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name)) -- -- c_compiler = shutil.which('gcc') -- if not c_compiler: -- c_compiler = shutil.which('cc') -- if not c_compiler: -- # No C compiler available, give up -- return None -- -- temp = tempfile.NamedTemporaryFile() -- try: -- args = [c_compiler, '-Wl,-t', '-o', temp.name, '-l' + name] -- -- env = dict(os.environ) -- env['LC_ALL'] = 'C' -- env['LANG'] = 'C' -- try: -- proc = subprocess.Popen(args, -- stdout=subprocess.PIPE, -- stderr=subprocess.STDOUT, -- env=env) -- except OSError: # E.g. bad executable -- return None -- with proc: -- trace = proc.stdout.read() -- finally: -- try: -- temp.close() -- except FileNotFoundError: -- # Raised if the file was already removed, which is the normal -- # behaviour of GCC if linking fails -- pass -- res = re.findall(expr, trace) -- if not res: -- return None -- -- for file in res: -- # Check if the given file is an elf file: gcc can report -- # some files that are linker scripts and not actual -- # shared objects. See bpo-41976 for more details -- if not _is_elf(file): -- continue -- return os.fsdecode(file) -+ return None - - - if sys.platform == "sunos5": @@ -268,34 +222,7 @@ def find_library(name, is64 = False): else: diff --git a/pkgs/development/interpreters/python/cpython/3.9/no-ldconfig.patch b/pkgs/development/interpreters/python/cpython/3.9/no-ldconfig.patch index 41d3ab52345b2..1a5eccb9eca83 100644 --- a/pkgs/development/interpreters/python/cpython/3.9/no-ldconfig.patch +++ b/pkgs/development/interpreters/python/cpython/3.9/no-ldconfig.patch @@ -11,61 +11,6 @@ diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py index 0c2510e161..7fb98af308 100644 --- a/Lib/ctypes/util.py +++ b/Lib/ctypes/util.py -@@ -100,53 +100,7 @@ elif os.name == "posix": - return thefile.read(4) == elf_header - - def _findLib_gcc(name): -- # Run GCC's linker with the -t (aka --trace) option and examine the -- # library name it prints out. The GCC command will fail because we -- # haven't supplied a proper program with main(), but that does not -- # matter. -- expr = os.fsencode(r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name)) -- -- c_compiler = shutil.which('gcc') -- if not c_compiler: -- c_compiler = shutil.which('cc') -- if not c_compiler: -- # No C compiler available, give up -- return None -- -- temp = tempfile.NamedTemporaryFile() -- try: -- args = [c_compiler, '-Wl,-t', '-o', temp.name, '-l' + name] -- -- env = dict(os.environ) -- env['LC_ALL'] = 'C' -- env['LANG'] = 'C' -- try: -- proc = subprocess.Popen(args, -- stdout=subprocess.PIPE, -- stderr=subprocess.STDOUT, -- env=env) -- except OSError: # E.g. bad executable -- return None -- with proc: -- trace = proc.stdout.read() -- finally: -- try: -- temp.close() -- except FileNotFoundError: -- # Raised if the file was already removed, which is the normal -- # behaviour of GCC if linking fails -- pass -- res = re.findall(expr, trace) -- if not res: -- return None -- -- for file in res: -- # Check if the given file is an elf file: gcc can report -- # some files that are linker scripts and not actual -- # shared objects. See bpo-41976 for more details -- if not _is_elf(file): -- continue -- return os.fsdecode(file) -+ return None - - - if sys.platform == "sunos5": @@ -268,34 +222,7 @@ elif os.name == "posix": else: