mrustc: MacOS + GCC11: `LIBS` build error (Undefined symbol `___atomic_compare_exchange_16`)

Getting closer but the following error appears with GCC 11 / Mac OS X 10.6:

(2/26) BUILDING cmake v0.1.38
> bin/mrustc rustc-1.39.0-src/vendor/cmake/src/lib.rs -o output-1.39.0/libcmake-0_1_38.rlib --crate-name cmake --crate-type rlib -C emit-depfile=output-1.39.0/libcmake-0_1_38.rlib.d --crate-tag 0_1_38 -g --cfg debug_assertions -O -L output-1.39.0 --extern cc=output-1.39.0/libcc-1_0_35.rlib
> bin/mrustc rustc-1.39.0-src/vendor/libc/build.rs --crate-name build --crate-type bin -o output-1.39.0/build_libc-0_2_62_Hd_run -L output-1.39.0 -g --cfg feature=rustc-dep-of-std --cfg feature=align --cfg feature=rustc-std-workspace-core
Undefined symbols for architecture x86_64:
  "___atomic_compare_exchange_16", referenced from:
      _ZRG4cE9core0_0_09core_arch6x86_6410cmpxchg16b_D0g in libcore.rlib.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

Maybe mrustc needs to add another GCC flag or libatomic linkage?

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 25 (25 by maintainers)

Commits related to this issue

Most upvoted comments

Just for records. An easy hack to make gcc works very well is adding cargo:rustc-link-lib=atomic to script-overrides/stable-1.54.0-macos/build_libc.txt

The very first Intel Macs were 32-bit “Core Solo” and “Core Duo”. Poking around EveryMac, it appears that the first 64-bit Macs were in fact core2. So I think it’s safe to add to the x86_64 target.

-mcpu=core2 works on a small test program.