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

Fix sanitizer on win #1132

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,18 @@ jobs:
aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DUSE_CPU_EXTENSIONS=OFF

windows:
windows-sanitizer:
runs-on: windows-2022 # latest
steps:
- name: Setup MSVC dev env (san, etc...)
uses: TheMrMilchmann/setup-msvc-dev@v3
with:
arch: x64
# note: default sanitizer pair is address,undefined. win currently only supports address.
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')"
python builder.pyz build -p ${{ env.PACKAGE_NAME }}
python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DENABLE_SANITIZERS=ON

windows-vc16:
runs-on: windows-2022 # latest
Expand Down
14 changes: 12 additions & 2 deletions cmake/AwsSanitizers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,18 @@ function(aws_add_sanitizers target)
endforeach()

if(PRESENT_SANITIZERS)
target_compile_options(${target} PRIVATE -fno-omit-frame-pointer -fsanitize=${PRESENT_SANITIZERS})
target_link_libraries(${target} PUBLIC "-fno-omit-frame-pointer -fsanitize=${PRESENT_SANITIZERS}")
if(MSVC)
if(AWS_ARCH_INTEL_X64)
target_compile_options(${target} PRIVATE -fsanitize=${PRESENT_SANITIZERS})
target_link_libraries(${target} PRIVATE clang_rt.asan_dynamic-x86_64 clang_rt.asan_dynamic_runtime_thunk-x86_64)
else()
message("On Win platforms sanitizer is only supported on x86-64")
return()
endif()
else()
target_compile_options(${target} PRIVATE -fno-omit-frame-pointer -fsanitize=${PRESENT_SANITIZERS})
target_link_libraries(${target} PUBLIC "-fsanitize=${PRESENT_SANITIZERS}")
endif()

string(REPLACE "," ";" PRESENT_SANITIZERS "${PRESENT_SANITIZERS}")
set(${target}_SANITIZERS ${PRESENT_SANITIZERS} PARENT_SCOPE)
Expand Down
Loading