Skip to content

Mac builds broken on bleeding edge rustc #3313

Closed
@JohnHeitmann

Description

Problem Description

Bevy builds (all current versions going back to at least 0.5) break when building executables targetting Mac OS (any recent version going back to at least 11) when using very new rustc builds.

If you build with the following toolchains or newer:

  • nightly-2021-11-26
  • 1.58.0-beta.2
  • 1.58.0 (when released in a few weeks)

you will encounter linker errors that look like this when building your bins:

          ld: warning: object file (/Users/johnheitmann/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy-glsl-to-spirv-0.2.1/build/osx/libSPIRV-Tools-opt.glsltospirv.a(loop_dependence_helpers.cpp.o)) was built for newer macOS version (10.13) than being linked (10.7)
          Undefined symbols for architecture x86_64:
            "_CGDisplayCreateUUIDFromDisplayID", referenced from:
                _$LT$winit..platform_impl..platform..monitor..MonitorHandle$u20$as$u20$core..cmp..PartialEq$GT$::eq::h6f78623ba25a9eed in libwinit-8bce922fba7e3e4a.rlib(winit-8bce922fba7e3e4a.winit.10d84408-cgu.7.rcgu.o)
                winit::platform_impl::platform::monitor::MonitorHandle::ns_screen::h017dddbbcaca8c42 in libwinit-8bce922fba7e3e4a.rlib(winit-8bce922fba7e3e4a.winit.10d84408-cgu.7.rcgu.o)
            "_AudioUnitUninitialize", referenced from:
                _$LT$coreaudio..audio_unit..AudioUnit$u20$as$u20$core..ops..drop..Drop$GT$::drop::hdf3f9e1637ddb136 in libcoreaudio-593b06aab60419df.rlib(coreaudio-593b06aab60419df.coreaudio.25abf266-cgu.3.rcgu.o)
            "_AudioComponentInstanceDispose", referenced from:
                _$LT$coreaudio..audio_unit..AudioUnit$u20$as$u20$core..ops..drop..Drop$GT$::drop::hdf3f9e1637ddb136 in libcoreaudio-593b06aab60419df.rlib(coreaudio-593b06aab60419df.coreaudio.25abf266-cgu.3.rcgu.o)
            "_AudioComponentInstanceNew", referenced from:
                coreaudio::audio_unit::AudioUnit::new_with_flags::hb074a98038137feb in libcpal-4b4bbe89a6c5fa70.rlib(cpal-4b4bbe89a6c5fa70.cpal.d7755c34-cgu.6.rcgu.o)
            "_AudioComponentFindNext", referenced from:
                coreaudio::audio_unit::AudioUnit::new_with_flags::hb074a98038137feb in libcpal-4b4bbe89a6c5fa70.rlib(cpal-4b4bbe89a6c5fa70.cpal.d7755c34-cgu.6.rcgu.o)
            "_AudioOutputUnitStart", referenced from:
                coreaudio::audio_unit::AudioUnit::start::hece0dd7b15eec55d in libcoreaudio-593b06aab60419df.rlib(coreaudio-593b06aab60419df.coreaudio.25abf266-cgu.3.rcgu.o)
            "_AudioUnitInitialize", referenced from:
                coreaudio::audio_unit::AudioUnit::new_with_flags::hb074a98038137feb in libcpal-4b4bbe89a6c5fa70.rlib(cpal-4b4bbe89a6c5fa70.cpal.d7755c34-cgu.6.rcgu.o)
            "_AudioOutputUnitStop", referenced from:
                coreaudio::audio_unit::AudioUnit::stop::hbd2793409d2e72e2 in libcoreaudio-593b06aab60419df.rlib(coreaudio-593b06aab60419df.coreaudio.25abf266-cgu.3.rcgu.o)
            "_AudioUnitSetProperty", referenced from:
                coreaudio::audio_unit::set_property::h264624134583a3dd in libcpal-4b4bbe89a6c5fa70.rlib(cpal-4b4bbe89a6c5fa70.cpal.d7755c34-cgu.6.rcgu.o)
                coreaudio::audio_unit::set_property::hed651af50df18749 in libcoreaudio-593b06aab60419df.rlib(coreaudio-593b06aab60419df.coreaudio.25abf266-cgu.3.rcgu.o)
                coreaudio::audio_unit::set_property::h4ef85d566116da2c in librodio-74f0a70551800e01.rlib(rodio-74f0a70551800e01.rodio.45f70489-cgu.15.rcgu.o)
            "_AudioUnitGetProperty", referenced from:
                coreaudio::audio_unit::get_property::h5b62a84e4052ca5d in libcpal-4b4bbe89a6c5fa70.rlib(cpal-4b4bbe89a6c5fa70.cpal.d7755c34-cgu.6.rcgu.o)
                coreaudio::audio_unit::get_property::h8773bf66bc0b0060 in libcoreaudio-593b06aab60419df.rlib(coreaudio-593b06aab60419df.coreaudio.25abf266-cgu.3.rcgu.o)
          ld: symbol(s) not found for architecture x86_64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

A quick one-liner to reproduce this on a Mac is: cargo +beta build --example spawner.

Workarounds for Bevy Users

Set the mac deployment target to a more recent version than the default 10.7 target using the MACOSX_DEPLOYMENT_TARGET setting. e.g.: MACOSX_DEPLOYMENT_TARGET=11.0 cargo +beta build --example spawner

Alternately, build with rust 1.57.x or older.

Root Cause Fix & Info

Root cause as tracked in the rust project: rust-lang/rust#91372

Short version: rustc used to let binaries be built for os versions they couldn't actually run on. New and intended logic makes the deployment target more painfully explicit so users can't accidentally build unrunnable binaries. Impacted libraries should do some combination of removing dependencies on new OS symbols, and/or raising their deployment target manually. The two crates that affect bevy in this way are coreaudio and winit. PRs (currently pending) for their fixes are here:

rust-windowing/winit#2078
RustAudio/coreaudio-sys#49

Metadata

Assignees

No one assigned

    Labels

    C-BugAn unexpected or incorrect behaviorO-MacOSSpecific to the MacOS (Apple) desktop operating systemS-BlockedThis cannot move forward until something else changes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions