Skip to content

Commit

Permalink
Merge pull request #1393 from aleksisch:partly_support_gcc
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 694211043
  • Loading branch information
copybara-github committed Nov 7, 2024
2 parents e2df071 + e2987d3 commit b19cc13
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/cmake_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install -yq \
ccache clang cmake ninja-build libprotobuf-dev protobuf-compiler
ccache clang gcc g++ cmake ninja-build libprotobuf-dev protobuf-compiler
- name: Restore latest cache
uses: actions/cache/restore@v4
with:
Expand All @@ -63,9 +63,10 @@ jobs:
-D CMAKE_C_COMPILER_LAUNCHER=ccache \
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache \
-D CMAKE_BUILD_TYPE=RelWithDebug \
-D FUZZTEST_REPO="${{ github.repository }}" \
-D FUZZTEST_REPO_BRANCH="${{ github.head_ref || github.ref_name }}" \
&& cmake --build build_codelab -j $(nproc)
- name: Run all tests in default mode
- name: Run all tests in default mode with clang
if: matrix.mode == 'default'
run: |
CC=clang CXX=clang++ cmake \
Expand All @@ -78,6 +79,20 @@ jobs:
-D FUZZTEST_BUILD_TESTING=on \
&& cmake --build build -j $(nproc) \
&& ctest --test-dir build -j $(nproc) --output-on-failure
- name: Run all tests in default mode with gcc
if: matrix.mode == 'default'
run: |
CC=gcc CXX=g++ cmake \
-S . \
-B build_gcc \
-G Ninja \
-D CMAKE_C_COMPILER_LAUNCHER=ccache \
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache \
-D CMAKE_BUILD_TYPE=RelWithDebug \
-D FUZZTEST_BUILD_TESTING=on \
&& cmake --build build_gcc -j $(nproc)
# TODO: Rewrite helper `PrintValue` to obtain same output under clang and gcc
# && ctest --test-dir build_gcc -j $(nproc) --output-on-failure
- name: Run end-to-end tests in fuzzing mode
if: matrix.mode == 'fuzzing'
run: |
Expand Down
5 changes: 3 additions & 2 deletions codelab/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ set(CMAKE_CXX_STANDARD 17)

include(FetchContent)

set(FUZZTEST_REPO "FuzzTest repository." CACHE STRING "google/fuzztest")
set(FUZZTEST_REPO_BRANCH "FuzzTest repository branch." CACHE STRING "main")
message("Building fuzztest at branch " ${FUZZTEST_REPO_BRANCH})
message("Building fuzztest from ${FUZZTEST_REPO} at branch " ${FUZZTEST_REPO_BRANCH})

FetchContent_Declare(
fuzztest
GIT_REPOSITORY https://github.com/google/fuzztest.git
GIT_REPOSITORY https://github.com/${FUZZTEST_REPO}.git
GIT_TAG ${FUZZTEST_REPO_BRANCH}
)

Expand Down
6 changes: 4 additions & 2 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-coverage=0")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-coverage=0")
if (NOT COMPILER_GCC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-coverage=0")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-coverage=0")
endif()

### Libraries

Expand Down
8 changes: 6 additions & 2 deletions fuzztest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ include_directories(${PARENT_DIR})

add_subdirectory(grammars)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-coverage=0")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-coverage=0")

if (NOT COMPILER_GCC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-coverage=0")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-coverage=0")
endif()


fuzztest_cc_library(
NAME
Expand Down

0 comments on commit b19cc13

Please sign in to comment.