aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/environment.py
diff options
context:
space:
mode:
authorGustavoLCR <gugulcr@gmail.com>2022-09-14 01:34:46 -0300
committerJussi Pakkanen <jpakkane@gmail.com>2022-10-25 14:59:06 +0300
commit32bc64e63210cee6df7364a39005d89cdfdc6b71 (patch)
tree281c411c322547f9ca45fe14a62795e03eef3da1 /mesonbuild/environment.py
parent3c0ac626d7bbf667762b72a8b075617763e17795 (diff)
downloadmeson-32bc64e63210cee6df7364a39005d89cdfdc6b71.zip
meson-32bc64e63210cee6df7364a39005d89cdfdc6b71.tar.gz
meson-32bc64e63210cee6df7364a39005d89cdfdc6b71.tar.bz2
Fix native compilation on ARM64 Windows
Move `detect_native_windows_arch()` to `mesonlib/universal.py` and rename it to `windows_detect_native_arch()` Use `IsWow64Process2()` to detect native architecture if available Use native `vcvarsarm64.bat` to initialize vsenv if available
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r--mesonbuild/environment.py22
1 files changed, 3 insertions, 19 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index bf6d374..7b09a2c 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -20,7 +20,7 @@ import collections
from . import coredata
from . import mesonlib
from .mesonlib import (
- MesonException, EnvironmentException, MachineChoice, Popen_safe, PerMachine,
+ MesonException, MachineChoice, Popen_safe, PerMachine,
PerMachineDefaultable, PerThreeMachineDefaultable, split_args, quote_arg, OptionKey,
search_version, MesonBugException
)
@@ -228,22 +228,6 @@ def detect_clangformat() -> T.List[str]:
return [path]
return []
-def detect_native_windows_arch():
- """
- The architecture of Windows itself: x86, amd64 or arm64
- """
- # These env variables are always available. See:
- # https://msdn.microsoft.com/en-us/library/aa384274(VS.85).aspx
- # https://blogs.msdn.microsoft.com/david.wang/2006/03/27/howto-detect-process-bitness/
- arch = os.environ.get('PROCESSOR_ARCHITEW6432', '').lower()
- if not arch:
- try:
- # If this doesn't exist, something is messing with the environment
- arch = os.environ['PROCESSOR_ARCHITECTURE'].lower()
- except KeyError:
- raise EnvironmentException('Unable to detect native OS architecture')
- return arch
-
def detect_windows_arch(compilers: CompilersDict) -> str:
"""
Detecting the 'native' architecture of Windows is not a trivial task. We
@@ -268,7 +252,7 @@ def detect_windows_arch(compilers: CompilersDict) -> str:
3. Otherwise, use the actual Windows architecture
"""
- os_arch = detect_native_windows_arch()
+ os_arch = mesonlib.windows_detect_native_arch()
if os_arch == 'x86':
return os_arch
# If we're on 64-bit Windows, 32-bit apps can be compiled without
@@ -375,7 +359,7 @@ def detect_cpu(compilers: CompilersDict) -> str:
# Same check as above for cpu_family
if any_compiler_has_define(compilers, '__i386__'):
trial = 'i686' # All 64 bit cpus have at least this level of x86 support.
- elif trial.startswith('aarch64'):
+ elif trial.startswith('aarch64') or trial.startswith('arm64'):
# Same check as above for cpu_family
if any_compiler_has_define(compilers, '__arm__'):
trial = 'arm'