Skip to content

Commit cbb1e43

Browse files
committed
ci: test libc++ instead of libstdc++ in one job
Also add IWYU to the default job, since using libc++ instead of libstdc++ causes IWYU to give slightly different recommendations. Better to comply with both sets of recommendations so IWYU is usable on more platforms.
1 parent 7631345 commit cbb1e43

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ if(MP_ENABLE_IWYU)
4040
message(FATAL_ERROR "MP_ENABLE_IWYU is ON but include-what-you-use was not found.")
4141
endif()
4242
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "${IWYU_EXECUTABLE};-Xiwyu;--error")
43+
if(DEFINED ENV{IWYU_MAPPING_FILE})
44+
list(APPEND CMAKE_CXX_INCLUDE_WHAT_YOU_USE "-Xiwyu" "--mapping_file=$ENV{IWYU_MAPPING_FILE}")
45+
endif()
4346
endif()
4447

4548
include("cmake/compat_config.cmake")

ci/configs/default.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
CI_DESC="CI job using default libraries and tools"
1+
CI_DESC="CI job using default libraries and tools, and running IWYU"
22
CI_DIR=build-default
33
export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wno-unused-parameter"
4+
CMAKE_ARGS=(-DMP_ENABLE_IWYU=ON)
45
BUILD_ARGS=(-k)

ci/configs/llvm.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
CI_DESC="CI job using LLVM-based tools (clang, clang-tidy, iwyu) and testing Ninja"
1+
CI_DESC="CI job using LLVM-based libraries and tools (clang, libc++, clang-tidy, iwyu) and testing Ninja"
22
CI_DIR=build-llvm
3+
NIX_ARGS=(--arg enableLibcxx true)
34
export CXX=clang++
45
export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wthread-safety-analysis -Wno-unused-parameter"
56
CMAKE_ARGS=(

ci/scripts/run.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env bash
22
set -o errexit -o nounset -o pipefail -o xtrace
33

4-
nix-shell --pure --keep CI_CONFIG --keep CI_CLEAN --run ci/scripts/ci.sh shell.nix
4+
[ "${CI_CONFIG+x}" ] && source "$CI_CONFIG"
5+
6+
nix-shell --pure --keep CI_CONFIG --keep CI_CLEAN "${NIX_ARGS[@]+"${NIX_ARGS[@]}"}" --run ci/scripts/ci.sh shell.nix

shell.nix

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
1-
{ pkgs ? import <nixpkgs> {} }:
1+
{ pkgs ? import <nixpkgs> {}
2+
, enableLibcxx ? false # Whether to use libc++ toolchain and libraries instead of libstdc++
3+
}:
24

3-
pkgs.mkShell {
4-
buildInputs = with pkgs; [
5+
let
6+
lib = pkgs.lib;
7+
llvm = pkgs.llvmPackages_20;
8+
capnproto = pkgs.capnproto.override (lib.optionalAttrs enableLibcxx { clangStdenv = llvm.libcxxStdenv; });
9+
clang = if enableLibcxx then llvm.libcxxClang else llvm.clang;
10+
clang-tools = llvm.clang-tools.override { inherit enableLibcxx; };
11+
in pkgs.mkShell {
12+
buildInputs = [
513
capnproto
14+
llvm.libcxx
615
];
716
nativeBuildInputs = with pkgs; [
17+
clang
18+
clang-tools
819
cmake
920
include-what-you-use
10-
llvmPackages_20.clang
11-
llvmPackages_20.clang-tools
1221
ninja
1322
];
23+
24+
# Tell IWYU where its libc++ mapping lives
25+
IWYU_MAPPING_FILE = if enableLibcxx then "${llvm.libcxx.dev}/include/c++/v1/libcxx.imp" else null;
1426
}

0 commit comments

Comments
 (0)