problem generating cross compiled dynamic libraries on macOS

Alan Snyder <[email protected]> Thu, 24 Apr 2025 10:36:05 -0700
Newsgroups gmane.comp.sysutils.autoconf.bugs
Message-ID <[email protected]>
I'm trying to build a fftw dynamic library for macOS/x86 on a macOS/arm system. I am able to build a dynamic library for arm and a static library for x86, but unable to build a dynamic library for x86.

This code builds a static library for x86:

export CFLAGS="-arch x86_64"
./configure --host=x86_64-apple-macos10.10 --target=x86_64-apple-macos10.10

This code should also build a dynamic library, but it does not:

export CFLAGS="-arch x86_64"
./configure --host=x86_64-apple-macos10.10 --target=x86_64-apple-macos10.10 --enable-shared

The configure log says some unexpected things:

checking whether the gcc linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... no
checking if libtool supports shared libraries... no

When building for arm (i.e., not cross compiling), these say yes.

I’m a complete gnub when it comes to autoconf and similar tools, but it looks like this could be a bug.

I also noticed something odd in the configure log:

configure:4614: checking whether we are cross compiling
configure:4622: gcc -o conftest -arch x86_64   conftest.c  >&5
configure:4626: $? = 0
configure:4633: ./conftest
configure:4637: $? = 0
configure:4652: result: no

It fails to recognize cross compilation because the cross compiled executable actually runs on macOS.

I don’t know if this is related.

Just out of curiosity, why do I need to set CFLAGS? Doesn’t the host and target provide enough information?