emscripten icon indicating copy to clipboard operation
emscripten copied to clipboard

CMake 3.28 and C++20, error: CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND

Open Boris-Rasin opened this issue 1 year ago • 13 comments
trafficstars

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)

Boris-Rasin avatar Mar 27 '24 21:03 Boris-Rasin

@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

sbc100 avatar Mar 27 '24 21:03 sbc100

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?

sbc100 avatar Mar 27 '24 21:03 sbc100

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.

dschuff avatar Mar 27 '24 22:03 dschuff

I think maybe we don't build "clang/tools" at all yet on our builder.

sbc100 avatar Mar 27 '24 22:03 sbc100

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

dschuff avatar Mar 29 '24 15:03 dschuff

Can you provide a simple example, including CMake configuration? I always encounter errors when compiling modules!

sxstd001 avatar May 22 '24 14:05 sxstd001

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

sbc100 avatar May 22 '24 16:05 sbc100

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 avatar May 22 '24 21:05 Boris-Rasin

@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?

sbc100 avatar May 22 '24 21:05 sbc100

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.

Boris-Rasin avatar May 23 '24 14:05 Boris-Rasin

Thanks! I was able to reproduce now. Uploading a fix now.

sbc100 avatar May 23 '24 16:05 sbc100

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.

jpvanoosten avatar Jul 25 '24 12:07 jpvanoosten

The fix for this has not yet landed.

sbc100 avatar Jul 31 '24 21:07 sbc100

Any know workaround? I can think of:

  • Using CMake <= 3.27
  • Using C++ <= 17

tuket avatar Oct 23 '24 11:10 tuket

Workaround that imports the bits of PR#21987: https://github.com/eliemichel/cpp20-cmake-emscripten-template

eliemichel avatar Oct 27 '24 08:10 eliemichel

Any updates? This is still an issue and prevents using c++20

hsdk123 avatar Jan 25 '25 00:01 hsdk123

This should be fixed by https://github.com/emscripten-core/emscripten/pull/21987

dschuff avatar Jan 30 '25 21:01 dschuff

@dschuff The issue seems to persist

hsdk123 avatar Jan 30 '25 22:01 hsdk123

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?

hsdk123 avatar Jan 30 '25 22:01 hsdk123

Likely in a week or two. However you can try it today using emsdk install tot

sbc100 avatar Jan 30 '25 22:01 sbc100

The implemented fix to this issue seems to cause another issue here: https://github.com/emscripten-core/emscripten/issues/24410

hsdk123 avatar May 26 '25 12:05 hsdk123