aldanor / hdf5-rust

HDF5 for Rust
https://docs.rs/hdf5
Apache License 2.0
310 stars 85 forks source link

Build failure on Mac #118

Closed Timmmm closed 4 years ago

Timmmm commented 4 years ago

I have this in Cargo.toml:

hdf5 = "0.7.0"

If I run cargo build on OSX I get this error:

   Compiling hdf5-sys v0.7.0
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-m64" "-L" "/Users/me/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/me/project/target/debug/build/hdf5-sys-7fff02f825a421e2/build_script_build-7fff02f825a421e2.build_script_build.7a55f7n0-cgu.0.rcgu.o" "/Users/me/project/target/debug/build/hdf5-sys-7fff02f825a421e2/build_script_build-7fff02f825a421e2.build_script_build.7a55f7n0-cgu.1.rcgu.o" "/Users/me/project/target/debug/build/hdf5-sys-7fff02f825a421e2/build_script_build-7fff02f825a421e2.build_script_build.7a55f7n0-cgu.10.rcgu.o" "/Users/me/project/target/debug/build/hdf5-sys-7fff02f825a421e2/build_script_build-7fff02f825a421e2.build_script_build.7a55f7n0-cgu.11.rcgu.o" "/Users/me/project/target/debug/build/hdf5-sys-7fff02f825a421e2/build_script_build-7fff02f825a421e2.build_script_build.7a55f7n0-cgu.12.rcgu.o" "/Users/me/project/target/debug/build/hdf5-sys-7fff02f825a421e2/build_script_build-7fff02f825a421e2.build_script_build.7a55f7n0-cgu.13.rcgu.o" "/Users/me/project/target/debug/build/hdf5-sys-7fff02f825a421e2/build_script_build-7fff02f825a421e2.build_script_build.7a55f7n0-cgu.14.rcgu.o" "/Users/me/project/target/debug/build/hdf5-sys-7fff02f825a421e2/build_script_build-7fff02f825a421e2.build_script_build.7a55f7n0-cgu.15.rcgu.o" "/Users/me/project/target/debug/build/hdf5-sys-7fff02f825a421e2/build_script_build-7fff02f825a421e2.build_script_build.7a55f7n0-cgu.2.rcgu.o" "/Users/me/project/target/debug/build/hdf5-sys-7fff02f825a421e2/build_script_build-7fff02f825a421e2.build_script_build.7a55f7n0-cgu.3.rcgu.o" "/Users/me/project/target/debug/build/hdf5-sys-7fff02f825a421e2/build_script_build-7fff02f825a421e2.build_script_build.7a55f7n0-cgu.4.rcgu.o" "/Users/me/project/target/debug/build/hdf5-sys-7fff02f825a421e2/build_script_build-7fff02f825a421e2.build_script_build.7a55f7n0-cgu.5.rcgu.o" "/Users/me/project/target/debug/build/hdf5-sys-7fff02f825a421e2/build_script_build-7fff02f825a421e2.build_script_build.7a55f7n0-cgu.6.rcgu.o" "/Users/me/project/target/debug/build/hdf5-sys-7fff02f825a421e2/build_script_build-7fff02f825a421e2.build_script_build.7a55f7n0-cgu.7.rcgu.o" "/Users/me/project/target/debug/build/hdf5-sys-7fff02f825a421e2/build_script_build-7fff02f825a421e2.build_script_build.7a55f7n0-cgu.8.rcgu.o" "/Users/me/project/target/debug/build/hdf5-sys-7fff02f825a421e2/build_script_build-7fff02f825a421e2.build_script_build.7a55f7n0-cgu.9.rcgu.o" "-o" "/Users/me/project/target/debug/build/hdf5-sys-7fff02f825a421e2/build_script_build-7fff02f825a421e2" "/Users/me/project/target/debug/build/hdf5-sys-7fff02f825a421e2/build_script_build-7fff02f825a421e2.583sodp479d2edm6.rcgu.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/me/project/target/debug/deps" "-L" "/Users/me/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/me/project/target/debug/deps/liblibloading-c941c9916a6b2a31.rlib" "/Users/me/project/target/debug/deps/libregex-dd5c6e74c0cf5cbf.rlib" "/Users/me/project/target/debug/deps/libthread_local-63b2c4993b179977.rlib" "/Users/me/project/target/debug/deps/liblazy_static-5d8a7ecca0359d1e.rlib" "/Users/me/project/target/debug/deps/libregex_syntax-59ba61b481e3e3be.rlib" "/Users/me/project/target/debug/deps/libaho_corasick-e730acd6588763c8.rlib" "/Users/me/project/target/debug/deps/libmemchr-36ec507b852c0eaa.rlib" "/Users/me/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-f13f993217d0ff19.rlib" "/Users/me/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-fd322230517448c5.rlib" "/Users/me/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-bfac32b2346e6f4f.rlib" "/Users/me/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-366aa1278b6a1212.rlib" "/Users/me/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace-e3336f6b916a3e06.rlib" "/Users/me/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace_sys-f90e2fda5c4354a8.rlib" "/Users/me/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-3f082039d6523013.rlib" "/Users/me/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-0e0d502cf4053e50.rlib" "/Users/me/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-a69411463c63ffac.rlib" "/Users/me/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-63b216fe2d62ff77.rlib" "/Users/me/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-4e60e72e5eb2e571.rlib" "/Users/me/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-4c26a78942ac2ec8.rlib" "/Users/me/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-81342cbee8440a1f.rlib" "/Users/me/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-f0244eb4ede32fb8.rlib" "-lSystem" "-lresolv" "-lc" "-lm"
  = note: Undefined symbols for architecture x86_64:
            "regex_syntax::hir::literal::Literals::all_complete::h8381b63a5049fd0e", referenced from:
                regex::literal::imp::LiteralSearcher::new::h139288daeeced387 (.llvm.4870232668318024664) in libregex-dd5c6e74c0cf5cbf.rlib(regex-dd5c6e74c0cf5cbf.regex.5gg6lukd-cgu.14.rcgu.o)
            "regex_syntax::hir::literal::Literals::longest_common_prefix::hb81f34a3e6cbb381", referenced from:
                regex::literal::imp::LiteralSearcher::new::h139288daeeced387 (.llvm.4870232668318024664) in libregex-dd5c6e74c0cf5cbf.rlib(regex-dd5c6e74c0cf5cbf.regex.5gg6lukd-cgu.14.rcgu.o)
            "regex_syntax::hir::literal::Literals::longest_common_suffix::h725f8f56b83ce078", referenced from:
                regex::literal::imp::LiteralSearcher::new::h139288daeeced387 (.llvm.4870232668318024664) in libregex-dd5c6e74c0cf5cbf.rlib(regex-dd5c6e74c0cf5cbf.regex.5gg6lukd-cgu.14.rcgu.o)
            "_$LT$regex_syntax..hir..literal..Literal$u20$as$u20$core..ops..deref..Deref$GT$::deref::h0d2d9073db509dd0", referenced from:
                regex::literal::imp::LiteralSearcher::prefixes::h4e3905a12617783d in libregex-dd5c6e74c0cf5cbf.rlib(regex-dd5c6e74c0cf5cbf.regex.5gg6lukd-cgu.14.rcgu.o)
                regex::literal::imp::LiteralSearcher::suffixes::h6e52ac384f0b183c in libregex-dd5c6e74c0cf5cbf.rlib(regex-dd5c6e74c0cf5cbf.regex.5gg6lukd-cgu.14.rcgu.o)
                regex::literal::imp::LiteralSearcher::find_start::h562f196af6e646b5 in libregex-dd5c6e74c0cf5cbf.rlib(regex-dd5c6e74c0cf5cbf.regex.5gg6lukd-cgu.14.rcgu.o)
                regex::literal::imp::LiteralSearcher::find_end::h0e14b1822b399000 in libregex-dd5c6e74c0cf5cbf.rlib(regex-dd5c6e74c0cf5cbf.regex.5gg6lukd-cgu.14.rcgu.o)
                regex::literal::imp::Matcher::new::h066b96129dbeee79 in libregex-dd5c6e74c0cf5cbf.rlib(regex-dd5c6e74c0cf5cbf.regex.5gg6lukd-cgu.14.rcgu.o)
            "regex_syntax::hir::literal::Literals::union_prefixes::h171ca26071984cb4", referenced from:
                regex::exec::ExecBuilder::build::hc0693c64d9baffc7 in libregex-dd5c6e74c0cf5cbf.rlib(regex-dd5c6e74c0cf5cbf.regex.5gg6lukd-cgu.9.rcgu.o)
            "regex_syntax::hir::literal::Literals::union_suffixes::h9af1a57a0ddfeed0", referenced from:
                regex::exec::ExecBuilder::build::hc0693c64d9baffc7 in libregex-dd5c6e74c0cf5cbf.rlib(regex-dd5c6e74c0cf5cbf.regex.5gg6lukd-cgu.9.rcgu.o)
            "regex_syntax::hir::literal::Literals::literals::h6816bcbea3c42c7c", referenced from:
                regex::literal::imp::LiteralSearcher::prefixes::h4e3905a12617783d in libregex-dd5c6e74c0cf5cbf.rlib(regex-dd5c6e74c0cf5cbf.regex.5gg6lukd-cgu.14.rcgu.o)
                regex::literal::imp::LiteralSearcher::suffixes::h6e52ac384f0b183c in libregex-dd5c6e74c0cf5cbf.rlib(regex-dd5c6e74c0cf5cbf.regex.5gg6lukd-cgu.14.rcgu.o)
                regex::literal::imp::Matcher::new::h066b96129dbeee79 in libregex-dd5c6e74c0cf5cbf.rlib(regex-dd5c6e74c0cf5cbf.regex.5gg6lukd-cgu.14.rcgu.o)
            "regex_syntax::hir::literal::Literals::empty::h9cc03fb926f85c8f", referenced from:
                regex::prog::Program::new::hecfb79e978169ab4 in libregex-dd5c6e74c0cf5cbf.rlib(regex-dd5c6e74c0cf5cbf.regex.5gg6lukd-cgu.15.rcgu.o)
                regex::exec::ExecBuilder::build::hc0693c64d9baffc7 in libregex-dd5c6e74c0cf5cbf.rlib(regex-dd5c6e74c0cf5cbf.regex.5gg6lukd-cgu.9.rcgu.o)
            "_$LT$regex_syntax..hir..literal..Literal$u20$as$u20$core..convert..AsRef$LT$$u5b$u8$u5d$$GT$$GT$::as_ref::hf2407149e57bb975", referenced from:
                aho_corasick::packed::api::Builder::extend::h7fffe5a241dee95c in libregex-dd5c6e74c0cf5cbf.rlib(regex-dd5c6e74c0cf5cbf.regex.5gg6lukd-cgu.10.rcgu.o)
                aho_corasick::nfa::Builder::build::h3ca67b95ed337814 in libregex-dd5c6e74c0cf5cbf.rlib(regex-dd5c6e74c0cf5cbf.regex.5gg6lukd-cgu.4.rcgu.o)
          ld: symbol(s) not found for architecture x86_64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to previous error

error: could not compile `hdf5-sys`.

I also tried adding this to Cargo.toml but it doesn't change anything:

hdf5-sys = { version = "0.7.0", features = ["static"] }

This is using Rust 1.45.2.

magnusuMET commented 4 years ago

That is quite the strange error, why wouldn't it find items for regex_syntax? Does a verbose build (cargo b -vvv) give more information?

Timmmm commented 4 years ago

Hmm I realised it might be because I am using sccache. After deleting its cache and rebuilding it worked fine. Well, ish. I had to try a couple of times - it doesn't seem very robust to non-clean builds but I guess that is what you get if you wrap a C library.

magnusuMET commented 4 years ago

We might have to emit some more cargo:rebuild-if-changed lines to the build scripts. Are there any relevant environment flags which should be checked for?

Timmmm commented 4 years ago

I have no idea, sorry!