Skip to content

import C++20 module but clang-scan-deps doen't known the "-s USE_WEBGPU=1" options. #21866

Closed

Description

@eminor1988

EMSDK version:

  • 3.1.56-asserts

Compile command:

emcmake cmake ${PWD}/../ -G "Ninja" -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DCMAKE_CXX_COMPILER_CLANG_SCAN_DEPS="/root/emsdk/upstream/bin/clang-scan-deps"

Output / Error message:

CMakeFiles/trd-party-lib-dear-imgui.dir/cpp/3rdParty/imgui-1.90.4-docking/imgui_tables.cpp.o.ddi 
"/root/emsdk/upstream/bin/clang-scan-deps" -format=p1689 -- /root/emsdk/upstream/emscripten/em++ -DIMGUI_DEFINE_MATH_OPERATORS -I/home/ubuntu/git/cpp/3rdParty/imgui-1.90.4-docking -I/home/ubuntu/git/cpp/3rdParty/imgui-1.90.4-docking/backends -I/home/ubuntu/git/cpp/3rdParty/imgui-1.90.4-docking/backends/libs -I/home/ubuntu/git/cpp/3rdParty/imgui-1.90.4-docking/examples/libs -O2 -g -DNDEBUG -std=c++23 -s USE_WEBGPU=1 -x c++ /home/ubuntu/git/cpp/3rdParty/imgui-1.90.4-docking/imgui_tables.cpp -c -o CMakeFiles/trd-party-lib-dear-imgui.dir/cpp/3rdParty/imgui-1.90.4-docking/imgui_tables.cpp.o -MT CMakeFiles/trd-party-lib-dear-imgui.dir/cpp/3rdParty/imgui-1.90.4-docking/imgui_tables.cpp.o.ddi -MD -MF CMakeFiles/trd-party-lib-dear-imgui.dir/cpp/3rdParty/imgui-1.90.4-docking/imgui_tables.cpp.o.ddi.d > CMakeFiles/trd-party-lib-dear-imgui.dir/cpp/3rdParty/imgui-1.90.4-docking/imgui_tables.cpp.o.ddi.tmp && mv CMakeFiles/trd-party-lib-dear-imgui.dir/cpp/3rdParty/imgui-1.90.4-docking/imgui_tables.cpp.o.ddi.tmp CMakeFiles/trd-party-lib-dear-imgui.dir/cpp/3rdParty/imgui-1.90.4-docking/imgui_tables.cpp.o.ddi
error: no such file or directory: 'USE_WEBGPU=1'

Expectation:

  • I think the dependency scanning process should be able to recognize the compiler option "-s USE_WEBGPU=1", right?

Activity

  1. sbc100 commented on Apr 10, 2024

    @sbc100
    Collaborator

    Does cmake always assume it can pass all cflags to clang-scan-deps?

    If so I guess we need an emcc-scan-deps that wraps clang-scan-deps and removes the flags.

    In any case I don't think passing -DCMAKE_CXX_COMPILER_CLANG_SCAN_DEPS="/root/emsdk/upstream/bin/clang-scan-deps" is the right thing to do.. if you don't specify CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS at all, what does cmake default to?

  2. eminor1988 commented on Apr 10, 2024

    @eminor1988
    Author

    Sorry for bad English skill...

    I am trying to use C++20 module in my project.

    I thought emsdk/upstream/bin/clang-scan-deps had already addressed this issue, so I reported it.

    Since the code itself relies on <webgpu/webgpu.h> from emscripten, I think it's still necessary to include "-s USE_WEBGPU=1" for clang-scan-deps, but I am not sure.

  3. sbc100 commented on Apr 10, 2024

    @sbc100
    Collaborator

    The problem is that -sUSE_WEBGPU is an emscripten-specific flag so clang won't understand that.

    I guess we need to add some kind of emcc-scan-deps wrapper.

  4. Diyou commented on May 3, 2024

    @Diyou
    Contributor

    USE_WEBGPU is only a link flag. Did you set it explicitly as a compile flag?
    I can build simple modules when not setting any emscripten compile flags but clang-scan-deps fails then to find any header in /upstream/emscripten/cache/sysroot/include like emscripten.h or webgpu/webgpu.h

  5. Diyou commented on May 7, 2024

    @Diyou
    Contributor

    For some reason /upstream/emscripten/cache/sysroot/include does not get passed to clang-scan-deps by cmake even after include_directories() or target_include_directories().
    I tried to pass <emscripten.h> as a precompiled header which results in an error:

    [build] "/mnt/e/Workspace/Diyou.Engine/.cache/emsdk/upstream/bin/clang-scan-deps" -format=p1689 -- /mnt/e/Workspace/Diyou.Engine/.cache/emsdk/upstream/emscripten/em++  -I/mnt/e/Workspace/Diyou.Engine/build/Debug.WASM/.cache/SDL3/include -I/mnt/e/Workspace/Diyou.Engine/.cache/SDL3/include -I/mnt/e/Workspace/Diyou.Engine/.cache/SDL3/include/SDL3 -g -std=c++23 -flto=thin -fPIC -idirafter/mnt/e/Workspace/Diyou.Engine/.cache/SDL3/src/video/khronos -Winvalid-pch -Xclang -include-pch -Xclang /mnt/e/Workspace/Diyou.Engine/build/Debug.WASM/CMakeFiles/Diyou.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /mnt/e/Workspace/Diyou.Engine/build/Debug.WASM/CMakeFiles/Diyou.dir/cmake_pch.hxx -x c++ /mnt/e/Workspace/Diyou.Engine/Source/Runtime.c++ -c -o CMakeFiles/Diyou.dir/Source/Runtime.c++.o -MT CMakeFiles/Diyou.dir/Source/Runtime.c++.o.ddi -MD -MF CMakeFiles/Diyou.dir/Source/Runtime.c++.o.ddi.d > CMakeFiles/Diyou.dir/Source/Runtime.c++.o.ddi.tmp && mv CMakeFiles/Diyou.dir/Source/Runtime.c++.o.ddi.tmp CMakeFiles/Diyou.dir/Source/Runtime.c++.o.ddi
    [build] Error while scanning dependencies for /mnt/e/Workspace/Diyou.Engine/Source/Runtime.c++:
    [build] error: ignore exceptions was enabled in PCH file but is currently disabled
    [build] error: PCH file was compiled for the target 'wasm32-unknown-emscripten' but the current translation unit is being compiled for target 'x86_64-unknown-linux-gnu'
  6. sbc100 commented on May 7, 2024

    @sbc100
    Collaborator

    I don't think its going to be easy to make clang-scan-deps works out of the box. There are a bunch of flags you would need to pass to it, most importantly --sysroot=.. and --target=... You might be able do this yourselve by hacking but in the long run we are doing to want and emscripten-specific wrapper around clang-scan-deps I belive.

  7. RichardLuo0 commented on Jan 24, 2025

    @RichardLuo0

    Just pass -DCMAKE_SYSROOT="<emsdk>/upstream/emscripten/cache/sysroot" solves everything...

  8. RichardLuo0 commented on Jan 24, 2025

    @RichardLuo0

    This needs to be done in toolchain cmake file

    Just pass -DCMAKE_SYSROOT="<emsdk>/upstream/emscripten/cache/sysroot" solves everything...

  9. added a commit that references this issue on Jan 30, 2025
    209b704
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions