Skip to content

Commit

Permalink
improve musl detection in libgcc finder
Browse files Browse the repository at this point in the history
Signed-off-by: Zen <[email protected]>
  • Loading branch information
desultory committed Nov 3, 2024
1 parent 29d8516 commit 04d6dd9
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/ugrd/base/core.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__author__ = "desultory"
__version__ = "3.10.0"
__version__ = "3.10.1"

from pathlib import Path
from typing import Union
Expand Down Expand Up @@ -169,11 +169,16 @@ def find_libgcc(self) -> None:
"""
from pathlib import Path

try:
ldconfig = self._run(["ldconfig", "-p"]).stdout.decode().split("\n")
except RuntimeError:
self.logger.critical("Unable to run ldconfig -p, if GCC is being used, this is fatal!")
return self.logger.critical("This check can be disabled by setting `find_libgcc = false` in the configuration.")
cmd = self._run(["ldconfig", "-p"], fail_silent=True, fail_hard=False)

if b"Unimplemented option: -p" in cmd.stderr: # Probably musl libc
self.logger.warning("This check can be disabled by setting `find_libgcc = false` in the configuration.")
return self.logger.warning("Unable to run ldconfig -p, if GCC is being used, this is fatal!")

if cmd.returncode != 0:
return self.logger.critical("Unable to run ldconfig -p, if GCC is being used, this is fatal!")

ldconfig = cmd.stdout.decode("utf-8").splitlines()

libgcc = [lib for lib in ldconfig if "libgcc_s" in lib and "(libc6," in lib][0]
source_path = Path(libgcc.partition("=> ")[-1])
Expand Down

0 comments on commit 04d6dd9

Please sign in to comment.