Cross build problem from MacOS arm64 to MacOS x86_64

Martin Štrympl sfence.software at gmail.com
Sat Aug 31 11:17:19 CEST 2024


GMP 6.3.0 source in /Users/user/Desktop/build_app/deps/gmp-6.3.0

Configure:
dir="/Users/user/Desktop/build_app/deps"
CFLAGS="-arch x86_64" LDFLAGS="-arch x86_64" CXXFLAGS="-arch x86_64"
./configure "--prefix=$dir/install" --with-pic --enable-cxx
M4=/opt/homebrew/Cellar/m4/1.4.19/bin/m4 "--host=x86_64-apple-darwin"
make 2>&1 | tee build_log

file .libs/* -> .libs/libgmpxx.4.dylib-master.o: Mach-O 64-bit object arm64
Every other .o, .dylibs etc. files are for x86_64.

Looks like somehow -arch x86_64 flags has not be added to link command
for .libs/libgmpxx.4.dylib-master.o,

Causes "make check" to fail on t-iostream because of trying to link
x86_64 with arm64 .o file.

See build_log:

libtool: link: g++ -std=gnu++11 -r -keep_private_externs -nostdlib -o
.libs/libgmpxx.4.dylib-master.o  cxx/.libs/dummy.o cxx/.libs/isfuns.o
cxx/.libs/ismpf.o cxx/.libs/ismpq.o cxx/.libs/ismpz.o
cxx/.libs/ismpznw.o cxx/.libs/limits.o cxx/.libs/osdoprnti.o
cxx/.libs/osfuns.o cxx/.libs/osmpf.o cxx/.libs/osmpq.o
cxx/.libs/osmpz.o

libtool: link: g++ -std=gnu++11 -dynamiclib -Wl,-undefined
-Wl,dynamic_lookup -o .libs/libgmpxx.4.dylib
.libs/libgmpxx.4.dylib-master.o  ./.libs/libgmp.dylib  -arch x86_64
-arch x86_64   -install_name
/Users/sfence/Desktop/minetest/minetest_build_x86_64_104/deps/install/lib/libgmpxx.4.dylib
-compatibility_version 12 -current_version 12.0

ld: warning: ignoring file
'/Users/sfence/Desktop/minetest/minetest_build_x86_64_104/deps/gmp-6.3.0/.libs/libgmpxx.4.dylib-master.o':
found architecture 'arm64', required architecture 'x86_64'

See lines in config.status:

archive_cmds_CXX='$CC -r -keep_private_externs -nostdlib -o
$lib-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib
$lib-master.o $deplibs $compiler_flags -install_name $rpath/$soname
$verstring'

archive_expsym_cmds_CXX='/usr/bin/sed '\''s|^|_|'\'' < $export_symbols
> $output_objdir/$libname-symbols.expsym~$CC -r -keep_private_externs
-nostdlib -o $lib-master.o $libobjs~$CC -dynamiclib
$allow_undefined_flag -o $lib $lib-master.o $deplibs $compiler_flags
-install_name $rpath/$soname $verstring
$wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym'
-------------- next part --------------
A non-text attachment was scrubbed...
Name: config.status
Type: application/octet-stream
Size: 99629 bytes
Desc: not available
URL: <https://gmplib.org/list-archives/gmp-bugs/attachments/20240831/53bfb55e/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: build_log
Type: application/octet-stream
Size: 13562 bytes
Desc: not available
URL: <https://gmplib.org/list-archives/gmp-bugs/attachments/20240831/53bfb55e/attachment-0003.obj>


More information about the gmp-bugs mailing list