Intel MacOS Linking Error

Building my project is failing due to a linker error.
'cargo build' runs fine, but 'cargo test' fails. I guess that's because it is attempting to link the executable binary in that step.

According to the 'cargo test' output, the culprit is 'function makeSymbolStringInPlace, file SymbolString.cpp, line 74'.

I've included the build log at the end of this post.

This is on a MacBook Pro (Intel processor), MacOS 14.1.1.

After looking up what to do to fix this, I've tried:

  • Upgrading MacOS and rebooting
  • Updating the Rust toolchain
  • Reinstalling Xcode command line tools (i.e. xcode-select --install)
  • Updating all of the dependant crates to their latest version
  • Setting MACOSX_DEPLOYMENT_TARGET to 10.7
  • Adding rust flags to ~/.cargo/config

TIA, Steve

error: linking with cc failed: exit status: 1
|
= note: LC_ALL="C" PATH="/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/bin:/Users/balls/.cargo/bin:/Users/balls/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin" VSLANG="1033" ZERO_AR_DATE="1" "cc" "-arch" "x86_64" "-m64" "/var/folders/wj/b1np43zn3d19sgxx2rgvjqtm0000gn/T/rustcD75Cmv/symbols.o" "/Users/balls/Local/Rust/xrust/target/debug/deps/intmuttree-6293bfd888e91c80.101h8puhtaatnj0v.rcgu.o"
[... lots of these entries omitted ...]
"/Users/balls/Local/Rust/xrust/target/debug/deps/intmuttree-6293bfd888e91c80.5cntjnzilosotz6s.rcgu.o" "-L" "/Users/balls/Local/Rust/xrust/target/debug/deps" "-L" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libtest-2baad81e6467d477.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libgetopts-0f83adf62232ab7b.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunicode_width-e556250ec4101a17.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_std-dc1377819bec645f.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libxrust-4cd90819569d8520.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libunicode_segmentation-21ca151b0c891b73.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/liburl-ef9182eff8d645f8.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libidna-1a401c22213c5eaf.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libunicode_normalization-e5d80c381be329c4.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libtinyvec-70e292e3080a4c6d.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libtinyvec_macros-936640f7f412bf14.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libunicode_bidi-e56772a5ca0f59f2.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libform_urlencoded-af88fdd7a53241e8.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libpercent_encoding-7bb5f4fa70283c80.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/librust_decimal-60ac82f5bed7cd4f.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libserde-3badcb09ad98556c.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libarrayvec-a435de0bedad3e5b.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libchrono-baa66320e11e7a10.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libnum_traits-0044716a5c682095.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libiana_time_zone-b42f74abd089c6c9.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libcore_foundation_sys-821981c66f26db6e.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libnom-300875d914cb45e6.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libmemchr-0d0af0849a10b363.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-ddfda73b15f9600b.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-eabe75f1776ca242.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libobject-131ae04902e8c815.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libmemchr-a6ee6c043bffc279.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libaddr2line-36439e0ce6096072.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libgimli-9077577b83fc4fd1.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-983fd450352c94e0.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd_detect-054b1ccd53d5cf8e.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-5736cf4f651bb669.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-d58d328b1d6ba75e.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libminiz_oxide-b8c1767249dac0c7.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libadler-09d4b5c092ea9610.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-f7cb43206a2f6d47.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-9d3e0fefc36a1ed6.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-50e16fadc8d2cb6e.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-fff7598d6e185851.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-c75e4d2c0e3ae5d1.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-6359584a409e26e3.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-9c90a2632a379147.rlib" "-framework" "CoreFoundation" "-lSystem" "-lc" "-lm" "-L" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "-o" "/Users/balls/Local/Rust/xrust/target/debug/deps/intmuttree-6293bfd888e91c80" "-Wl,-dead_strip" "-nodefaultlibs" "-undefined" "dynamic_lookup"
= note: 0 0x1049f3f43 __assert_rtn + 64
1 0x10494758d ld::DynamicAtomFile::makeNamedAtom(std::__1::basic_string_view<char, std::__1::char_traits>, ld::file_format::Scope, bool) + 653
2 0x104914f0c ___ZNK2ld10InputFiles11SliceParser15parseObjectFileEPKN6mach_o6HeaderE_block_invoke.46 + 348
3 0x10490fbfd ld::InputFiles::SliceParser::parseObjectFile(mach_o::Header const*) const + 9453
4 0x104922b71 ld::InputFiles::parseAllFiles(void (ld::AtomFile const*) block_pointer)::$_7::operator()(unsigned long, ld::FileInfo const&) const + 657
5 0x7ff8079ab5cd _dispatch_client_callout2 + 8
6 0x7ff8079bbe3e _dispatch_apply_invoke + 214
7 0x7ff8079ab59a _dispatch_client_callout + 8
8 0x7ff8079ba99d _dispatch_root_queue_drain + 879
9 0x7ff8079baf22 _dispatch_worker_thread2 + 152
10 0x7ff807b4fc06 _pthread_wqthread + 262
ld: Assertion failed: (name.size() <= maxLength), function makeSymbolStringInPlace, file SymbolString.cpp, line 74.
clang: error: linker command failed with exit code 1 (use -v to see invocation)

warning: xrust (test "intmuttree") generated 3 warnings
error: could not compile xrust (test "intmuttree") due to previous error; 3 warnings emitted
warning: build failed, waiting for other jobs to finish...
error: linking with cc failed: exit status: 1
|
= note: LC_ALL="C" PATH="/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/bin:/Users/balls/.cargo/bin:/Users/balls/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin" VSLANG="1033" ZERO_AR_DATE="1" "cc" "-arch" "x86_64" "-m64" "/var/folders/wj/b1np43zn3d19sgxx2rgvjqtm0000gn/T/rustcHbTNQn/symbols.o" "/Users/balls/Local/Rust/xrust/target/debug/deps/mod-2fea7e0f0b07ab76.1227vrxcprpsr4q2.rcgu.o"
[... lots of these entries omitted ...]
"/Users/balls/Local/Rust/xrust/target/debug/deps/mod-2fea7e0f0b07ab76.3ez17edjko3tnjv9.rcgu.o" "-L" "/Users/balls/Local/Rust/xrust/target/debug/deps" "-L" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libtest-2baad81e6467d477.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libgetopts-0f83adf62232ab7b.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunicode_width-e556250ec4101a17.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_std-dc1377819bec645f.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libencoding_rs_io-5e3ced1be8b1511d.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libencoding_rs-dc84dc720128014b.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libcfg_if-ffae4f042235402c.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libxrust-4cd90819569d8520.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libunicode_segmentation-21ca151b0c891b73.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/liburl-ef9182eff8d645f8.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libidna-1a401c22213c5eaf.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libunicode_normalization-e5d80c381be329c4.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libtinyvec-70e292e3080a4c6d.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libtinyvec_macros-936640f7f412bf14.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libunicode_bidi-e56772a5ca0f59f2.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libform_urlencoded-af88fdd7a53241e8.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libpercent_encoding-7bb5f4fa70283c80.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/librust_decimal-60ac82f5bed7cd4f.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libserde-3badcb09ad98556c.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libarrayvec-a435de0bedad3e5b.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libchrono-baa66320e11e7a10.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libnum_traits-0044716a5c682095.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libiana_time_zone-b42f74abd089c6c9.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libcore_foundation_sys-821981c66f26db6e.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libnom-300875d914cb45e6.rlib" "/Users/balls/Local/Rust/xrust/target/debug/deps/libmemchr-0d0af0849a10b363.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-ddfda73b15f9600b.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-eabe75f1776ca242.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libobject-131ae04902e8c815.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libmemchr-a6ee6c043bffc279.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libaddr2line-36439e0ce6096072.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libgimli-9077577b83fc4fd1.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-983fd450352c94e0.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd_detect-054b1ccd53d5cf8e.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-5736cf4f651bb669.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-d58d328b1d6ba75e.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libminiz_oxide-b8c1767249dac0c7.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libadler-09d4b5c092ea9610.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-f7cb43206a2f6d47.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-9d3e0fefc36a1ed6.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-50e16fadc8d2cb6e.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-fff7598d6e185851.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-c75e4d2c0e3ae5d1.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-6359584a409e26e3.rlib" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-9c90a2632a379147.rlib" "-framework" "CoreFoundation" "-lSystem" "-lc" "-lm" "-L" "/Users/balls/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "-o" "/Users/balls/Local/Rust/xrust/target/debug/deps/mod-2fea7e0f0b07ab76" "-Wl,-dead_strip" "-nodefaultlibs" "-undefined" "dynamic_lookup"
= note: 0 0x1044c3f43 __assert_rtn + 64
1 0x10441758d ld::DynamicAtomFile::makeNamedAtom(std::__1::basic_string_view<char, std::__1::char_traits>, ld::file_format::Scope, bool) + 653
2 0x1043e4f0c ___ZNK2ld10InputFiles11SliceParser15parseObjectFileEPKN6mach_o6HeaderE_block_invoke.46 + 348
3 0x1043dfbfd ld::InputFiles::SliceParser::parseObjectFile(mach_o::Header const*) const + 9453
4 0x1043f2b71 ld::InputFiles::parseAllFiles(void (ld::AtomFile const*) block_pointer)::$_7::operator()(unsigned long, ld::FileInfo const&) const + 657
5 0x7ff8079ab5cd _dispatch_client_callout2 + 8
6 0x7ff8079bbe3e _dispatch_apply_invoke + 214
7 0x7ff8079ab59a _dispatch_client_callout + 8
8 0x7ff8079ba99d _dispatch_root_queue_drain + 879
9 0x7ff8079baf22 _dispatch_worker_thread2 + 152
10 0x7ff807b4fc06 _pthread_wqthread + 262
ld: Assertion failed: (name.size() <= maxLength), function makeSymbolStringInPlace, file SymbolString.cpp, line 74.
clang: error: linker command failed with exit code 1 (use -v to see invocation)

warning: xrust (test "mod") generated 3 warnings (3 duplicates)
error: could not compile xrust (test "mod") due to previous error; 3 warnings emitted

This means that it's a bug in the linker. I don't think there's anything you can do about it, apart from trying to use another linker.

Do I understand right that this is a cross-compiled project? How/on which machine (host or target) are the tests expected to run?

Latest Xcode ld is apparently broken, could be that.

(I don't have a better citation on hand (on mobile), but found some other discussion by web search after that last topic.)

1 Like

No, I'm not cross-compiling. Just trying to get the project running on my laptop.

Over the weekend I tried installing and configuring an alternate linker. mold refuses to run on MacOSX (they want you to use the commercial version, sold, instead), and gcc's i386-elf-ld requires a different configuration. So that's gone into the "too hard" basket for now.

I've got Linux set up in a VM, so I'll just compile and test in that for now.

Unfortunately, that hasn't worked for me :frowning:

The problem seems to have resolved itself.

One of the modules in my project is a parser, using a parser combinator. The grammar I'm building a parser for has a recursive definition. Rust really doesn't like that. In the end, I had to use Box<dyn ...> for all of the function return types so that the recursion is resolved at run-time, rather than at compile-time. That seems to have done the trick, as well as solving build problems on Windows.

Just thought people might like to know.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.