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

linking error when used with bevy on macOS aarch64 #1165

Open
TarekAS opened this issue Feb 8, 2024 · 0 comments
Open

linking error when used with bevy on macOS aarch64 #1165

TarekAS opened this issue Feb 8, 2024 · 0 comments

Comments

@TarekAS
Copy link

TarekAS commented Feb 8, 2024

Describe the bug
When building a project containing wry, tao and bevy on macOS (M1 Mac), with dynamic_linking enabled on bevy, it leads to the following linking error:

error: linking with `cc` failed: exit status: 1
  |
  = note: env -u <redacted env print>

= note: ld: warning: ignoring duplicate libraries: '-lSystem', '-lobjc'
          ld: Undefined symbols:
            _RustObjCExceptionTryCatch, referenced from:
                objc_exception::try_no_ret::hb6c5f46d0765cd58 in libtao-b2a7c9fe6e7760b2.rlib[7](tao-b2a7c9fe6e7760b2.tao.44e5656fbb1da1ec-cgu.04.rcgu.o)
                objc_exception::try_no_ret::heb888d6999c3a1ab in libtao-b2a7c9fe6e7760b2.rlib[7](tao-b2a7c9fe6e7760b2.tao.44e5656fbb1da1ec-cgu.04.rcgu.o)
                objc_exception::try_no_ret::h467675c166da1eb2 in libcocoa-bdc083df61ae20c1.rlib[5](cocoa-bdc083df61ae20c1.cocoa.9d90b2958afad0f3-cgu.2.rcgu.o)
                objc_exception::try_no_ret::ha07b8ef05ba8efa8 in libcocoa-bdc083df61ae20c1.rlib[5](cocoa-bdc083df61ae20c1.cocoa.9d90b2958afad0f3-cgu.2.rcgu.o)
                objc_exception::try_no_ret::hd9a8b230a39d73a6 in libcocoa-bdc083df61ae20c1.rlib[5](cocoa-bdc083df61ae20c1.cocoa.9d90b2958afad0f3-cgu.2.rcgu.o)
                objc_exception::try_no_ret::he0d4cb60d8d7f302 in libcocoa-bdc083df61ae20c1.rlib[5](cocoa-bdc083df61ae20c1.cocoa.9d90b2958afad0f3-cgu.2.rcgu.o)
                objc_exception::try_no_ret::he239be2eac779649 in libcocoa-bdc083df61ae20c1.rlib[5](cocoa-bdc083df61ae20c1.cocoa.9d90b2958afad0f3-cgu.2.rcgu.o)
                ...
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

Switching to Mach-O LLVM linker (aka ld64.lld) doesn't help, and returns a similar error:

note: ld64.lld: error: undefined symbol: RustObjCExceptionTryCatch
          >>> referenced by lib.rs:44 (/Users/redacted/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc_exception-0.1.2/src/lib.rs:44)
          >>>               /Users/redacted/wrkspc/bevy_sandbox/target/debug/deps/libtao-b2a7c9fe6e7760b2.rlib(tao-b2a7c9fe6e7760b2.tao.44e5656fbb1da1ec-cgu.04.rcgu.o):(symbol objc_exception::try_no_ret::hb6c5f46d0765cd58+0xb8)
          >>> referenced by lib.rs:44 (/Users/redacted/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc_exception-0.1.2/src/lib.rs:44)
          >>>               /Users/redacted/wrkspc/bevy_sandbox/target/debug/deps/libtao-b2a7c9fe6e7760b2.rlib(tao-b2a7c9fe6e7760b2.tao.44e5656fbb1da1ec-cgu.04.rcgu.o):(symbol objc_exception::try_no_ret::heb888d6999c3a1ab+0xa4)
          >>> referenced by lib.rs:44 (/Users/redacted/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc_exception-0.1.2/src/lib.rs:44)
          >>>               /Users/redacted/wrkspc/bevy_sandbox/target/debug/deps/libcocoa-bdc083df61ae20c1.rlib(cocoa-bdc083df61ae20c1.cocoa.9d90b2958afad0f3-cgu.2.rcgu.o):(symbol objc_exception::try_no_ret::h467675c166da1eb2+0xb8)
          >>> referenced 17 more times
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

Although the error mentions tao rather than wry, simply removing wry from Cargo.toml makes it work. So there's some funky business going on when these 3 packages are combined (with bevy's dynamic linking)

This occurs on both release and debug builds. I tried downgrading wry and tao from their latest versions (0.36 and 0.25 respectively) but still ended up with the same variation of the error.

Steps To Reproduce
Consider the following minimal Rust program:

// main.rs
use bevy::prelude::*;

use tao::event_loop::EventLoop;

fn main() {
    let event_loop: EventLoop<()> = EventLoop::new();
}
// Cargo.toml
[package]
name = "mygame"
version = "0.1.0"
edition = "2021"

[dependencies]
bevy = { version = "0.12.1", default-features = false, features = [
    "bevy_render",
    "dynamic_linking",
] }
tao = { version = "0.25.0", default-features = false }
wry = { version = "0.36.0" }

Run it on an ARM Mac and it will cause the issue. I have tried this on 3 separate M1 Macs and it causes the same issue. I updated the OS and Xcode and that didn't solve the problem either.

Expected behavior
Project should build with no issue, or an error at the compile level.

Platform and Versions (please complete the following information):
Chip: Apple M1 Max
OS: macOS Sonoma 14.3
Rustc: 1.75.0 (stable)
Xcode 15.2

Additional context
I open a parallel issue in the bevy repo (here), as it may not be clear which project is causing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant