Skip to content

CI: Add Clang 15 support in regression tests #974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/regression-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,26 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
compiler: [g++-10, g++-13]
compiler: [g++-10, g++-13, clang++-15]
include:
- os: ubuntu-20.04
compiler: clang++-12
- os: macos-13
compiler: clang++
- os: macos-13
compiler: clang++-15
- os: windows-latest
compiler: cl.exe
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Prepare compilers
if: matrix.os == 'macos-13'
run: |
sudo xcode-select --switch /Applications/Xcode_14.3.1.app
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Explanation] The path is taken from here.

sudo ln -s "$(brew --prefix llvm@15)/bin/clang" /usr/local/bin/clang++-15

- name: Run regression tests - Linux and macOS version
if: startsWith(matrix.os, 'ubuntu') || matrix.os == 'macos-13'
run: |
Expand Down
26 changes: 17 additions & 9 deletions regression-tests/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,31 +129,39 @@ if [[ "$cxx_compiler" == *"cl.exe"* ]]; then
exec_out_dir="$expected_results_dir/msvc-2022"
compiler_version=$(cl.exe)
else
compiler_cmd="$cxx_compiler -I../../../include -std=c++20 -pthread -o "
compiler_version=$("$cxx_compiler" --version)

# We don't currently support Apple Clang 15 so try and switch to 14
if [[ "$compiler_version" == *"Apple clang version 15.0"* ]]; then
printf "Found Apple Clang 15, attempting to switch to Apple Clang 14"
cxx_compiler=$(xcodebuild -find clang++)
compiler_version=$("$cxx_compiler" --version)
# Verify the compiler command
which "$cxx_compiler" > /dev/null
if [[ $? != 0 ]]; then
printf "The compiler '$cxx_compiler' is not installed\n\n"
exit 2
fi

if [[ "$compiler_version" == *"Apple clang version 14.0"* ]]; then
cpp_std=c++2b
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests should be run with C++20.
This makes it not do so, right?
We can't even have tests for C++23 (e.g., see commit 76f6d52).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry, I didn't know. The confusion came from the fact that pure2-assert-expected-not-null.cpp2 uses std::expected which is a C++-23 feature. I also saw PRs adding more support for std::expected to cppfront.
All tests currently only work for MSVC which uses c++latest. This seems to mean C++23 (at least for std implementation) given that the test with std::expected does compile. As I mentioned it the PR description using c++2b makes this test compile and work for GCC 13 as well.
As you can see from the fact that all the GitHub actions succeed, c++2b works for all compilers on Ubuntu 2204 for the current tests. Only GCC 10 doesn't support that option. Clang 15 also has problems with this option but this seems to be a GitHub runner issue.
Given that it is 2024 already and C++26 is WIP I think it makes a lot of sense to start using C++23 features for compilers that support them and look into compilers that support even more of them.
This PR allows to select the C++ standard used for each compiler.
It is already the case that compilation issues are committed as expected test results for certain compilers. The test scripts lists all such cases at the end. In fact, currently no compiler on POSIX platforms can compile the lowered code for all the tests. I would argue it will be very hard for a future-oriented project like cppfront to either only support older features or support newer features but not to have tests of that support.
All that being said, I believe this is @hsutter's call in the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hsutter I you are OK with compiling all regression tests with c++2b for compilers that support that this PR is ready for merging, I you prefer to revert to c++20 I can do that.

compiler_version=$("$cxx_compiler" --version)

if [[ "$compiler_version" == *"Apple clang version 14.0"* ||
"$compiler_version" == *"Homebrew clang version 15.0"* ]]; then
exec_out_dir="$expected_results_dir/apple-clang-14"
elif [[ "$compiler_version" == *"clang version 12.0"* ]]; then
exec_out_dir="$expected_results_dir/clang-12"
elif [[ "$compiler_version" == *"clang version 15.0"* ]]; then
exec_out_dir="$expected_results_dir/clang-15"
# c++2b causes starge issues on GitHub ubuntu-latest runner
cpp_std="c++20"
elif [[ "$compiler_version" == *"g++-10"* ]]; then
exec_out_dir="$expected_results_dir/gcc-10"
# GCC 10 does not support c++2b
cpp_std=c++20
elif [[ "$compiler_version" == *"g++-12"* ||
"$compiler_version" == *"g++-13"*
]]; then
exec_out_dir="$expected_results_dir/gcc-13"
else
printf "Unhandled compiler version:\n$compiler_version\n\n"
exit 2
fi

compiler_cmd="$cxx_compiler -I../../../include -std=$cpp_std -pthread -o "
fi

if [[ -d "$exec_out_dir" ]]; then
Expand Down
4 changes: 4 additions & 0 deletions regression-tests/test-results/clang-15/clang-version.output
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Ubuntu clang version 15.0.7
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello world
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
v as X< 0> = 0
v as X< 1> = 1
v as X< 2> = 2
v as X< 3> = 3
v as X< 4> = 4
v as X< 5> = 5
v as X< 6> = 6
v as X< 7> = 7
v as X< 8> = 8
v as X< 9> = 9
v as X<10> = 10
v as X<11> = 11
v as X<12> = 12
v as X<13> = 13
v as X<14> = 14
v as X<15> = 15
v as X<16> = 16
v as X<17> = 17
v as X<18> = 18
v as X<19> = 19
as_const(v) as X< 0> = 0
as_const(v) as X< 1> = 1
as_const(v) as X< 2> = 2
as_const(v) as X< 3> = 3
as_const(v) as X< 4> = 4
as_const(v) as X< 5> = 5
as_const(v) as X< 6> = 6
as_const(v) as X< 7> = 7
as_const(v) as X< 8> = 8
as_const(v) as X< 9> = 9
as_const(v) as X<10> = 10
as_const(v) as X<11> = 11
as_const(v) as X<12> = 12
as_const(v) as X<13> = 13
as_const(v) as X<14> = 14
as_const(v) as X<15> = 15
as_const(v) as X<16> = 16
as_const(v) as X<17> = 17
as_const(v) as X<18> = 18
as_const(v) as X<19> = 19
move(v) as X< 0> = 0
move(v) as X< 1> = 1
move(v) as X< 2> = 2
move(v) as X< 3> = 3
move(v) as X< 4> = 4
move(v) as X< 5> = 5
move(v) as X< 6> = 6
move(v) as X< 7> = 7
move(v) as X< 8> = 8
move(v) as X< 9> = 9
move(v) as X<10> = 10
move(v) as X<11> = 11
move(v) as X<12> = 12
move(v) as X<13> = 13
move(v) as X<14> = 14
move(v) as X<15> = 15
move(v) as X<16> = 16
move(v) as X<17> = 17
move(v) as X<18> = 18
move(v) as X<19> = 19
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bounds safety violation: out of bounds access attempt detected - attempted access at index 5, [min,max] range is [0,4]
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1
44
45
46
5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bounds safety violation
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
hello
2022
hello-ish
2022-ish
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
true
false
"test.exe"
true
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
123
123
123
123
123
123
123456
123
123
123
123
123
123
123456
123456
123456
456
456
1e+10
1e+10
1e-10
1e-10
1e-10
1e-10
1e-10
1e-10
1e-10
123456
123456
456
456
1e+10
1e+10
1e-10
1e-10
1e-10
1e-10
1e-10
1e-10
1e-10
123
123
123
123
123
123
123456
123
123
123
123
123
123
123456
123456
456
1e+10
1e+10
1e-10
1e-10
1e-10
1e-10
1e-10
123456
456
1e+10
1e+10
1e-10
1e-10
1e-10
1e-10
1e-10
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
+X 1
+X 2
copy X 1
copy X 2
copy X 1
move X 2
+X 3
+X 4
copy X 3
copy X 4
move X 3
move X 4
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hello-ish maybe
2022-ish maybe
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
hello
2022
hello-ish
2022-ish
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
hello
2022
hello-ish
2022-ish
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

hello

2023
hello-ish
2023-ish
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

hello

2022
hello-ish
2022-ish
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello [world]
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
12234
12234
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Contract violation: fill: value must contain at least count elements
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
>> [xyzzy]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
inspected vec : std::vector
inspected arr : std::array
inspected var : std::variant
inspected myt : my_type
inspected vec : std::vector
inspected arr : std::array
inspected var : std::variant
inspected myt : my_type
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
i is between 11 and 20
less than 20
i is between 10 and 30
v is empty
v is empty
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
rev dodgson
(no match)
the answer
zero
plugh
zero
1 or 2
1 or 2
3
integer -42
xyzzy
3
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
>> hello
>> big
>> world
** ** **
>> [hello]
>> [big]
>> [world]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1 42
2 84
3 168
4 336
5 672
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sending error to my framework... [dynamic null dereference attempt detected]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
>> 42
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a is 10
b is xyzzy
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
enter main
enter f00
enter f01
+X 1
exit f01
-X 1
exit f00

enter f10
enter f11
enter f12
enter f13
enter f14
+X 2
exit f14
exit f13
exit f12
-X 2
exit f11
exit f10
exit main
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
42
exxxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
xyzzy and plugh
xyzzyplugh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
a = 2, b = (empty)
a^2 + b = 46
sv = my string_view
osv = (empty)
osv = string literal bound to optional string_view
var = (empty)
var = abracadabra
var = 2.718280
mypair = (12, 3.400000)
tup1 = (12)
tup2 = (12, 3.400000)
tup3 = (12, 3.400000, 456)
p = (first, (empty))
t = (3.140000, (empty), (empty))
vv = 0
vv = (1, 2.300000)
custom = (customize me - no cpp2::to_string overload exists for this type)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
1.1 is int? false
1 is int? true

s* is Shape? true
s* is Circle? true
s* is Square? false
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rain
rain
Loading