Merge pull request #9014 from bonzini/mixed-language-link
Use appropriate compiler for the source file for "links" tests with file argumentpull/9307/head
commit
fa47d8dab0
9 changed files with 92 additions and 9 deletions
@ -0,0 +1,21 @@ |
||||
== Link tests can use sources for a different compiler == |
||||
|
||||
Usually, the `links` method of the compiler object uses a single program |
||||
invocation to do both compilation and linking. Starting with this version, |
||||
whenever the argument to `links` is a file, Meson will check if the file |
||||
suffix matches the compiler object's language. If they do not match, |
||||
as in the following case: |
||||
|
||||
``` |
||||
cxx = meson.get_compiler('cpp') |
||||
cxx.links(files('test.c')) |
||||
``` |
||||
|
||||
then Meson will separate compilation and linking. In the above example |
||||
`test.c` will be compiled with a C compiler and the resulting object file |
||||
will be linked with a C++ compiler. This makes it possible to detect |
||||
misconfigurations of the compilation environment, for example when the |
||||
C++ runtime is not compatible with the one expected by the C compiler. |
||||
|
||||
For this reason, passing file arguments with an unrecognized suffix to |
||||
`links` will cause a warning. |
@ -0,0 +1,11 @@ |
||||
project('test', ['c', 'cpp']) |
||||
|
||||
cc = meson.get_compiler('c') |
||||
cxx = meson.get_compiler('cpp') |
||||
|
||||
# used by run_unittests.py to grab the path to the C and C++ compilers |
||||
assert(cc.compiles(files('test.c'))) |
||||
assert(cxx.compiles(files('test.c'))) |
||||
|
||||
assert(cc.links(files('test.c'))) |
||||
assert(cxx.links(files('test.c'))) |
@ -0,0 +1 @@ |
||||
int main(void) { return 0; } |
Loading…
Reference in new issue