Skip to content

Rebuild netcdf4; Rebuild libnetcdf; fix runtime failure due to missing listxattr#5951

Open
MMesch wants to merge 4 commits into
emscripten-forge:mainfrom
MMesch:fix-netcdf4-dimscales
Open

Rebuild netcdf4; Rebuild libnetcdf; fix runtime failure due to missing listxattr#5951
MMesch wants to merge 4 commits into
emscripten-forge:mainfrom
MMesch:fix-netcdf4-dimscales

Conversation

@MMesch

@MMesch MMesch commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Edited after splitting out new PR #6007 .

Summary

Fixes the runtime failure xarray.open_dataset(...)netCDF4.Datasetnc_openH5DSis_scaleDynamic linking error: cannot resolve symbol H5DSis_scale in the browser, and the follow-on RuntimeError: ring type mismatch occurred for cache entry that surfaces once H5DSis_scale is reachable.

Build Notes

  • netcdf4: add -lhdf5_hl to LDFLAGS. This may not strictly be necessary since it seems to be activated by default. But it's probably safer to add. The bug we observed was related to this library.
  • libnetcdf: skip the DAOS-container check under __EMSCRIPTEN__: netcdf-c 4.10.1 references listxattr from libdispatch/dinfermodel.cinside the DAOS-container probe, guarded by HAVE_SYS_XATTR_H. Emscripten's <sys/xattr.h> declares listxattr but the runtime doesn't implement it, so the built .so fails to load. configure.ac seems to have no DAOS knobs. We therefore patch the source to early-return NC_ENOTNC under __EMSCRIPTEN__. Attempting to set the variable ac_cv_header_sys_xattr_h=no produced garbled compile errors in the surrounding isdaoscontainer() function under -std=gnu23 and was abandoned.
  • variant.yaml bumped: hdf5: 1.14.6, libnetcdf: 4.10.1.

@MMesch
MMesch force-pushed the fix-netcdf4-dimscales branch 2 times, most recently from f4548c4 to 5495139 Compare July 20, 2026 15:17
@MMesch

MMesch commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

@IsabelParedes , waiting for your thoughts on this now. After discussing with @DerThorsten these are some points to consider:

  • the feclearexcept(FE_INVALID) issue is solved upstream in hdf5 2.x.
  • the deduplication problem should be solved generally. But we can use the patch here as hot fix and move ahead with this recipe more quickly.
  • the netcdf updates could be split out in a separate PR

@IsabelParedes

Copy link
Copy Markdown
Member

the netcdf updates could be split out in a separate PR

This would be nice. Thanks!

- bump 1.12.3 -> 1.14.6, update source URL template
- patches/0001-fenv-fe-invalid-guard.patch: guard FE_INVALID use in
  H5Tinit_float.c; emscripten's <bits/fenv.h> defines only rounding
  modes, FE_INVALID is not declared. This patch is already upstream in
  hdf5 2.x and can probably be dropped once we update further
  https://github.com/HDFGroup/hdf5/blob/f8844a64c639f7ba33592a7948d4adacacb2d451/src/H5Tinit_float.c#L614-L617
- patches/0002-drop-soversion.patch: skip VERSION/SOVERSION properties
  under EMSCRIPTEN so libhdf5_hl.so records bare "libhdf5.so" as its
  NEEDED entry. Otherwise it records "libhdf5.so.310.5.1" while
  other packages link with -lhdf5 and record "libhdf5.so".
  The emscripten loader seems to dedupe by string identity (not realpath) and
  ends up loading libhdf5.so twice. One visible symptom of this was that the
  hdf5 metadata cache errors when calls cross between those two loaded
  instances, something which blocks simple file reading and also affects
  netcdf4 transitively. Note that this is a hot fix and a proper
  solution that also works for other libraries would be nicer to have.
- variant.yaml: pin hdf5 to 1.14.6
- 1.14 auto-generates settings/ so the old workaround is dropped
@MMesch
MMesch force-pushed the fix-netcdf4-dimscales branch from 5495139 to 82c366e Compare July 23, 2026 13:55
MMesch added 3 commits July 23, 2026 16:40
- HDF5_VERSION 1.12.3 -> 1.14.6
- drop the ctypes.CDLL preload prepended to __init__.py; the
  hdf5 SOVERSION fix makes the emscripten loader dedupe libhdf5.so
  properly, so the manual dlopen seems no longer needed.
- add version check and a dimension-scale round-trip test that guards
  the HL path (H5DSset_scale + attach_scale + is_scale after reopen)
netcdf-c's isdaoscontainer() in libdispatch/dinfermodel.c uses
listxattr/getxattr to sniff a path for DAOS marker attributes.
Emscripten's <sys/xattr.h> declares these but the runtime does not
implement them, so the built .so fails to load with "cannot resolve
symbol listxattr". There is no --disable-daos configure option (the
check is hard-coded), so patch the source to early-return NC_ENOTNC
under __EMSCRIPTEN__.

Also bump the variant.yaml pin to 4.10.1 to match the recipe version;
the previous 4.9.3 pin was forcing consumers to resolve against upstream
4.9.3 which had been built against HDF5 1.12.3 headers and aborted at
runtime against a 1.14.6 runtime.
netcdf-4 file access walks the HDF5 tree with H5DSis_scale to
distinguish coordinate dims from data variables. Without -lhdf5_hl
in the extension LDFLAGS the built _netCDF4.so has no libhdf5_hl.so
in its NEEDED entries, so the loader never brings it in and calls
to H5DSis_scale die with "Dynamic linking error: cannot resolve
symbol H5DSis_scale" the moment xarray/netCDF4 opens a NETCDF4 file.

Also replace the smoke test with two focused cases: a NETCDF3_CLASSIC
round-trip and a NETCDF4 round-trip that exercises dim + variable +
attribute together.
@MMesch
MMesch force-pushed the fix-netcdf4-dimscales branch from 82c366e to f682d4f Compare July 23, 2026 14:40
@MMesch MMesch changed the title Fix netcdf4/h5py dimension scales on emscripten Rebuild netcdf4 Jul 23, 2026
@MMesch MMesch changed the title Rebuild netcdf4 Rebuild netcdf4; fix runtime failure Jul 23, 2026
@DerThorsten

DerThorsten commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

2. libhdf5_hl.so records NEEDED libhdf5.so.310.5.1

@MMesch isnt that the culprint / root-problem
I would expect that one never explicitly links against the versioned so, just the unversioned so (ie libhdf5.so)
the unversioned so ist then just a symlink to the versioned so, that way one can swap out the symlink and point to a newer version.

@MMesch did you trace the stuff in the browser to see that libhdf5_hl.so records NEEDED libhdf5.so.310.5.1 or whats a good way to see that

@MMesch MMesch changed the title Rebuild netcdf4; fix runtime failure Rebuild netcdf4; Rebuild libnetcdf; fix runtime failure due to missing listxattr Jul 23, 2026
@MMesch

MMesch commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

@DerThorsten , I split out hdf5 to PR #6007. I'll write a more detailed description what I did in there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants