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

Mac builds broken on bleeding edge rustc #3313

Closed
JohnHeitmann opened this issue Dec 13, 2021 · 3 comments
Closed

Mac builds broken on bleeding edge rustc #3313

JohnHeitmann opened this issue Dec 13, 2021 · 3 comments
Labels
C-Bug An unexpected or incorrect behavior O-MacOS Specific to the MacOS (Apple) desktop operating system S-Blocked This cannot more forward until something else changes

Comments

@JohnHeitmann
Copy link

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

@JohnHeitmann JohnHeitmann added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Dec 13, 2021
@alice-i-cecile alice-i-cecile added O-MacOS Specific to the MacOS (Apple) desktop operating system S-Blocked This cannot more forward until something else changes and removed S-Needs-Triage This issue needs to be labelled labels Dec 13, 2021
@alice-i-cecile
Copy link
Member

Thanks for writing this up; there's not much we can do ourselves, but the links (and investigation!) are incredibly helpful.

@madsmtm
Copy link

madsmtm commented Jan 27, 2022

The rustc change was reverted, and the affected crates have since fixed (rust-windowing/winit#2078 and RustAudio/coreaudio-sys#51), so I believe this can be closed.

@alice-i-cecile
Copy link
Member

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Bug An unexpected or incorrect behavior O-MacOS Specific to the MacOS (Apple) desktop operating system S-Blocked This cannot more forward until something else changes
Projects
None yet
Development

No branches or pull requests

3 participants