kevinmehall / rust-soapysdr

Rust bindings for SoapySDR, the vendor-neutral software defined radio hardware abstraction layer
Apache License 2.0
79 stars 22 forks source link

MacOS: `libclang` shared library is not loaded on this thread #22

Closed justacec closed 3 years ago

justacec commented 3 years ago

(Disclamer, I originally posted this in the clang crate repo, but realized that maybe it should go here as this was the crate that was crashing from it.)

I have been trying to compile FutureSDR with the "soapy" feature which pulls in clang-sys. I have installed LLVM via Homebrew and it is living at '/usr/local/opt/llvm'. The libclang.dynlib is under that dir in the lib directory and the 'llvm-config' command is under that directory in the bin dir. I have set the environment variables as:

LLVM_CONFIG_PATH=/usr/local/opt/llvm/bin/llvm-config
LIBCLANG_PATH=/usr/local/opt/llvm/lib/libclang.dylib

Build Error

❯ RUST_BACKTRACE=full cargo build --examples
   Compiling soapysdr-sys v0.7.2
   Compiling rodio v0.14.0
error: failed to run custom build command for `soapysdr-sys v0.7.2`

Caused by:
  process didn't exit successfully: `/Users/justaceclutter/Source/FutureSDR/target/debug/build/soapysdr-sys-763a0a3c5ea62682/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=SOAPYSDR_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=SOAPYSDR_STATIC
  cargo:rerun-if-env-changed=SOAPYSDR_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=SOAPYSDR_STATIC
  cargo:rerun-if-env-changed=SOAPYSDR_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rustc-link-search=native=/usr/local/Cellar/soapysdr/0.8.1/lib
  cargo:rustc-link-lib=SoapySDR
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=SOAPYSDR_STATIC
  cargo:rerun-if-env-changed=SOAPYSDR_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  thread 'main' panicked at 'a `libclang` shared library is not loaded on this thread', /Users/justaceclutter/.cargo/registry/src/github.com-1ecc6299db9ec823/clang-sys-1.2.0/src/lib.rs:1682:1
  stack backtrace:
     0:        0x10bd8a871 - std::backtrace_rs::backtrace::libunwind::trace::hbebac83a7f69c4c2
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
     1:        0x10bd8a871 - std::backtrace_rs::backtrace::trace_unsynchronized::h70204c1920f029d2
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
     2:        0x10bd8a871 - std::sys_common::backtrace::_print_fmt::he9f032d543410c72
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/sys_common/backtrace.rs:67:5
     3:        0x10bd8a871 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4e8c7f30caf14f6b
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/sys_common/backtrace.rs:46:22
     4:        0x10bdaa0ab - core::fmt::write::h6f39ff4b18ec6aa7
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/core/src/fmt/mod.rs:1161:17
     5:        0x10bd867da - std::io::Write::write_fmt::h899eefaff8efe903
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/io/mod.rs:1668:15
     6:        0x10bd8c9b5 - std::sys_common::backtrace::_print::hd174081a00e4492d
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/sys_common/backtrace.rs:49:5
     7:        0x10bd8c9b5 - std::sys_common::backtrace::print::h34ed55d4c4c57d09
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/sys_common/backtrace.rs:36:9
     8:        0x10bd8c9b5 - std::panicking::default_hook::{{closure}}::h409faa78641a7645
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/panicking.rs:210:50
     9:        0x10bd8c59f - std::panicking::default_hook::h7ee7aa30ab262721
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/panicking.rs:227:9
    10:        0x10bd8d0a0 - std::panicking::rust_panic_with_hook::h5c4d3dad4cf39db7
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/panicking.rs:624:17
    11:        0x10bd8cb3e - std::panicking::begin_panic_handler::{{closure}}::hbf5ff5e8c653ab15
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/panicking.rs:521:13
    12:        0x10bd8ace7 - std::sys_common::backtrace::__rust_end_short_backtrace::h8ba5e37c718cb8e4
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/sys_common/backtrace.rs:141:18
    13:        0x10bd8caaa - rust_begin_unwind
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/panicking.rs:517:5
    14:        0x10bdb9eef - core::panicking::panic_fmt::h6c191e7f85e62838
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/core/src/panicking.rs:100:14
    15:        0x10bda86eb - core::panicking::panic_display::hec0e0339ecb4d7ac
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/core/src/panicking.rs:64:5
    16:        0x10bdb9dfc - core::option::expect_failed::hbff261a7d3cf636c
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/core/src/option.rs:1624:5
    17:        0x10bc92576 - core::option::Option<T>::expect::h230311a187a18542
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/core/src/option.rs:706:21
    18:        0x10bc7ff79 - clang_sys::clang_createIndex::hf8163e7de4770240
                                 at /Users/justaceclutter/.cargo/registry/src/github.com-1ecc6299db9ec823/clang-sys-1.2.0/src/link.rs:157:25
    19:        0x10b9c0f0e - bindgen::clang::Index::new::h38e52c19637dc2b5
                                 at /Users/justaceclutter/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.57.0/src/clang.rs:1532:20
    20:        0x10ba8d53a - bindgen::ir::context::BindgenContext::new::hd4732857e895e29c
                                 at /Users/justaceclutter/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.57.0/src/ir/context.rs:516:21
    21:        0x10b99e338 - bindgen::Bindings::generate::hab6864fa3249b77e
                                 at /Users/justaceclutter/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.57.0/src/lib.rs:2190:27
    22:        0x10b99bf8f - bindgen::Builder::generate::hd0bdc00bd5b95a37
                                 at /Users/justaceclutter/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.57.0/src/lib.rs:1380:9
    23:        0x10b8d08ef - build_script_build::main::hf8f2c81678fffc65
                                 at /Users/justaceclutter/.cargo/registry/src/github.com-1ecc6299db9ec823/soapysdr-sys-0.7.2/build.rs:32:20
    24:        0x10b8cfeae - core::ops::function::FnOnce::call_once::h6b4a5cfcb10bf215
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/core/src/ops/function.rs:227:5
    25:        0x10b8cfa71 - std::sys_common::backtrace::__rust_begin_short_backtrace::hc497ae0dfbce6332
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/sys_common/backtrace.rs:125:18
    26:        0x10b8cf924 - std::rt::lang_start::{{closure}}::he70b13a4c5aab169
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/rt.rs:146:18
    27:        0x10bd8a114 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h2bb4e56f9a9ac6d4
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/core/src/ops/function.rs:259:13
    28:        0x10bd8a114 - std::panicking::try::do_call::h9ea5cb80949e7410
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/panicking.rs:403:40
    29:        0x10bd8a114 - std::panicking::try::h4b562ecd9d6aae1e
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/panicking.rs:367:19
    30:        0x10bd8a114 - std::panic::catch_unwind::hb2383c409919c466
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/panic.rs:133:14
    31:        0x10bd8a114 - std::rt::lang_start_internal::{{closure}}::hbab7bdef1dae4bda
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/rt.rs:128:48
    32:        0x10bd8a114 - std::panicking::try::do_call::h66dd746a0228a095
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/panicking.rs:403:40
    33:        0x10bd8a114 - std::panicking::try::h9cadd6ac84f681cb
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/panicking.rs:367:19
    34:        0x10bd8a114 - std::panic::catch_unwind::h5278b4a6bc69b4e6
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/panic.rs:133:14
    35:        0x10bd8a114 - std::rt::lang_start_internal::h8e9b61b890af96ee
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/rt.rs:128:20
    36:        0x10b8cf8fe - std::rt::lang_start::h463b8cec341bfbdf
                                 at /rustc/11491938f80988c7261a1179cf71a25c379c8783/library/std/src/rt.rs:145:17
    37:        0x10b8d0c46 - <unknown>
                                 at /Users/justaceclutter/.cargo/registry/src/github.com-1ecc6299db9ec823/soapysdr-sys-0.7.2/build.rs:41:2

Rust Configuration

❯ rustup show
Default host: x86_64-apple-darwin
rustup home:  /Users/justaceclutter/.rustup

installed toolchains
--------------------

stable-x86_64-apple-darwin
nightly-2019-07-19-x86_64-apple-darwin
nightly-2019-07-29-x86_64-apple-darwin
nightly-x86_64-apple-darwin (default)
1.52-x86_64-apple-darwin

installed targets for active toolchain
--------------------------------------

arm-unknown-linux-gnueabihf
armv7-unknown-linux-gnueabihf
thumbv7em-none-eabi
thumbv7em-none-eabihf
thumbv7m-none-eabi
wasm32-unknown-unknown
x86_64-apple-darwin

active toolchain
----------------

nightly-x86_64-apple-darwin (default)
rustc 1.57.0-nightly (11491938f 2021-09-29)

LLVM install info

❯ brew info llvm
llvm: stable 13.0.0 (bottled), HEAD [keg-only]
Next-gen compiler infrastructure
https://llvm.org/
/usr/local/Cellar/llvm/13.0.0_1 (10,841 files, 1.8GB)
  Poured from bottle on 2021-10-16 at 15:30:41
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/llvm.rb
License: Apache-2.0 with LLVM-exception
==> Dependencies
Build: cmake ✘, swig ✘
Required: python@3.9 ✔
==> Options
--HEAD
    Install HEAD version
==> Caveats
To use the bundled libc++ please add the following LDFLAGS:
  LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"

llvm is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have llvm first in your PATH, run:
  echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> /Users/justaceclutter/.bash_profile

For compilers to find llvm you may need to set:
  export LDFLAGS="-L/usr/local/opt/llvm/lib"
  export CPPFLAGS="-I/usr/local/opt/llvm/include"

==> Analytics
install: 30,913 (30 days), 68,387 (90 days), 267,969 (365 days)
install-on-request: 22,031 (30 days), 47,539 (90 days), 201,152 (365 days)
build-error: 0 (30 days)

MacOS Info

Version: 11.6

justacec commented 3 years ago

Ugg. Did some last minute cross-checking and Soapysdr is compiling clean, bindgen is compiling clean, and cpal is compiling clean all on their own. It seems the problem might be better diagnosed in the FutureSDR package. Moving there. This is the last move of this issue. I will accept my public flogging...

kevinmehall commented 3 years ago

This might be the same as #19. If the fix to that is the addition of bindgen's runtime cargo feature in #20, note that I haven't yet published that to crates.io.

kevinmehall commented 3 years ago

Just published version 0.3.1 of this crate; see if that fixes this.

justacec commented 3 years ago

I switched out the Cargo.toml file dep in the FutureSDR crate to use the git master for soapysdr. Got a good compile.

justacec commented 3 years ago

It also works with Ver 3.1. I will submit a PR to the FutureSDR framework for the version bump.