gcc-runtime: fix case of only gfortran in macOS

This commit is contained in:
Massimiliano Culpo 2025-02-14 12:56:16 +01:00
parent ae1f39339b
commit cc8447968e
No known key found for this signature in database
GPG Key ID: 3E52BB992233066C

View File

@ -76,9 +76,8 @@ def install(self, spec, prefix):
def _get_libraries_macho(self):
"""Same as _get_libraries_elf but for Mach-O binaries"""
cc = Executable(self["gcc"].cc)
cc = self._get_compiler()
path_and_install_name = []
for name in self.LIBRARIES:
if name == "gcc_s":
# On darwin, libgcc_s is versioned and can't be linked as -lgcc_s,
@ -116,6 +115,23 @@ def _get_libraries_macho(self):
return path_and_install_name
def _get_compiler(self):
gcc_pkg = self["gcc"]
exe_path = None
for attr_name in ("cc", "cxx", "fortran"):
try:
exe_path = getattr(gcc_pkg, attr_name)
except AttributeError:
pass
if not exe_path:
continue
cc = Executable(exe_path)
break
else:
raise InstallError(f"cannot find any compiler for {gcc_pkg.spec}")
return cc
@property
def libs(self):
# Currently these libs are not linkable with -l, they all have a suffix.