aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/environment.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-02-12 14:05:34 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2017-02-12 14:55:32 +0200
commit5973dcc25bae5c0541a778516046de08eb9860dc (patch)
tree69e6850df7dca2121363b9ed5060f2bc3239d5d6 /mesonbuild/environment.py
parentf3d106e786ecad2758a58817ce4565b380ccee4f (diff)
downloadmeson-5973dcc25bae5c0541a778516046de08eb9860dc.zip
meson-5973dcc25bae5c0541a778516046de08eb9860dc.tar.gz
meson-5973dcc25bae5c0541a778516046de08eb9860dc.tar.bz2
Detect x86/amd64 from the compilers because system info may be incorrect.
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r--mesonbuild/environment.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index e143b0b..51a3d43 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -121,6 +121,18 @@ def detect_cpu_family(compilers):
if trial.startswith('arm'):
return 'arm'
if trial in ('amd64', 'x64'):
+ trial = 'x86_64'
+ if trial == 'x86_64':
+ # On Linux (and maybe others) there can be any mixture of 32/64 bit
+ # code in the kernel, Python, system etc. The only reliable way
+ # to know is to check the compiler defines.
+ for c in compilers.values():
+ try:
+ if c.has_define('__i386__'):
+ return 'x86'
+ except mesonlib.MesonException:
+ # Ignore compilers that do not support has_define.
+ pass
return 'x86_64'
# Add fixes here as bugs are reported.
return trial
@@ -131,6 +143,15 @@ def detect_cpu(compilers):
else:
trial = platform.machine().lower()
if trial in ('amd64', 'x64'):
+ trial = 'x86_64'
+ if trial == 'x86_64':
+ # Same check as above for cpu_family
+ for c in compilers.values():
+ try:
+ if c.has_define('__i386__'):
+ return 'i686' # All 64 bit cpus have at least this level of x86 support.
+ except mesonlib.MesonException:
+ pass
return 'x86_64'
# Add fixes here as bugs are reported.
return trial