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

coreaudio-sys compile fails on MacOS due to LLVM change; cannot build bevy #10274

Closed
dmlary opened this issue Oct 26, 2023 · 6 comments
Closed
Labels
A-Audio Sounds playback and modification C-Bug An unexpected or incorrect behavior O-MacOS Specific to the MacOS (Apple) desktop operating system

Comments

@dmlary
Copy link
Contributor

dmlary commented Oct 26, 2023

Bevy version

HEAD of master branch (a830530)

Relevant system information

MacOS Ventura 13.6.1, but more importantly LLVM v15.0.0 (system version for ventura).

What you did

cargo build

What went wrong

Cannot build bevy on MacOS. Build fails on coreaudio-sys with the following output:

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

Caused by:
  process didn't exit successfully: `/Users/dmlary/src/bevy/vendor/bevy/target/debug/build/coreaudio-sys-88e19d2770556f5d/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
  thread 'main' panicked at /Users/dmlary/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.58/src/fallback.rs:811:9:
  "enum_(unnamed_at_/Library/Developer/CommandLineTools/SDKs/MacOSX_sdk/usr/include/MacTypes_h_382_1)" is not a valid Ident
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

The key piece is enum_(unnamed_at_/Library/Developer/CommandLineTools/SDKs/MacOSX_sdk/usr/include/MacTypes_h_382_1)" is not a valid Ident.

This is happening because LLVM changed the output for unnamed types, as a result bindgen generates invalid code. There's an issue describing the problem, and says it is resolved in bindgen v0.62. coreaudio-sys v0.2.12 updates to bindgen v0.64 1.

Additional information

I've confirmed that coreaudio-sys v0.2.11 will not build stand-alone on my macos system. This is after removing all additional LLVM installs, removing and reinstalling xcode & xcode command-line tools.

When I update to coreaudio-sys v0.2.12 (commit ad6cac44), I am able to build the crate with a few warnings, but it works.

Footnotes

  1. https://github.com/RustAudio/coreaudio-sys/pull/86

@dmlary dmlary added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Oct 26, 2023
@dmlary
Copy link
Contributor Author

dmlary commented Oct 26, 2023

Damnit, this was my cargo.lock

@dmlary dmlary closed this as completed Oct 26, 2023
@alice-i-cecile alice-i-cecile added A-Audio Sounds playback and modification O-MacOS Specific to the MacOS (Apple) desktop operating system and removed S-Needs-Triage This issue needs to be labelled labels Oct 26, 2023
@FrankenApps
Copy link

I had the same issue and can confirm that running cargo update --package coreaudio-rs fixed the problem.

@currenthandle
Copy link

currenthandle commented Nov 29, 2023

I can't get this to work.

I've run cargo update --package coreaudio-rs and cargo update --package coreaudio-sys. I've also tried deleting theCargo.lock file.

right now my Cargo.toml is:

[package]
name = "globe-bevy"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy = "0.12.0"
coreaudio-sys = "0.2.12"

# Enable a small amount of optimization in debug mode
[profile.dev]
opt-level = 1

# Enable high optimizations for dependencies (incl. Bevy), but not for our code:
[profile.dev.package."*"]
opt-level = 3

I've also tried coreaudio-sys = "0.2.14"

cargo build output:

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

Caused by:
  process didn't exit successfully: `/Users/casey/Dev/ezkl-work/globe-bevy/target/debug/build/coreaudio-sys-9a5602721b8610bb/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 /Users/casey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.69.1/lib.rs:620:31:
  Unable to find libclang: "the `libclang` shared library at /opt/homebrew/opt/llvm@15/lib/libclang.dylib could not be opened: dlopen(/opt/homebrew/opt/llvm@15/lib/libclang.dylib, 0x0005): tried: '/opt/homebrew/opt/llvm@15/lib/libclang.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/llvm@15/lib/libclang.dylib' (no such file), '/opt/homebrew/opt/llvm@15/lib/libclang.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/opt/homebrew/Cellar/llvm@15/15.0.7/lib/libclang.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/llvm@15/15.0.7/lib/libclang.dylib' (no such file), '/opt/homebrew/Cellar/llvm@15/15.0.7/lib/libclang.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))"
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

rust-toolchain.toml

[toolchain]
channel = "nightly"
components = ["rustfmt", "clippy"]
targets = ["aarch64-apple-darwin"]

rust-analzer output error logs:

[ERROR rust_analyzer::main_loop] FetchBuildDataError:
error: failed to run custom build command for `coreaudio-sys v0.2.14`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

Caused by:
  process didn't exit successfully: `/Users/casey/Dev/ezkl-work/globe-bevy/target/debug/build/coreaudio-sys-ab0a4f0454e32783/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 /Users/casey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.69.1/lib.rs:620:31:
  Unable to find libclang: "the `libclang` shared library at /opt/homebrew/opt/llvm@15/lib/libclang.dylib could not be opened: dlopen(/opt/homebrew/opt/llvm@15/lib/libclang.dylib, 0x0005): tried: '/opt/homebrew/opt/llvm@15/lib/libclang.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/llvm@15/lib/libclang.dylib' (no such file), '/opt/homebrew/opt/llvm@15/lib/libclang.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/opt/homebrew/Cellar/llvm@15/15.0.7/lib/libclang.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/llvm@15/15.0.7/lib/libclang.dylib' (no such file), '/opt/homebrew/Cellar/llvm@15/15.0.7/lib/libclang.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))"
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:597:5
     1: core::panicking::panic_fmt
               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panicking.rs:72:14
     2: core::result::unwrap_failed
               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/result.rs:1652:5
     3: std::sync::once::Once::call_once::{{closure}}
     4: std::sys_common::once::queue::Once::call
               at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/sys_common/once/queue.rs:183:21
     5: bindgen::ensure_libclang_is_loaded
     6: bindgen::Builder::generate
     7: build_script_build::main
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@dmlary
Copy link
Contributor Author

dmlary commented Nov 29, 2023

Try removing the homebrew installed llvm from your path. It’s an annoyance, but I did see that suggested in one of the earliest GitHub issues about this problem.

Also, I’d take a look at cargo tree to see if maybe some other dependency is still using an older version of coreaudio, or maybe bindgen.

@currenthandle
Copy link

@dmlary Thanks for the response! Someone in Discord #jam-voice-1 totally bailed me out 🙌

I think there were a couple issues. One with the path, or order of stuff in my path causing llvm 15 (not 17) to be in use. and the wrong default for rustup default being set. I'll leave my message up for context but perhaps not the same issue. Though it was failing on coreaudio-sys on mac

@SolarLiner SolarLiner added this to Audio Mar 12, 2024
@mkatychev
Copy link

Can confirm cargo update --package coreaudio-sys got it to compile on M1 Sonoma

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Audio Sounds playback and modification C-Bug An unexpected or incorrect behavior O-MacOS Specific to the MacOS (Apple) desktop operating system
Projects
Status: No status
Development

No branches or pull requests

5 participants