Using Perlbrew after macOS Mojave 10.14 update
sorangutan last edited by
I would like to share a minor fixup when using Perl with Perlbrew on MacOS.
After updating to MacOS X Mojave... I was not able to compile any XS module.. or even reinstall a different version of Perl itself...
Here one example output when trying to compile Clone for example
> make Skip blib/lib/Clone.pm (unchanged) Running Mkbootstrap for Clone () chmod 644 "Clone.bs" "/usr/local/perl/perls/perl-5.26.1/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Clone.bs blib/arch/auto/Clone/Clone.bs 644 "/usr/local/perl/perls/perl-5.26.1/bin/perl" "/usr/local/perl/perls/perl-5.26.1/lib/5.26.1/ExtUtils/xsubpp" -typemap '/usr/local/perl/perls/perl-5.26.1/lib/5.26.1/ExtUtils/typemap' Clone.xs > Clone.xsc mv Clone.xsc Clone.c cc -c -fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -O3 -DVERSION=\"0.39\" -DXS_VERSION=\"0.39\" "-I/usr/local/perl/perls/perl-5.26.1/lib/5.26.1/darwin-2level/CORE" Clone.c rm -f blib/arch/auto/Clone/Clone.bundle env MACOSX_DEPLOYMENT_TARGET=10.3 cc -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector-strong Clone.o -o blib/arch/auto/Clone/Clone.bundle \ \
ld: library not found for -lgcc_s.10.4
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [blib/arch/auto/Clone/Clone.bundle] Error 1
This was coming from the setting of the LD variable in the Makefile...
LD = env MACOSX_DEPLOYMENT_TARGET=10.3 cc
which is advertised by Perl itself... which mean I had to recompile/reinstall all Perl versions on my system.
> perl -V | grep ld= ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc'
When using Perlbrew some configuration tweak are applied by Devel::PatchPerl (a Perlbrew companion...) the version used by Perlbrew on my system was *really* outdated, and this took me some time to realize this was the source of my issues...
In order to fix it I had to update install-patchperl using perlbrew command line and force to override. (I was under the incorrect assumption that 'perlbrew self-upgrade' would take care of this for me :-)
To Fix it, just update install-patchperl
> perlbrew install-patchperl
/usr/local/perl/bin/patchperl already exists, are you sure to override ? [y/N] [N] y
patchperl is installed to
It does not hurt to the same with cpanm: "perlbrew install-cpanm"
Alternatively I coud have also compiled Perl without using Devel::PatchPerl
> perlbrew install --no-patchperl perl-5.26.2
or by forcing to use ccache
> perlbrew install -Dcc="ccache gcc" perl-5.26.2
Do not forget to recompile/reinstall Perl after updating patchperl, and remove any existing Perl version.
You should consider reinstalling older Perl versions if you need them.
> perlbrew install perl-5.26.2
Hope this would help some others experiencing a similar issue...
© Lightnetics 2018