Issue
I'm trying to build a GCC cross-compiler for x86
on M1, but it failed during linking.
This is the error message:
Undefined symbols for architecture arm64:
"___aarch64_cas8_acq_rel", referenced from:
_macho_add in libbacktrace.a(macho.o)
_backtrace_initialize in libbacktrace.a(macho.o)
_backtrace_dwarf_add in libbacktrace.a(dwarf.o)
"___aarch64_swp4_acq", referenced from:
_backtrace_free in libbacktrace.a(mmap.o)
_backtrace_alloc in libbacktrace.a(mmap.o)
"_host_hooks", referenced from:
c_common_no_more_pch() in c-pch.o
toplev::main(int, char**) in libbackend.a(toplev.o)
gt_pch_save(__sFILE*) in libbackend.a(ggc-common.o)
gt_pch_restore(__sFILE*) in libbackend.a(ggc-common.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [cc1] Error 1
make: *** [all-gcc] Error 2
For context, I'm using gcc-11.3.0
installed via brew
. Additionally, gmp
, mpfr
, and libmpc
are also installed via brew
.
Below are the steps I used:
cd /tmp/src
curl -O https://ftp.gnu.org/gnu/gcc/gcc-11.3.0/gcc-11.3.0.tar.xz
tar xf gcc-11.3.0.tar.xz
mkdir gcc-build
cd gcc-build
../gcc-11.3.0/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --disable-libssp --enable-language=c --without-headers --with-gmp="/opt/homebrew/Cellar/gmp/6.2.1_1" --with-mpfr="/opt/homebrew/Cellar/mpfr/4.1.0" --with-mpc="/opt/homebrew/Cellar/libmpc/1.2.1"
make all-gcc all-target-libgcc
Any ideas how to fix this?
Solution
I managed to fix this issue myself. My builtin Apple clang
is able to build binutils
, gcc
, and gdb
as well.
Answered By - Nguyen Thai Binh Answer Checked By - Cary Denson (WPSolving Admin)