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 RelWithDebInfo. #4669

Merged
merged 7 commits into from
Feb 8, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci-linux_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ env:
CC: ${{ inputs.matrix_compiler_cc }}
CFLAGS: ${{ inputs.matrix_compiler_cflags }}
CXXFLAGS: ${{ inputs.matrix_compiler_cxxflags }}
bootstrap_args: "--enable-ccache ${{ inputs.bootstrap_args }} ${{ inputs.asan && '--enable-sanitizer=address' || '' }}"
bootstrap_args: "--enable-ccache --vcpkg-base-triplet=x64-${{ startsWith(inputs.matrix_image, 'ubuntu-') && 'linux' || 'osx' }} ${{ inputs.bootstrap_args }} ${{ inputs.asan && '--enable-sanitizer=address' || '' }}"
VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite'
SCCACHE_GHA_ENABLED: "true"

Expand Down
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 --vcpkg-base-triplet=x64-linux'
bootstrap_args: '--enable-serialization'
asan: true

ci10:
Expand Down
21 changes: 0 additions & 21 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,6 @@ 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 Down
15 changes: 15 additions & 0 deletions cmake/Options/TileDBToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@ if(TILEDB_SANITIZER STREQUAL "address")
set(VCPKG_TARGET_TRIPLET "${TILEDB_VCPKG_BASE_TRIPLET}-asan")
endif()

get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG)
# On Windows vcpkg always builds dependencies with symbols.
# https://github.com/microsoft/vcpkg/blob/master/scripts/toolchains/windows.cmake
if(NOT WIN32 AND NOT is_multi_config AND CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" AND NOT VCPKG_TARGET_TRIPLET)
if(TILEDB_SANITIZER STREQUAL "address")
message(FATAL_ERROR "Cannot enable both RelWithDebInfo and ASAN at the same time.")
endif()
if(TILEDB_VCPKG_BASE_TRIPLET)
message(STATUS "Overriding vcpkg triplet to ${TILEDB_VCPKG_BASE_TRIPLET}-relwithdebinfo")
set(VCPKG_TARGET_TRIPLET "${TILEDB_VCPKG_BASE_TRIPLET}-relwithdebinfo")
else()
message(WARNING "Dependencies will be built without symbols. You have to set either VCPKG_TARGET_TRIPLET or TILEDB_VCPKG_BASE_TRIPLET.")
endif()
endif()

set(VCPKG_INSTALL_OPTIONS "--no-print-usage")

macro(tiledb_vcpkg_enable_if tiledb_feature vcpkg_feature)
Expand Down
35 changes: 34 additions & 1 deletion doc/dev/BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ The following are the most common configuration options:
|macOS/Linux flag|Windows flag|CMake variable|Description|
|----------------|------------|--------------|-----------|
|`--prefix=PREFIX`|`-Prefix=PREFIX`|`CMAKE_INSTALL_PREFIX=<PREFIX>`|Install files in tree rooted at `PREFIX` (defaults to `TileDB/dist`)|
|`--vcpkg-base-triplet=TRIPLET`|`-VcpkgBaseTriplet=TRIPLET`|`TILEDB_VCPKG_BASE_TRIPLET=TRIPLET`|Vcpkg base triplet, needed for features like ASAN and RelWithDebInfo|
|`--linkage=shared/static`|`-Linkage=shared/static`|`BUILD_SHARED_LIBS=ON/OFF`|Linkage of the compiled TileDB library (defaults to `shared`) |
|`--remove-deprecations`|`-RemoveDeprecations`|`TILEDB_REMOVE_DEPRECATIONS=ON`|Build TileDB without deprecated APIs|
|`--enable-debug`|`-EnableDebug`|`CMAKE_BUILD_TYPE=Debug`|Enables debug build|
Expand All @@ -84,6 +85,13 @@ The following are the most common configuration options:
|`--disable-stats`|`-DisableStats`|`TILEDB_STATS=OFF`|Disables internal TileDB statistics|
|`--disable-tests`|`-DisableTests`|`TILEDB_TESTS=OFF`|Disables building the TileDB test suite|

The supported vcpkg base triplet values are:

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

> [!TIP]
> You can see all TileDB-specific CMake variables in [BuildOptions.cmake](../../cmake/Options/BuildOptions.cmake).

Expand Down Expand Up @@ -125,4 +133,29 @@ Vcpkg will not be automatically downloaded if:
* The `TILEDB_DISABLE_AUTO_VCPKG` environment variable has been defined.
* The build tree has been configured by directly calling CMake and the `CMAKE_TOOLCHAIN_FILE` variable has been set by the user.

In these cases no dependencies CMake will find the dependencies based on the rules of the [`find_package`](https://cmake.org/cmake/help/latest/command/find_package.html#command:find_package) command. The user is responsible for providing them.
In these cases CMake will find the dependencies based on the rules of the [`find_package`](https://cmake.org/cmake/help/latest/command/find_package.html) command. The user is responsible for providing the dependencies.

### 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](#configuration-options) corresponding to your platform:

> [!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.

### Building with optimizations and debug symbols

TileDB supports configuring in `RelWithDebInfo` mode, which compiles code with optimizations while also emitting debug symbols. However on non-Windows platforms the dependencies built by vcpkg do not build by default with symbols. To enable that you have to do either of the following:

* [Specify a vcpkg base triplet](#configuration-options).
* Configure by directly calling CMake and setting a vcpkg triplet with the `VCPKG_DEFAULT_TRIPLET` variable. In this case you are responsible to ensure the appropriate options are passed to the triplet file.

Configuring in `RelWithDebInfo` mode and enabling ASAN at the same time is not supported.
10 changes: 10 additions & 0 deletions ports/triplets/arm64-osx-relwithdebinfo.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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_OSX_DEPLOYMENT_TARGET 11)

set(VCPKG_CXX_FLAGS "-g")
set(VCPKG_C_FLAGS "-g")
8 changes: 8 additions & 0 deletions ports/triplets/x64-linux-relwithdebinfo.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_CXX_FLAGS "-g")
set(VCPKG_C_FLAGS "-g")
10 changes: 10 additions & 0 deletions ports/triplets/x64-osx-relwithdebinfo.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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_OSX_DEPLOYMENT_TARGET 11)

set(VCPKG_CXX_FLAGS "-g")
set(VCPKG_C_FLAGS "-g")
Loading