Skip to content
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

Add a libs_dynamic() method #295

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hakonhagland
Copy link
Contributor

When the alienfile is using the Gather::IsolateDynamic plugin together with configure option -enable-shared, the alien client might want to know how to link with the shared version of the library in the "share" install dir.

Background: I am considering submitting a PR to Alien-GSL in response to PerlAlien/Alien-GSL#17

When Gather::IsolateDynamic plugin together with configure option
-enable-shared, the alien client might want to know how to
link with the shared version of the library.
@plicease
Copy link
Member

Preferred way to handle this would be to migrate Alien::GSL to use Alien::Role::Dino, but note the caveats:
https://metacpan.org/pod/Alien::Role::Dino#Your-Alien-becomes-a-run-time-dependency.

my $d_basename = Path::Tiny->new($dyndir)->basename;
my $l_dirname = $class->dist_dir;
my $l_basename = 'lib';
$libs =~ s<-L${l_dirname}/\K$l_basename><$d_basename>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is bumping the Perl prereq:

✅ doublethink% perlver lib --blame

 ------------------------------------------------------------
 File    : lib/Alien/Base.pm
 Line    : 362
 Char    : 12
 Rule    : _regex
 Version : 5.009005
 ------------------------------------------------------------
 s&lt;-L${l_dirname}/\K$l_basename&gt;&lt;$d_basename&gt;
 ------------------------------------------------------------

@hakonhagland
Copy link
Contributor Author

Preferred way to handle this would be to migrate Alien::GSL to use Alien::Role::Dino

@plicease Ok, thanks for the pointer. I did a simple test here. When I try to install the dependencies for this branch in an Ubuntu 20.04 docker container like this:

cpanm --notest Alien::Build
git clone https://github.com/hakonhagland/Alien-GSL.git
cd Alien-GSL
git checkout dino
cpanm --installdeps --notest .

it fails with:

Entering /root/Alien-GSL
Configuring /root/Alien-GSL
Running Makefile.PL
Alien::Build::Plugin::PkgConfig::Negotiate> Using PkgConfig plugin: PkgConfig::PP
Can't locate Alien/Build/Plugin/Gather/Dino.pm in @INC (you may need to install the Alien::Build::Plugin::Gather::Dino module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .) at /usr/local/share/perl/5.30.0/Alien/Build.pm line 1138.
-> N/A

Any idea how I can make cpanm install the dependencies when using Alien::Role::Dino ?

@plicease
Copy link
Member

@hakonhagland I think that is a bug in cpanm, if you cpanm on the tarball it installs the prereqs correctly (at least it does for me). I think cpanm runs Makefile.PL first when you do a local install from dir like that even if there is a MYMETA.json with configure prereqs.

I think we will also need a runtime prereq on Alien::Role::Dino and Role::Tiny. I think your changes are on the right track, maybe you can open what you have as a PR against Alien-GSL and we can workshop it. I will also work on slimming down the prereqs for Alien::Role::Dino, they are unnecessarily large atm.

@Grinnz
Copy link

Grinnz commented Feb 27, 2022

It's not a bug the problem is you do not have the META.json in the repository for it to use before it runs Build.PL. MYMETA.json/yml should not be included, those should be generated at install time only.

@plicease
Copy link
Member

It's not a bug the problem is you do not have the META.json in the repository for it to use before it runs Build.PL. MYMETA.json/yml should not be included, those should be generated at install time only.

ah true. I misinterpreted that as META and then typed MYMETA lol.

@hakonhagland
Copy link
Contributor Author

It's not a bug the problem is you do not have the META.json in the repository for it to use

@Grinnz Thanks, I was not aware of the difference between MYMETA.json and META.json. I found some information about CPAN distribution metadata here that tries to explain it. However, when I delete MYMETA.json and try to run (in order to generate META.json) :

$ perl Makefile.PL
Alien::Build::Plugin::PkgConfig::Negotiate> Using PkgConfig plugin: PkgConfig::CommandLine
Alien::Build::CommandSequence> + pkg-config --exists gsl
Alien::Build::CommandSequence> + pkg-config --modversion gsl
Alien::Build::CommandSequence> [output consumed by Alien::Build recipe]
Generating a Unix-style Makefile
Writing Makefile for Alien::GSL
Writing MYMETA.yml and MYMETA.json

$ make
cp lib/Alien/GSL.pm blib/lib/Alien/GSL.pm
Manifying 1 pod document

$ make dist
rm -rf Alien-GSL-1.03
"/home/hakon/perlbrew/perls/perl-5.34.0/bin/perl" "-MExtUtils::Manifest=manicopy,maniread" \
	-e "manicopy(maniread(),'Alien-GSL-1.03', 'best');"
Problem opening MANIFEST: No such file or directory at /home/hakon/perlbrew/perls/perl-5.34.0/lib/5.34.0/ExtUtils/Manifest.pm line 349.
mkdir Alien-GSL-1.03
Generating META.yml
Generating META.json
Could not add META.yml to MANIFEST: Could not open MANIFEST: No such file or directory at /home/hakon/perlbrew/perls/perl-5.34.0/lib/5.34.0/ExtUtils/Manifest.pm line 723.
make: *** [Makefile:726: distmeta] Error 2

I get this error..

@Grinnz
Copy link

Grinnz commented Feb 27, 2022

You have to make manifest before make dist.

@hakonhagland
Copy link
Contributor Author

@Grinnz Yes, make manifest; make dist works. I now exatracted the tar ball and copied META.json and META.yml back into the repository (root dir of Alien-GSL). Then commited these to the GitHub remote, now cpanm --installdeps . works fine from the docker container.

@plicease However it still does not generate a shared library (from Alien-GSL root directory after having installed the dependencies) :

# perl Makefile.PL 
Alien::Build::Plugin::PkgConfig::Negotiate> Using PkgConfig plugin: PkgConfig::PP
Alien::Build> error in probe (will do a share install): package gsl not found at /usr/local/share/perl/5.30.0/Alien/Build/Plugin/PkgConfig/PP.pm line 89.
Alien::Build> Don't panic, we will attempt a share build from source if possible.
Alien::Build> Do not file a bug unless you expected a system install to succeed.
Generating a Unix-style Makefile
Writing Makefile for Alien::GSL
Writing MYMETA.yml and MYMETA.json

# make
cp lib/Alien/GSL.pm blib/lib/Alien/GSL.pm
"/usr/bin/perl" -MAlien::Build::MM=cmd -e prefix site /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30
Alien::Build::Plugin::PkgConfig::Negotiate> Using PkgConfig plugin: PkgConfig::PP
main> prefix /usr/local/lib/x86_64-linux-gnu/perl/5.30.0/auto/share/dist/Alien-GSL
"/usr/bin/perl" -MAlien::Build::MM=cmd -e version 1.03
Alien::Build::Plugin::PkgConfig::Negotiate> Using PkgConfig plugin: PkgConfig::PP
"/usr/bin/perl" -MAlien::Build::MM=cmd -e download
Alien::Build::Plugin::PkgConfig::Negotiate> Using PkgConfig plugin: PkgConfig::PP
Alien::Build::Plugin::Fetch::CurlCommand> writeout: ab-filename     :%{filename_effective}\n
Alien::Build::Plugin::Fetch::CurlCommand> writeout: ab-content_type :%{content_type}\n
Alien::Build::Plugin::Fetch::CurlCommand> writeout: ab-url          :%{url_effective}\n
Alien::Build::Plugin::Fetch::CurlCommand> + /usr/bin/curl -L -f -O -J -w @writeout https://ftp.gnu.org/gnu/gsl
Alien::Build::Plugin::Core::Download> decoding html
Alien::Build::Plugin::Core::Download> candidate *https://ftp.gnu.org/gnu/gsl/gsl-2.7.1.tar.gz
Alien::Build::Plugin::Core::Download> candidate  https://ftp.gnu.org/gnu/gsl/gsl-2.7.tar.gz
Alien::Build::Plugin::Core::Download> candidate  https://ftp.gnu.org/gnu/gsl/gsl-2.6.tar.gz
Alien::Build::Plugin::Core::Download> candidate  https://ftp.gnu.org/gnu/gsl/gsl-2.5.tar.gz
Alien::Build::Plugin::Core::Download> candidate  https://ftp.gnu.org/gnu/gsl/gsl-2.4.tar.gz
Alien::Build::Plugin::Core::Download> candidate  https://ftp.gnu.org/gnu/gsl/gsl-2.3.tar.gz
Alien::Build::Plugin::Core::Download> candidate  https://ftp.gnu.org/gnu/gsl/gsl-2.2.1.tar.gz
Alien::Build::Plugin::Core::Download> candidate  https://ftp.gnu.org/gnu/gsl/gsl-2.2.tar.gz
Alien::Build::Plugin::Core::Download> candidate  ...
Alien::Build::Plugin::Fetch::CurlCommand> writeout: ab-filename     :%{filename_effective}\n
Alien::Build::Plugin::Fetch::CurlCommand> writeout: ab-content_type :%{content_type}\n
Alien::Build::Plugin::Fetch::CurlCommand> writeout: ab-url          :%{url_effective}\n
Alien::Build::Plugin::Fetch::CurlCommand> + /usr/bin/curl -L -f -O -J -w @writeout https://ftp.gnu.org/gnu/gsl/gsl-2.7.1.tar.gz
Alien::Build::Plugin::Core::Download> setting version based on archive to 2.7.1
Alien::Build::Plugin::Core::Download> downloaded gsl-2.7.1.tar.gz
"/usr/bin/perl" -MAlien::Build::MM=cmd -e build
Alien::Build::Plugin::PkgConfig::Negotiate> Using PkgConfig plugin: PkgConfig::PP
Alien::Build::CommandSequence> + ./configure --prefix=/usr/local/lib/x86_64-linux-gnu/perl/5.30.0/auto/share/dist/Alien-GSL --with-pic --disable-shared
configure: loading site script /tmp/MgnJZV06IG/config.site
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /usr/bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
[...]

Notice that it runs the following configure command:

./configure --prefix=/usr/local/lib/x86_64-linux-gnu/perl/5.30.0/auto/share/dist/Alien-GSL --with-pic --disable-shared

with --disable-shared option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants