Skip to content

Commit c3d57a1

Browse files
authored
chore: compile with C++ 20 (#6889)
We can switch to C++20 as the latest DuckDB Docker image to build extensions now supports it: https://github.com/vortex-data/duckdb-vortex/actions/runs/22958627873/job/66642571037?pr=76 Signed-off-by: Alexander Droste <alexander.droste@protonmail.com>
1 parent 9c051ae commit c3d57a1

9 files changed

Lines changed: 16 additions & 20 deletions

File tree

docs/api/cpp/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Installation
2020
The C++ bindings are built using CMake. Requirements:
2121

2222
* CMake 3.22 or higher
23-
* C++17 compatible compiler
23+
* C++20 compatible compiler
2424
* Rust toolchain (for building the underlying Rust library)
2525

2626
.. code-block:: bash

vortex-cuda/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ fn nvcc_compile_ptx(
138138
.join(cu_path.file_name().unwrap())
139139
.with_extension("ptx");
140140

141-
cmd.arg("-std=c++17")
141+
cmd.arg("-std=c++20")
142142
.arg("-arch=native")
143143
// Flags forwarded to Clang.
144144
.arg("--compiler-options=-Wall -Wextra -Wpedantic -Werror")

vortex-cuda/cub/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn is_cuda_available() -> bool {
5757
fn compile_shared_library(kernel_dir: &Path, sources: &[PathBuf], out_dir: &Path) {
5858
let lib_path = out_dir.join("libvortex_cub.so");
5959
let mut cmd = Command::new("nvcc");
60-
cmd.args(["-std=c++17", "-arch=native"]);
60+
cmd.args(["-std=c++20", "-arch=native"]);
6161

6262
if env::var("PROFILE").unwrap() == "debug" {
6363
cmd.args(["-O0", "-g", "-G", "-lineinfo"]);

vortex-cxx/CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ cmake_policy(SET CMP0135 NEW)
88

99
project(vortex)
1010

11-
set(CMAKE_CXX_STANDARD 17)
11+
set(CMAKE_CXX_STANDARD 20)
1212
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1313

1414
find_program(SCCACHE_PROGRAM sccache)
@@ -72,17 +72,17 @@ set(CPP_PRIVATE_INCLUDE_DIRS
7272

7373
# Create the main library combining C++ and Rust code
7474
add_library(vortex STATIC ${CPP_SOURCE_FILE})
75-
target_include_directories(vortex PUBLIC ${CPP_INCLUDE_DIRS}
75+
target_include_directories(vortex PUBLIC ${CPP_INCLUDE_DIRS}
7676
${CMAKE_CURRENT_BINARY_DIR}/corrosion_generated/cxxbridge/vortex_cxx_bridge/include)
77-
target_include_directories(vortex PRIVATE
77+
target_include_directories(vortex PRIVATE
7878
${CPP_PRIVATE_INCLUDE_DIRS}
7979
)
80-
target_link_libraries(vortex
80+
target_link_libraries(vortex
8181
PUBLIC nanoarrow_static
8282
PRIVATE vortex_cxx_bridge
8383
)
8484

85-
if (VORTEX_ENABLE_ASAN)
85+
if (VORTEX_ENABLE_ASAN)
8686
target_compile_options(vortex PRIVATE -fsanitize=leak,address,undefined -fno-omit-frame-pointer -fno-common -O1)
8787
target_link_options(vortex PRIVATE -fsanitize=leak,address,undefined)
8888
endif()
@@ -102,15 +102,15 @@ if (VORTEX_ENABLE_TESTING)
102102
target_include_directories(vortex_cxx_test PUBLIC ${CPP_INCLUDE_DIRS})
103103
target_include_directories(vortex_cxx_test PRIVATE cpp/tests)
104104
target_link_libraries(vortex_cxx_test PRIVATE gtest_main vortex nanoarrow_static)
105-
target_include_directories(vortex_cxx_test PRIVATE
105+
target_include_directories(vortex_cxx_test PRIVATE
106106
${CMAKE_CURRENT_BINARY_DIR}/corrosion_generated/cxxbridge/vortex_cxx_bridge/include
107107
)
108108
# Platform-specific configuration
109109
if(APPLE)
110110
set(APPLE_LINK_FLAGS "-framework CoreFoundation -framework Security")
111111
endif()
112112
target_link_libraries(vortex_cxx_test PRIVATE vortex_cxx_bridge ${APPLE_LINK_FLAGS})
113-
if (VORTEX_ENABLE_ASAN)
113+
if (VORTEX_ENABLE_ASAN)
114114
target_compile_options(vortex_cxx_test PRIVATE -fsanitize=leak,address,undefined -fno-omit-frame-pointer -fno-common -O1)
115115
target_link_options(vortex_cxx_test PRIVATE -fsanitize=leak,address,undefined)
116116
endif()

vortex-cxx/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This directory contains C++ bindings for Vortex using the [cxx](https://cxx.rs/)
77
### Requirements
88

99
- CMake 3.22 or higher
10-
- C++17 compatible compiler
10+
- C++20 compatible compiler
1111
- Rust toolchain (for building the Rust components)
1212
- (optional) Ninja (`ninja-build`)
1313

vortex-cxx/examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.22)
55

66
project(vortex-examples)
77

8-
set(CMAKE_CXX_STANDARD 17)
8+
set(CMAKE_CXX_STANDARD 20)
99
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1010

1111

vortex-duckdb/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Rust bindings for DuckDB. Supports DuckDB precompiled libraries for fast builds
66

77
- **Ninja**: `brew install ninja` (macOS) | `apt-get install ninja-build` (Ubuntu)
88
- **CMake**: `brew install cmake` (macOS) | `apt-get install cmake` (Ubuntu)
9-
- **C++17 compatible compiler**: GCC or Clang
9+
- **C++20 compatible compiler**: GCC or Clang
1010

1111
## Build Modes
1212

vortex-duckdb/build.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -499,15 +499,11 @@ fn main() {
499499

500500
// Compile our C++ code that exposes additional DuckDB functionality.
501501
cc::Build::new()
502-
.std("c++17")
502+
.std("c++20")
503503
// Enable compiler warnings.
504504
.flag("-Wall")
505505
.flag("-Wextra")
506506
.flag("-Wpedantic")
507-
// Allow C++20 designator syntax even with C++17 std
508-
.flag("-Wno-c++20-designator")
509-
// Enable C++20 extensions
510-
.flag("-Wno-c++20-extensions")
511507
// Unused parameter warnings are disabled as we include DuckDB
512508
// headers with implementations that have unused parameters.
513509
.flag("-Wno-unused-parameter")

vortex-duckdb/cpp/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
cmake_minimum_required(VERSION 3.20)
1515
project(vortex_duckdb_cpp)
1616

17-
set(CMAKE_CXX_STANDARD 17)
17+
set(CMAKE_CXX_STANDARD 20)
1818
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1919

2020
# Default to debug if build config is not explicitly set.
@@ -23,7 +23,7 @@ if (NOT CMAKE_BUILD_TYPE)
2323
endif ()
2424

2525
# Enable compiler warnings (matching build.rs flags).
26-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wno-c++20-designator -Wno-c++20-extensions")
26+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wno-unused-parameter")
2727

2828
# Find DuckDB include directory via the symlink created by build.rs.
2929
# The symlink points to target/duckdb-source-vX.Y.Z which contains duckdb-X.Y.Z/

0 commit comments

Comments
 (0)