Closed max-te closed 4 months ago
A workaround is to force a debug-build of hdf5-src:
[profile.release.package.hdf5-src]
opt-level = 0
Seems strange that the debug build of hdf5-src should fix this problem. Is the parallel flag enabled only for the release build of hdf5?
You should be able to run cargo update netcdf-src
and get the fix
Thanks, it compiles now, but as soon as I use e.g. netcdf::open
, the linking fails:
error: linking with `cc` failed: exit status: 1
|
= note: LC_ALL="C" PATH="/home/max/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/max/.cache/zsh/zinit/polaris/bin:/home/max/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/home/max/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/android-sdk/platform-tools:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/opt/rocm/bin:/usr/lib/rustup/bin:/opt/android-sdk/platform-tools:/home/max/.cargo/bin:/home/max/.local/bin" VSLANG="1033" "cc" "-m64" "/tmp/rustcv55eTS/symbols.o" "/home/max/dev/bug/target/release/deps/bug-a2b8f3e61be9efc4.bug.ccaa775bfa9f94d7-cgu.0.rcgu.o" "/home/max/dev/bug/target/release/deps/bug-a2b8f3e61be9efc4.2do8gvq4tu6jf2q2.rcgu.o" "-Wl,--as-needed" "-L" "/home/max/dev/bug/target/release/deps" "-L" "/home/max/dev/bug/target/release/build/netcdf-src-0f716cb9ba04d569/out/lib" "-L" "/home/max/dev/bug/target/release/build/hdf5-src-614e7233f98d8695/out/lib" "-L" "/home/max/dev/bug/target/release/build/libz-sys-97b733af6dc36c2b/out/lib" "-L" "/home/max/dev/bug/target/release/build/libz-sys-97b733af6dc36c2b/out/lib" "-L" "/home/max/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/max/dev/bug/target/release/deps/libnetcdf-54d0061f1408d96a.rlib" "/home/max/dev/bug/target/release/deps/libbitflags-e1edd608d2279ef5.rlib" "/home/max/dev/bug/target/release/deps/libndarray-a520037548548015.rlib" "/home/max/dev/bug/target/release/deps/libmatrixmultiply-77af54bfaf3802cc.rlib" "/home/max/dev/bug/target/release/deps/libnum_complex-eecdf8110d69816a.rlib" "/home/max/dev/bug/target/release/deps/libnum_integer-72aa4e2196cd81c4.rlib" "/home/max/dev/bug/target/release/deps/libnum_traits-e1c3e3ffc27f3447.rlib" "/home/max/dev/bug/target/release/deps/librawpointer-75fd1a582b448a5f.rlib" "/home/max/dev/bug/target/release/deps/libnetcdf_sys-076c07e3415d6306.rlib" "/home/max/dev/bug/target/release/deps/libnetcdf_src-593ebe26b88c6da0.rlib" "/home/max/dev/bug/target/release/deps/libhdf5_sys-142811e55ce0bac4.rlib" "/home/max/dev/bug/target/release/deps/liblibc-8fe09481f39ba46e.rlib" "/home/max/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-2d08990d644ac786.rlib" "/home/max/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-6f2d4ec7ff80253d.rlib" "/home/max/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-c194d68892442324.rlib" "/home/max/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-9a71c52c5946f83b.rlib" "/home/max/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-ae9aec4ce2dabc4f.rlib" "/home/max/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-6a207457d27610cc.rlib" "/home/max/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-fb1d2514710eef16.rlib" "/home/max/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-e36e7ed4b08caeac.rlib" "/home/max/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-9e8dafdf0a1b7ecd.rlib" "/home/max/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-b218f37fe3c9ce2e.rlib" "/home/max/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-20c30954fd9b5ef4.rlib" "/home/max/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-6d3dfaf536d51163.rlib" "/home/max/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-cb4ce50789112af8.rlib" "/home/max/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-9897980a3b548e05.rlib" "/home/max/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-b7bd4d010c784af2.rlib" "/home/max/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-6d4515df28ba3369.rlib" "/home/max/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-e28568c1a21499f7.rlib" "/home/max/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-eedf3675950a13c2.rlib" "/home/max/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-715e69127681e2e0.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/max/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/max/dev/bug/target/release/deps/bug-a2b8f3e61be9efc4" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-debug" "-nodefaultlibs"
= note: /usr/bin/ld: /home/max/dev/bug/target/release/deps/libnetcdf_sys-076c07e3415d6306.rlib(hdf5create.c.o): in function `nc4_create_file':
/home/max/.cargo/registry/src/index.crates.io-6f17d22bba15001f/netcdf-src-0.3.4/source/libhdf5/hdf5create.c:205:(.text.NC4_create+0x3a3): undefined reference to `H5Pset_all_coll_metadata_ops'
/usr/bin/ld: /home/max/.cargo/registry/src/index.crates.io-6f17d22bba15001f/netcdf-src-0.3.4/source/libhdf5/hdf5create.c:207:(.text.NC4_create+0x3ba): undefined reference to `H5Pset_coll_metadata_write'
collect2: error: ld returned 1 exit status
= note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
= note: use the `-l` flag to specify native libraries to link
= note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib)
I suspect that this is an upstream problem in hdf5-src and it doesn't set the correct flags in release builds.
This seems like two versions of hdf5
are installed, and the wrong one is linked. This could either happen on the rust side, or by cmake when building netcdf-c. Do you have a way for me to replicate your environment?
That was a pointer in the right direction. I do have hdf5-openmpi
1.14.3 installed on my system (Arch Linux) as a dependency of FreeCAD. When I uninstall that and cargo clean
, the release build works! So it looks like the system installed hdf5
is preferred over the statically built one during linking. This does not trigger for unoptimized builds since there _d
is added to the library name.
The cmake command in netcdf-src with
static
feature fails for me on release builds.Steps to reproduce (in an empty folder)
Output: