-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmake check_c_source_compiles
fails while finding deps when c
binary is a list of strings
#13049
Comments
check_c_source_compiles
fails while finding deps when c
binaries is a list of stringscheck_c_source_compiles
fails while finding deps when c
binary is a list of strings
Looks like a meson upstream bug to me. Passing it this way is the blessed way e.g. see meson/cross/armclang-linux.txt Line 20 in e455cb0
(with upstream I meant meson problem. Thought I was in the vcpkg repo; how the hell did I end up here?) |
Experimented with "test cases/frameworks/15 llvm/". diff --git a/test cases/frameworks/15 llvm/meson.build b/test cases/frameworks/15 llvm/meson.build
index bb945cc44..c1c15721e 100644
--- a/test cases/frameworks/15 llvm/meson.build
+++ b/test cases/frameworks/15 llvm/meson.build
@@ -15,7 +15,7 @@ endif
modules_to_find = [
'bitwriter', 'asmprinter', 'executionengine', 'mcjit', 'target',
- 'nativecodegen', 'amdgpu', 'engine'
+ 'nativecodegen', 'amdgpu', 'engine', 'LLVMSupport',
]
if method == 'combination' meson logs:
So this is reproducible using the meson unittests as a guideline. |
In builddir/meson-private/cmake_LLVM/CMakeMesonToolchainFile.cmake # Variables from meson
set(CMAKE_SIZEOF_VOID_P "8")
set(CMAKE_C_COMPILER "/usr/bin/cc" "-fPIC" "-O3" "-DNDEBUG")
set(CMAKE_CXX_COMPILER_LAUNCHER "/usr/bin/ccache")
set(CMAKE_CXX_COMPILER "/usr/bin/c++") I'm guessing maybe CMAKE_C_COMPILER isn't meant to work this way... |
meson/mesonbuild/cmake/toolchain.py Lines 71 to 79 in 24a96a3
meson/mesonbuild/cmake/toolchain.py Lines 111 to 114 in 24a96a3
Defaults for compilers are defined here based on meson's own compiler environment info: meson/mesonbuild/cmake/toolchain.py Lines 175 to 192 in 24a96a3
So with this machine file: [binaries]
c = ['/usr/bin/cc', '-fPIC', '-O3', '-DNDEBUG'] variables has (python): self.variables = {}
self.variables['CMAKE_C_COMPILER'] = ['/usr/bin/cc', '-fPIC', '-O3', '-DNDEBUG'] |
https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER.html: "The full path to the compiler for OTOH https://mesonbuild.com/Machine-files.html#binariesallows lists of strings for binaries. It even uses a list for the "Cross example". Now the question is how to translate this for CMake, with out intruding too much into the CMake toolchain's setup of flags. |
Meson expects compile definitions and optimization flags and similar to be in CFLAGS, not in the CC binary definition itself. However it's a common use case to do something like The distinction is whether the flags in question are intended to select the right compiler output profile. Questions such as "does this influence what cross compile platform the compiler masquerades at" or "will it affect --print-search-dirs reporting" are key. Since this issue would affect that usage as well, I figure the answer isn't just "move it to meson's c_args list / $CFLAGS".
I seem to recall that cmake has a separate setting for ccache, as opposed to meson which defines the use of ccache as "the compiler is ccache cc". Could this be related? |
Describe the bug
Vcpkg port mesa fails to build in configurations which transitively depend on libterminfo (
Terminfo::terminfo
) viaLLVMSupport
.I suspect the issue is in meson.
Vcpkg passes
c
via a machine file as:LLVMConfig.cmake
callsfind_package(Terminfo)
as it does during llvm build. And the find module is properly found as part of the llvm's CMake config files.
This module has a
check_c_source_compiles("..." Terminfo_LINKABLE)
as a prerequisite for
Terminfo_FOUND
and target setup.However, this
check_c_source_compiles
fails when meson tries to find llvm via CMake. Inbuildtrees/mesa/x64-linux-rel/meson-private/cmake_LLVM/CMakeFiles/CMakeConfigureLog.yaml
, I found:Note the
"/usr/bin/cc;-fPIC;-O3;-DNDEBUG"
which points at thec
list of strings being incorrectly fed as a single item intoCMAKE_C_COMPILER
To Reproduce
All I can offer now is
on x64-linux which takes while due to llvm, even in release-only build.
In vcpkg CI, mesa on linux was disabled for a number of problems, but I'm trying to fix that in microsoft/vcpkg#36081.
It is probaly possible to create a more trivial reproducer for the given input (multi-string
c
, cmake dependency,check_c_source_compiles
).Expected behavior
It should run
/usr/bin/cc -fPIC -O3 -DNDEBUG ...
, letting the mesa link steps succeed.system parameters
The text was updated successfully, but these errors were encountered: