diff options
author | Michael Hirsch, Ph.D <scivision@users.noreply.github.com> | 2019-11-17 11:33:58 -0500 |
---|---|---|
committer | Michael Hirsch, Ph.D <scivision@users.noreply.github.com> | 2019-11-17 11:50:49 -0500 |
commit | c8bfa6b7485316505e294c42eccb691630c85d3d (patch) | |
tree | fa4646aab139a6d3786acddf0764fea90bf262d4 | |
parent | f6ad5d139869db1db130e675275d25fff08dc09f (diff) | |
download | meson-darwin_arch.zip meson-darwin_arch.tar.gz meson-darwin_arch.tar.bz2 |
macos: detect old OS/cpu 64-bit CPU in 32-bit MacOS kerneldarwin_arch
intended to fix #6187 pending user verification
-rw-r--r-- | mesonbuild/environment.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index f53f17f..247ab1f 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -298,6 +298,23 @@ def detect_windows_arch(compilers: CompilersDict) -> str: return 'x86' return os_arch + +def detect_osx_arch() -> str: + """ + per #6187, handle early Mac 64-bit Intel CPU with 64-bit OSX using a **32-bit kernel** + testing this requires old MacOS and hardware, not easily available for cloud CI, + so users needing this functionality may kindly need to help with debugging info. + """ + try: + ret = subprocess.run(['sysctl', '-n', 'hw.cpu64bit_capable'], + universal_newlines=True, stderr=subprocess.DEVNULL).stdout + trial = 'x86_64' if ret.strip() == '1' else 'x86' + except Exception: + # very old MacOS version with implicit 32-bit CPU due to calling if-elif stack + trial = 'x86' + return trial + + def any_compiler_has_define(compilers: CompilersDict, define): for c in compilers.values(): try: @@ -322,7 +339,11 @@ def detect_cpu_family(compilers: CompilersDict) -> str: else: trial = platform.machine().lower() if trial.startswith('i') and trial.endswith('86'): - trial = 'x86' + if mesonlib.is_osx(): + # handle corner case with early Mac 64-bit CPU and older OSX + trial = detect_osx_arch() + else: + trial = 'x86' elif trial == 'bepc': trial = 'x86' elif trial.startswith('arm') or trial.startswith('earm'): |