perl
Configure
Section titled “Configure”- Check if we need
-Dar=llvm-ar,-Dld=ld.lld,-Dnm=llvm-nmand-Dranlib=llvm-ranlibor if the regular symlinksar,nmandranlibare already provided byllvm - Check if we can disable more extensions (see
cpan/,dist/andext/) (also checkextensionsandknown_extensionsinconfig.shafter runningConfigure)
- Check if
perlstill does not build withltoenabled (particularly-flto=thin):
generate_uudmap.o: file not recognized: file format not recognized- Check if
--pack-dyn-relocs=relrcauses issues or not (the following error occurred during a native build on aglibchost only so check again if a native build in amuslchroot will complain or not):
./try: error while loading shared libraries: ./try: DT_RELR without GLIBC_ABI_DT_RELR dependency- Check if
$LDFLAGSshould be passed to-Dldflagsor to-Dlddlflagsor both - Check whether
$LDshould be kept asld.lldor set toclangvia-Dld=clang
- Check if we still need to add
core_perlto$PATHin bootstrap to prevent warnings about missingpod2manor if that was only needed for the previousgcc+binutilstoolchain (we now remove/usr/bin/pod2maninstead check if we require apod2manstub if anything requires it)
Prepare
Section titled “Prepare”- Depends on
mawk - Does not depend on a loopback
lonetwork device or a/etc/hostsfile (only the test suite does) - No need to set
LDFLAGS="-Wl,-z,stack-size=2097152 -pthread"or use stack size patches formuslonx86_64(only fors390x)
Configure
Section titled “Configure”- After running
Configureaconfig.shfile containing configuration data will be generated - Prefer
-D/-Uto='define'/='undef',='true'/='false'and='y'/='n'respectively -Doverrides values inhints/linux.sh, while-Aappends to them- It is better to use
-Accflagsto add preprocessor macros like-DNO_TAINT_SUPPORTand not optimization flags (seeINSTALL) - Do not use
-Dccflagsas that overrides preprocessor macros defined inhints/linux.sh(seeINSTALL) - It is better to use
-Doptimizeto completely override optimization flags forperl - No need to pass
-Accflags=-D_GNU_SOURCEasperlalready detectsmusland passes it (seeconfig.shafterConfigureis run andhints/linux.sh) - Explicitly specify
ccusing-Dcc=clangasConfiguredoes not honor$CC(seeConfigureandINSTALL) -Dusemallocwrapis enabled by default onlinux(seehints/linux.sh)-Uusemymallocuses systemmalloc(e.g.musl) instead of bundledmalloc.cand is the default onlinux(seehints/linux.sh)- Explicitly set
-Dusethreadsasperldefaults to compiling without thread support (perlpreviously had two threads implementations, the currentithreadswhich is synonymous withthreadsand the deprecated5005threads) (seeINSTALL) - Large file support is enabled by default on
linux(seehints/linux.shandINSTALL) - Avoid
-Duse64bitintand-Duse64bitallon a 64-bit system as they are intended as workarounds on legacy 32-bit hardware (seeINSTALL) - Avoid
-Dusemorebitsas it enables both 64-bit support andlong doublesupport - Avoid
-Dusequadmathwithclang -Accflags=-DNO_TAINT_SUPPORTprovides a 5-10% performance improvement without compromising security unlike-Accflags=-DSILENT_NO_TAINT_SUPPORT(seeINSTALL)- Avoid changing or overriding the default hash functions used by
perlas they are already good enough (seeINSTALL) - Avoid
-Duselongdoubleas it may double memory overhead and cause non-deterministic behavior onmusl - Avoid
-Dusesocksas it configuresperlto be “socksified” (linked againstlibsocks) (seeINSTALL) - Avoid
-Uusedlas it forcesperlto be compiled completely statically (seeINSTALL) -Duseshrplibprovides a sharedperllibrarylibperl.soand this comes with a performance penalty; however, not using it results in a larger install and a staticlibperl.a(seeINSTALL)$prefixexpis generated from$prefix, with~expansion done to convert home directories into absolute paths (seeINSTALL)-Dman1dir=noneand-Dman3dir=noneshould “in theory” disable man pages butinstallmaninstalls them regardless (seeINSTALL)man1dir,man3dir,siteman1dir,siteman3dir,vendorman1dirandvendorman3dirall default to/usr/man/man1and/usr/man/man3respectively which is not desired but we do not care as we installperlusing theinstall.perltarget (seePolicy_sh.SH)perldoes not installhtmldocumentation by default (set tonone) (seeINSTALL)- Avoid passing
DESTDIRto-Dinstallprefix=$DESTDIRand prefermake DESTDIR="$DESTDIR" installinstead (seeINSTALL) - Avoid
-Duserelocatableincas it is not compatible with-Duseshrplib(seeINSTALL) - Explicitly specify
-Dinc_version_list=noneto disable using olderperlversions and modules (seeINSTALL) - Avoid
-DDEBUGGINGas it bloatsperlby a factor of 2x to 3x and use-UDEBUGGINGinstead (seeINSTALL) - Avoid
-Dusedtraceasglaucusdoes not providedtrace - Avoid
-Dusemultiplicityasglaucusdoes not provide or allow multipleperlversions to coexist (seeConfigure) Configurewill build all supported extensions by default (e.g.GDBM_Fileif the gdbm library exists) (seeINSTALL)- Prefer
-Dnoextensions='DB_File GDBM_File NDBM_File ODBM_File SDBM_File'to-Ui_db -Ui_ndbm -Ui_gdbm -Ui_odbm -Ui_sdbm(seeINSTALL) - Prefer
-Dnoextensions="Archive/Tar Compress/Raw/Bzip2 Compress/Raw/Zlib IO/Compress IO/Zlib XS/APItest XS/Typemap"to-Dnoextensions="Archive-Tar Compress-Raw-Bzip2 Compress-Raw-Zlib DB_File GDBM_File IO-Compress IO-Zlib NDBM_File ODBM_File SDBM_File XS-APItest XS-Typemap"as the latter does not correctly detect extensions - Disabling
bzip2andzlibvia-Dnoextensionsis enough and the following is not enough or needed after-Dnoextensions:
rm -fR cpan/Compress-Raw-Zlib/zlib-srcrm -fR cpan/Compress-Raw-Bzip2/bzip2-src
sed '/\(bzip2\|zlib\)-src/d' -i MANIFEST
BUILD_BZIP2=0 \BUILD_ZLIB=0 \USE_ZLIB_NG=0 \./Configure \...- Avoid
-Dhostgenerate,-Dhostperl,-Dsysroot,-Dtargetarch,-Dtargetdir,-Dtargetenv,-Dtargethost,-Dtargetuserand-Dusecrosscompileas we only plan to natively compileperlas cross compilingperlis a major hassle (seeINSTALL) suidperlis no longer available, use a separate privilege escalation tool (seeINSTALL)miniperlis a small temporary version of perl built automatically during the build process with enough functionality to bootstrap the rest of the build until the finalperlbinary is fully built (seeINSTALL)- Explicitly specify
-Uusenmto prevent the “faster”nmextraction (orllvm-nm) from running onlibcduringConfigurefor a more accurate symbol probing (seeINSTALL) - Append
-DNO_MATHOMStoccflagsto stop functions frommathoms.cfrom being compiled as they are no longer used byperland are only included for compatibility reasons without being completely removed (seeINSTALL) - Do not set
-Accflags=-DZ_SOLOas it is only for bundledzlibwhich we disable withBUILD_ZLIB=0in favor of systemlibz usesonameis no longer available- Do not unset
-Ud_fpos64_tand-Ud_off64_tasmusldefinesfpos64_tandoff64_tso let the build system decide - Explicitly set
-Dd_sockaddr_in6as musl definessockaddr_in6 siteprefixis automatically set toprefix, unlikevendorprefixwhich is not set by default (seeINSTALL)Configure -ddisablesusedeveland an explicit-Dusedevelis required to enable development builds if needed (seeINSTALL)- Avoid
PERL_EXTERNAL_GLOBas it is a legacy behavior retained only forcsh(seeINSTALL) perl’s build system automatically detectsstatic_inlineless -isis a simpler and saner default compared toless -iRs- Relying only on
-Dprefix=/usrand-Dvendorprefix=/usr(as-Dsiteprefix=/usris set by default implicitly) produces the following layout (which is not desirable):
$dir/usr/lib/perl5/5.42.0/x86_64-linux-thread-multi$dir/usr/lib/perl5/site_perl/5.42.0/x86_64-linux-thread-multiprivlib,sitelibandvendorlibare not architecture specific and contain pureperlcode (not compiled) and should go under/usr/shareas recommended byFHSarchlib,sitearchandvendorarchare architecture specific and contain compiled extensions and should go under/usr/lib- Do not embed version information or host/target tuples in install paths like
perl5/5.42.0/x86_64-linux-thread-multi scriptdir,sitescriptandvendorscriptare automatically set to$prefix/binwhere binaries and scripts are stored (seeconfig.shafter runningConfigure)PERL_MM_USE_DEFAULT=1uses default values when answering questions for latercpanandmodulebuilds-Dinstallusrbinperldoes nothing with our configure options as it ensure/usr/bin/perlexists which it does given our paths-Ddefault_inc_excludes_dotis set by default and-Udefault_inc_excludes_dotturns on the old less secure behavior (seeINSTALL)- Explicitly specify
-Uusecbacktraceto disablebacktracesupport for a slightly smallerperl - Explicitly specify
-Uuselanginfoto disablelocalesupport and also pass-Accflags=-DNO_LOCALEto ensureI18N/Langinfo.pmandI18N/Langinfo/Langinfo.soare not getting installed in/usr/lib/perl5/core_perl(no need to pass-Dnoextensions='I18N/Langinfo I18N/Collate I18N/LangTags'as it has no effect) - Do not use
-Ud_uselocaleas it does not disableperllocale support and instead unsets feature detection ofuselocalewhichmuslsupports - Do not use
-Accflags='-DNO_POSIX_2008_LOCALE -DNO_THREAD_SAFE_LOCALE'as they letperlfallback to the old non-thread safe locale support (seepod/perllocale.pod) usevforkis disabled by default onlinuxunlikefreebsd(seehints/linux.sh)
make realcleanis equivalent tomake clean
Package
Section titled “Package”- Do not use
make install-stripas it installsmanpages and runsinstallmaneven when setting all*man*variables tonone:
-Dman1dir=none-Dman3dir=none-Dsiteman1dir=none-Dsiteman3dir=none-Dvendorman1dir=none-Dvendorman3dir=nonemake install.perldoes not installmanpages but still installspodfiles, it also does notstripinstalled binaries by default./perl installperl -p --destdir=$dirdoes not installmanpages andpodfiles (due to-p)./perl installperl -hshows a list of possible options that can be passed toINSTALLFLAGSwhen runningmake install.perl- Use
make INSTALLFLAGS='-s -f -o -p' install.perlas it strips installed binaries and does not installmanpages andpodfiles - No need to add additional
findstatements to remove.bs,.packlist,Change,READMEandTODOas they do not exist given the method we use to installperl $dir/usr/bin/perland$dir/usr/bin/perl$verare hard links meaning they are two names for the same file, so remove the latter versioned oneperl$ver
- Even-numbered subreleases (like
5.40.xand5.42.x) are stable maintenance releases (seeINSTALL) - Odd-numbered subreleases (like
5.41.xand5.43.x) are unstable development releases (seeINSTALL) - With
5.36the C compiler baseline requirement changed from “ANSI C89” to “C89 plus some specific C99 features” - The
configure.gnuscript is a compatibility shim forgnuconfigure that may not understand-Dsymbols and is not used by default (INSTALLmentions it forwards options toConfigureso use that instead) - The
configpmscript is run usingminiperlto regeneratelib/Config.pm,lib/Config_heavy.plandlib/Config.podfrom the contents ofconfig.sh,Porting/Glossaryandmyconfig.SHand it accepts a--no-glossaryoption which stopsPorting/Glossaryfrom being included inlib/Config.podthough we do not require it as we manually remove allpodfiles post install - The
myconfig.SHscript is a helper script that is used for bug reports - The scripts under
hints/are used byConfigureto set things whichConfigureeither can’t or doesn’t guess properly - The
Policy_sh.SHscript is run byConfigureto generatePolicy.shfor repeated builds and-DoverridesPolicy.shdefinitions perl -V:config_argsshows howperlwas configuredperlmanpages take 20 MB (a 1/3 of its entire install size) so remove them
References
Section titled “References”Offline
Section titled “Offline”- cflags.SH
- Configure
- INSTALL
- installperl
- hints/linux.sh
- hints/README.hints
- Makefile.SH
- pod/perllocale.pod
- Policy_sh.SH
- Porting/Glossary