Skip to content

Commit

Permalink
Fixes skupperproject#343 - compile C++ tests with -fno-strict-aliasing
Browse files Browse the repository at this point in the history
  • Loading branch information
jiridanek committed Apr 19, 2022
1 parent 2c27ff0 commit 078f178
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion tests/c_benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ find_package(benchmark REQUIRED)
# need -Wno-pedantic, for two reasons:
# incompatibility in older libbenchmark, https://github.com/google/benchmark/issues/494#issuecomment-502444478
# PRIu64 macros without spaces around are invalid C++ (c.f. the C++11 value suffixes feature)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD_FLAGS} ${SANITIZE_FLAGS} -Wno-pedantic -Wno-unused-function")
# -fno-strict-aliasing: struct in C++ defines a type, causing a double definition (see issue #343)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD_FLAGS} ${SANITIZE_FLAGS} -Wno-pedantic -Wno-unused-function -fno-strict-aliasing")

add_executable(c-benchmarks
../c_unittests/helpers.cpp
Expand Down
3 changes: 2 additions & 1 deletion tests/c_unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

# -fno-inline: just to be extra sure, no particular reason so far
# -fno-builtin: GCC would optimize e.g. abs() and we would not be able to stub
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD_FLAGS} -fno-inline -fno-builtin -fno-stack-protector")
# -fno-strict-aliasing: struct in C++ defines a type, causing a double definition (see issue #343)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD_FLAGS} -fno-inline -fno-builtin -fno-stack-protector -fno-strict-aliasing")
# DISPATCH-2196 Linking object files containing instances of the same C++ template fails on s390x with sanitizers enabled
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "s390x")
# set the sanitizer flags only for linking, not for compilation; this workarounds the failure
Expand Down

0 comments on commit 078f178

Please sign in to comment.