arm64 CPU architecture is wrongly detected during configuration of ilib_build
When running ilib_build on the native arm64 build of Scilab, the configure generates a Makefile which forces the cross-compilation of a x86_64 binary library
--> ilib_build('build_c',['fun1','sci_fun1'],files,[]);
Generate a gateway file
Generate a loader file
Generate a Makefile
ilib_gen_Make: configure : Generate Makefile.
ilib_gen_Make: Copy compilation files (Makefile*, libtool...) to TMPDIR
ilib_gen_Make: Copy fun1.c to TMPDIR
ilib_gen_Make: Copy fun2.c to TMPDIR
ilib_gen_Make: Copy libbuild_c.cpp to TMPDIR
ilib_gen_Make: Copy libbuild_c.h to TMPDIR
ilib_gen_Make: Copy libbuild_c.hxx to TMPDIR
ilib_gen_Make: Copy sci_fun1.c to TMPDIR
ilib_gen_Make: Modification of the Makefile in TMPDIR.
Running the makefile
Generate a cleaner file
-->
--> // load the shared library
-->
--> exec loader.sce;
Link failed for dynamic library '/private/var/folders/ft/1_j5ty6d7bv69ps7x75v_5sc0000gn/T/SCI_TMP_60536_KTFZPU/example_ilib_build_c//libbuild_c.dylib'.
An error occurred: dlopen(/private/var/folders/ft/1_j5ty6d7bv69ps7x75v_5sc0000gn/T/SCI_TMP_60536_KTFZPU/example_ilib_build_c//libbuild_c.dylib, 10): no suitable image found. Did find:
/private/var/folders/ft/1_j5ty6d7bv69ps7x75v_5sc0000gn/T/SCI_TMP_60536_KTFZPU/example_ilib_build_c//libbuild_c.dylib: mach-o, but wrong architecture
/private/var/folders/ft/1_j5ty6d7bv69ps7x75v_5sc0000gn/T/SCI_TMP_60536_KTFZPU/example_ilib_build_c/libbuild_c.dylib: mach-o, but wrong architecture
in fact we have
--> unix_g("lipo -archs "+TMPDIR+"/example_ilib_build_c/libbuild_c.dylib")
ans =
"x86_64"
although
--> unix_g("uname -m")
ans =
"arm64"
This is due to a wrong added flag in the Makefile:
CC = arm64-apple-darwin20.0.0-clang -arch x86_64
CXX = arm64-apple-darwin20.0.0-clang++ -arch x86_64
how can it be ? I think the problem is in modules/dynamic_link/src/scripts/configure.ac
:
# Mac OS >= 10.6 need -arch xx
case "$host" in
*-*-darwin*)
CFLAGS=" $CFLAGS -I/sw/include "
CPPFLAGS=" $CPPFLAGS -I/sw/include "
LDFLAGS=" $LDFLAGS -L/sw/lib/ "
CC=" $CC -arch x86_64 "
CXX=" $CXX -arch x86_64 "
esac
All the above is now obsolete.