Skip to content

linking error when used with wry/tao on macOS aarch64 #11779

Open
@TarekAS

Description

@TarekAS

Bevy version

0.12.1

Relevant system information

Chip: Apple M1 Max
OS: macOS Sonoma 14.3
Rustc: 1.75.0 (stable)
Xcode 15.2

What you did

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 a linking error. 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.

What went wrong

Project is expected to build with no issue, or an error at the compile level. Instead I get 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)

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

Additional information

I opened a parallel issue in the wry repo (here), as I can't tell which project is actually causing this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    O-MacOSSpecific to the MacOS (Apple) desktop operating systemP-Compile-FailureA failure to compile Bevy appsS-Needs-InvestigationThis issue requires detective work to figure out what's going wrong

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions