-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manage Perl modules with "Universal Binary" (e.g. arm64, x86_64) #775
Comments
perlbrew itself does not do compilation of Perl modules but only tweaks enough env variables to make Also the complication setup of a module depends on the content of Makerile.PL or Build.PL of the module. To my knowledge, I don't think any comonnly-used, simple, setup would produce universal binaries at the end. The "ARCHFLAG" approach you've mentioned in Perl-Toolchain-Gang/ExtUtils-MakeMaker#445 seems to lead to some viable solution. But currently this variable is not special to perlbrew. |
I did find that So, while
As FYI, I am not currently a user of |
I haven't test it myself but I believe so. Since ARCHFLAGS is not specially handled by perlbrew itself, by properly
Since perlbrew itself is meant for personal use on a single computer instead of producing / distributing binary builds, I see little value of building universal-binaries. But maybe that's something people would want. It would still be nice to mention this approach (once verified) in a document. Eventually we will find it to be useful. :) |
Why use ARCHFLAGS and not put it in ccflags/ldflags/lddlflags? |
@gugod Good point on scope, here, there situation...
For clarification, this issue actually is a "personal use on a single computer" situation. I'm not trying to create any binaries for distribution. Goal: personal use, single user, standard-release Perl installation without Instruction Set Architecture (ISA) runtime issues... on Rosetta enabled macOS. After a user has enabled Rosetta 2 on an Apple Silicon computer, there are two Instruction Set Architectures (ISA) which automatically dispatch without requiring any additional user interaction. A Rosetta 2 enabled Apple Silicon computer has automatic dispatch on either the native At a technical level, which binaries slices ( BREW_INSTALL_DIR = /Library/Perl
find $BREW_INSTALL_DIR -name "*.bundle" | xargs file
# -- or, check the whole system --
find / -name "*.bundle" 2> /dev/null | xargs file |
@Leont A shapshot of findings relative to the current state of "universal binaries" and perl...
Good question… there appears to be a least three approaches to create mach-o universal binary loadable library bundles in the Perl eco-system:
ARCHFLAGS Use of The above information is clearly not recent because it speaks to PowerPC/Intel and 32/64 bit support. Even so, the above information was found to still successfully work for Perl as follows: env ARCHFLAGS='-arch arm64 -arch arm64e -arch x86_64' perl Makefile.PL
make
### An Apple Silicon machine can test all three architectures:
arch -x86_64 make test
arch -arm64 make test
arch -arm64e make test
### An Apple Intel machine can only test its native architecture:
make test
(sudo) make install An addition, I later found that (sudo) env ARCHFLAGS='-arch arm64 -arch arm64e -arch x86_64' cpan App::cpanminus
(sudo) env ARCHFLAGS='-arch arm64 -arch arm64e -arch x86_64' cpanm Test2
(sudo) env ARCHFLAGS='-arch arm64 -arch arm64e -arch x86_64' cpanm Finance::Quote
(sudo) env ARCHFLAGS='-arch arm64 -arch arm64e -arch x86_64' cpanm JSON::Parse
### verify universal binaries
find /Library/Perl -name "*.bundle" | xargs file Side note: It was @Leont comment "If you can make -arch x86_64 -arch arm64 work…" that lead to my grepping terms like lipo - universal binary tool The current Apple Developer documentation for "Building a Universal macOS Binary" provides information to use the 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
man lipo ccflags/ldflags/lddlflags -- Proof of Concept -- A proof-of-concept #! /bin/bash
arch_opt="-arch x86_64 -arch arm64"
opt1="-I./Encode -fno-common -DPERL_DARWIN -fno-strict-aliasing"
opt2="-mmacosx-version-min=12.0 -fstack-protector-strong"
opt3="-pipe -DPERL_USE_SAFE_PUTENV -Wno-error=implicit-function-declaration -O3"
opt4=-DVERSION=\"3.19\"
opt5=-DXS_VERSION=\"3.19\"
opt6="-I/opt/homebrew/Cellar/perl/5.34.0/lib/perl5/5.34.0/darwin-thread-multi-2level/CORE"
ccopts="$arch_opt $opt1 $opt2 $opt3 $opt4 $opt5 $opt6"
ldopts="$arch_opt $opt2"
cc -c $ccopts Encode.c
cc -c $ccopts def_t.c
cc -c $ccopts encengine.c
cc -bundle -undefined dynamic_lookup $ldopts \
Encode.o def_t.o encengine.o -o blib/arch/auto/Encode/Encode.bundle
file blib/arch/auto/Encode/Encode.bundle -- ExtUtils::FakeConfig Config_u -- The next finding was package Config_u;
require ExtUtils::FakeConfig;
require Config;
my %values =
( lddlflags => ' -arch i386 -arch ppc ' . $Config::Config{lddlflags},
ccflags => ' -arch i386 -arch ppc ' . $Config::Config{ccflags},
);
ExtUtils::FakeConfig->import( %values ); The MConfig_u use synopsis looked simple enough: perl -MConfig_u Makefile.PL
make
make test
make install However,
Note: This was the point in time where I inquired if -- Perl Variables -- It was news to me that ccflags/ldflags/lddlflags might be built into perl itself...
Interesting. Yet, puzzles remain:
Summary
|
@Leont Switching from a user to implementer perspective...
Perhaps a meaningful difference is that Some GitHub related code searches: |
Uniformity is a good thing. A uniform way of building perl and building perl modules is ideal. For example, if I wanted to create a macOS distribution of perl 5.32.1 and then install modules that are also universal and then distribute that perl so that both x86_64 and arm64e customers could use it, then I'd want to use the same mechanism to perform all operations so that universal binaries were produced. I think that's the first thing people would think of: one way to identify my intentions for all compilations. |
Does
App::perlbrew
support the management of the*.bundle
macOS "Universal Binary" (e.g. arm64, x86_64) files in Perl modules?Related:
The text was updated successfully, but these errors were encountered: