Martin Storsjö [Tue, 10 Jun 2025 10:53:41 +0000 (13:53 +0300)]
ci: Add jobs for building binaries for Windows and Linux
Build binaries for x86_64 and aarch64 on Linux, and i686, x86_64
and aarch64 for Windows.
The Windows binaries are cross compiled from Linux. For x86, it
uses distro provided compilers, while it uses llvm-mingw installed
separately for targeting aarch64. (Most distros don't have packages
for mingw cross compilers for targeting Windows on aarch64 yet. GCC
isn't mature for this target yet, but Clang has supported this
target for many years now. Llvm-mingw is essentially the same toolchain
setup as MSYS2 uses in their clangarm64 environment, but available
as a standalone cross compiler too.)
Martin Storsjö [Wed, 30 Jul 2025 09:05:22 +0000 (12:05 +0300)]
ci: Add a toolchain file for (cross) compilation for aarch64-w64-mingw32
Contrary to the existing toolchain files, this doesn't hardcode
CMAKE_FIND_ROOT_PATH to a location in /usr, but locates the
compiler from the path, and picks a sysroot adjacent to it - allowing
using a compiler installed in any path.
This uses a compiler named "${TOOLCHAIN_PREFIX}-gcc" - toolchains
such as llvm-mingw do provide cross tools named "-gcc" for
compatibility, even if they use Clang.
Martin Storsjö [Tue, 10 Jun 2025 10:31:42 +0000 (13:31 +0300)]
ci: Extend the msys2 testing to the "clangarm64" environment
The clangarm64 msys environment doesn't have a "gcc" command
by default, unless the "gcc-compat" package is installed.
One may consider using "cc" as well, which is available when
the "toolchain" package is installed in each environment, but
that tool in clang environments fails the "direct" test case.
Martin Storsjö [Tue, 10 Jun 2025 10:28:53 +0000 (13:28 +0300)]
ci: Use pacboy to simplify installation of msys2 packages
See [1] and [2] for reference on using pacboy to simplify installing
mingw packages in msys2. The relevant bit to know is that by
specifying plain package names with a ":p" suffix, in the "pacboy"
section in msys2/setup-msys2, those packages are installed within
the current msys2 environment.
This avoids needing to specify the long package prefix like
"mingw-w64-x86_64". For other environments like "ucrt64", "clang64"
and "clangarm64", the prefix is even longer and less obvious.
Martin Storsjö [Tue, 10 Jun 2025 10:55:00 +0000 (13:55 +0300)]
ci: Stop manually installing Ninja on Linux and macOS
Since https://github.com/actions/runner-images/pull/11706,
https://github.com/actions/runner-images/pull/11707 and
https://github.com/actions/runner-images/pull/11737, ninja is
preinstalled in the Ubuntu, macOS and x86 Windows runner images.
Joel Rosdahl [Sun, 3 Aug 2025 16:04:29 +0000 (18:04 +0200)]
ci: Declare downloaded zstd as EXCLUDE_FROM_ALL
8648532e3cdcd6a0c4fb12b65e1ca9a8972a1e06 removed usage of
FetchContent_Populate to avoid warnings from newer CMake versions, but
the EXCLUDE_FROM_ALL part got lost in translation.
Corresponding semantics is available by passing EXCLUDE_FROM_ALL to
FetchContent_Declare, but only since CMake 3.28 so we need to add some
backward compatibility goo.
Joel Rosdahl [Sun, 20 Jul 2025 13:41:44 +0000 (15:41 +0200)]
fix: Keep original order of compiler arguments
Now when CCACHE_NOCPP2 (run_second_cpp = false) has been removed (see fd9de83446aeaf1eb1b33a2d900ea1ff757c4509) we can simplify compiler
argument juggling: instead of partitioning arguments into different
lists and reassemble them later, we can build up the preprocessor and
compiler command lines while we go, thus keeping the original order of
arguments.
Joel Rosdahl [Sat, 19 Jul 2025 18:43:32 +0000 (20:43 +0200)]
chore: Remove ability to avoid 2nd call to preprocessor (run_second_cpp)
ccache before version 1.6 (2002) always sent precompiled source to the
compiler as an optimization to avoid running the preprocessor a second
time. ccache 1.6 (2002) introduced CCACHE_CPP2 to optionally disable
this optimization. This seemed to work well until mid 2010s when
compilers started to behave differently when compiling preprocessed and
non-preprocessed source code. Thus, ccache 3.3 (2016) flipped the
default to make the optimization opt-in via CCACHE_NOCPP2 (or
"run_second_cpp = false").
Fast forward to 2025:
- As far as I can tell, CCACHE_NOCPP2 is used by essentially nobody
which isn't surprising since it generally doesn't work well.
- The feature comes with increased code complexity. The most painful
part is that compiler arguments need to be carefully filtered and sent
to only the preprocessor, only the compiler or both, depending on
whether run_second_cpp is true or false. And it can be forced to true
in the middle of argument parsing when an argument that is
incompatible with "run_second_cpp = false" is found.
- There have been a non-trivial amount of bugs related to CCACHE_NOCPP2
during the years due to the added complexity and due to new compiler
behavior that is incompatible with the mode.a
- The depend mode is a more performant alternative to "run_second_cpp =
false" since ccache 3.6 (2019), though with different tradeoffs.
Thus it's time to make the code less complex and more maintainable:
remove the optimization to send the precompiled source code to the
compiler.
This opens up making argument juggling simpler and fixing bug #738.
Joel Rosdahl [Sat, 7 Jun 2025 19:16:30 +0000 (21:16 +0200)]
fix: Detect cc/c++ hard link to clang/clang++ before gcc/g++
Apparently clang/clang++ can be gcc/g++ in addition to cc/c++, at least
on some macOS versions, so detect clang hard link before gcc since the
other way around (gcc installed as an alias of clang) seems less likely.
Gregor Jasny [Sun, 25 May 2025 13:35:53 +0000 (15:35 +0200)]
ci: Use CodeQL v3 (#1592)
This workflow throws an deprecation warning right now:
CodeQL Action major versions v1 and v2 have been deprecated. Please update all occurrences of the CodeQL Action in your workflow files to v3. For more information, see https://github.blog/changelog/2025-01-10-code-scanning-codeql-action-v2-is-now-deprecated/
Joel Rosdahl [Thu, 1 May 2025 15:22:15 +0000 (17:22 +0200)]
ci: Disable testing for Windows MSYS2 mingw64 clang
Clang warns about doctest's include of ciso646:
In file included from D:/a/ccache/ccache/unittest/main.cpp:26:
In file included from D:/a/ccache/ccache/build/_deps/doctest-src/doctest/doctest.h:499:
D:/a/_temp/msys64/mingw64/include/c++/15.1.0/ciso646:46:4: error: "<ciso646> is deprecated in C++17, use <version> to detect implementation-specific macros" [-Werror,-W#warnings]
46 | # warning "<ciso646> is deprecated in C++17, use <version> to detect implementation-specific macros"
Joel Rosdahl [Wed, 23 Apr 2025 17:16:24 +0000 (19:16 +0200)]
chore: Split util::split_once into util::split_once{,_to_views}
The util::split_once(std::string&&, char) version is a bit overly smart
in that it returns std::string instead of std::string_view for a
temporary std::string input. To reduce the risk for surprises, introduce
a util::split_once_into_views so that input lifetime is indicated in the
method name instead.
kzlar [Wed, 5 Mar 2025 17:37:04 +0000 (19:37 +0200)]
feat: Add knowledge about options related to react-native builds (#1567)
- Add compopt entries for -ivfsoverlay, -fmodules-cache-path, -fmodule-map-file and -fbuild-session-file
- Add hashing of build session file mtime unless sloppiness flag is set
- Add unit tests for the flags above as well as an e2e test for -fbuild-session-file