UNIVERSAL_ARCHFLAGS

Joshua Root jmr at macports.org
Sat Feb 8 14:37:30 UTC 2020


On 2020-2-9 00:46 , Mihir Luthra wrote:
> Hi,
> 
> There is something I am not able to understand in base.
> 
> Looking into aclocal.m4, based on the version of  macOS, supported archs
> are being determined. Based on them -arch flags are constructed.
> 
> For example, if using macos 10.13, 
> UNIVERSAL_ARCHFLAGS= -arch x86_64 -arch i386.
> 
> Would adding them to CFLAGS and compiling mean that the result would be
> compatible with both x86_64 and i386? Or it it overriding the previous flag?

With clang and Apple gcc, -arch flags are cumulative.

> Doesn't it automatically default to the arch as per the os version
> without using -arch flags?

The default is up to the compiler, but sure.

> As for what it makes sense, I assume its producing library to be
> compatible with both x86_64 and i386. It is being used in
> darwintracelib1.0 and darwintracelib needs to be compatible with all
> supported archs on OS as it is getting injected into the installation.
> How important is it to support i386 as for now? Will it be okay if i386
> support is withdrawn and -arch is specified as x86_64 only?

It's important to have on all versions older than 10.14.

> Is there anyway to produce static libraries like this?
> The best option I find is libtool -static -arch_only <arch> but that
> works only if it's a single argument.

Creating a static library from fat object files works fine as long as
there's an index. That means using the -s option with ar, or running
ranlib after creation. The usual command is "ar crs <libname>.a *.o".

- Josh


More information about the macports-dev mailing list