From 1f5b617ae4533a67ff07364331db4738e63d04eb Mon Sep 17 00:00:00 2001 From: Christian Zentgraf Date: Mon, 28 Jul 2025 10:58:54 -0700 Subject: [PATCH] [native] Update to use C++20 This updates the C++ standard to C++20 to match the Velox C++ standard. --- presto-native-execution/CMakeLists.txt | 11 ++++++----- presto-native-execution/README.md | 11 ++++++----- .../presto_cpp/main/http/HttpClient.cpp | 2 +- .../main/types/tests/FunctionMetadataTest.cpp | 9 ++++++--- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/presto-native-execution/CMakeLists.txt b/presto-native-execution/CMakeLists.txt index 5aa29f07b001f..d483c0b2ce262 100644 --- a/presto-native-execution/CMakeLists.txt +++ b/presto-native-execution/CMakeLists.txt @@ -24,7 +24,7 @@ execute_process( OUTPUT_VARIABLE SCRIPT_CXX_FLAGS RESULT_VARIABLE COMMAND_STATUS) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED True) message("Appending CMAKE_CXX_FLAGS with ${SCRIPT_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SCRIPT_CXX_FLAGS}") @@ -70,9 +70,9 @@ option(PRESTO_ENABLE_JWT "Enable JWT (JSON Web Token) authentication" OFF) option(PRESTO_ENABLE_ARROW_FLIGHT_CONNECTOR "Enable Arrow Flight connector" OFF) -# Set all Velox options below -# Make sure that if we include folly headers or other dependency headers -# that include folly headers we turn off the coroutines and turn on int128. +# Set all Velox options below and make sure that if we include folly headers or +# other dependency headers that include folly headers we turn off the coroutines +# and turn on int128. add_compile_definitions(FOLLY_HAVE_INT128_T=1 FOLLY_CFG_NO_COROUTINES) if(PRESTO_ENABLE_S3) @@ -210,7 +210,8 @@ find_package(wangle CONFIG) find_package(FBThrift) include_directories(SYSTEM ${FBTHRIFT_INCLUDE_DIR}) -set(PROXYGEN_LIBRARIES ${PROXYGEN_HTTP_SERVER} ${PROXYGEN} ${WANGLE} ${FIZZ} ${MVFST_EXCEPTION}) +set(PROXYGEN_LIBRARIES ${PROXYGEN_HTTP_SERVER} ${PROXYGEN} ${WANGLE} ${FIZZ} + ${MVFST_EXCEPTION}) find_path(PROXYGEN_DIR NAMES include/proxygen) set(PROXYGEN_INCLUDE_DIR "${PROXYGEN_DIR}/include/proxygen") diff --git a/presto-native-execution/README.md b/presto-native-execution/README.md index 53231496bcc20..ca60721f858de 100644 --- a/presto-native-execution/README.md +++ b/presto-native-execution/README.md @@ -65,18 +65,19 @@ The supported architectures are `x86_64 (avx, sse)`, and `AArch64 (apple-m1+crc, Prestissimo can be built by a variety of compilers (and versions) but not all. Compilers (and versions) not mentioned are known to not work or have not been tried. -#### Recommended +#### Minimum required | OS | compiler | | -- | -------- | -| CentOS 9/RHEL 9 | `gcc12` | | Ubuntu 22.04 | `gcc11` | | macOS | `clang15` | +| CentOS 9/RHEL 9 | `gcc11` | -#### Older alternatives +#### Recommended | OS | compiler | | -- | -------- | -| Ubuntu 20.04 | `gcc9` | -| macOS | `clang14` | +| CentOS 9/RHEL 9 | `gcc12` | +| Ubuntu 22.04 | `gcc11` | +| macOS | `clang15 (or later)` | ### Build Prestissimo #### Parquet and S3 Support diff --git a/presto-native-execution/presto_cpp/main/http/HttpClient.cpp b/presto-native-execution/presto_cpp/main/http/HttpClient.cpp index e54d1588ff0ed..d2be3dde677e2 100644 --- a/presto-native-execution/presto_cpp/main/http/HttpClient.cpp +++ b/presto-native-execution/presto_cpp/main/http/HttpClient.cpp @@ -542,7 +542,7 @@ folly::SemiFuture> HttpClient::sendRequest( if (eventBase_ != nullptr) { if (delayMs > 0) { // schedule() is expected to be run in the event base thread - eventBase_->runInEventBaseThread([=]() { + eventBase_->runInEventBaseThread([=, this]() { eventBase_->schedule(sendCb, std::chrono::milliseconds(delayMs)); }); } else { diff --git a/presto-native-execution/presto_cpp/main/types/tests/FunctionMetadataTest.cpp b/presto-native-execution/presto_cpp/main/types/tests/FunctionMetadataTest.cpp index 91bc12fe24605..ea177f980533d 100644 --- a/presto-native-execution/presto_cpp/main/types/tests/FunctionMetadataTest.cpp +++ b/presto-native-execution/presto_cpp/main/types/tests/FunctionMetadataTest.cpp @@ -48,12 +48,15 @@ class FunctionMetadataTest : public ::testing::Test { EXPECT_EQ(metadataList.size(), expectedSize); std::string expectedStr = slurp(test::utils::getDataPath(expectedFile)); auto expected = json::parse(expectedStr); + auto comparator = [](const json& a, const json& b) { + return (a["outputType"] < b["outputType"]); + }; json::array_t expectedList = expected[name]; - std::sort(expectedList.begin(), expectedList.end()); - std::sort(metadataList.begin(), metadataList.end()); + std::sort(expectedList.begin(), expectedList.end(), comparator); + std::sort(metadataList.begin(), metadataList.end(), comparator); for (auto i = 0; i < expectedSize; i++) { - EXPECT_EQ(expectedList[i], metadataList[i]); + EXPECT_EQ(expectedList[i], metadataList[i]) << "Position: " << i; } }