Skip to content

Commit a4d75a3

Browse files
Unittest under libc++ (jeremy-rifkin#156)
1 parent d64a935 commit a4d75a3

3 files changed

Lines changed: 26 additions & 5 deletions

File tree

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ jobs:
137137
138138
139139
unittest-linux:
140-
runs-on: ubuntu-22.04
140+
runs-on: ubuntu-24.04
141141
steps:
142142
- uses: actions/checkout@v4
143143
- name: dependencies
144144
run: |
145-
sudo apt install gcc-10 g++-10 libgcc-10-dev ninja-build
145+
sudo apt install gcc-10 g++-10 libgcc-10-dev ninja-build libc++-dev
146146
cd ..
147147
cpptrace/ci/setup-prerequisites-unittest.sh
148148
- name: build and test

ci/setup-prerequisites-unittest.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,8 @@ git fetch --depth 1 origin f8d7d77c06936315286eb55f8de22cd23c188571
3232
git checkout FETCH_HEAD
3333
mkdir build
3434
cd build
35-
cmake .. -GNinja
35+
cmake .. -GNinja -DCMAKE_INSTALL_PREFIX=/tmp/gtest_install
36+
sudo ninja install
37+
rm -rf *
38+
cmake .. -GNinja -DCMAKE_CXX_COMPILER=clang++-18 -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DCMAKE_INSTALL_PREFIX=/tmp/gtest_install_libcxx
3639
sudo ninja install

ci/unittest.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ def get_c_compiler_counterpart(compiler: str) -> str:
1717
def build(runner: MatrixRunner):
1818
if platform.system() == "Linux":
1919
matrix = runner.current_config()
20+
if "stdlib" in matrix and matrix["stdlib"] == "libc++":
21+
gtest_path = "/tmp/gtest_install_libcxx"
22+
else:
23+
gtest_path = "/tmp/gtest_install"
2024
args = [
2125
"cmake",
2226
"..",
@@ -35,6 +39,8 @@ def build(runner: MatrixRunner):
3539
f"-DCPPTRACE_USE_EXTERNAL_LIBDWARF=On",
3640
f"-DCPPTRACE_USE_EXTERNAL_ZSTD=On",
3741
f"-DCPPTRACE_USE_EXTERNAL_GTEST=On",
42+
f"-DCMAKE_PREFIX_PATH={gtest_path}",
43+
*(["-DCMAKE_CXX_FLAGS=-stdlib=libc++"] if "stdlib" in matrix and matrix["stdlib"] == "libc++" else [])
3844
]
3945
return runner.run_command(*args) and runner.run_command("ninja")
4046
elif platform.system() == "Darwin":
@@ -87,6 +93,7 @@ def build_and_test(runner: MatrixRunner):
8793
if (
8894
last is None
8995
or last["compiler"] != current["compiler"]
96+
or ("stdlib" in current and last["stdlib"] != current["stdlib"])
9097
or (platform.system() == "Darwin" and last["sanitizers"] != current["sanitizers"])
9198
) and os.path.exists("build"):
9299
shutil.rmtree("build", ignore_errors=True)
@@ -107,15 +114,26 @@ def build_and_test(runner: MatrixRunner):
107114
def run_linux_matrix():
108115
MatrixRunner(
109116
matrix = {
110-
"compiler": ["g++-10", "clang++-14"],
117+
"compiler": ["g++-10", "clang++-18"],
118+
"stdlib": ["libstdc++", "libc++"],
111119
"sanitizers": ["OFF", "ON"],
112120
"build_type": ["Debug", "RelWithDebInfo"],
113121
"shared": ["OFF", "ON"],
114122
"has_dl_find_object": ["OFF", "ON"],
115123
"split_dwarf": ["OFF", "ON"],
116124
"dwarf_version": ["4", "5"],
117125
},
118-
exclude = []
126+
exclude = [
127+
{
128+
"compiler": "g++-10",
129+
"stdlib": "libc++",
130+
},
131+
{
132+
# need to workaround https://github.com/llvm/llvm-project/issues/59432 later
133+
"stdlib": "libc++",
134+
"sanitizers": "ON",
135+
},
136+
]
119137
).run(build_and_test)
120138

121139
def run_macos_matrix():

0 commit comments

Comments
 (0)