Skip to content

Commit d856abd

Browse files
authored
Merge pull request #270 from FeignClaims/fix/undef_fortify_source
fix: undef _FORTIFY_SOURCE before setting
2 parents 3e5ba3a + 8a526b6 commit d856abd

3 files changed

Lines changed: 5 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@ jobs:
4040
- os: "windows-2022"
4141
compiler: "msvc"
4242
vcvarsall: false
43-
- os: "macos-11"
44-
compiler: "gcc"
45-
cmake: true
46-
vcvarsall: true
47-
- os: "macos-13"
48-
compiler: "gcc"
49-
cmake: true
50-
vcvarsall: true
5143
exclude:
5244
# fails with an internal error
5345
- os: "macos-12"

src/Hardening.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function(
4444
list(APPEND HARDENING_COMPILE_OPTIONS -Wstringop-overflow=4 -Wformat-overflow=2)
4545
endif()
4646

47-
target_compile_definitions(${_project_name} INTERFACE $<$<CONFIG:Release,RelWithDebInfo>:_FORTIFY_SOURCE=3>)
47+
target_compile_options(${_project_name} INTERFACE $<$<CONFIG:Release,RelWithDebInfo>:-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3>)
4848
endif()
4949

5050
if(${ENABLE_ELF_PROTECTION})

tests/myproj/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ project_options(
8888
# CLANG_WARNINGS "-Weverything"
8989
LINKER
9090
"${LINKER}"
91+
92+
# Test if _FORTIFY_SOURCE is defined only once when ENABLE_OVERFLOW_PROTECTION
93+
ENABLE_OVERFLOW_PROTECTION
94+
CLANG_TIDY_EXTRA_ARGUMENTS "-warnings-as-errors=clang-diagnostic-macro-redefined"
9195
)
9296
# NOTE: project_options and project_warnings are defined inside project_options
9397

0 commit comments

Comments
 (0)