Skip to content

Commit

Permalink
Fix ASAN Builds (#921)
Browse files Browse the repository at this point in the history
* Do not build libcxx/libcxxabi when building llvm

* Update triplets for asan flags

* Remove unneeded flags for sanitizers

Co-authored-by: Eric Kilmer <[email protected]>
  • Loading branch information
artemdinaburg and ekilmer authored Mar 26, 2022
1 parent 209a5c5 commit d4dbbe4
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 20 deletions.
2 changes: 0 additions & 2 deletions ports/llvm-12/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
"compiler-rt",
"default-options",
"cxx-common-targets",
"libcxx",
"libcxxabi",
"mlir",
"tools",
"utils"
Expand Down
2 changes: 0 additions & 2 deletions ports/llvm-13/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
"compiler-rt",
"default-options",
"cxx-common-targets",
"libcxx",
"libcxxabi",
"mlir",
"tools",
"utils"
Expand Down
6 changes: 3 additions & 3 deletions triplets/arm64-osx-asan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ set(VCPKG_USE_SANITIZER "Address")

# If the following flags cause errors during build, you might need to manually
# ignore the PORT and check VCPKG_USE_SANITIZER
if(NOT PORT MATCHES "^((llvm)|(llvm-[0-9]+)|(upb))$")
set(VCPKG_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls -ffunction-sections -fdata-sections")
set(VCPKG_C_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls -ffunction-sections -fdata-sections")
if(NOT PORT MATCHES "^((upb))$")
set(VCPKG_CXX_FLAGS "-O1 -g -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls")
set(VCPKG_C_FLAGS "-O1 -g -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls")
endif()

# Always apply sanitizer to linker flags
Expand Down
11 changes: 7 additions & 4 deletions triplets/x64-linux-asan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ set(VCPKG_LIBRARY_LINKAGE static)
# ASAN
# Make sure this value matches up with https://llvm.org/docs/CMake.html "LLVM_USE_SANITIZER"
set(VCPKG_USE_SANITIZER "Address")

# If the following flags cause errors during build, you might need to manually
# ignore the PORT and check VCPKG_USE_SANITIZER
if(NOT PORT MATCHES "^((llvm)|(llvm-[0-9]+)|(upb))$")
set(VCPKG_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls -ffunction-sections -fdata-sections")
set(VCPKG_C_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls -ffunction-sections -fdata-sections")
set(VCPKG_LINKER_FLAGS "-fsanitize=address")
if(NOT PORT MATCHES "^((upb))$")
set(VCPKG_CXX_FLAGS "-O1 -g -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls")
set(VCPKG_C_FLAGS "-O1 -g -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls")
endif()

# Always apply sanitizer to linker flags
set(VCPKG_LINKER_FLAGS "-fsanitize=address")

set(VCPKG_CMAKE_SYSTEM_NAME Linux)
6 changes: 3 additions & 3 deletions triplets/x64-linux-rel-asan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ set(VCPKG_USE_SANITIZER "Address")

# If the following flags cause errors during build, you might need to manually
# ignore the PORT and check VCPKG_USE_SANITIZER
if(NOT PORT MATCHES "^((llvm)|(llvm-[0-9]+)|(upb))$")
set(VCPKG_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls -ffunction-sections -fdata-sections")
set(VCPKG_C_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls -ffunction-sections -fdata-sections")
if(NOT PORT MATCHES "^((upb))$")
set(VCPKG_CXX_FLAGS "-fsanitize=address -g -fno-omit-frame-pointer -fno-optimize-sibling-calls")
set(VCPKG_C_FLAGS "-fsanitize=address -g -fno-omit-frame-pointer -fno-optimize-sibling-calls")
endif()

# Always apply sanitizer to linker flags
Expand Down
6 changes: 3 additions & 3 deletions triplets/x64-osx-asan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ set(VCPKG_USE_SANITIZER "Address")

# If the following flags cause errors during build, you might need to manually
# ignore the PORT and check VCPKG_USE_SANITIZER
if(NOT PORT MATCHES "^((llvm)|(llvm-[0-9]+)|(upb))$")
set(VCPKG_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls -ffunction-sections -fdata-sections")
set(VCPKG_C_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls -ffunction-sections -fdata-sections")
if(NOT PORT MATCHES "^((upb))$")
set(VCPKG_CXX_FLAGS "-O1 -g -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls")
set(VCPKG_C_FLAGS "-O1 -g -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls")
set(VCPKG_LINKER_FLAGS "-fsanitize=address")
endif()

Expand Down
6 changes: 3 additions & 3 deletions triplets/x64-osx-rel-asan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ set(VCPKG_USE_SANITIZER "Address")

# If the following flags cause errors during build, you might need to manually
# ignore the PORT and check VCPKG_USE_SANITIZER
if(NOT PORT MATCHES "^((llvm)|(llvm-[0-9]+)|(upb))$")
set(VCPKG_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls -ffunction-sections -fdata-sections")
set(VCPKG_C_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls -ffunction-sections -fdata-sections")
if(NOT PORT MATCHES "^((upb))$")
set(VCPKG_CXX_FLAGS "-fsanitize=address -g -fno-omit-frame-pointer -fno-optimize-sibling-calls")
set(VCPKG_C_FLAGS "-fsanitize=address -g -fno-omit-frame-pointer -fno-optimize-sibling-calls")
endif()

# Always apply sanitizer to linker flags
Expand Down

0 comments on commit d4dbbe4

Please sign in to comment.