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

Add vcpkg triplets for ASAN. #4515

Merged
merged 24 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b481312
Add triplets for ASAN.
teo-tsirpanis Nov 9, 2023
a2dc1ca
Rename `macos` to `osx` in the triplet names.
teo-tsirpanis Nov 13, 2023
385c2fc
Bump vcpkg to a version that has the Apple architecture detection fixed.
teo-tsirpanis Nov 13, 2023
8ae406a
Fix OS detection.
teo-tsirpanis Nov 14, 2023
f219fdb
Merge branch 'dev' into asan-triplets
teo-tsirpanis Nov 17, 2023
fe5643e
Add a license header to TileDBToolchain.cmake.
teo-tsirpanis Nov 17, 2023
a53ab27
Import the Sanitizer module from #2392.
teo-tsirpanis Nov 17, 2023
b369878
Change the sanitizer module to set compiler options globally.
teo-tsirpanis Nov 17, 2023
5c7e0da
Allow only address sanitizer.
teo-tsirpanis Nov 17, 2023
2c7bf01
Refactor the sanitizer module to use generator expressions, and move …
teo-tsirpanis Nov 23, 2023
39070c7
Merge branch 'dev' into asan-triplets
teo-tsirpanis Nov 27, 2023
7869ffc
Try finding an ASAN-compatible triplet.
teo-tsirpanis Nov 28, 2023
9dd3bf9
Add options in the bootstrap script to specify the vcpkg triplet.
teo-tsirpanis Nov 28, 2023
cc1d88d
Add instructions in the contributor's guide to build with sanitizers.
teo-tsirpanis Nov 29, 2023
2e847eb
Set the triplet on the ASAN CI job.
teo-tsirpanis Nov 29, 2023
3104863
Fix CI.
teo-tsirpanis Nov 29, 2023
3031337
Pass `-fsanitize` in the linker to GCC as well.
teo-tsirpanis Nov 29, 2023
c83ceb0
Merge branch 'dev' into asan-triplets
teo-tsirpanis Dec 18, 2023
f9d1cc6
Rename the `SANITIZER` variable to `TILEDB_SANITIZER` and add it in t…
teo-tsirpanis Dec 18, 2023
d7d51d3
Add a "vcpkg base triplet" option that is required when building with…
teo-tsirpanis Dec 18, 2023
3b2e13c
Update documentation.
teo-tsirpanis Dec 18, 2023
425fd62
Add a notice that sanitizer builds should be placed in their own buil…
teo-tsirpanis Dec 18, 2023
620699c
Fix typo.
teo-tsirpanis Dec 18, 2023
c94ded2
Update Sanitizer.cmake
teo-tsirpanis Dec 20, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/full-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
matrix_compiler_cc: 'gcc-10'
matrix_compiler_cxx: 'g++-10'
timeout: 120
bootstrap_args: '--enable-serialization'
bootstrap_args: '--enable-serialization --vcpkg-base-triplet=x64-linux'
asan: true

ci10:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/nightly-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- os: macos-latest
- os: macos-latest # ASAN build
sanitizer: "address"
base_triplet: "x64-osx"
- os: macos-latest
experimental: ON
- os: windows-latest
Expand Down Expand Up @@ -46,7 +47,7 @@ jobs:
EXPERIMENTAL: ${{ matrix.experimental || 'OFF' }}
working-directory: ${{ matrix.working_directory || github.workspace }}
run: |
cmake -B build ${{ matrix.config != 'Debug' && '-DTILEDB_VCPKG=OFF' }} -DTILEDB_WERROR=ON -DTILEDB_SERIALIZATION=ON -DTILEDB_EXPERIMENTAL_FEATURES=$EXPERIMENTAL -DCMAKE_BUILD_TYPE=${{ matrix.config || 'Release' }} -DSANITIZER=$SANITIZER_ARG
cmake -B build ${{ matrix.config != 'Debug' && '-DTILEDB_VCPKG=OFF' }} -DTILEDB_WERROR=ON -DTILEDB_SERIALIZATION=ON -DTILEDB_EXPERIMENTAL_FEATURES=$EXPERIMENTAL -DCMAKE_BUILD_TYPE=${{ matrix.config || 'Release' }} -DTILEDB_SANITIZER=$SANITIZER_ARG -DTILEDB_VCPKG_BASE_TRIPLET=${{ matrix.base_triplet }}

- name: Configure TileDB CMake (Windows)
if: contains(matrix.os, 'windows')
Expand Down
21 changes: 3 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Options")
include(CIConfig)
include(BuildOptions)
include(global-policies NO_POLICY_SCOPE)
include(Sanitizer)
include(TileDBToolchain)
include(Doxygen)
include(Format)
Expand Down Expand Up @@ -250,24 +251,8 @@ if (COMPILER_SUPPORTS_AVX2)
add_compile_options(${COMPILER_AVX2_FLAG})
endif()

# HACK: Set the sanitizer configuration globally after the
# superbuild has finished. We want to enable sanitization for
# TileDB, but not our dependencies.
#
# The reasoning for setting this globally is due to false positives
# in the `AddressSanitizerContainerOverflow` checks [1].
#
# [1] https://github.com/google/sanitizers/wiki/AddressSanitizerContainerOverflow#false-positives
if (SANITIZER)
string(TOLOWER ${SANITIZER} SANITIZER)
if (NOT SANITIZER MATCHES "^(address|memory|leak|thread|undefined)$")
message(FATAL_ERROR "Unknown clang sanitizer: ${SANITIZER})")
else()
message(STATUS "The TileDB library is compiled with sanitizer ${SANITIZER} enabled")
endif()
add_compile_options(-DTILEDB_SANITIZER=${SANITIZER})
add_compile_options(-g -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=${SANITIZER})
add_link_options(-fsanitize=${SANITIZER})
if(TILEDB_SANITIZER)
validate_sanitizer_options()
endif()

#######################################################
Expand Down
27 changes: 24 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,27 @@ Formatting conventions:
- comments are good, TileDB uses [doxygen](http://www.stack.nl/~dimitri/doxygen/manual/docblocks.html) for class doc strings.
- format code using [clang-format](https://clang.llvm.org/docs/ClangFormat.html)

### Building with sanitizers

TileDB can be built with [clang sanitizers](https://clang.llvm.org/docs/AddressSanitizer.html) enabled. To enable them, you have to bootstrap with the `--enable-sanitizer` flag, as well as the vcpkg base triplet corresponding to your platform. The following platforms support sanitizers:

* `arm64-osx`
* `x64-linux`
* `x64-osx`
* `x64-windows`

> [!NOTE]
> Currently only the `address` sanitizer is supported.

```bash
cd TileDB && mkdir build-asan && cd build-asan
../bootstrap --enable-sanitizer=address --vcpkg-base-triplet=x64-linux
make && make check
```

> [!IMPORTANT]
> To avoid errors, building with sanitizers must be done in a separate build directory.

### Pull Requests:

- `dev` is the development branch, all PR’s should be rebased on top of the latest `dev` commit.
Expand All @@ -78,7 +99,7 @@ Formatting conventions:

- Submit a PR, writing a descriptive message. If a PR closes an open issue, reference the issue in the PR message (ex. If an issue closes issue number 10, you would write `closes #10`)

- Make sure CI (continuous integration) is passing for your PR -- click `Show all checks` in the pull request status box at the bottom of each PR page. The continous integration project pages will also list all recently-built PRs:
- Make sure CI (continuous integration) is passing for your PR -- click `Show all checks` in the pull request status box at the bottom of each PR page. The continuous integration project pages will also list all recently-built PRs:
- [Azure Pipelines](https://dev.azure.com/TileDB-Inc/CI/_build)

### Documentation Pull Requests:
Expand Down Expand Up @@ -107,8 +128,8 @@ This will install all the required packages in a Python virtual environment, and
- [Organization](https://github.com/TileDB-Inc/)


* Github / Git
* GitHub / Git
- [Git cheatsheet](https://services.github.com/on-demand/downloads/github-git-cheat-sheet/)
- [Github Documentation](https://help.github.com/)
- [GitHub Documentation](https://help.github.com/)
- [Forking a Repo](https://help.github.com/articles/fork-a-repo/)
- [More Learning Resources](https://help.github.com/articles/git-and-github-learning-resources/)
8 changes: 7 additions & 1 deletion bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Configuration:
--help print this message
--prefix=PREFIX install files in tree rooted at PREFIX
['"${default_prefix}"']
--vcpkg-base-triplet=TRIPLET vcpkg base triplet to use when building with sanitizers
--enable-vcpkg use vcpkg for downloading and building dependencies
--dependency=DIRs specify the dependencies at DIRs, separated by colon
['"${default_dependency}"']
Expand All @@ -52,6 +53,7 @@ Configuration:
--enable-static-tiledb enables building TileDB as a static library (deprecated, use --linkage=static)
--enable-sanitizer=SAN enable sanitizer (clang only)
(address|memory|leak|thread|undefined)
Must manually specify a vcpkg base triplet.
--enable-debug enable debug build
--enable-assertions enable assertions in compiled code
--enable-release-symbols enable create symbols for release build
Expand Down Expand Up @@ -88,6 +90,7 @@ Example:

# Parse arguments
prefix_dirs="${default_prefix}"
vcpkg_base_triplet=""
tiledb_vcpkg="ON"
dependency_dir="${default_dependency}"
sanitizer=""
Expand Down Expand Up @@ -119,6 +122,8 @@ while test $# != 0; do
case "$1" in
--prefix=*) dir=`arg "$1"`
prefix_dirs="$dir";;
--vcpkg-base-triplet=*) vcpkg_base_triplet=`arg "$1"`
vcpkg_base_triplet="-DTILEDB_VCPKG_BASE_TRIPLET=${vcpkg_base_triplet}";;
--enable-vcpkg) echo "Argument '--enable-vcpkg' is obsolete and will be removed in a future version. Vcpkg is now enabled by default."
tiledb_vcpkg="ON";;
--dependency=*) dir=`arg "$1"`
Expand Down Expand Up @@ -256,11 +261,12 @@ ${cmake} -DCMAKE_BUILD_TYPE=${build_type} \
-DTILEDB_WEBP=${tiledb_build_webp} \
-DTILEDB_FORCE_ALL_DEPS=${tiledb_force_all_deps} \
-DTILEDB_REMOVE_DEPRECATIONS=${tiledb_remove_deprecations} \
-DSANITIZER="${sanitizer}" \
-DTILEDB_SANITIZER="${sanitizer}" \
-DTILEDB_EXPERIMENTAL_FEATURES=${tiledb_experimental_features} \
-DTILEDB_TESTS_ENABLE_REST=${tiledb_tests_enable_rest} \
-DTILEDB_TESTS_AWS_S3_CONFIG=${tiledb_tests_aws_s3_config} \
${tiledb_disable_avx2} \
${vcpkg_base_triplet} \
"${source_dir}" || die "failed to configure the project"

echo 'bootstrap success. Run "make" to build, "make check" to test, or "make -C tiledb install" to install.'
12 changes: 11 additions & 1 deletion bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ develop TileDB.
.PARAMETER Prefix
Installs files in tree rooted at PREFIX (defaults to TileDB\dist).

.PARAMETER VcpkgBaseTriplet
Optionally specify the vcpkg target triplet, e.g. "x64-windows-release".
Defaults to automatically detecting it from the environment.

.PARAMETER Dependency
Semicolon separated list to binary dependencies.

Expand Down Expand Up @@ -117,6 +121,7 @@ https://github.com/TileDB-Inc/TileDB
[CmdletBinding()]
Param(
[string]$Prefix,
[string]$VcpkgBaseTriplet,
[string]$Dependency,
[string]$Linkage = "shared",
[string]$CMakeGenerator,
Expand Down Expand Up @@ -163,6 +168,11 @@ $DefaultPrefix = Join-Path $BinaryDirectory "dist"
# Choose the default dependency install prefix.
$DefaultDependency = $DefaultPrefix

# Set the vcpkg base triplet.
if ($VcpkgBaseTriplet.IsPresent) {
$VcpkgBaseTriplet = "-DTILEDB_VCPKG_BASE_TRIPLET=$VcpkgBaseTriplet"
}

# Set assertion mode
# No-op for a debug build.
$AssertionMode = "OFF"
Expand Down Expand Up @@ -327,7 +337,7 @@ if ($CMakeGenerator -eq $null) {

# Run CMake.
# We use Invoke-Expression so we can echo the command to the user.
$CommandString = "cmake -A X64 -DTILEDB_VCPKG=$UseVcpkg -DCMAKE_BUILD_TYPE=$BuildType -DCMAKE_INSTALL_PREFIX=""$InstallPrefix"" -DCMAKE_PREFIX_PATH=""$DependencyDir"" -DMSVC_MP_FLAG=""/MP$BuildProcesses"" -DTILEDB_ASSERTIONS=$AssertionMode -DTILEDB_VERBOSE=$Verbosity -DTILEDB_AZURE=$UseAzure -DTILEDB_S3=$UseS3 -DTILEDB_GCS=$UseGcs -DTILEDB_SERIALIZATION=$UseSerialization -DTILEDB_WERROR=$Werror -DTILEDB_CPP_API=$CppApi -DTILEDB_TESTS=$Tests -DTILEDB_STATS=$Stats -DBUILD_SHARED_LIBS=$BuildSharedLibs -DTILEDB_FORCE_ALL_DEPS=$TileDBBuildDeps -DTILEDB_REMOVE_DEPRECATIONS=$RemoveDeprecations -DTILEDB_TOOLS=$TileDBTools -DTILEDB_EXPERIMENTAL_FEATURES=$TileDBExperimentalFeatures -DTILEDB_WEBP=$BuildWebP -DTILEDB_CRC32=$BuildCrc32 -DTILEDB_ARROW_TESTS=$ArrowTests -DTILEDB_TESTS_ENABLE_REST=$RestTests -DTILEDB_TESTS_AWS_S3_CONFIG=$ConfigureS3 $GeneratorFlag ""$SourceDirectory"""
$CommandString = "cmake -A X64 -DTILEDB_VCPKG=$UseVcpkg -DCMAKE_BUILD_TYPE=$BuildType -DCMAKE_INSTALL_PREFIX=""$InstallPrefix"" $VcpkgBaseTriplet -DCMAKE_PREFIX_PATH=""$DependencyDir"" -DMSVC_MP_FLAG=""/MP$BuildProcesses"" -DTILEDB_ASSERTIONS=$AssertionMode -DTILEDB_VERBOSE=$Verbosity -DTILEDB_AZURE=$UseAzure -DTILEDB_S3=$UseS3 -DTILEDB_GCS=$UseGcs -DTILEDB_SERIALIZATION=$UseSerialization -DTILEDB_WERROR=$Werror -DTILEDB_CPP_API=$CppApi -DTILEDB_TESTS=$Tests -DTILEDB_STATS=$Stats -DBUILD_SHARED_LIBS=$BuildSharedLibs -DTILEDB_FORCE_ALL_DEPS=$TileDBBuildDeps -DTILEDB_REMOVE_DEPRECATIONS=$RemoveDeprecations -DTILEDB_TOOLS=$TileDBTools -DTILEDB_EXPERIMENTAL_FEATURES=$TileDBExperimentalFeatures -DTILEDB_WEBP=$BuildWebP -DTILEDB_CRC32=$BuildCrc32 -DTILEDB_ARROW_TESTS=$ArrowTests -DTILEDB_TESTS_ENABLE_REST=$RestTests -DTILEDB_TESTS_AWS_S3_CONFIG=$ConfigureS3 $GeneratorFlag ""$SourceDirectory"""
Write-Host $CommandString
Write-Host
Invoke-Expression "$CommandString"
Expand Down
105 changes: 105 additions & 0 deletions cmake/Modules/Sanitizer.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#
# cmake/Modules/Sanitizers.cmake
#
# The MIT License
#
# Copyright (c) 2023 TileDB, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# Sanitizers
# https://github.com/google/sanitizers
# https://github.com/google/sanitizers/wiki/AddressSanitizer
#
# GCC
# all: https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html
# All the sanitizer options are here, together with all the similar options gcc offers.
#
# Clang
# address: https://clang.llvm.org/docs/AddressSanitizer.html
# Recommends linking with `clang++`. No warning if otherwise at this time.
# undefined behavior: https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
# memory: https://clang.llvm.org/docs/MemorySanitizer.html
#
# MSVC
# Only supports the address sanitizer
# https://docs.microsoft.com/en-us/cpp/sanitizers/asan
# https://docs.microsoft.com/en-us/cpp/sanitizers/asan-building
# https://devblogs.microsoft.com/cppblog/addresssanitizer-asan-for-windows-with-msvc/
# https://devblogs.microsoft.com/cppblog/address-sanitizer-for-msvc-now-generally-available/

if(NOT TILEDB_SANITIZER)
return()
endif()

# The basic sanitizer option is standard across compilers
add_compile_options(-fsanitize=${TILEDB_SANITIZER})

# Check that the sanitizer name is well-formed
if (NOT TILEDB_SANITIZER MATCHES "^[-A-Za-z]*$")
message(FATAL_ERROR "Bad sanitizer specification \"${sanitizer}\";"
" permissible characters are only alphabetic and hyphen")
endif()

# Verify that the sanitizer is one that some compiler supports
string(TOLOWER ${TILEDB_SANITIZER} TILEDB_SANITIZER)
if (NOT TILEDB_SANITIZER MATCHES "^address$")
message(FATAL_ERROR "Unsupported sanitizer ${sanitizer}")
endif()

# Catch has a conflict with ASAN on Windows. Disable the SEH handler in Catch to avoid the conflict.
add_compile_definitions("$<$<CXX_COMPILER_ID:MSVC>:CATCH_CONFIG_NO_WINDOWS_SEH>")
# Microsoft suppresses /INCREMENTAL, but emits a warning, so silence it.
teo-tsirpanis marked this conversation as resolved.
Show resolved Hide resolved
add_link_options("$<$<CXX_COMPILER_ID:MSVC>:/INCREMENTAL:NO>")

# Ordinary gcc/clang behavior.
add_compile_options("$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-g;-fno-omit-frame-pointer;-fno-optimize-sibling-calls>")
add_link_options("$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-fsanitize=${TILEDB_SANITIZER}>")
if(TILEDB_SANITIZER STREQUAL "address")
# There may be problems if clang tries to link the ASAN library statically
add_link_options("$<$<CXX_COMPILER_ID:Clang>:-shared-libasan>")
endif()

# Validate sanitizer options.
# This must be called after the project() command, where the compiler is known.
macro(validate_sanitizer_options)
# For known compilers, check that the sanitizer is supported.
# If we know it's not supported, we'll fail so that we avoid false confidence.
# If we don't know, we'll warn that it might not work.
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
if (TILEDB_SANITIZER STREQUAL "address")
# MSVC support for the address sanitizer began with Visual Studio 2019 Version 16.4
# and was announced as "fully supported" in version 16.9
if (MSVC_VERSION LESS 1924)
message(FATAL_ERROR "MSVC version ${MSVC_VERSION} too early to support address sanitizer." )
endif()
if (MSVC_VERSION LESS 1929)
message(WARNING "MSVC version ${MSVC_VERSION} may only partially support address sanitizer." )
endif()
else()
# MSVC support only the address sanitizer
message(FATAL_ERROR "MSVC only supports sanitizer \"address\"")
endif()

# May also need to explicitly remove /RTC flags

elseif (NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU"))
message(WARN "Compiler \"${CMAKE_CXX_COMPILER_ID}\" not explicitly supported; behaving as if GNU")
endif()
endmacro()
2 changes: 2 additions & 0 deletions cmake/Options/BuildOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ include(CMakeDependentOption)
option(TILEDB_SUPERBUILD "If true, perform a superbuild (builds all missing dependencies)." ON)
option(TILEDB_VCPKG "If true, use vcpkg to download and build dependencies." ON)
cmake_dependent_option(TILEDB_FORCE_ALL_DEPS "If true, force superbuild to download and build all dependencies, even those installed on the system." OFF "NOT TILEDB_VCPKG" OFF)
option(TILEDB_SANITIZER "Sets the sanitizers to use. Only address is currently supported." "")
option(TILEDB_VCPKG_BASE_TRIPLET "Sets the base vcpkg triplet when building with sanitizers." "")
option(TILEDB_REMOVE_DEPRECATIONS "If true, do not build deprecated APIs." OFF)
option(TILEDB_VERBOSE "Prints TileDB errors with verbosity" OFF)
option(TILEDB_S3 "Enables S3/minio support using aws-cpp-sdk" OFF)
Expand Down
34 changes: 29 additions & 5 deletions cmake/Options/TileDBToolchain.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
#
# cmake/Options/TileDBToolchain.cmake
#
# The MIT License
#
# Copyright (c) 2023 TileDB, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
############################################################
# TileDB Toolchain Setup
############################################################
Expand Down Expand Up @@ -33,12 +58,11 @@ if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
endif()
endif()

if(APPLE AND NOT DEFINED VCPKG_TARGET_TRIPLET)
if (CMAKE_OSX_ARCHITECTURES STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(AMD64|amd64)|(^i.86$)")
set(VCPKG_TARGET_TRIPLET "x64-osx")
elseif (CMAKE_OSX_ARCHITECTURES STREQUAL arm64 OR CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
set(VCPKG_TARGET_TRIPLET "arm64-osx")
if(TILEDB_SANITIZER STREQUAL "address")
if(NOT TILEDB_VCPKG_BASE_TRIPLET)
message(FATAL_ERROR "TILEDB_VCPKG_BASE_TRIPLET must be defined when building with ASAN.")
endif()
set(VCPKG_TARGET_TRIPLET "${TILEDB_VCPKG_BASE_TRIPLET}-asan")
endif()

set(VCPKG_INSTALL_OPTIONS "--no-print-usage")
Expand Down
2 changes: 1 addition & 1 deletion cmake/TileDB-Superbuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ set(INHERITED_CMAKE_ARGS
-DTILEDB_CPP_API=${TILEDB_CPP_API}
-DTILEDB_FORCE_ALL_DEPS=${TILEDB_FORCE_ALL_DEPS}
-DTILEDB_REMOVE_DEPRECATIONS=${TILEDB_REMOVE_DEPRECATIONS}
-DSANITIZER=${SANITIZER}
-DTILEDB_SANITIZER=${TILEDB_SANITIZER}
-DTILEDB_EP_BASE=${TILEDB_EP_BASE}
-DTILEDB_STATS=${TILEDB_STATS}
-DTILEDB_TESTS=${TILEDB_TESTS}
Expand Down
9 changes: 9 additions & 0 deletions ports/triplets/arm64-osx-asan.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set(VCPKG_TARGET_ARCHITECTURE arm64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)

set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
set(VCPKG_OSX_ARCHITECTURES arm64)

set(VCPKG_C_FLAGS "-fsanitize=address")
set(VCPKG_CXX_FLAGS "-fsanitize=address")
8 changes: 8 additions & 0 deletions ports/triplets/x64-linux-asan.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)

set(VCPKG_CMAKE_SYSTEM_NAME Linux)

set(VCPKG_C_FLAGS "-fsanitize=address")
set(VCPKG_CXX_FLAGS "-fsanitize=address")
9 changes: 9 additions & 0 deletions ports/triplets/x64-osx-asan.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)

set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
set(VCPKG_OSX_ARCHITECTURES x86_64)

set(VCPKG_C_FLAGS "-fsanitize=address")
set(VCPKG_CXX_FLAGS "-fsanitize=address")
Loading
Loading