This is an automated email from the ASF dual-hosted git repository.
yuanzhou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git
The following commit(s) were added to refs/heads/main by this push:
new 45a40edeac [GLUTEN-9626][VL] Support lib geos in vcpkg (#9659)
45a40edeac is described below
commit 45a40edeac9d537a7be7c326efef50674f40da02
Author: PHILO-HE <[email protected]>
AuthorDate: Fri May 16 20:32:10 2025 +0800
[GLUTEN-9626][VL] Support lib geos in vcpkg (#9659)
This lib was added to Velox several months ago. This pr is supporting
3.10.2 based on the ports for 3.10.0 microsoft/vcpkg@ce73eeb.
changed the file hash
removed useless patch which is only required for 3.10.0.
included two patches from Velox, which will be applied before the build.
https://github.com/facebookincubator/velox/tree/main/CMake/resolve_dependency_modules/geos
Issue: #9626
---
cpp/velox/CMakeLists.txt | 9 ++-
dev/vcpkg/ports/geos/disable-warning-4996.patch | 13 ++++
dev/vcpkg/ports/geos/fix-exported-config.patch | 76 +++++++++++++++++++++++
dev/vcpkg/ports/geos/geos-build.patch | 46 ++++++++++++++
dev/vcpkg/ports/geos/geos-cmakelists.patch | 22 +++++++
dev/vcpkg/ports/geos/portfile.cmake | 81 +++++++++++++++++++++++++
dev/vcpkg/ports/geos/usage | 10 +++
dev/vcpkg/ports/geos/vcpkg.json | 16 +++++
dev/vcpkg/vcpkg.json | 3 +-
ep/build-velox/src/setup-centos7.sh | 10 +++
ep/build-velox/src/setup-centos8.sh | 10 +++
ep/build-velox/src/setup-openeuler24.sh | 9 +++
12 files changed, 299 insertions(+), 6 deletions(-)
diff --git a/cpp/velox/CMakeLists.txt b/cpp/velox/CMakeLists.txt
index 611a1c1ec1..4613e1a200 100644
--- a/cpp/velox/CMakeLists.txt
+++ b/cpp/velox/CMakeLists.txt
@@ -270,12 +270,11 @@ else()
endif()
target_link_libraries(velox PUBLIC external::stemmer)
-find_library(GEOS_LIB NAMES libgeos.a)
-if(GEOS_LIB)
- message(STATUS "Found geos: ${GEOS_LIB}")
- add_library(external::geos STATIC IMPORTED)
- set_target_properties(external::geos PROPERTIES IMPORTED_LOCATION
${GEOS_LIB})
+find_package(geos)
+if(geos_FOUND AND TARGET GEOS::geos)
+ add_library(external::geos ALIAS GEOS::geos)
else()
+ message(STATUS "import Velox bundled geos")
import_library(external::geos ${VELOX_BUILD_PATH}/lib/libgeos.a)
endif()
target_link_libraries(velox PUBLIC external::geos)
diff --git a/dev/vcpkg/ports/geos/disable-warning-4996.patch
b/dev/vcpkg/ports/geos/disable-warning-4996.patch
new file mode 100644
index 0000000000..af39e2ed6a
--- /dev/null
+++ b/dev/vcpkg/ports/geos/disable-warning-4996.patch
@@ -0,0 +1,13 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index accc1a2..34d2055 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -174,7 +174,7 @@ target_compile_features(geos_cxx_flags INTERFACE
cxx_std_11)
+ target_compile_options(geos_cxx_flags INTERFACE
+
"$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-ffp-contract=off>"
+ "$<$<CXX_COMPILER_ID:GNU>:-ffp-contract=off>"
+- "$<$<CXX_COMPILER_ID:MSVC>:/fp:precise>"
++ $<$<CXX_COMPILER_ID:MSVC>:/fp:precise /wd4996>
+ )
+
+ # Use -ffloat-store for 32-bit builds (needed to make some tests pass)
diff --git a/dev/vcpkg/ports/geos/fix-exported-config.patch
b/dev/vcpkg/ports/geos/fix-exported-config.patch
new file mode 100644
index 0000000000..40aa835e0c
--- /dev/null
+++ b/dev/vcpkg/ports/geos/fix-exported-config.patch
@@ -0,0 +1,76 @@
+diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
+index bc0e774..e3ca0bd 100644
+--- a/tools/CMakeLists.txt
++++ b/tools/CMakeLists.txt
+@@ -45,11 +45,18 @@ function(configure_install_geos_pc)
+ set(includedir "$\{prefix\}/${CMAKE_INSTALL_INCLUDEDIR}")
+ set(libdir "$\{exec_prefix\}/${CMAKE_INSTALL_LIBDIR}")
+ set(VERSION ${GEOS_VERSION})
+- set(EXTRA_LIBS "-lstdc++")
++ if(APPLE OR CMAKE_ANDROID_STL_TYPE MATCHES "^c\\+\\+")
++ set(EXTRA_LIBS "-lc++")
++ elseif(UNIX OR MINGW)
++ set(EXTRA_LIBS "-lstdc++")
++ else()
++ set(EXTRA_LIBS "")
++ endif()
+ if(HAVE_LIBM)
+ list(APPEND EXTRA_LIBS "-lm")
+ endif()
+ list(JOIN EXTRA_LIBS " " EXTRA_LIBS)
++ set(EXTRA_LIBS "${EXTRA_LIBS}" PARENT_SCOPE) # for geos-config
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/geos.pc.in
+@@ -61,9 +68,9 @@ function(configure_install_geos_pc)
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+ endfunction()
+
++configure_install_geos_pc()
+ if(NOT MSVC)
+ configure_install_geos_config()
+- configure_install_geos_pc()
+ endif()
+
+ option(BUILD_ASTYLE "Build astyle (Artistic Style) tool" OFF)
+diff --git a/tools/geos-config.in b/tools/geos-config.in
+index 6eff1eb..8827f6a 100644
+--- a/tools/geos-config.in
++++ b/tools/geos-config.in
+@@ -1,9 +1,11 @@
+ #!/bin/sh
+
+-prefix=@prefix@
+-exec_prefix=@exec_prefix@
+-includedir=@includedir@
+-libdir=@libdir@
++DIRNAME=$(dirname $0)
++TOOLS=$(dirname $DIRNAME)
++prefix=$(CDPATH= cd -- "${DIRNAME%/tools/geos/*}" && pwd -P)
++exec_prefix=${prefix}
++includedir=${prefix}/include
++libdir=${prefix}${TOOLS##*/geos}/lib
+
+ usage()
+ {
+@@ -47,16 +49,16 @@ while test $# -gt 0; do
+ echo -L${libdir} -lgeos-@VERSION_RELEASE@
+ ;;
+ --clibs)
+- echo -L${libdir} -lgeos_c
++ echo -L${libdir} -lgeos_c $(if test "@BUILD_SHARED_LIBS@" != "ON"; then
echo "-lgeos @EXTRA_LIBS@"; fi)
+ ;;
+ --cclibs)
+- echo -L${libdir} -lgeos
++ echo -L${libdir} -lgeos $(if test "@BUILD_SHARED_LIBS@" != "ON"; then
echo "@EXTRA_LIBS@"; fi)
+ ;;
+ --static-clibs)
+- echo -L${libdir} -lgeos_c -lgeos -lm
++ echo -L${libdir} -lgeos_c -lgeos @EXTRA_LIBS@
+ ;;
+ --static-cclibs)
+- echo -L${libdir} -lgeos -lm
++ echo -L${libdir} -lgeos @EXTRA_LIBS@
+ ;;
+ --cflags)
+ echo -I${includedir}
diff --git a/dev/vcpkg/ports/geos/geos-build.patch
b/dev/vcpkg/ports/geos/geos-build.patch
new file mode 100644
index 0000000000..4194a5f44c
--- /dev/null
+++ b/dev/vcpkg/ports/geos/geos-build.patch
@@ -0,0 +1,46 @@
+--- a/capi/geos_ts_c.cpp
++++ b/capi/geos_ts_c.cpp
+@@ -2168,7 +2168,7 @@ extern "C" {
+ const char* GEOSversion()
+ {
+ static char version[256];
+- sprintf(version, "%s", GEOS_CAPI_VERSION);
++ snprintf(version, sizeof(version), "%s", GEOS_CAPI_VERSION);
+ return version;
+ }
+
+--- a/include/geos/io/ByteOrderDataInStream.h
++++ b/include/geos/io/ByteOrderDataInStream.h
+@@ -22,6 +22,7 @@
+
+ #include <geos/export.h>
+ #include <cstdint>
++#include <cstddef>
+
+ //#include <geos/io/ParseException.h>
+ //#include <geos/io/ByteOrderValues.h>
+--- a/tests/unit/math/DDTest.cpp
++++ b/tests/unit/math/DDTest.cpp
+@@ -160,11 +160,9 @@ struct test_dd_data {
+ DD t2 = t*t;
+ DD at(0.0);
+ DD two(2.0);
+- int k = 0;
+ DD d(1.0);
+ int sign = 1;
+ while (t.doubleValue() > eps) {
+- k++;
+ if (sign < 0)
+ at = at - (t / d);
+ else
+@@ -187,10 +185,8 @@ struct test_dd_data {
+ DD s(2.0);
+ DD t(1.0);
+ double n = 1.0;
+- int i = 0;
+ while(t.doubleValue() > eps)
+ {
+- i++;
+ n += 1.0;
+ t = t / DD(n);
+ s = s + t;
diff --git a/dev/vcpkg/ports/geos/geos-cmakelists.patch
b/dev/vcpkg/ports/geos/geos-cmakelists.patch
new file mode 100644
index 0000000000..1fcf338b4a
--- /dev/null
+++ b/dev/vcpkg/ports/geos/geos-cmakelists.patch
@@ -0,0 +1,22 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -437,19 +437,5 @@ if(NOT _is_multi_config_generator)
+ message(STATUS "GEOS: Configured 'dist' target")
+ endif()
+
+-#-----------------------------------------------------------------------------
+-# "make check" workalike
+-#-----------------------------------------------------------------------------
+-
+-add_custom_target(check COMMAND ${CMAKE_BUILD_TOOL} test)
+-
+-#-----------------------------------------------------------------------------
+-# "make distcheck" workalike
+-#-----------------------------------------------------------------------------
+-if(NOT _is_multi_config_generator)
+- find_package(MakeDistCheck)
+- AddMakeDistCheck()
+- message(STATUS "GEOS: Configured 'distcheck' target")
+-endif()
+
+ unset(_is_multi_config_generator)
diff --git a/dev/vcpkg/ports/geos/portfile.cmake
b/dev/vcpkg/ports/geos/portfile.cmake
new file mode 100644
index 0000000000..fee2f53e09
--- /dev/null
+++ b/dev/vcpkg/ports/geos/portfile.cmake
@@ -0,0 +1,81 @@
+set(GEOS_VERSION 3.10.2)
+
+vcpkg_download_distfile(ARCHIVE
+ URLS "https://download.osgeo.org/geos/geos-${GEOS_VERSION}.tar.bz2"
+ FILENAME "geos-${GEOS_VERSION}.tar.bz2"
+ SHA512
390381711ccf56b862c2736cf6329200822f121de1c49df52b8b85cabea8c7787b199df2196acacc2e5c677ff3ebe042d93d70e89deadbc19d754499edb65126
+)
+vcpkg_extract_source_archive_ex(
+ OUT_SOURCE_PATH SOURCE_PATH
+ ARCHIVE "${ARCHIVE}"
+ REF ${GEOS_VERSION}
+ PATCHES
+ disable-warning-4996.patch
+ fix-exported-config.patch
+ # The two patches below come from Velox.
+ geos-build.patch
+ geos-cmakelists.patch
+)
+
+if(VCPKG_TARGET_IS_MINGW)
+ set(_CMAKE_EXTRA_OPTIONS "-DDISABLE_GEOS_INLINE=ON")
+else()
+ set(_CMAKE_EXTRA_OPTIONS "")
+endif()
+
+vcpkg_cmake_configure(
+ SOURCE_PATH "${SOURCE_PATH}"
+ OPTIONS
+ -DBUILD_ASTYLE=OFF
+ -DBUILD_DOCUMENTATION=OFF
+ -DBUILD_GEOSOP=OFF
+ -DBUILD_TESTING=OFF
+ -DBUILD_BENCHMARKS=OFF
+ ${_CMAKE_EXTRA_OPTIONS}
+ OPTIONS_DEBUG
+ -DCMAKE_DEBUG_POSTFIX=d # Legacy decision, hard coded in depending
ports
+)
+vcpkg_cmake_install()
+vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/GEOS)
+vcpkg_fixup_pkgconfig()
+
+function(geos_add_debug_postfix config_file)
+ file(READ "${config_file}" contents)
+ string(REGEX REPLACE "(-lgeos(_c)?)d?([^-_d])" "\\1d\\3" fixed_contents
"${contents}")
+ file(WRITE "${config_file}" "${fixed_contents}")
+endfunction()
+if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
+ if(NOT VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_MINGW)
+ file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin")
+ file(RENAME "${CURRENT_PACKAGES_DIR}/bin/geos-config"
"${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin/geos-config")
+ file(CHMOD "${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin/geos-config"
FILE_PERMISSIONS
+ OWNER_READ OWNER_WRITE OWNER_EXECUTE
+ GROUP_READ GROUP_EXECUTE
+ WORLD_READ WORLD_EXECUTE
+ )
+ endif()
+endif()
+if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
+
geos_add_debug_postfix("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/geos.pc")
+ if(NOT VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_MINGW)
+ file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug/bin")
+ file(RENAME "${CURRENT_PACKAGES_DIR}/debug/bin/geos-config"
"${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug/bin/geos-config")
+
geos_add_debug_postfix("${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug/bin/geos-config")
+ file(CHMOD
"${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug/bin/geos-config" FILE_PERMISSIONS
+ OWNER_READ OWNER_WRITE OWNER_EXECUTE
+ GROUP_READ GROUP_EXECUTE
+ WORLD_READ WORLD_EXECUTE
+ )
+ endif()
+endif()
+
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
+if(VCPKG_LIBRARY_LINKAGE STREQUAL "static" OR NOT VCPKG_TARGET_IS_WINDOWS)
+ file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin"
"${CURRENT_PACKAGES_DIR}/debug/bin")
+endif()
+
+# Handle copyright
+configure_file("${SOURCE_PATH}/COPYING"
"${CURRENT_PACKAGES_DIR}/share/geos/copyright" COPYONLY)
+
+vcpkg_copy_pdbs()
+file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION
"${CURRENT_PACKAGES_DIR}/share/${PORT}")
diff --git a/dev/vcpkg/ports/geos/usage b/dev/vcpkg/ports/geos/usage
new file mode 100644
index 0000000000..139e40dd27
--- /dev/null
+++ b/dev/vcpkg/ports/geos/usage
@@ -0,0 +1,10 @@
+The package geos provides CMake targets:
+
+ # C API (provides long-term ABI stability)
+ find_package(GEOS CONFIG REQUIRED)
+ target_link_libraries(main PRIVATE GEOS::geos_c)
+
+ # C++ API (will likely change across versions)
+ find_package(GEOS CONFIG REQUIRED)
+ target_link_libraries(main PRIVATE GEOS::geos)
+
diff --git a/dev/vcpkg/ports/geos/vcpkg.json b/dev/vcpkg/ports/geos/vcpkg.json
new file mode 100644
index 0000000000..acc9047654
--- /dev/null
+++ b/dev/vcpkg/ports/geos/vcpkg.json
@@ -0,0 +1,16 @@
+{
+ "name": "geos",
+ "version": "3.10.2",
+ "description": "Geometry Engine Open Source",
+ "homepage": "https://www.osgeo.org/projects/geos/",
+ "dependencies": [
+ {
+ "name": "vcpkg-cmake",
+ "host": true
+ },
+ {
+ "name": "vcpkg-cmake-config",
+ "host": true
+ }
+ ]
+}
diff --git a/dev/vcpkg/vcpkg.json b/dev/vcpkg/vcpkg.json
index a6a70ec913..fb349dd05f 100644
--- a/dev/vcpkg/vcpkg.json
+++ b/dev/vcpkg/vcpkg.json
@@ -51,7 +51,8 @@
"benchmark",
"icu",
"thrift",
- "libstemmer"
+ "libstemmer",
+ "geos"
]
},
"velox-s3": {
diff --git a/ep/build-velox/src/setup-centos7.sh
b/ep/build-velox/src/setup-centos7.sh
index f73af6dadf..5402e5b0a6 100755
--- a/ep/build-velox/src/setup-centos7.sh
+++ b/ep/build-velox/src/setup-centos7.sh
@@ -24,11 +24,13 @@ CPU_TARGET="${CPU_TARGET:-avx}"
NPROC=$(getconf _NPROCESSORS_ONLN)
FMT_VERSION=10.1.1
BUILD_DUCKDB="${BUILD_DUCKDB:-true}"
+BUILD_GEOS="${BUILD_GEOS:-true}"
export CFLAGS=$(get_cxx_flags $CPU_TARGET) # Used by LZO.
export CXXFLAGS=$CFLAGS # Used by boost.
export CPPFLAGS=$CFLAGS # Used by LZO.
export
PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib64/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH
FB_OS_VERSION="v2024.07.01.00"
+GEOS_VERSION="3.10.2"
# shellcheck disable=SC2037
SUDO="sudo -E"
@@ -197,6 +199,13 @@ function install_duckdb {
fi
}
+function install_geos {
+ if [[ "$BUILD_GEOS" == "true" ]]; then
+ wget_and_untar
https://github.com/libgeos/geos/archive/${GEOS_VERSION}.tar.gz geos
+ cmake_install_dir geos -DBUILD_TESTING=OFF
+ fi
+}
+
function install_prerequisites {
run_and_time install_lzo
run_and_time install_boost
@@ -216,6 +225,7 @@ function install_velox_deps {
run_and_time install_gtest
run_and_time install_conda
run_and_time install_duckdb
+ run_and_time install_geos
}
$SUDO dnf makecache
diff --git a/ep/build-velox/src/setup-centos8.sh
b/ep/build-velox/src/setup-centos8.sh
index 2e1792a415..072bd83bf4 100755
--- a/ep/build-velox/src/setup-centos8.sh
+++ b/ep/build-velox/src/setup-centos8.sh
@@ -38,6 +38,7 @@ export CXXFLAGS=$CFLAGS # Used by boost.
export CPPFLAGS=$CFLAGS # Used by LZO.
CMAKE_BUILD_TYPE="${BUILD_TYPE:-Release}"
BUILD_DUCKDB="${BUILD_DUCKDB:-true}"
+BUILD_GEOS="${BUILD_GEOS:-true}"
export CC=/opt/rh/gcc-toolset-11/root/bin/gcc
export CXX=/opt/rh/gcc-toolset-11/root/bin/g++
DEPENDENCY_DIR=${DEPENDENCY_DIR:-$(pwd)/deps-download}
@@ -45,6 +46,7 @@ DEPENDENCY_DIR=${DEPENDENCY_DIR:-$(pwd)/deps-download}
FB_OS_VERSION="v2024.07.01.00"
FMT_VERSION="10.1.1"
BOOST_VERSION="boost-1.84.0"
+GEOS_VERSION="3.10.2"
function dnf_install {
dnf install -y -q --setopt=install_weak_deps=False "$@"
@@ -176,6 +178,13 @@ function install_cuda {
yum install -y cuda-nvcc-$(echo $1 | tr '.' '-') cuda-cudart-devel-$(echo $1
| tr '.' '-')
}
+function install_geos {
+ if [[ "$BUILD_GEOS" == "true" ]]; then
+ wget_and_untar
https://github.com/libgeos/geos/archive/${GEOS_VERSION}.tar.gz geos
+ cmake_install_dir geos -DBUILD_TESTING=OFF
+ fi
+}
+
function install_velox_deps {
run_and_time install_velox_deps_from_dnf
run_and_time install_conda
@@ -193,6 +202,7 @@ function install_velox_deps {
run_and_time install_fbthrift
run_and_time install_openssl
run_and_time install_duckdb
+ run_and_time install_geos
}
(return 2> /dev/null) && return # If script was sourced, don't run commands.
diff --git a/ep/build-velox/src/setup-openeuler24.sh
b/ep/build-velox/src/setup-openeuler24.sh
index d08d674957..3647b8c2b1 100755
--- a/ep/build-velox/src/setup-openeuler24.sh
+++ b/ep/build-velox/src/setup-openeuler24.sh
@@ -39,6 +39,7 @@ export CPPFLAGS=$CFLAGS # Used by LZO.
CMAKE_BUILD_TYPE="${BUILD_TYPE:-Release}"
VELOX_BUILD_SHARED=${VELOX_BUILD_SHARED:-"OFF"} #Build folly and gflags shared
for use in libvelox.so.
BUILD_DUCKDB="${BUILD_DUCKDB:-true}"
+BUILD_GEOS="${BUILD_GEOS:-true}"
VERSION=$(cat /etc/os-release | grep VERSION_ID)
export INSTALL_PREFIX=${INSTALL_PREFIX:-"/usr/local"}
DEPENDENCY_DIR=${DEPENDENCY_DIR:-$(pwd)/deps-download}
@@ -47,6 +48,7 @@ FB_OS_VERSION="v2024.07.01.00"
FMT_VERSION="10.1.1"
BOOST_VERSION="boost-1.84.0"
DUCKDB_VERSION="v0.8.1"
+GEOS_VERSION="3.10.2"
function dnf_install {
dnf install -y -q --setopt=install_weak_deps=False "$@"
@@ -159,6 +161,12 @@ function install_duckdb {
fi
}
+function install_geos {
+ if [[ "$BUILD_GEOS" == "true" ]]; then
+ wget_and_untar
https://github.com/libgeos/geos/archive/${GEOS_VERSION}.tar.gz geos
+ cmake_install_dir geos -DBUILD_TESTING=OFF
+ fi
+}
function install_velox_deps {
run_and_time install_velox_deps_from_dnf
run_and_time install_gflags
@@ -174,6 +182,7 @@ function install_velox_deps {
run_and_time install_mvfst
run_and_time install_fbthrift
run_and_time install_duckdb
+ run_and_time install_geos
}
(return 2> /dev/null) && return # If script was sourced, don't run commands.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]