I’m trying to cross-compile binutils for i386-elf
on macOS (Sequoia 15.0.1, arm64) but encounter an error when running make
. Here are the steps I followed:
-
Installed required dependencies:
brew install gmp mpfr libmpc texinfo
-
Downloaded and extracted binutils 2.41:
mkdir -p ~/src cd ~/src wget https://ftp.gnu.org/gnu/binutils/binutils-2.41.tar.gz tar -xzf binutils-2.41.tar.gz
-
Created a build directory:
mkdir build-binutils cd build-binutils
-
Set environment variables:
export CC=gcc export CXX=g++ export AR=llvm-ar
-
Configured binutils:
../binutils-2.41/configure \ --target=i386-elf \ --prefix=/usr/local/cross \ --disable-nls \ --disable-werror
-
Ran
make
while compiling thelibbfd.la
target and encountered the following error:
llvm-ar: error: truncated or malformed archive (terminator characters in archive member "\000\000" not the correct "`\n" values for the archive member header for 0 0 644)
make[4]: *** [libbfd.la] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-bfd] Error 2
make: *** [all] Error 2
Before that I only get source code related warnings.
I found a similar issue that suggests the archive must be less than 4GB (link), but I’m unsure how to resolve this on my setup. I also don’t think that the archive is >4GB.
It might be unrelated, but I’m concerned that when I run gcc --version
, it shows Clang instead of GCC:
$ gcc --version
Apple clang version 16.0.0 (clang-1600.0.26.3)
Target: arm64-apple-darwin24.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
System Info:
- macOS Sequoia 15.0.1 (arm64)
Edit
When I configure and make it with expor AR=ar
I get a more precise error:
checking whether gcc supports -Wold-style-definition... ld: multiple errors: archive member '/' not a mach-o file in '/Users/viliamholly/src/binutils-build/libiberty/libiberty.a'; archive member '/' not a mach-o file in '/Users/viliamholly/src/binutils-build/zlib/libz.a'; archive member '/' not a mach-o file in '/Users/viliamholly/src/binutils-build/bfd/.libs/libbfd.a'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
You need to sign in to view this answers