From 5973dcc25bae5c0541a778516046de08eb9860dc Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sun, 12 Feb 2017 14:05:34 +0200 Subject: [PATCH 1/2] Detect x86/amd64 from the compilers because system info may be incorrect. --- mesonbuild/environment.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index e143b0b8b..51a3d4392 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 From 1f2f01076555f943023d1fb74e4977750db5d8a3 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sun, 12 Feb 2017 14:59:37 +0200 Subject: [PATCH 2/2] Detect Boost libraries primarily with the C++ compiler's find_library. --- mesonbuild/dependencies.py | 20 ++++++++++++++++--- .../5 dependency versions/meson.build | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py index c894b0ebd..9525ffa34 100644 --- a/mesonbuild/dependencies.py +++ b/mesonbuild/dependencies.py @@ -1,4 +1,4 @@ -# Copyright 2013-2015 The Meson development team +# Copyright 2013-2017 The Meson development team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -589,6 +589,9 @@ class BoostDependency(Dependency): mlog.log('Dependency Boost (%s) found:' % module_str, mlog.green('YES'), info) else: mlog.log("Dependency Boost (%s) found:" % module_str, mlog.red('NO')) + if 'cpp' not in self.environment.coredata.compilers: + raise DependencyException('Tried to use Boost but a C++ compiler is not defined.') + self.cpp_compiler = self.environment.coredata.compilers['cpp'] def detect_win_root(self): globtext = 'c:\\local\\boost_*' @@ -721,8 +724,19 @@ class BoostDependency(Dependency): args.append('-L' + os.path.join(self.boost_root, 'lib')) for module in self.requested_modules: module = BoostDependency.name2lib.get(module, module) - if module in self.lib_modules or module in self.lib_modules_mt: - linkcmd = '-lboost_' + module + libname = 'boost_' + module + # The compiler's library detector is the most reliable so use that first. + default_detect = self.cpp_compiler.find_library(libname, self.environment, []) + if default_detect is not None: + if module == 'unit_testing_framework': + emon_args = self.cpp_compiler.find_library('boost_test_exec_monitor') + else: + emon_args = None + args += default_detect + if emon_args is not None: + args += emon_args + elif module in self.lib_modules or module in self.lib_modules_mt: + linkcmd = '-l' + libname args.append(linkcmd) # FIXME a hack, but Boost's testing framework has a lot of # different options and it's hard to determine what to do diff --git a/test cases/linuxlike/5 dependency versions/meson.build b/test cases/linuxlike/5 dependency versions/meson.build index 20b3df585..1b01cd6b1 100644 --- a/test cases/linuxlike/5 dependency versions/meson.build +++ b/test cases/linuxlike/5 dependency versions/meson.build @@ -1,4 +1,4 @@ -project('dep versions', 'c') +project('dep versions', 'c', 'cpp') # Find external dependency without version zlib = dependency('zlib')