Rust 1.6 Hello World compilation aborts on OSX Monterey over XCODE license

Just installed Rust 1.6 via rustup script on OSX Monterey.

Installation successful as:

rustc --version

.......yields the following

rustc 1.60.0 (7737e0b5c 2022-04-04)

However, after following the hello world tutorial and running:

rustc main.rs

I get the following curious error:

[error: linking with cc failed: exit status: 69
|
= note: "cc" "-m64" "-arch" "x86_64" "main.main.b84c6bff-cgu.0.rcgu.o" "main.main.b84c6bff-cgu.1.rcgu.o" "main.main.b84c6bff-cgu.2.rcgu.o" "main.main.b84c6bff-cgu.3.rcgu.o" "main.main.b84c6bff-cgu.4.rcgu.o" "main.main.b84c6bff-cgu.5.rcgu.o" "main.main.b84c6bff-cgu.6.rcgu.o" "main.main.b84c6bff-cgu.7.rcgu.o" "main.4p5xu59favf1skfn.rcgu.o" "-L" "/Users/tom/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/tom/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-04b20da5d2b4e02d.rlib" "/Users/tom/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-00f5b50d82ace1e3.rlib" "/Users/tom/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libobject-45c041bae4e30a62.rlib" "/Users/tom/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libmemchr-1bc22f5f5be77a23.rlib" "/Users/tom/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libaddr2line-caa784d0cecbd501.rlib" "/Users/tom/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libgimli-0ad46247e89234f6.rlib" "/Users/tom/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-68dabd8f37218f7c.rlib" "/Users/tom/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd_detect-4c67204728564461.rlib" "/Users/tom/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-eca93a0d11ef9a39.rlib" "/Users/tom/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-6ddabe46ef182f8b.rlib" "/Users/tom/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-7dc1037a76f2c18c.rlib" "/Users/tom/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-100dc4191a6287d7.rlib" "/Users/tom/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-c596c47fc21af016.rlib" "/Users/tom/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-c7163fef4a8cdd33.rlib" "/Users/tom/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-3463abc69f183e66.rlib" "/Users/tom/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-12a50039d8929e4e.rlib" "/Users/tom/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-a4134bbc9f4f0dab.rlib" "-lSystem" "-lresolv" "-lc" "-lm" "-liconv" "-L" "/Users/tom/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "-o" "main" "-Wl,-dead_strip" "-nodefaultlibs"
= note:
You have not agreed to the Xcode license agreements, please run 'sudo xcodebuild -license' from within a Terminal window to review and agree to the Xcode license agreements.

error: aborting due to previous error

I had the impression the Rust toolchain was independent of native tools. Is this not the case?

Why do I need to agree to an Apple Xcode license to use a non-Apple language like Rust?

It is not. Languages generally don't have their own linker (because it's unnecessary), and Rust is no exception – it uses the available external linker (either lld or GNU ld or gold or MSVC's linker on Windows, etc.).

As an aside, note that Rust 1.60 is very different from Rust 1.6 because version numbers are not decimals but tuples of numbers! Trailing zeroes matter. Rust 1.6 was released in January 2016, fifty-four versions ago.

1 Like

@H2CO3 Thanks..... will look into activating XCODE to gain access to ld.
Also have read interesting things about MOLD linker.
Does RUST community have any opinions/recommendations on one linker over another?

@jdahlstrom Aah....that's an important distinction to keep in mind w.r.t. RUST's version numbering convention.
Thanks for pointing that out!

In general, using the platform linker is fine. Using a different linker is typically of niche applicability.

1 Like