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

docs: add documentation for AddressSanitizer on MSVC #4161

Merged
merged 2 commits into from
Nov 18, 2022

Conversation

Nerixyz
Copy link
Contributor

@Nerixyz Nerixyz commented Nov 17, 2022

Pull request checklist:

  • CHANGELOG.md was updated, if applicable

Description

Initially I wanted to enable ASan in tests as well, but this just won't work (which is really sad), because ASan doesn't like the Settings. At least it can be documented how one enables ASan with MSVC now, since sanitizers-cmake doesn't cover MSVC.

@pajlada
Copy link
Member

pajlada commented Nov 18, 2022

@Nerixyz Could you try the -DSANITIZE_ADDRESS=On flag to cmake and see if that works as expected (or at least as good as the current recommentation in your documentation?)

@Nerixyz
Copy link
Contributor Author

Nerixyz commented Nov 18, 2022

@Nerixyz Could you try the -DSANITIZE_ADDRESS=On flag to cmake and see if that works as expected (or at least as good as the current recommentation in your documentation?)

I probably should've made that clearer in my original comment. sanitizers-cmake (the project used to supply the CMake flags for sanitizers) mainly supports GCC and Clang and has the flags to enable the sanitizers hardcoded. MSVC has these Microsofty-style flags in the form of /name=value, so it will fail:

-- Try MSVC AddressSanitizer flag = [-g -fsanitize=address -fno-omit-frame-pointer]
-- Performing Test ASan_FLAG_DETECTED
-- Performing Test ASan_FLAG_DETECTED - Failed
-- Try MSVC AddressSanitizer flag = [-g -fsanitize=address]
-- Performing Test ASan_FLAG_DETECTED
-- Performing Test ASan_FLAG_DETECTED - Failed
-- Try MSVC AddressSanitizer flag = [-g -faddress-sanitizer]
-- Performing Test ASan_FLAG_DETECTED
-- Performing Test ASan_FLAG_DETECTED - Failed
CMake Warning at cmake/sanitizers-cmake/cmake/sanitize-helpers.cmake:150 (message):
  AddressSanitizer is not available for MSVC compiler.  Targets using this
  compiler will be compiled without AddressSanitizer.
Call Stack (most recent call first):
  cmake/sanitizers-cmake/cmake/FindASan.cmake:46 (sanitizer_check_compiler_flags)
  cmake/sanitizers-cmake/cmake/FindSanitizers.cmake:37 (find_package)
  CMakeLists.txt:61 (find_package)


-- Try  AddressSanitizer flag = [-g -fsanitize=address -fno-omit-frame-pointer]
-- Try  AddressSanitizer flag = [-g -fsanitize=address]
-- Try  AddressSanitizer flag = [-g -faddress-sanitizer]
CMake Warning at cmake/sanitizers-cmake/cmake/sanitize-helpers.cmake:150 (message):
  AddressSanitizer is not available for compiler.  Targets using this
  compiler will be compiled without AddressSanitizer.
Call Stack (most recent call first):
  cmake/sanitizers-cmake/cmake/FindASan.cmake:46 (sanitizer_check_compiler_flags)
  cmake/sanitizers-cmake/cmake/FindSanitizers.cmake:37 (find_package)
  CMakeLists.txt:61 (find_package)

@pajlada pajlada enabled auto-merge (squash) November 18, 2022 17:06
@pajlada pajlada merged commit 79a36e7 into Chatterino:master Nov 18, 2022
@Nerixyz Nerixyz deleted the docs/msvc-asan branch November 18, 2022 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants