emscripten
emscripten copied to clipboard
CMake 3.28 and C++20, error: CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND
EMSDK needs to include "clang-scan-deps" tool, as CMake 3.28 with C++20 and clang compiler always runs this tool.
This CMake produces the error, test.cpp could be empty:
cmake_minimum_required(VERSION 3.5...3.28)
project(test)
set(CMAKE_CXX_STANDARD 20)
add_executable(test test.cpp)
@dschuff should we start including this? This tool doesn't seem to exist on my debian-based system, is it new?
$ which clang-scan-deps
$ apt-cache search clang-scan-deps
Ah, I found it via sudo apt-get install clang-tools-17. Does that mean that CMake 3.28 with C++20 depends not just on the clang package but also on the clang-tools package?
Yes, clang-scan-deps is used with C++20 modules. Actually we got a recent request for this, https://github.com/emscripten-core/emscripten/issues/21042 and I thought I fixed it. But looking at that change, it maybe that it only affected non-release builds. Let me check on that some more.
I think maybe we don't build "clang/tools" at all yet on our builder.
I went ahead and did a minimal fix for this in https://chromium-review.googlesource.com/c/emscripten-releases/+/5402952 so the next release should be good. By the way, the non-LTO builds of emscripten-releases should have this binary in them already, so if you wanted to try it out you could use emsdk to install one of them, e.g. emsdk install 3.1.56-asserts
Can you provide a simple example, including CMake configuration? I always encounter errors when compiling modules!
emscripten doesn't really have support for C++20 modules yet. Its something we should probably add tests for, but for now its not something that is easy to do. Just FYI
Just to note, this problem prevents using CMake 3.28 (or later) with C++20 (or later), even in a project without modules.
@Boris-Rasin I'm not seeing any iseeu with simply using C++20. For example, with the above CMakeLists.txt file I can run cmake 3.2.8 just fine:
./emcmake cmake -S . -B out/test/
configure: cmake -S . -B out/test/ -DCMAKE_TOOLCHAIN_FILE=/usr/local/google/home/sbc/dev/wasm/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/local/google/home/sbc/dev/wasm/emsdk/node/18.20.3_64bit/bin/node
-- Configuring done (1.5s)
-- Generating done (0.0s)
-- Build files have been written to: /usr/local/google/home/sbc/dev/wasm/emscripten/out/test
$ cmake --version
cmake version 3.28.3
What problems do you see when you don't use modules?
The problem I see is listed in this bug report title: "error: CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND".
This happens with provided CMake file and empty "test.cpp" file.
Which means it happens with a project that does not use modules.
The error is during build, not during CMake config.
Thanks! I was able to reproduce now. Uploading a fix now.
Is this issue fixed on Windows? I'm using Emscripten 3.1.64 and using CMake 3.29 and with
target_compile_features( ${TARGET} PUBLIC cxx_std_20 )
I'm still getting the CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND error.
Is this tool included in the Windows distributions?
Note: I am not using modules, but CMake doesn't seem to care.
The fix for this has not yet landed.
Any know workaround? I can think of:
- Using CMake <= 3.27
- Using C++ <= 17
Workaround that imports the bits of PR#21987: https://github.com/eliemichel/cpp20-cmake-emscripten-template
Any updates? This is still an issue and prevents using c++20
This should be fixed by https://github.com/emscripten-core/emscripten/pull/21987
@dschuff The issue seems to persist
Actually,
C:\Users\daego\Desktop\Projects\emsdk (main -> origin)
λ .\emsdk list
The *recommended* precompiled SDK download is 4.0.2 (cc8eba40de8235f9c33d92463018f87b3edaa09e).
To install/activate it use:
latest
This is equivalent to installing/activating:
4.0.2 INSTALLED
All recent (non-legacy) installable versions are:
4.0.2 INSTALLED
When will we 4.0.3 be available?
Likely in a week or two. However you can try it today using emsdk install tot
The implemented fix to this issue seems to cause another issue here: https://github.com/emscripten-core/emscripten/issues/24410