4
4
usage () {
5
5
echo " Usage: $0 -c <compiler> [-l <run label>] [-t <tests to run>]"
6
6
echo " -c <compiler> The compiler to use for the test"
7
+ echo " -s <cxx_std> The C++ standard to compile with (e.g. 'c++20', 'c++2b', 'c++latest' depending on the compiler)"
8
+ echo " -d <stdlib> Clang-only: the C++ Standard Library to link with ('libstdc++', 'libc++', or 'default' for platform default)"
7
9
echo " -l <run label> The label to use in output patch file name"
8
10
echo " -t <tests to run> Runs only the provided, comma-separated tests (filenames including .cpp2)"
9
11
echo " If the argument is not used all tests are run"
@@ -46,7 +48,7 @@ check_file () {
46
48
git ls-files --error-unmatch " $file " > /dev/null 2>&1
47
49
untracked=$?
48
50
49
- patch_file=" $label$ cxx_compiler .patch"
51
+ patch_file=" ${ label} - ${ cxx_compiler} - ${cxx_std} - ${cxx_stdlib} .patch"
50
52
51
53
if [[ $untracked -eq 1 ]]; then
52
54
# Add the file to the index to be able to diff it...
@@ -67,14 +69,20 @@ check_file () {
67
69
fi
68
70
}
69
71
70
- optstring=" c:l:t:"
72
+ optstring=" c:s:d: l:t:"
71
73
while getopts ${optstring} arg; do
72
74
case " ${arg} " in
73
75
c)
74
76
cxx_compiler=" ${OPTARG} "
75
77
;;
78
+ s)
79
+ cxx_std=" ${OPTARG} "
80
+ ;;
81
+ d)
82
+ cxx_stdlib=" ${OPTARG} "
83
+ ;;
76
84
l)
77
- label=" ${OPTARG} - "
85
+ label=" ${OPTARG} "
78
86
;;
79
87
t)
80
88
# Replace commas with spaces
@@ -125,8 +133,8 @@ expected_results_dir="test-results"
125
133
# ###############
126
134
# Get the directory with the exec outputs and compilation command
127
135
if [[ " $cxx_compiler " == * " cl.exe" * ]]; then
128
- compiler_cmd=' cl.exe -nologo -std:c++latest -MD -EHsc -I ..\..\..\include -Fe:'
129
- exec_out_dir=" $expected_results_dir /msvc-2022"
136
+ compiler_cmd=" cl.exe -nologo -std:${cxx_std} -MD -EHsc -I ..\..\..\include -Fe:"
137
+ exec_out_dir=" $expected_results_dir /msvc-2022- ${cxx_std} "
130
138
compiler_version=$( cl.exe)
131
139
else
132
140
# Verify the compiler command
136
144
exit 2
137
145
fi
138
146
139
- cpp_std=c++2b
140
147
compiler_version=$( " $cxx_compiler " --version)
141
148
142
149
if [[ " $compiler_version " == * " Apple clang version 14.0" * ||
@@ -148,16 +155,10 @@ else
148
155
exec_out_dir=" $expected_results_dir /clang-12"
149
156
elif [[ " $compiler_version " == * " clang version 15.0" * ]]; then
150
157
exec_out_dir=" $expected_results_dir /clang-15"
151
- # c++2b causes starge issues on GitHub ubuntu runners
152
- cpp_std=" c++20"
153
158
elif [[ " $compiler_version " == * " clang version 18.1" * ]]; then
154
159
exec_out_dir=" $expected_results_dir /clang-18"
155
- # c++2b causes starge issues on GitHub ubuntu runners
156
- cpp_std=" c++20"
157
160
elif [[ " $compiler_version " == * " g++-10" * ]]; then
158
161
exec_out_dir=" $expected_results_dir /gcc-10"
159
- # GCC 10 does not support c++2b
160
- cpp_std=c++20
161
162
elif [[ " $compiler_version " == * " g++-12" * ||
162
163
" $compiler_version " == * " g++-13" *
163
164
]]; then
@@ -169,15 +170,44 @@ else
169
170
exit 2
170
171
fi
171
172
172
- compiler_cmd=" $cxx_compiler -I../../../include -std=$cpp_std -pthread -o "
173
+ # Append the C++ standard (e.g. 'c++20') to the expected output dir name
174
+ exec_out_dir=" ${exec_out_dir} -${cxx_std} "
175
+
176
+ # Clang can link with either libstdc++ or libc++
177
+ # By default clang on ubuntu links with libstdc++ and on macOS links with libc++.
178
+ if [[ " $compiler_version " == * " clang" * ]]; then
179
+ if [[ " $cxx_stdlib " == " default" || " $cxx_stdlib " == " " ]]; then
180
+ cxx_stdlib_link_arg=" " # Use compiler/platform default
181
+ elif [[ " $cxx_stdlib " == " libstdc++" ]]; then
182
+ cxx_stdlib_link_arg=" -stdlib=libstdc++"
183
+ elif [[ " $cxx_stdlib " == * " libc++" * ]]; then
184
+
185
+ # Need to install the correct libc++ packages, e.g. `libc++-15-dev` and `libc++abi-15-dev` for clang 15.
186
+ # Our `cxx_stdlib` variable contains the `libc++-XX-dev` package name so we need to create the abi version.
187
+ cxx_stdlib_abi_package=" ${cxx_stdlib/ libc++/ libc++abi} "
188
+ printf " Installing packages: $cxx_stdlib $cxx_stdlib_abi_package \n\n"
189
+ sudo apt-get install -y $cxx_stdlib $cxx_stdlib_abi_package
190
+
191
+ cxx_stdlib_link_arg=" -stdlib=libc++"
192
+ exec_out_dir=" ${exec_out_dir} -libcpp"
193
+ else
194
+ printf " Unhandled C++ Standard Library option:\n$cxx_stdlib \n\n"
195
+ exit 2
196
+ fi
197
+ else
198
+ cxx_stdlib_link_arg=" " # Use compiler/platform default
199
+ fi
200
+
201
+ compiler_cmd=" $cxx_compiler -I../../../include -std=$cxx_std $cxx_stdlib_link_arg -pthread -o "
202
+ printf " \ncompiler_cmd: $compiler_cmd \n\n"
173
203
fi
174
204
175
205
if [[ -d " $exec_out_dir " ]]; then
176
206
printf " Full compiler version for '$cxx_compiler ':\n$compiler_version \n\n"
177
207
178
208
printf " Directory with reference compilation/execution files to use:\n$exec_out_dir \n\n"
179
209
else
180
- printf " Directory with reference compilation/execution files not found for compiler: '$cxx_compiler '\n\n"
210
+ printf " Directory with reference compilation/execution files not found for compiler: '$cxx_compiler ' at $exec_out_dir \n\n"
181
211
exit 2
182
212
fi
183
213
@@ -197,8 +227,8 @@ regression_test_link_obj=""
197
227
if [[ " $cxx_compiler " == * " cl.exe" * ]]; then
198
228
echo " Building std and std.compat modules"
199
229
(cd $exec_out_dir ; \
200
- cl.exe -nologo -std:c++latest -MD -EHsc -c " ${VCToolsInstallDir} /modules/std.ixx" ;
201
- cl.exe -nologo -std:c++latest -MD -EHsc -c " ${VCToolsInstallDir} /modules/std.compat.ixx" )
230
+ cl.exe -nologo -std:${cxx_std} -MD -EHsc -c " ${VCToolsInstallDir} /modules/std.ixx" ;
231
+ cl.exe -nologo -std:${cxx_std} -MD -EHsc -c " ${VCToolsInstallDir} /modules/std.compat.ixx" )
202
232
regression_test_link_obj=" std.obj std.compat.obj"
203
233
fi
204
234
0 commit comments