Skip to content

Commit 080c3ad

Browse files
Build MobilityDuck without GSL (#520)
MEOS draws its random numbers from the pg_prng generators of PostgreSQL and calls no GSL function, and the MobilityDB commit the meos port builds finds no GSL package. MobilityDuck therefore neither installs nor links GSL: the manifest and the meos port name no gsl dependency, and CMakeLists.txt finds no GSL package and links no GSL target. The meos port's version is 18. The comments state what MEOS is: it keeps the PROJ context and its two random number generators in thread-local storage and holds no GEOS or GSL context, its convex hull of a temporal circular buffer is its own, and the mutex around a MEOS-backed scalar function body keeps the MEOS calls of concurrent pipelines from overlapping. The vcpkg-built libraries the artifact must absorb are MEOS, PROJ, GDAL, json-c, h3 and libxml2, and the meos port leaves out the MEOS C test binaries because the extension links only the library.
1 parent 1648011 commit 080c3ad

8 files changed

Lines changed: 17 additions & 27 deletions

File tree

‎.github/workflows/MainDistributionPipeline.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ jobs:
187187
else
188188
readelf -d "$EXT" | sed -n 's/.*NEEDED.*\[\(.*\)\]/\1/p' > deps.txt
189189
# glibc's own set plus the C++ runtime. Anything vcpkg built (MEOS,
190-
# PROJ, GDAL, GSL, json-c, h3, libxml2) must be absorbed into
190+
# PROJ, GDAL, json-c, h3, libxml2) must be absorbed into
191191
# the binary, so none of them may appear here.
192192
ALLOW='^(libc\.so|libm\.so|libdl\.so|libpthread\.so|librt\.so|libresolv\.so|libstdc\+\+\.so|libgcc_s\.so|libz\.so|ld-linux)'
193193
fi

‎CMakeLists.txt‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ endif()
2626
# Dependencies (vcpkg)
2727
# -----------------------------
2828
find_package(PROJ CONFIG REQUIRED)
29-
find_package(GSL REQUIRED)
3029
find_package(OpenSSL REQUIRED)
3130
find_package(json-c CONFIG QUIET)
3231
if(NOT json-c_FOUND)
@@ -251,7 +250,7 @@ endforeach()
251250
# libmeos is a static archive (the meos port follows the triplet's static
252251
# linkage), so it carries only MEOS's objects: every library MEOS itself calls
253252
# into has to be resolved on this link line instead of inside a shared libmeos.
254-
# PROJ, GSL and json-c already appear in the link list below; these four
253+
# PROJ and json-c already appear in the link list below; these four
255254
# are the ones the list was missing, one per optional family the meos port
256255
# enables with -DALL=ON — H3 for th3index, GDAL for the raster operators, and
257256
# libxml2 plus zlib for the pgPointCloud core.
@@ -266,8 +265,6 @@ find_package(ZLIB REQUIRED)
266265
set(MOBILITYDUCK_LINK_LIBS
267266
MEOS::meos
268267
PROJ::proj
269-
GSL::gsl
270-
GSL::gslcblas
271268
${JSONC_TGT}
272269
OpenSSL::SSL
273270
OpenSSL::Crypto

‎src/include/mobilityduck/meos_exec_serial.hpp‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,9 @@
1515
namespace duckdb {
1616

1717
/**
18-
* Mutex serialization for MobilityDuck scalar function bodies that ultimately call
19-
* MEOS / liblwgeom. MEOS uses GEOS's legacy global API (`initGEOS` / `finishGEOS`)
20-
* internally from worker threads; concurrent legacy GEOS init/teardown from DuckDB's
21-
* parallelism triggers intermittent GEOS errors and allocator corruption when spatial
22-
* and MobilityDuck coexist.
23-
*
24-
* Wrapping each MEOS-backed ScalarFunction execution prevents overlapping MEOS/GEOS
25-
* legacy pairs across concurrent pipelines while preserving parallelism elsewhere.
18+
* Mutex serialization for MobilityDuck scalar function bodies that call MEOS:
19+
* wrapping each MEOS-backed ScalarFunction execution keeps the MEOS calls of
20+
* concurrent pipelines from overlapping while preserving parallelism elsewhere.
2621
*/
2722
inline std::mutex &MeosSerializedExecMutex() {
2823
static std::mutex mutex;

‎src/include/mobilityduck/meos_thread.hpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ inline std::string &MeosThreadTimezone() {
2424
return zone;
2525
}
2626

27-
// MEOS keeps the session timezone, the collation cache, errno, the PROJ and
28-
// GEOS contexts and the RNGs in thread-local storage, so a thread that calls
27+
// MEOS keeps the session timezone, the collation cache, errno, the PROJ
28+
// context and the RNGs in thread-local storage, so a thread that calls
2929
// MEOS initialises its own caches before its first call (see meos.h,
3030
// "Multithreading"). DuckDB runs scalar, cast and aggregate bodies on
3131
// TaskScheduler worker threads, so a one-shot init on the load thread leaves
@@ -38,9 +38,9 @@ inline std::string &MeosThreadTimezone() {
3838
// process-global error handler to the exit-on-error default, so an error
3939
// raised on any other thread during that window would print a bare message and
4040
// end the process rather than reach the handler that turns it into a DuckDB
41-
// exception. The PROJ, GEOS and GSL contexts are thread-local statics inside
42-
// MEOS that it creates lazily on first use, so a caller neither can nor needs
43-
// to initialise them.
41+
// exception. The PROJ context and the RNGs are thread-local statics inside MEOS
42+
// that it creates lazily on first use, so a caller neither can nor needs to
43+
// initialise them.
4444
inline void EnsureMeosThreadInitialized() {
4545
static thread_local const bool meos_thread_ready = []() {
4646
meos_initialize_timezone(MEOS_DEFAULT_TIMEZONE);

‎test/sql/tcbuffer.test‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ SELECT endValue(tcbuffer '{Cbuffer(Point(1 1),0.5)@2000-01-01, Cbuffer(Point(2 2
128128
----
129129
Cbuffer(010100000000000000000000400000000000000040,1)
130130

131-
# spatial accessor: convex hull of the swept region. convexHull is a linear (GEOS-polygonized)
132-
# hull of the traversed area, not a curved CURVEDPOLYGON (see the tcbuffer manual note); a
133-
# zero-radius input yields the point trajectory's stable, arc-free triangle. The geometry
134-
# marshals to the DuckDB GEOMETRY type.
131+
# spatial accessor: convex hull of the swept region. convexHull is computed on the exact
132+
# traversed area, arcs included, so a buffer of nonzero radius yields a CURVEPOLYGON (see the
133+
# tcbuffer manual note); a zero-radius input carries no arc and yields the point trajectory's
134+
# triangle. The geometry marshals to the DuckDB GEOMETRY type.
135135
query I
136136
SELECT ST_AsText(convexHull(tcbuffer '[Cbuffer(Point(0 0),0)@2000-01-01, Cbuffer(Point(3 0),0)@2000-01-02, Cbuffer(Point(3 4),0)@2000-01-03]'));
137137
----

‎vcpkg.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"dependencies": [
3-
"gsl",
43
{ "name": "meos", "version>=": "0" },
54

65
"vcpkg-cmake",

‎vcpkg_ports/meos/portfile.cmake‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ vcpkg_cmake_configure(
8585
# one .duckdb_extension file with nowhere to put a sidecar libmeos, so
8686
# forcing a shared build here produced a binary that referenced
8787
# @rpath/libmeos.dylib and failed to load anywhere but the CI runner.
88-
# Build only the MEOS library, not the MEOS C test binaries: those link
89-
# the GEOS C++ API, which the arm64-linux vcpkg triplet does not carry.
88+
# Build only the MEOS library, the one artifact the extension links, not
89+
# the MEOS C test binaries.
9090
-DBUILD_TESTING=OFF
9191
"-DCMAKE_PROJECT_INCLUDE=${CMAKE_CURRENT_LIST_DIR}/cmake-project-include.cmake"
9292
)

‎vcpkg_ports/meos/vcpkg.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
{
22
"name": "meos",
33
"version-string": "git",
4-
"port-version": 17,
4+
"port-version": 18,
55
"description": "MEOS - Mobility Engine Open Source C library (built from MobilityDB with -DMEOS=ON)",
66
"homepage": "https://libmeos.org/",
77
"dependencies": [
88
"vcpkg-cmake",
99
"vcpkg-cmake-config",
1010
"proj",
1111
"json-c",
12-
"gsl",
1312
"h3",
1413
{ "name": "gdal", "default-features": false },
1514
{ "name": "libxml2", "features": [ "zlib" ], "default-features": false },

0 commit comments

Comments
 (0)