Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
48794ffd
Commit
48794ffd
authored
5 years ago
by
David Fairbrother
Browse files
Options
Downloads
Patches
Plain Diff
Switch to generator expressions for sanitizer flags
parent
14251c1d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
buildconfig/CMake/Sanitizers.cmake
+19
-33
19 additions, 33 deletions
buildconfig/CMake/Sanitizers.cmake
with
19 additions
and
33 deletions
buildconfig/CMake/Sanitizers.cmake
+
19
−
33
View file @
48794ffd
...
...
@@ -9,12 +9,6 @@ set_property(CACHE USE_SANITIZER PROPERTY STRINGS
string
(
TOLOWER
"
${
USE_SANITIZER
}
"
USE_SANITIZERS_LOWER
)
if
(
NOT
${
USE_SANITIZERS_LOWER
}
MATCHES
"off"
)
if
(
${
CMAKE_VERSION
}
VERSION_LESS
"3.13.0"
)
# Version 13 is needed for add_link_options, but not all platforms
# currently have it
message
(
FATAL_ERROR
"CMake 3.13 onwards is required to run the sanitizers"
)
endif
()
if
(
WIN32
)
message
(
FATAL_ERROR
"Windows does not support sanitizers"
)
endif
()
...
...
@@ -39,32 +33,24 @@ if(NOT ${USE_SANITIZERS_LOWER} MATCHES "off")
# Allow all instrumented code to continue beyond the first error
add_compile_options
(
-fsanitize-recover=all
)
# N.b. we can switch this to add_link_options in CMake 3.13
# rather than have to check the linker options etc
if
(
USE_SANITIZERS_LOWER STREQUAL
"address"
)
message
(
STATUS
"Enabling address sanitizer"
)
add_compile_options
(
-fsanitize=address
)
add_link_options
(
-fsanitize=address
)
elseif
(
USE_SANITIZERS_LOWER STREQUAL
"thread"
)
message
(
STATUS
"Enabling Thread sanitizer"
)
add_compile_options
(
-fsanitize=thread
)
add_link_options
(
-fsanitize=thread
)
elseif
(
USE_SANITIZERS_LOWER STREQUAL
"undefined"
)
message
(
STATUS
"Enabling undefined behaviour sanitizer"
)
add_compile_options
(
-fsanitize=undefined
# RTTI information is not exported for some classes causing the
# linker to fail whilst adding vptr instrumentation
-fno-sanitize=vptr
)
add_link_options
(
-fsanitize=undefined
)
else
()
message
(
FATAL_ERROR
"Unrecognised Sanitizer Option"
)
endif
()
# Address
add_compile_options
(
$<$<STREQUAL:$<LOWER_CASE:
${
USE_SANITIZER
}
>,
"address"
>:-fsanitize=address>
)
add_link_options
(
$<$<STREQUAL:$<LOWER_CASE:
${
USE_SANITIZER
}
>,
"address"
>:-fsanitize=address>
)
# Thread
add_compile_options
(
$<$<STREQUAL:$<LOWER_CASE:
${
USE_SANITIZER
}
>,
"thread"
>:-fsanitize=thread>
)
add_link_options
(
$<$<STREQUAL:$<LOWER_CASE:
${
USE_SANITIZER
}
>,
"thread"
>:-fsanitize=thread>
)
# Undefined
# RTTI information is not exported for some classes causing the
# linker to fail whilst adding vptr instrumentation
add_compile_options
(
$<$<STREQUAL:$<LOWER_CASE:
${
USE_SANITIZER
}
>,
"undefined"
>:-fsanitize=undefined -fno-sanitize=vptr>
)
add_link_options
(
$<$<STREQUAL:$<LOWER_CASE:
${
USE_SANITIZER
}
>,
"undefined"
>:-fsanitize=undefined>
)
endif
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment