timlegge / perl-IO-Compress-Brotli

https://metacpan.org/pod/IO::Compress::Brotli
0 stars 0 forks source link

Static build failed + workaround #4

Open vadimkantorov opened 3 months ago

vadimkantorov commented 3 months ago

When doing a static install, there is a bug in Makefile that leads to the following

rm -f "blib/arch/auto/IO/Compress/Brotli/Brotli.a"
cp brotli/libbrotlienc.a brotli/libbrotlidec.a brotli/libbrotlicommon.a "blib/arch/auto/IO/Compress/Brotli/Brotli.a"
# cp: target 'blib/arch/auto/IO/Compress/Brotli/Brotli.a' is not a directory

The problem is because $(MYEXTLIB) contains several libraries (from Makefile): # MYEXTLIB => q[brotli/libbrotlienc$(LIB_EXT) brotli/libbrotlidec$(LIB_EXT) brotli/libbrotlicommon$(LIB_EXT)]

With the following fix, it starts working:

perl Makefile.PL LINKTYPE=static
sed -i 's/$(CP) $(MYEXTLIB) "$@"/$(CP) $(MYEXTLIB) "$(dir $@)"/' Makefile
make
make install

Don't know if this can be fixed in this package or needs to be fixed in MakeMaker...

timlegge commented 3 months ago

@vadimkantorov I have not seen that issue. Which platform/linux distro are you using

vadimkantorov commented 3 months ago

It was on Ubuntu-22.04 on GitHub Actions (prep work for static compilation of https://github.com/plk/biber ):

If you delete the workaround here, you'll repro the bug

name: staticperl_biber

env:
  URLPERL: https://www.cpan.org/src/5.0/perl-5.32.0.tar.gz

on: workflow_dispatch

jobs:
  staticperl_biber:
    runs-on: ubuntu-22.04
    steps:
       - name: Install Package Dependencies
         run: sudo apt install -y libxml2-dev libxslt-dev libbtparse-dev p7zip-full cmake

       - uses: actions/checkout@v2

       - name: Install Perl static
         run: |
           mkdir perlsourcestatic
           wget -nc $URLPERL
           tar -xf $(basename $URLPERL) --strip-components=1 --directory=perlsourcestatic
           cd perlsourcestatic
           bash +x ./Configure -sde -Dprefix="$RUNNER_WORKSPACE/localperlstatic" -Dextras="DBI" -Dstatic_ext="attributes B Cwd Data/Dumper Devel/Peek Digest/MD5 Digest/SHA Encode Encode/Unicode Encode/CN Encode/KR Encode/TW Encode/JP  Encode/Symbol Encode/EBCDIC Encode/Byte Fcntl File/Glob Hash/Util I18N/Langinfo IO List/Util mro Opcode PerlIO/encoding PerlIO/scalar PerlIO/via POSIX PerlIO/mmap Time/HiRes re Socket  Unicode/Normalize Unicode/Collate Compress/Raw/Zlib Compress/Raw/Bzip2 threads threads/shared Sys/Syslog Sys/Hostname File/DosGlob Math/BigInt/FastCalc Hash/Util/FieldHash Filter/Util/Call IPC/SysV MIME/Base64" -Dusedevel -Accflags="-lm -ldl" -Aldflags="-lm -ldl" -Dlibs="-lpthread -ldl -lm -lutil -lc"
           make
           make install
           $RUNNER_WORKSPACE/localperlstatic/bin/perl5.32.0 -e "print('hello world');"
           ln -s $RUNNER_WORKSPACE/localperlstatic/bin/enc2xs5.32.0 $RUNNER_WORKSPACE/localperlstatic/bin/enc2xs
           find $RUNNER_WORKSPACE/localperlstatic
           #$RUNNER_WORKSPACE/localperlstatic/bin/cpan5.32.0 -T Alien::Base::Wrapper Alien::cmake3 inc::Module::Install
           echo "$RUNNER_WORKSPACE/localperlstatic/bin" >> $GITHUB_PATH
           echo "LD_LIBRARY_PATH=$RUNNER_WORKSPACE/localperlstatic/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV

       - name: Install build-time deps
         run: $RUNNER_WORKSPACE/localperlstatic/bin/cpan5.32.0 -T Alien::Base::Wrapper Alien::Build Alien::Build::MM Alien::cmake3 Alien::Libxml2 inc::Module::Install Module::Implementation Config::AutoConf ExtUtils::LibBuilder # DBI

       - name: Install Perl static extra packages
         run: |
           export PERLBIN=$RUNNER_WORKSPACE/localperlstatic/bin/perl5.32.0
           for MOD in Sort::Key Encode::EUCJPASCII Encode::JIS2K Encode::HanExtra XML::LibXML autovivification Devel::Caller Devel::LexAlias XML::LibXSLT XML::Parser::Expat Unicode::LineBreak Clone PadWalker  PerlIO::utf8_strict HTML::Parser List::MoreUtils::XS List::SomeUtils::XS DBI Net::SSLeay Sub::Identify DateTime Storable Variable::Magic Class::XSAccessor Package::Stash::XS Params::Util DBD::SQLite; do
               URL=$(wget -q -O - https://fastapi.metacpan.org/v1/download_url/$MOD | grep download_url | cut -d'"' -f4)
               PKG=${MOD//::/-}
               mkdir -p myextsource myext/$PKG
               wget -nc $URL -P myextsource
               tar -xf myextsource/$(basename $URL) --strip-components=1 --directory myext/$PKG
               cd myext/$PKG
               $PERLBIN Makefile.PL LINKTYPE=static
               make
               make install
               cd ../..
            done

       - name: Install Brotli
         run: |
           export PERLBIN=$RUNNER_WORKSPACE/localperlstatic/bin/perl5.32.0
           URL=$(wget -q -O - https://fastapi.metacpan.org/v1/download_url/IO::Compress::Brotli | grep download_url | cut -d'"' -f4)
           mkdir -p myextsource myext/IO-Compress-Brotli
           wget -nc $URL -P myextsource
           tar -xf myextsource/$(basename $URL) --strip-components=1 --directory myext/IO-Compress-Brotli
           cd myext/IO-Compress-Brotli
           $PERLBIN Makefile.PL LINKTYPE=static
           sed -i 's/$(CP) $(MYEXTLIB) "$@"/$(CP) $(MYEXTLIB) "$(dir $@)"/' Makefile
           make
           make install

       - name: Install Params/Validate/XS
         run: |
           export PERLBIN=$RUNNER_WORKSPACE/localperlstatic/bin/perl5.32.0
           URL=$(wget -q -O - https://fastapi.metacpan.org/v1/download_url/Params::Validate::XS | grep download_url | cut -d'"' -f4)
           mkdir -p myextsource myext/Params-Validate-XS
           wget -nc $URL -P myextsource
           tar -xf myextsource/$(basename $URL) --strip-components=1 --directory myext/Params-Validate-XS
           cd myext/Params-Validate-XS
           $PERLBIN ./Build.PL
           $PERLBIN ./Build
           $PERLBIN ./Build install
           ar crs ../../../localperlstatic/lib/site_perl/5.32.0/x86_64-linux/auto/Params/Validate/XS/XS.a lib/Params/Validate/XS.o

       - name: Install Text/BibTeX
         run: |
           export PERLBIN=$RUNNER_WORKSPACE/localperlstatic/bin/perl5.32.0
           URL=$(wget -q -O - https://fastapi.metacpan.org/v1/download_url/Text::BibTeX | grep download_url | cut -d'"' -f4)
           mkdir -p myextsource myext/Text-BibTeX
           wget -nc $URL -P myextsource
           tar -xf myextsource/$(basename $URL) --strip-components=1 --directory myext/Text-BibTeX
           cd myext/Text-BibTeX
           $PERLBIN ./Build.PL
           $PERLBIN ./Build
           $PERLBIN ./Build install
           ar crs  ../../../localperlstatic/lib/site_perl/5.32.0/x86_64-linux/auto/Text/BibTeX/BibTeX.a    xscode/BibTeX.o xscode/btxs_support.o btparse/src/init.o btparse/src/input.o btparse/src/bibtex.o btparse/src/err.o btparse/src/scan.o btparse/src/error.o btparse/src/lex_auxiliary.o btparse/src/parse_auxiliary.o btparse/src/bibtex_ast.o btparse/src/sym.o btparse/src/util.o btparse/src/postprocess.o btparse/src/macros.o btparse/src/traversal.o btparse/src/modify.o btparse/src/names.o btparse/src/tex_tree.o btparse/src/string_util.o