Skip to content
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

build: check the combination of Sanitizers #2408

Merged
merged 1 commit into from
Sep 11, 2024

Conversation

tchaikov
Copy link
Contributor

@tchaikov tchaikov commented Aug 27, 2024

we are going to add a build with ThreadSanitizer enabled, but ThreadSanitizer cannot be used along with AddressSanitizer. the existing sanitizer detection checks each sanitizer separately, so even if the sanitizers combination does not work, the detection still passes.

also, we hardwire two sanitizers in FindSanitizers.cmake, this is not extensible to the use case where we only need to selectively find a certain (combination) of sanitizers.

in order to address these problems, in this change

  • find specified component(s) in FindSanitizers.cmake, to prepare for the change which selectively specifies a subset of sanitizers
  • check if the compiler supports the combination of compile options required by all specified sanitizers
  • explicitly specify the used sanitizers in SeastarDependencies.cmake.

@tchaikov tchaikov force-pushed the find-sanitizer branch 2 times, most recently from 2c2136e to fa285ae Compare August 27, 2024 06:07
@tchaikov tchaikov force-pushed the find-sanitizer branch 2 times, most recently from 232aa02 to c50d312 Compare August 28, 2024 00:48
@tchaikov tchaikov changed the title build: check combination of Sanitizers build: check the combination of Sanitizers Aug 28, 2024
set(Sanitizers_FIND_COMPONENTS
address
undefined_behavior)
endif()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this preserves the backward compatibility if some parent projects use find_package(Sanitizers) without specifying the COMPONENTS parameter.

elseif (component STREQUAL "undefined_behavior")
list (APPEND ${compile_options} -fsanitize=undefined)
# Disable vptr because of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88684
list (APPEND ${compile_options} -fno-sanitize=vptr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this was fixed in gcc 10 (or perhaps 9?) - gcc-mirror/gcc@c24847a so we can drop it later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure. will do in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created #2430

seastar_set_dep_args (Sanitizers
COMPONENTS
address
undefined_behavior)
seastar_set_dep_args (ucontext REQUIRED)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this complexity typical for projects that use sanitizers? I don't mind merging it, but isn't cmake supposed to do this for us?

The code is incomprehensible to me.

Copy link
Contributor Author

@tchaikov tchaikov Sep 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wanted to make it explicit. yes, it's taken care of. see #2408 (comment) . but with #2406, we will need to specify it anyway. probably not in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anyway, i dropped this change in the latest revision.

we are going to add a build with ThreadSanitizer enabled, but
ThreadSanitizer cannot be used along with AddressSanitizer. the
existing sanitizer detection checks each sanitizer separately, so
even if the sanitizers combination does not work, the detection
still passes.

also, we hardwire two sanitizers in `FindSanitizers.cmake`, this
is not extensible to the use case where we only need to selectively
find a certain (combination) of sanitizers.

in order to address these problems, in this change

* find specified component(s) in FindSanitizers.cmake, to prepare for
  the change which selectively specifies a subset of sanitizers
* check if the compiler supports the combination of compile options
  required by all specified sanitizers

Signed-off-by: Kefu Chai <[email protected]>
@tchaikov
Copy link
Contributor Author

tchaikov commented Sep 2, 2024

@avikivity mind taking another look?

@tchaikov
Copy link
Contributor Author

tchaikov commented Sep 2, 2024

v2:

  • do not specify the "COMPONENTS" for Sanitizers in cmake/SeastarDependencies.cmake

@tchaikov
Copy link
Contributor Author

tchaikov commented Sep 7, 2024

@scylladb/seastar-maint and @avikivity could you help review this change?

@avikivity avikivity merged commit ed88919 into scylladb:master Sep 11, 2024
14 checks passed
@tchaikov tchaikov deleted the find-sanitizer branch September 11, 2024 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants