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

Build fails with v0.2.11 on crates.io after updating to Clang 16 #75

Closed
publictheta opened this issue Mar 24, 2023 · 3 comments · Fixed by #76
Closed

Build fails with v0.2.11 on crates.io after updating to Clang 16 #75

publictheta opened this issue Mar 24, 2023 · 3 comments · Fixed by #76

Comments

@publictheta
Copy link

After updating to Clang (LLVM) 16, building coreaudio-sys v0.2.11 from crate.io began to fail with errors like "enum_(unnamed_at_...)" is not a valid Ident.

Here is a detailed log:

   Compiling coreaudio-sys v0.2.11
error: failed to run custom build command for `coreaudio-sys v0.2.11`

Caused by:
  process didn't exit successfully: `/Users/me/Developer/rust-coreaudio-sys-issue/target/debug/build/coreaudio-sys-7020e5761942a687/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=COREAUDIO_SDK_PATH
  cargo:rustc-link-lib=framework=AudioUnit
  cargo:rustc-link-lib=framework=AudioToolbox
  cargo:rustc-link-lib=framework=CoreAudio
  cargo:rustc-link-lib=framework=OpenAL
  cargo:rustc-link-lib=framework=CoreMIDI
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS

  --- stderr
  thread 'main' panicked at '"enum_(unnamed_at_/Library/Developer/CommandLineTools/SDKs/MacOSX_sdk/usr/include/MacTypes_h_382_1)" is not a valid Ident', /Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.53/src/fallback.rs:780:9
stack backtrace:
     0: rust_begin_unwind
               at /rustc/8460ca823e8367a30dda430efda790588b8c84d3/library/std/src/panicking.rs:575:5
     1: core::panicking::panic_fmt
               at /rustc/8460ca823e8367a30dda430efda790588b8c84d3/library/core/src/panicking.rs:64:14
     2: proc_macro2::fallback::validate_ident
               at /Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.53/src/fallback.rs:780:9
     3: proc_macro2::fallback::Ident::_new
               at /Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.53/src/fallback.rs:722:9
     4: proc_macro2::fallback::Ident::new
               at /Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.53/src/fallback.rs:732:9
     5: proc_macro2::imp::Ident::new
               at /Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.53/src/wrapper.rs:701:50
     6: proc_macro2::Ident::new
               at /Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.53/src/lib.rs:970:21
     7: bindgen::ir::context::BindgenContext::rust_ident_raw
               at /Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.61.0/ir/context.rs:859:9
     8: bindgen::ir::context::BindgenContext::rust_ident
               at /Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.61.0/ir/context.rs:851:9
     9: <bindgen::ir::enum_ty::Enum as bindgen::codegen::CodeGenerator>::codegen
               at /Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.61.0/codegen/mod.rs:3036:21
    10: <bindgen::ir::ty::Type as bindgen::codegen::CodeGenerator>::codegen
               at /Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.61.0/codegen/mod.rs:1040:39
    11: <bindgen::ir::item::Item as bindgen::codegen::CodeGenerator>::codegen
               at /Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.61.0/codegen/mod.rs:501:17
    12: <bindgen::ir::module::Module as bindgen::codegen::CodeGenerator>::codegen::{{closure}}
               at /Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.61.0/codegen/mod.rs:524:21
    13: <bindgen::ir::module::Module as bindgen::codegen::CodeGenerator>::codegen
               at /Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.61.0/codegen/mod.rs:554:13
    14: <bindgen::ir::item::Item as bindgen::codegen::CodeGenerator>::codegen
               at /Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.61.0/codegen/mod.rs:492:17
    15: bindgen::codegen::codegen::{{closure}}
               at /Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.61.0/codegen/mod.rs:4498:9
    16: bindgen::ir::context::BindgenContext::gen
               at /Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.61.0/ir/context.rs:1174:19
    17: bindgen::codegen::codegen
               at /Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.61.0/codegen/mod.rs:4462:5
    18: bindgen::Bindings::generate
               at /Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.61.0/lib.rs:2545:43
    19: bindgen::Builder::generate
               at /Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.61.0/lib.rs:1580:9
    20: build_script_build::build
               at ./build.rs:150:20
    21: build_script_build::main
               at ./build.rs:165:5
    22: core::ops::function::FnOnce::call_once
               at /rustc/8460ca823e8367a30dda430efda790588b8c84d3/library/core/src/ops/function.rs:250:5
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

This seems to be caused by a change in Clang's behavior mentioned in this fixed issue for the bindgen crate, and it is not occurring in the master branch of coreaudio-sys because Dependabot updated bindgen from v0.61 to v0.64.

As a temporary workaround, I have added the following patch section to my Cargo.toml, but I believe that once the current master branch is released on crates.io, it will help prevent unexpected build errors for users of crates that depend on this crate.

[patch.crates-io]
coreaudio-sys = { git = "https://github.com/RustAudio/coreaudio-sys.git" }

I hope this is helpful:)

@publictheta
Copy link
Author

publictheta commented Mar 24, 2023

Sorry! This is a duplicate of #74.

@simlay
Copy link
Member

simlay commented Mar 25, 2023

Ah so this should be fixed with the dependabot changes in #73? I'll bump the patch version for a publish to crates.io shortly. I tend to be a little hesitant to publish right after a bindgen bump as it's hard to know if generated rust may have breaking changes.

@leeola
Copy link

leeola commented Apr 2, 2023

Hmm, even with this, i still get this error:

error: failed to run custom build command for `coreaudio-sys v0.2.12`

Caused by:
  process didn't exit successfully: `/Users/foo/foo/target/debug/build/coreaudio-sys-56627feab3b3008a/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=COREAUDIO_SDK_PATH
  cargo:rustc-link-lib=framework=AudioUnit
  cargo:rustc-link-lib=framework=CoreAudio
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS

  --- stderr
  /Users/foo/.cargo/registry/src/github.com-1ecc6299db9ec823/coreaudio-sys-0.2.12/coreaudio.h:1:10: fatal error: 'AudioUnit/AudioUnit.h' file not found
  thread 'main' panicked at 'unable to generate bindings: ClangDiagnostic("/Users/foo/.cargo/registry/src/github.com-1ecc6299db9ec823/coreaudio-sys-0.2.12/coreaudio.h:1:10: fatal error: 'AudioUnit/AudioUnit.h' file not found\n")', /Users/foo/.cargo/registry/src/github.com-1ecc6299db9ec823/coreaudio-sys-0.2.12/build.rs:150:39
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

I experienced it on Monterey, upgraded to Ventura (13.3) out of curiosity and still see it. I'm not sure what the latest is settings i should use are, but i have the env set to:

foo@foo ~/foo (main) [101]> echo $COREAUDIO_SDK_PATH
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
foo@foo ~/foo (main)> xcrun --sdk macosx --show-sdk-path
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

Though i'm also using Nix (on Mac, ofc), and trying various things to get it working there with no luck either. Perhaps this should be a new issue.

Any thoughts? Note that coreaudio-sys is currently on 0.2.12. I also tried it against master to no avail.

edit: Hmm, no this looks to be a completely unrelated error? Just lots of path finding errors in this repo, all unique .. hm. Apologies, will open a new issue.

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 a pull request may close this issue.

3 participants