Skip to content

fail builds in CI on compiler warnings #389

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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
22 changes: 15 additions & 7 deletions .github/workflows/CI-unixish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,18 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install libc++-18-dev


# coreutils contains "nproc"
- name: Install missing software on macos
if: contains(matrix.os, 'macos')
run: |
brew install coreutils

# TODO: bail out on warning
- name: make simplecpp
run: make -j$(nproc)

# TODO: bail out on warning
- name: make test
run: make -j$(nproc) test

Expand All @@ -43,7 +51,7 @@ jobs:

- name: Run CMake
run: |
cmake -S . -B cmake.output
cmake -S . -B cmake.output -DCMAKE_COMPILE_WARNING_AS_ERROR=On

- name: CMake simplecpp
run: |
Expand All @@ -66,31 +74,31 @@ jobs:
if: matrix.os == 'ubuntu-24.04' && matrix.compiler == 'g++'
run: |
make clean
make -j$(nproc) test selfcheck CXXFLAGS="-g3 -D_GLIBCXX_DEBUG"
make -j$(nproc) test selfcheck CXXFLAGS="-Werror -Wno-multichar -g3 -D_GLIBCXX_DEBUG"

- name: Run with libc++ hardening mode
if: matrix.os == 'ubuntu-24.04' && matrix.compiler == 'clang++'
run: |
make clean
make -j$(nproc) test selfcheck CXXFLAGS="-stdlib=libc++ -g3 -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG" LDFLAGS="-lc++"
make -j$(nproc) test selfcheck CXXFLAGS="-Werror -Wno-multichar -stdlib=libc++ -g3 -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG" LDFLAGS="-lc++"

- name: Run AddressSanitizer
if: matrix.os == 'ubuntu-24.04'
run: |
make clean
make -j$(nproc) test selfcheck CXXFLAGS="-O2 -g3 -fsanitize=address" LDFLAGS="-fsanitize=address"
make -j$(nproc) test selfcheck CXXFLAGS="-Werror -Wno-multichar -O2 -g3 -fsanitize=address" LDFLAGS="-fsanitize=address"
env:
ASAN_OPTIONS: detect_stack_use_after_return=1

- name: Run UndefinedBehaviorSanitizer
if: matrix.os == 'ubuntu-24.04'
run: |
make clean
make -j$(nproc) test selfcheck CXXFLAGS="-O2 -g3 -fsanitize=undefined -fno-sanitize=signed-integer-overflow" LDFLAGS="-fsanitize=undefined -fno-sanitize=signed-integer-overflow"
make -j$(nproc) test selfcheck CXXFLAGS="-Werror -Wno-multichar -O2 -g3 -fsanitize=undefined -fno-sanitize=signed-integer-overflow" LDFLAGS="-fsanitize=undefined -fno-sanitize=signed-integer-overflow"

# TODO: requires instrumented libc++
- name: Run MemorySanitizer
if: false && matrix.os == 'ubuntu-24.04' && matrix.compiler == 'clang++'
run: |
make clean
make -j$(nproc) test selfcheck CXXFLAGS="-O2 -g3 -stdlib=libc++ -fsanitize=memory" LDFLAGS="-lc++ -fsanitize=memory"
make -j$(nproc) test selfcheck CXXFLAGS="-Werror -Wno-multichar -O2 -g3 -stdlib=libc++ -fsanitize=memory" LDFLAGS="-lc++ -fsanitize=memory"
6 changes: 4 additions & 2 deletions .github/workflows/CI-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@ jobs:
- name: Run cmake
if: matrix.os == 'windows-2019'
run: |
cmake -G "Visual Studio 16 2019" -A x64 . || exit /b !errorlevel!
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_COMPILE_WARNING_AS_ERROR=On . || exit /b !errorlevel!

- name: Run cmake
if: matrix.os == 'windows-2022'
run: |
cmake -G "Visual Studio 17 2022" -A x64 . || exit /b !errorlevel!
cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_COMPILE_WARNING_AS_ERROR=On . || exit /b !errorlevel!

- name: Build
run: |
msbuild -m simplecpp.sln /p:Configuration=${{ matrix.config }} /p:Platform=x64 || exit /b !errorlevel!
env:
_CL_: /WX

- name: Test
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

- name: Prepare CMake
run: |
cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DDISABLE_CPP03_SYNTAX_CHECK=ON
cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DDISABLE_CPP03_SYNTAX_CHECK=ON
env:
CXX: clang-19

Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ endfunction()

if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
add_compile_options(-Wall -Wextra -pedantic -Wcast-qual -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wredundant-decls -Wshadow -Wundef -Wold-style-cast -Wno-multichar)
add_compile_options(-Wno-shadow) # TODO: fix these
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Expand All @@ -38,6 +39,10 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# TODO: fix these?
add_compile_options(-Wno-padded -Wno-sign-conversion -Wno-implicit-int-conversion -Wno-shorten-64-to-32 -Wno-shadow-field-in-constructor)

if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
add_compile_options(-Wno-c++11-long-long)
endif()

if (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 14 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 14)
# TODO: verify this regression still exists in clang-15
if (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
Expand Down
Loading