From 4561a11ff350e3691211e4c7db6376e533cda0b7 Mon Sep 17 00:00:00 2001 From: Suraj Naik Date: Sat, 23 Nov 2024 09:56:05 +0000 Subject: [PATCH 1/2] [VL] Keep Core module's build flag consistent with Velox --- cpp/core/CMakeLists.txt | 30 ++++++++++++++++++++++-------- ep/build-velox/src/get_velox.sh | 1 - 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/cpp/core/CMakeLists.txt b/cpp/core/CMakeLists.txt index 94484eab826c..70edd38266f4 100644 --- a/cpp/core/CMakeLists.txt +++ b/cpp/core/CMakeLists.txt @@ -22,10 +22,29 @@ include(FindPkgConfig) include(GNUInstallDirs) include(CheckCXXCompilerFlag) -# Only set arch=native for non-AppleClang compilers. -if(NOT CMAKE_CXX_COMPILER_ID MATCHES "AppleClang") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") +set(CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -Wno-attributes") +if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-class-memaccess") +endif() + +if(NOT DEFINED VELOX_HOME) + set(VELOX_HOME ${GLUTEN_HOME}/ep/build-velox/build/velox_ep) + message(STATUS "Set VELOX_HOME to ${VELOX_HOME}") +endif() + +# Keep same compile option with Velox. +execute_process( + COMMAND + bash -c + "( source ${VELOX_HOME}/scripts/setup-helper-functions.sh && echo -n $(get_cxx_flags $ENV{CPU_TARGET}))" + OUTPUT_VARIABLE SCRIPT_CXX_FLAGS + RESULT_VARIABLE COMMAND_STATUS) +if(COMMAND_STATUS EQUAL "1") + message(FATAL_ERROR "Unable to determine compiler flags!") endif() +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SCRIPT_CXX_FLAGS}") +message("Core module final CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}" set(BOOST_MIN_VERSION "1.42.0") find_package(Boost REQUIRED) @@ -99,11 +118,6 @@ set_source_files_properties(${GLUTEN_PROTO_OUTPUT_FILES} PROPERTIES GENERATED TRUE) get_filename_component(GLUTEN_PROTO_DIR ${GLUTEN_PROTO_SRC_DIR}/ DIRECTORY) -set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -Wno-attributes") - -message("Core module final CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}") - set(SPARK_COLUMNAR_PLUGIN_SRCS ${SUBSTRAIT_PROTO_SRCS} ${GLUTEN_PROTO_SRCS} diff --git a/ep/build-velox/src/get_velox.sh b/ep/build-velox/src/get_velox.sh index e6a69a62f1e9..f2b74b367b8d 100755 --- a/ep/build-velox/src/get_velox.sh +++ b/ep/build-velox/src/get_velox.sh @@ -189,7 +189,6 @@ function setup_linux { local LINUX_VERSION_ID=$(. /etc/os-release && echo ${VERSION_ID}) # apply patches - sed -i 's/-mavx2 -mfma -mavx -mf16c -mlzcnt -std=c++17/-march=native -std=c++17 -mno-avx512f/g' scripts/setup-helper-functions.sh sed -i 's/SUDO="${SUDO:-""}"/SUDO="${SUDO:-"sudo --preserve-env"}"/g' scripts/setup-helper-functions.sh if [[ "$LINUX_DISTRIBUTION" == "ubuntu" || "$LINUX_DISTRIBUTION" == "debian" || "$LINUX_DISTRIBUTION" == "pop" ]]; then process_setup_ubuntu From 78fd018f4b96a0bde449ddd546f438328f2011f9 Mon Sep 17 00:00:00 2001 From: Suraj Naik Date: Sat, 23 Nov 2024 10:06:06 +0000 Subject: [PATCH 2/2] Fix Cmake --- cpp/core/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/core/CMakeLists.txt b/cpp/core/CMakeLists.txt index 70edd38266f4..88b0fd883e5c 100644 --- a/cpp/core/CMakeLists.txt +++ b/cpp/core/CMakeLists.txt @@ -44,7 +44,7 @@ if(COMMAND_STATUS EQUAL "1") message(FATAL_ERROR "Unable to determine compiler flags!") endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SCRIPT_CXX_FLAGS}") -message("Core module final CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}" +message("Core module final CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}") set(BOOST_MIN_VERSION "1.42.0") find_package(Boost REQUIRED)