Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use runtime clang-sys feature to match cpal #3

Merged
merged 1 commit into from
Jun 10, 2023

Conversation

kcking
Copy link
Contributor

@kcking kcking commented Jun 10, 2023

I was getting the following clang-sys failure when using vst3-bindgen in a crate that also depends on cpal:

  thread 'main' panicked at 'a `libclang` shared library is not loaded on this thread', /Users/kevin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clang-sys-1.6.1/src/lib.rs:1735:1

I think cpal's transitive dependency on clang-sys enables the runtime feature, also enabling it for com-scrape's usage of clang-sys. But clang_sys::load() must be called when the runtime feature is enabled.

We could in theory expose the clang-sys/runtime feature through vst3_bindgen -> com-scrape -> clang-sys if we don't always want it enabled, let me know what you think.

@glowcoil
Copy link
Contributor

Well, that's frustrating. I consider this to be an incorrect use of Cargo features on the part of clang-sys (and it looks like I'm not the first to point this out: KyleMayes/clang-sys#128), as features are supposed to be additive, i.e. enabling a feature of a crate should not break users of the crate who do not have that feature enabled (see the Cargo reference).

That being said, it will probably be very common for vst3-bindgen to coexist in the same dependency tree with bindgen, so I think this is worth doing. I also think it's fine not to bother with a feature for now; we can bother with that if there's actually a need for it at some point. In any case, I appreciate the PR!

com-scrape/src/generator.rs Outdated Show resolved Hide resolved
com-scrape/Cargo.toml Outdated Show resolved Hide resolved
I was getting the following `clang-sys` failure when using `vst3-bindgen` in a
crate that also depends on `cpal`:

```
  thread 'main' panicked at 'a `libclang` shared library is not loaded on this thread', /Users/kevin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clang-sys-1.6.1/src/lib.rs:1735:1
```

I think `cpal`'s transitive dependency on `clang-sys` enables the runtime
feature, also enabling it for `com-scrape`'s usage of `clang-sys`. But
`clang_sys::load()` must be called when the runtime feature is enabled.
@glowcoil glowcoil merged commit 7fd1d77 into coupler-rs:master Jun 10, 2023
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.

2 participants