mirror of
https://github.com/mesonbuild/meson.git
synced 2026-08-05 23:30:27 +00:00
compilers: pass external args to sanity check; add #include <stddef.h>
Two improvements so the compiler sanity check exercises the same code paths as cc.links(): 1. Compiler._sanity_check_compile_args (the base class) now passes get_external_args() and get_external_link_args() to the probe, just as build_wrapper_args() does. CLikeCompiler already did this via _get_basic_compiler_args(); the base class fix extends it to non-CLike compilers (Fortran, Swift, etc.). Duplicates in the CLike path are harmless because arglist deduplicates them. 2. CCompiler and CPPCompiler sanity check sources now include <stddef.h>. This ensures that a broken or missing include path is caught at compiler detection time with a natural compiler error, rather than surfacing later as a cryptic Meson exception.
This commit is contained in:
committed by
Paolo Bonzini
parent
c238c65b3f
commit
797decc3e4
@@ -75,7 +75,7 @@ class CCompiler(CLikeCompiler, Compiler):
|
||||
return ['-nostdinc']
|
||||
|
||||
def _sanity_check_source_code(self) -> str:
|
||||
return 'int main(void) { int class=0; return class; }\n'
|
||||
return '#include <stddef.h>\nint main(void) { int class=0; return class; }\n'
|
||||
|
||||
def has_header_symbol(self, hname: str, symbol: str, prefix: str, *,
|
||||
extra_args: T.Union[None, T.List[str], T.Callable[['CompileCheckMode'], T.List[str]]] = None,
|
||||
|
||||
@@ -1366,7 +1366,9 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
|
||||
:return: a tuple of arguments, the first is the executable and compiler
|
||||
arguments, the second is linker arguments
|
||||
"""
|
||||
return self.exelist_no_ccache + self.get_always_args() + self.get_output_args(binname) + [sourcename], []
|
||||
cargs = list(self.environment.coredata.get_external_args(self.for_machine, self.language))
|
||||
largs = list(self.environment.coredata.get_external_link_args(self.for_machine, self.language))
|
||||
return self.exelist_no_ccache + self.get_always_args() + self.get_output_args(binname) + [sourcename] + cargs, largs
|
||||
|
||||
@abc.abstractmethod
|
||||
def _sanity_check_source_code(self) -> str:
|
||||
|
||||
@@ -89,7 +89,7 @@ class CPPCompiler(CLikeCompiler, Compiler):
|
||||
return []
|
||||
|
||||
def _sanity_check_source_code(self) -> str:
|
||||
return 'class breakCCompiler;int main(void) { return 0; }\n'
|
||||
return '#include <stddef.h>\nclass breakCCompiler;int main(void) { return 0; }\n'
|
||||
|
||||
def get_compiler_check_args(self, mode: CompileCheckMode) -> T.List[str]:
|
||||
# -fpermissive allows non-conforming code to compile which is necessary
|
||||
|
||||
Reference in New Issue
Block a user