+universal for x864+arm64 on Macintel
ryandesign at macports.org
Mon Jun 13 07:48:06 UTC 2022
On Jun 10, 2022, at 11:23, René J.V. Bertin wrote:
> When I tried to test the new +universal variant of a x864_64 + arm64 port (port:VLC) installing from official DMGs on my 10.9.5 Mac I discovered that the variant wasn't added because the port only supported the current build architecture. Whaaat? It took me a while to realise that maybe "base" knew I can't build arm64 binaries (supposedly; never tried) and thus ignored the arm64 entry in the port's supported_archs list. The variant did appear when I added i386 support (bogus in this case as the universal DMG doesn't contain i386 binaries).
> Such intelligence from "base" is probably a good thing but somewhere I feel that it's inappropriate in this port's kind of situation. The universal DMG exists after all, and my port installs from there, not by building anything. Is there a way to override the logic and force the +universal variant?
> The problem isn't necessarily entirely moot; port:VLC installs a library that can be used by 3rd party (non-MacPorts) applications, and it doesn't strike as impossible to build arm64 binaries on a system where MacPorts considers that to be impossible.
In my view, MacPorts base is behaving correctly and doesn't need any changes, though your port might.
MacPorts base knows which architectures are supported by your OS version. OS X 10.9 supports i386 and x86_64. macOS 11 is the first version that supports arm64.
MacPorts also knows which architectures are supported by a port based on its supported_archs line. If such a line is not present, all architectures are assumed to be supported.
The intersection of those two lists of architectures is the list of architectures for which the port can be installed.
If the number of items in the list of architectures for which the port can be installed is greater than one, and if certain other conditions are met, then MacPorts creates a universal variant. Otherwise it does not.
A port that installs from an upstream binary should set supported_archs to the list of architectures for which that binary was compiled. If that list of architectures is greater than one, then on some systems this port will offer a universal variant (and if MacPorts does not create a universal variant automatically in this case then the port should do so itself) and the port should handle that correctly: if the universal variant is requested by the user, the port should install files with those architectures. In the simple case of a 2-architecture universal binary, the port can just install the binary files unmodified. But if the user does not request the universal variant, then the port should install files of only the architecture that was requested, for example by using lipo to thin the universal binary. The libxl port shows one way this can be done.
More information about the macports-dev