Should I expect Rust 1.28 & 1.30 to support building on MacOS 12?

Recently, GitHub Actions began transitioning macos-latest to macos-12. I have a project where I am building on minimum Rust versions 1.28 and 1.30 that began to show build errors on macos-12:

   Compiling libc v0.2.99
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-m64" "-L" "/Users/runner/.rustup/toolchains/1.30.0-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/runner/work/min-sized-rust/min-sized-rust/no_std/target/release/build/libc-c975b02cf3f7d8ed/build_script_build-c975b02cf3f7d8ed.build_script_build.32wt36t2-cgu.0.rcgu.o" "-o" "/Users/runner/work/min-sized-rust/min-sized-rust/no_std/target/release/build/libc-c975b02cf3f7d8ed/build_script_build-c975b02cf3f7d8ed" "/Users/runner/work/min-sized-rust/min-sized-rust/no_std/target/release/build/libc-c975b02cf3f7d8ed/build_script_build-c975b02cf3f7d8ed.2emquonry7w2cho0.rcgu.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/runner/work/min-sized-rust/min-sized-rust/no_std/target/release/deps" "-L" "/Users/runner/.rustup/toolchains/1.30.0-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/runner/.rustup/toolchains/1.30.0-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-29ce6fda87a76ebc.rlib" "/Users/runner/.rustup/toolchains/1.30.0-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-398b73b2e53c1ff1.rlib" "/Users/runner/.rustup/toolchains/1.30.0-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc_jemalloc-b44ec4903d844bed.rlib" "/Users/runner/.rustup/toolchains/1.30.0-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-5386821277fae731.rlib" "/Users/runner/.rustup/toolchains/1.30.0-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc_system-498e6384f8c92f09.rlib" "/Users/runner/.rustup/toolchains/1.30.0-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-4d611a500e28f0e5.rlib" "/Users/runner/.rustup/toolchains/1.30.0-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-71e3722defae21cf.rlib" "/Users/runner/.rustup/toolchains/1.30.0-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-48cbf085067c437e.rlib" "/Users/runner/.rustup/toolchains/1.30.0-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-27ec7eb585f2725d.rlib" "-lSystem" "-lresolv" "-lpthread" "-lc" "-lm"
  = note: ld: in /Users/runner/.rustup/toolchains/1.30.0-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-398b73b2e53c1ff1.rlib(rust.metadata.bin), archive member 'rust.metadata.bin' with length 24076 is not mach-o or llvm bitcode file '/Users/runner/.rustup/toolchains/1.30.0-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-398b73b2e53c1ff1.rlib'
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

Since MacOS 12 is relatively new, should this compile error simply be considered unsupported on those older stable Rust compiler versions?

You will need to use Rust 1.54 or newer. The older versions produced a slightly invalid format that newer versions of xcode are more restrictive on.

A workaround is to use an older xcode. I haven't tested, but I believe macos-12 uses xcode 14.0.1, and macos-11 uses xcode 13.2.1. The GitHub macos images come with several versions of xcode, and you can choose which one to use with xcode-select --switch. I would try that if you want a workaround. The list of available versions is at runner-images/macos-12-Readme.md at main · actions/runner-images · GitHub

2 Likes

Note that Xcode 12 is not supported on macOS 12. And for the future, Xcode 13 is not supported on macOS 13.

macOS targeting is a forced upgrade treadmill. It's just inherent to how Apple runs the ecosystem.

1 Like

Thanks for the details @ehuss!

Given that I also have issues with older Cargo included in 1.28 not accepting the new lockfile format, I'll probably simply drop the CI builds for 1.28-1.30 as they are becoming harder and harder to maintain.