-
Notifications
You must be signed in to change notification settings - Fork 78
Description
Can ExtUtils::MakeMaker
be used to generate a Makefile with macOS "Universal Binary" architecture directives (e.g. arm64, x86_64) for building a Perl module *.bundle
? If yes, then how? If not, could be this capability be added to the enhance|fix queue?
The general use case is for Perl on Apple hardware which will execute Perl module binaries with either the native arm64|arm64e processor or the Rosetta2 x86_64 binary translator.
In my particular case, I have run into significant blocking conflicts when working with Perl components of open source applications such as MacTeX, GnuCash, and LibreOffice. See: "StackOverflow: Install & update a Perl module as "universal" (x86_64, arm64)?"
Some investigation found inconsistencies in the Mach-O .bundle
architecture of Perl modules on the same arm-based computer. For example:
file /Library/Perl/5.30/darwin-thread-multi-2level/auto/Date/Simple/Simple.bundle
# /Library/Perl/5.30/darwin-thread-multi-2level/auto/Date/Simple/Simple.bundle:
# Mach-O 64-bit bundle arm64
file /Library/Perl/5.30/darwin-thread-multi-2level/auto/Encode/Encode.bundle
# /Library/Perl/5.30/darwin-thread-multi-2level/auto/Encode/Encode.bundle:
# Mach-O 64-bit bundle x86_64
file /System/Library/Perl/5.30/darwin-thread-multi-2level/auto/Encode/Encode.bundle
# /System/Library/Perl/5.30/darwin-thread-multi-2level/auto/Encode/Encode.bundle:
# Mach-O universal binary with 2 architectures:
# [x86_64:Mach-O 64-bit bundle x86_64]
# [arm64e:Mach-O 64-bit bundle arm64e]
Apple's instructions for building a macOS "Universal Binary" show how to "Update the Architecture List of Custom Makefiles".
x86_app: main.c
$(CC) main.c -o x86_app -target x86_64-apple-macos10.12
arm_app: main.c
$(CC) main.c -o arm_app -target arm64-apple-macos11
universal_app: x86_app arm_app
lipo -create -output universal_app x86_app arm_app
Note: lipo
can "create or operate on a universal file: convert a universal binary to a single architecture file, or vice versa."
It would be helpful if ExtUtils::MakeMaker
could support some KEY=VALUE
command line solution like the following:
perl Makefile.PL UNIVERSAL_BINARY="arm64,arm64e,x86_64"