How to compile ccache for Windows with MSYS2 #784
Replies: 4 comments
-
Hi, looks nice, that's a step by step instruction 👍 Most of this seems more MSYS2 related then ccache related, is that right? Could you explain step 8? I assume step 9 is for making steps 4+5 available? The use case is having ccache in MSYS2 environment where you use it with gcc/clang? |
Beta Was this translation helpful? Give feedback.
-
It is more or less the preparation of MSYS2 to get the ccache build to work. MSYS2 is just the base to install gcc, cmake and other tools as easy as possible. Step 8 is needed to compile the exe without any dll dependencies (needed dlls will become part of the executable). The use case for me is to use it as normal compiler cache for some gcc derivates (embedded c software) completly outside of the msys2 environment. msys2 was just used to compile ccache. I never used it before for anything else, but i was really impressed how easy it was to get it to work. |
Beta Was this translation helpful? Give feedback.
-
Another option would be to add hints like this to the ccache wiki (which is currently unused). I think that would make more sense than keeping detailed instructions in the official documentation. |
Beta Was this translation helpful? Give feedback.
-
TL;DR: I had fun time exploring the build to try finding and fixing the problem for MSYS2 in ccache codebase, but ended up discovering that carefully using the PATH (with Wrappers scripts are available as e.g.
For posterity: MSYS2 currently includes ccache: https://packages.msys2.org/search?t=binpkg&q=ccache but it seems to not work in practice on Windows MSYS2, possibly due to mixing the path separator characters. It seems unable to create the cache files after it has created the cache directory tree (though you might have to pre-create the So I found this effort to try rolling my own... Commenting as I go... Slight update for step(s) 5: per other docs, seems a better choice is
...due to:
For the build steps 9+10+11,
(*) UPDATE: In the end it was necessary to set the It failed to build however, with Tried to add pkgs:
because the test for whatever reason includes the )missing) Then discovered that this is not about libneon (XML parsing) but about ARM Neon CPU support... why here?.. While MSYS2 clang-11 includes the header, the compiler is not usable for ccache (lacks std::atomic it seems). Oh joy. Added Eventuantly went for blunt brute force with Seems this stems from
which I am not sure why fails fatally and not informatively. Neuthering the block (checking for bogus pointer size Also, for "sources from internet",
MSYS2 shell seems to recognize it both ways. But in the end, seems this was the problem for
However this is a more generic problem, as
(*) UPDATE: In the end, setting |
Beta Was this translation helpful? Give feedback.
-
Description
It is possible to compile ccache for windows by following these simple steps:
1.) Install MSYS2.
2.) Open MSYS2 MSYS console and run "pacman -Syu" multiple times until everything is updated.
3.) Close MSYS2 MSYS console and open MSYS2 MinGW 64-Bit console.
4.) Install "pacman -S mingw-w64-x86_64-gcc".
5.) Install "pacman -S mingw-w64-x86_64-cmake".
5.) Install "pacman -S make".
6.) Install "pacman -S zstd".
7.) Switch to ccache directory and create build directory "mkdir build".
8.) Edit CMakeLists.txt and add this line to create static linked exe file: "set(CMAKE_EXE_LINKER_FLAGS "-static")".
9.) Edit C:\msys64\home\username\.bashrc and add this line: "PATH=$PATH:/mingw64/bin/gcc:/mingw64/bin/cmake".
10.) Restart the MSYS MinGW 64-Bit console.
11.) Switch to build directory within ccache directory and run: "cmake -DCMAKE_BUILD_TYPE=Release -DZSTD_FROM_INTERNET=ON -G "MSYS Makefiles" ..".
12.) Run "make".
May be the docu can be enhanced because it costs me quite a while to get everything to work...
Beta Was this translation helpful? Give feedback.
All reactions