summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Weißmann <volker.weissmann@gmx.de>2023-04-15 20:58:56 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2023-05-13 11:06:24 +0300
commit2699fd4b8a7330bb67f79c3254777167cae19b48 (patch)
treee6b52420c89f11294f9f0a405b605915ccd03987
parent8d816111142694d032f68a549f4a9e18f38427e2 (diff)
downloadmeson-2699fd4b8a7330bb67f79c3254777167cae19b48.tar.gz
During reconfigure, show that no compiler was found, if compiler fails sanity check.
-rw-r--r--mesonbuild/ast/introspection.py2
-rw-r--r--mesonbuild/compilers/detect.py12
-rw-r--r--mesonbuild/coredata.py1
-rw-r--r--mesonbuild/interpreter/interpreter.py9
-rw-r--r--mesonbuild/modules/java.py2
-rw-r--r--unittests/allplatformstests.py14
6 files changed, 21 insertions, 19 deletions
diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py
index 3158aa2ee..4d6cd0c5e 100644
--- a/mesonbuild/ast/introspection.py
+++ b/mesonbuild/ast/introspection.py
@@ -181,7 +181,7 @@ class IntrospectionInterpreter(AstInterpreter):
lang = lang.lower()
if lang not in self.coredata.compilers[for_machine]:
try:
- comp = detect_compiler_for(self.environment, lang, for_machine)
+ comp = detect_compiler_for(self.environment, lang, for_machine, True)
except mesonlib.MesonException:
# do we even care about introspecting this language?
if required:
diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py
index 1237cacb7..c6d6ae3d9 100644
--- a/mesonbuild/compilers/detect.py
+++ b/mesonbuild/compilers/detect.py
@@ -111,11 +111,15 @@ def compiler_from_language(env: 'Environment', lang: str, for_machine: MachineCh
}
return lang_map[lang](env, for_machine) if lang in lang_map else None
-def detect_compiler_for(env: 'Environment', lang: str, for_machine: MachineChoice) -> T.Optional[Compiler]:
+def detect_compiler_for(env: 'Environment', lang: str, for_machine: MachineChoice, skip_sanity_check: bool) -> T.Optional[Compiler]:
comp = compiler_from_language(env, lang, for_machine)
- if comp is not None:
- assert comp.for_machine == for_machine
- env.coredata.process_new_compiler(lang, comp, env)
+ if comp is None:
+ return comp
+ assert comp.for_machine == for_machine
+ env.coredata.process_new_compiler(lang, comp, env)
+ if not skip_sanity_check:
+ comp.sanity_check(env.get_scratch_dir(), env)
+ env.coredata.compilers[comp.for_machine][lang] = comp
return comp
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index 6ce30c9c8..5365f6df6 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -918,7 +918,6 @@ class CoreData:
def process_new_compiler(self, lang: str, comp: 'Compiler', env: 'Environment') -> None:
from . import compilers
- self.compilers[comp.for_machine][lang] = comp
self.add_compiler_options(comp.get_options(), lang, comp.for_machine, env)
enabled_opts: T.List[OptionKey] = []
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index e51910e57..2da966ca3 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -1491,13 +1491,12 @@ class Interpreter(InterpreterBase, HoldableObject):
comp = self.coredata.compilers[for_machine].get(lang)
if not comp:
try:
- comp = compilers.detect_compiler_for(self.environment, lang, for_machine)
+ skip_sanity_check = self.should_skip_sanity_check(for_machine)
+ if skip_sanity_check:
+ mlog.log_once('Cross compiler sanity tests disabled via the cross file.')
+ comp = compilers.detect_compiler_for(self.environment, lang, for_machine, skip_sanity_check)
if comp is None:
raise InvalidArguments(f'Tried to use unknown language "{lang}".')
- if self.should_skip_sanity_check(for_machine):
- mlog.log_once('Cross compiler sanity tests disabled via the cross file.')
- else:
- comp.sanity_check(self.environment.get_scratch_dir(), self.environment)
except mesonlib.MesonException:
if not required:
mlog.log('Compiler for language',
diff --git a/mesonbuild/modules/java.py b/mesonbuild/modules/java.py
index 6861ee0a7..f6e448454 100644
--- a/mesonbuild/modules/java.py
+++ b/mesonbuild/modules/java.py
@@ -42,7 +42,7 @@ class JavaModule(NewExtensionModule):
def __get_java_compiler(self, state: ModuleState) -> Compiler:
if 'java' not in state.environment.coredata.compilers[MachineChoice.BUILD]:
- detect_compiler_for(state.environment, 'java', MachineChoice.BUILD)
+ detect_compiler_for(state.environment, 'java', MachineChoice.BUILD, False)
return state.environment.coredata.compilers[MachineChoice.BUILD]['java']
@FeatureNew('java.generate_native_headers', '0.62.0')
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index 46883dd11..1fcb1f3f3 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -841,7 +841,7 @@ class AllPlatformTests(BasePlatformTests):
testdir = os.path.join("test cases/cython", '2 generated sources')
env = get_fake_env(testdir, self.builddir, self.prefix)
try:
- detect_compiler_for(env, "cython", MachineChoice.HOST)
+ detect_compiler_for(env, "cython", MachineChoice.HOST, True)
except EnvironmentException:
raise SkipTest("Cython is not installed")
self.init(testdir)
@@ -866,7 +866,7 @@ class AllPlatformTests(BasePlatformTests):
testdir = os.path.join("test cases/cython", '2 generated sources')
env = get_fake_env(testdir, self.builddir, self.prefix)
try:
- cython = detect_compiler_for(env, "cython", MachineChoice.HOST)
+ cython = detect_compiler_for(env, "cython", MachineChoice.HOST, True)
if not version_compare(cython.version, '>=0.29.33'):
raise SkipTest('Cython is too old')
except EnvironmentException:
@@ -2141,7 +2141,7 @@ class AllPlatformTests(BasePlatformTests):
env = get_fake_env()
for l in ['cpp', 'cs', 'd', 'java', 'cuda', 'fortran', 'objc', 'objcpp', 'rust']:
try:
- comp = detect_compiler_for(env, l, MachineChoice.HOST)
+ comp = detect_compiler_for(env, l, MachineChoice.HOST, True)
with tempfile.TemporaryDirectory() as d:
comp.sanity_check(d, env)
langs.append(l)
@@ -2158,7 +2158,7 @@ class AllPlatformTests(BasePlatformTests):
if is_windows() and lang == 'fortran' and target_type == 'library':
# non-Gfortran Windows Fortran compilers do not do shared libraries in a Fortran standard way
# see "test cases/fortran/6 dynamic"
- fc = detect_compiler_for(env, 'fortran', MachineChoice.HOST)
+ fc = detect_compiler_for(env, 'fortran', MachineChoice.HOST, True)
if fc.get_id() in {'intel-cl', 'pgi'}:
continue
# test empty directory
@@ -4177,18 +4177,18 @@ class AllPlatformTests(BasePlatformTests):
env = get_fake_env()
# Get the compiler so we know which compiler class to mock.
- cc = detect_compiler_for(env, 'c', MachineChoice.HOST)
+ cc = detect_compiler_for(env, 'c', MachineChoice.HOST, True)
cc_type = type(cc)
# Test a compiler that acts as a linker
with mock.patch.object(cc_type, 'INVOKES_LINKER', True):
- cc = detect_compiler_for(env, 'c', MachineChoice.HOST)
+ cc = detect_compiler_for(env, 'c', MachineChoice.HOST, True)
link_args = env.coredata.get_external_link_args(cc.for_machine, cc.language)
self.assertEqual(sorted(link_args), sorted(['-DCFLAG', '-flto']))
# And one that doesn't
with mock.patch.object(cc_type, 'INVOKES_LINKER', False):
- cc = detect_compiler_for(env, 'c', MachineChoice.HOST)
+ cc = detect_compiler_for(env, 'c', MachineChoice.HOST, True)
link_args = env.coredata.get_external_link_args(cc.for_machine, cc.language)
self.assertEqual(sorted(link_args), sorted(['-flto']))