develooper Front page | perl.perl5.porters | Postings from May 2020

libpth issue

Thread Next
From:
H.Merijn Brand
Date:
May 4, 2020 07:48
Subject:
libpth issue
Message ID:
20200504094658.0b625d04@pc09.procura.nl
Very short:
    $Config{libpth} is wrong for 64bit environment

Short:
    $Config{libpth} has /usr/lib before /usr/lib64 for a 64bit
    environment, which will break finding matching libraries in e.g.
    Alien::GMP, which uses Alien::Build, which uses FFY::CheckLib
    which uses Dynaloader

$ locate gmp.pc
/usr/lib64/pkgconfig/gmp.pc

$ locate gmp.pc | xargs grep /lib
libdir=/usr/lib64

$ locate libgmp.so
/usr/lib/libgmp.so.10
/usr/lib/libgmp.so.10.4.0
/usr/lib64/libgmp.so
/usr/lib64/libgmp.so.10
/usr/lib64/libgmp.so.10.4.0

Alien-GMP-1.16-0$ make test
:
# dynamic_libs   = /usr/lib/libgmp.so.10.4.0
:
t/alien_gmp__ffi.t .. 1/?
# Failed test 'ffi'
# at t/alien_gmp__ffi.t line 26.
#   __gmpz_init_set_str not found
#   __gmpz_mul not found
t/alien_gmp__ffi.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/3 subtests

$ perl -MDynaLoader -wE'say for @DynaLoader::dl_library_path'
/usr/local/lib
/usr/lib64/gcc/x86_64-suse-linux/8/include-fixed
/usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/lib
/usr/lib
/pro/local/lib
/lib/../lib64
/usr/lib/../lib64
/lib
/lib64
/usr/lib64
/usr/local/lib64

$ perl -V:libpth
libpth='/usr/local/lib /usr/lib64/gcc/x86_64-suse-linux/8/include-fixed /usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/lib /usr/lib /pro/local/lib /lib/../lib64 /usr/lib/../lib64 /lib /lib64 /usr/lib64 /usr/local/lib64';

I think that libpth should be modified to make sure the all 64bit
versions should be in front of the 32bit versions for each folder
that has an entry for both:

--8<---
use 5.18.2;
use warnings;

use Config;

# Ignoring folders-with-spaces issues for now
my @libpth = split m/\s+/ => $Config{libpth};

say "Before:";
say for @libpth;

say "\nAfter:";
my (@p, %p);
for (@libpth) {
    my $p = s/64$//r;
    push @p => $p,
    push @{$p{$p}} => $_;
    }
foreach my $p (@p) {
    my @l = @{delete $p{$p} || []} or next;
    say for reverse sort @l;
    }
-->8---

Before:
/usr/local/lib
/usr/lib64/gcc/x86_64-suse-linux/8/include-fixed
/usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/lib
/usr/lib
/pro/local/lib
/lib/../lib64
/usr/lib/../lib64
/lib
/lib64
/usr/lib64
/usr/local/lib64

After:
/usr/local/lib64
/usr/local/lib
/usr/lib64/gcc/x86_64-suse-linux/8/include-fixed
/usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/lib
/usr/lib64
/usr/lib
/pro/local/lib
/lib/../lib64
/usr/lib/../lib64
/lib64
/lib

If I change 'libpth' to '/usr/local/lib64 /usr/local/lib
/usr/lib64/gcc/x86_64-suse-linux/8/include-fixed
/usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/lib
/usr/lib64 /usr/lib /pro/local/lib /lib/../lib64 /usr/lib/../lib64
/lib64 /lib" in
/pro/lib/perl5/5.30.0/x86_64-linux-thread-multi-ld/Config.pm

All tests PASS (as now expected)
-- 
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.31      porting perl5 on HP-UX, AIX, and Linux
https://useplaintext.email  https://tux.nl  http://www.test-smoke.org
http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About