Skip to content

libgdal-core: fix unresolved symbols; add tests; link geos and proj dynamically - #6586

Open
MMesch wants to merge 3 commits into
mainfrom
fix-libgdal-core-geos-link
Open

libgdal-core: fix unresolved symbols; add tests; link geos and proj dynamically#6586
MMesch wants to merge 3 commits into
mainfrom
fix-libgdal-core-geos-link

Conversation

@MMesch

@MMesch MMesch commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator
  • Bumped build number (0 → 1); version unchanged.

Package Details

  • Package Name: libgdal-core, libgdal-core-tests (new), libgdal-core-static
  • Version: 3.12.4 (build 1)

Build Notes

  • `build.sh` was passing static libs (`libgeos_c.a`, `libproj.a`) to CMake but with libgeos.a missing, so wasm-ld seemed to inline the geos C wrappers into `libgdal.so` but leaving hundreds of unresolved C++ callees and also an empty `dylink.0` NEEDED. This produced exceptions when loading libgdal independently before libgeos but it worked in other cases. In my case I discovered it with an `import pygplates` before `import shapely` under xeus-python. The actual hard crash was that it goes on stub calls into geos (`ZNK4geos4geom8Geometry12intersectionEPKS1`).
  • Instead of adding the missing dep directly, I decided to switch to shared objects as well and link `libgeos_c.so` and similarly also `libproj.so` for proj. Basically this means swapping `geos-static`/`proj-static` for `geos`/`proj >=9.8`. The resulting `libgdal.so` records proper NEEDED entries; the LDSO transitively loads libgeos and libproj before libgdal instantiates. The `-static` output keeps the static deps on the other hand
  • Finally, I added a `libgdal-core-tests` subpackage (following the `libboost-python-example` pattern) that compiles a MAIN_MODULE test against the pinned libgdal-core and runs it under node. The test exercises `OGR_G_Intersection` (GEOS path) and `OCTTransform` for EPSG:4326→EPSG:3857 (PROJ path).

CMake was passed libgeos_c.a but not libgeos.a, so wasm-ld inlined the
C wrapper into libgdal.so with 349 unresolved C++ callees and empty
dylink.0 NEEDED. Loading libgdal before libgeos (e.g. import pygplates
under xeus-python) then crashed on stub calls into geos.

Link libgeos_c.so instead: libgdal.so records NEEDED=libgeos_c.so and
the LDSO pulls libgeos in first. Add a runtime test that dlopens
libgdal and calls into geos via OGR to guard against regressions.
@MMesch
MMesch marked this pull request as ready for review September 7, 2026 16:40
@MMesch
MMesch requested a review from DerThorsten September 7, 2026 16:41
- build.sh: -DPROJ_LIBRARY libproj.a -> libproj.so
- recipe.yaml: proj-static -> proj >=9.8 on the dynamic output;
  new libgdal-core-tests subpackage (build compiles a MAIN_MODULE
  test, run_tests.sh mounts PROJ_DATA via NODEFS and executes it)
- tests: covers OGR_G_Intersection (GEOS) and OCTTransform (PROJ)
@MMesch MMesch changed the title libgdal-core: link geos dynamically libgdal-core: link geos and proj dynamically Sep 8, 2026
Comment on lines +31 to +32
-sFORCE_FILESYSTEM=1
-lnodefs.js

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what the best way is to do this. It's needed by proj.

@MMesch MMesch changed the title libgdal-core: link geos and proj dynamically libgdal-core: fix bug; add tests;link geos and proj dynamically Sep 8, 2026
@MMesch MMesch changed the title libgdal-core: fix bug; add tests;link geos and proj dynamically libgdal-core: fix unresolved symbols; add tests;link geos and proj dynamically Sep 8, 2026
@MMesch MMesch changed the title libgdal-core: fix unresolved symbols; add tests;link geos and proj dynamically libgdal-core: fix unresolved symbols; add tests; link geos and proj dynamically Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants