emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.65k stars 3.29k forks source link

`ccache` not working with `em++.bat` using `-DCMAKE_CXX_COMPILER_LAUNCHER=ccache` #22374

Open vittorioromeo opened 1 month ago

vittorioromeo commented 1 month ago

I'm using the canonical CMake way of enabling ccache via -DCMAKE_CXX_COMPILER_LAUNCHER=ccache. On my MSYS2/CLANG64 installation of Emscripten, this technique fails, probably due to the emscripten\em++.bat wrapper not correctly handling ccache as a prefix.


Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.64-git (7b466b4f097b05b9f1e4f6ae0753f525cac08c92)
clang version 19.0.0git
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: C:/msys64/clang64/opt/emscripten-llvm/bin

Failing command line in full:

[33/379] Building CXX object src/SFML/Window/CMakeFiles/sfml-window.dir/Touch.cpp.o
FAILED: src/SFML/Window/CMakeFiles/sfml-window.dir/Touch.cpp.o
ccache C:\msys64\clang64\lib\emscripten\em++.bat -DDOCTEST_CONFIG_SUPER_FAST_ASSERTS -DGL_GLEXT_PROTOTYPES -DSFML_BUILD_AUDIO -DSFML_BUILD_EXAMPLES -DSFML_BUILD_GRAPHICS -DSFML_BUILD_IMGUI -DSFML_BUILD_NETWORK -DSFML_BUILD_TEST_SUITE -DSFML_BUILD_WINDOW -DSFML_ENABLE_LIFETIME_TRACKING -DSFML_OPENGL_ES -DSFML_STATIC -D_GLIBCXX_ASSERTIONS=1 -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES -IC:/OHWorkspace/SFML/include -IC:/OHWorkspace/SFML/src -isystem C:/OHWorkspace/SFML/extlibs/headers/glad/include -isystem C:/OHWorkspace/SFML/extlibs/headers/vulkan -Wall -Wextra -Wpedantic -Wno-ignored-attributes -Wno-unused-command-line-argument -g -std=c++20 -fansi-escape-codes -fcolor-diagnostics -g3 -gsource-map -O0 -pthread -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wcast-align -Wunused -Woverloaded-virtual -Wconversion -Wsign-conversion -Wdouble-promotion -Wformat=2 -Wimplicit-fallthrough -Wsuggest-override -Wnull-dereference -Wold-style-cast -Wpedantic -Wno-c++20-extensions -Wno-unknown-warning-option -MD -MT src/SFML/Window/CMakeFiles/sfml-window.dir/Touch.cpp.o -MF src\SFML\Window\CMakeFiles\sfml-window.dir\Touch.cpp.o.d -o src/SFML/Window/CMakeFiles/sfml-window.dir/Touch.cpp.o -c C:/OHWorkspace/SFML/src/SFML/Window/Touch.cpp
The parameter is incorrect.

(This error is repeated for every single object file.)

Full link command and output with -v appended: Linking stage is never reached.

sbc100 commented 3 weeks ago

@juj may have some idea what is going on here? I think maybe you need a forked version of ccache?

juj commented 3 weeks ago

Sorry, not quite sure. It's been a while since I looked at ccache. (mainly due to not being able to make it deterministically run faster than non-ccache runs)

When I added support for ccache, I did not utilize it with the -DCMAKE_CXX_COMPILER_LAUNCHER=ccache parameter (this is the first I learn about this feature now).

The way the current Emsdk installation enables ccache is to "fuse" it with Emscripten, i.e. if ccache is installed and activated, then simply calling emcc ... will invoke it via ccache.