Skip to content

[doc] Changing libpth for building extensions #23267

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

Open
Flamefire opened this issue May 7, 2025 · 2 comments
Open

[doc] Changing libpth for building extensions #23267

Flamefire opened this issue May 7, 2025 · 2 comments

Comments

@Flamefire
Copy link

Where
Possibly ExtUtils::Liblist::ext()

Description

ExtUtils::Liblist::ext() use libpth to search for libraries and custom implementations of it follow suit.
If I understood this correctly libpth is set during the configure/build of Perl itself.

We are in an environment that sets LD_LIBRARY_PATH & LIBRARY_PATH dynamically before building and using extensions.
But this seems to get ignored.

I've seen e.g. Term:Readline:Gnu providing e.g. --libdir to add paths but haven't found any option to modify libpth to have something generic enough.

Is this missing from the documentation, somewhere I haven't found yet or does it not exist at all?

@jkeenan
Copy link
Contributor

jkeenan commented May 7, 2025

Where Possibly ExtUtils::Liblist::ext()

Description

ExtUtils::Liblist::ext() use libpth to search for libraries and custom implementations of it follow suit. If I understood this correctly libpth is set during the configure/build of Perl itself.

We are in an environment that sets LD_LIBRARY_PATH & LIBRARY_PATH dynamically before building and using extensions. But this seems to get ignored.

I've seen e.g. Term:Readline:Gnu providing e.g. --libdir to add paths but haven't found any option to modify libpth to have something generic enough.

Is this missing from the documentation, somewhere I haven't found yet or does it not exist at all?

My impression is that you haven't supplied sufficient information for us to help you with your problem. For example, I can't identify the operating system on which you are experiencing this problem.

Can you supply us with the output of ./perl -Ilib -V for the perl instance in which you are having this problem?

Can you supply us with the sequence of commands that reproduces the problem?

If you have a git checkout of the Perl core distribution (which you should, in order to investigate a problem like this), you can use the following command to locate instances of the string libpth within that checkout:

$  ack -l '\blibpth\b' .

Please note that ExtUtils::Liblist is maintained upstream on CPAN as part of the ExtUtils-MakeMaker distribution. So any code change will first have to be sent to that library's issue tracker/pull request queue and evaluated there before appearing in the Perl core distribution.

@Flamefire
Copy link
Author

I'm using a Linux system, SLES 8 to be exact but this applies to any system supporting LD_LIBRARY_PATH & LIBRARY_PATH

Not sure what you need to "reproduce". The question is basically: How to change libpth to respect the current $LIBRARY_PATH or equivalently what to pass to perl such that it is updated to a specific value or some value gets appended or prepended.
Maybe: perl -e 'use Config; print $Config{libpth}'
This should ideally be equal to $LIBRARY_PATH

This needs to be done either generally, via an environment variable or with a flag to perl such that perl MakeFile.PT can pick it up

In the source I have found this place where the value of this config options seems to be determined during configure and not updated on runtime:

'') plibpth=`LANG=C LC_ALL=C $gcc $ccflags $ldflags -print-search-dirs | grep libraries |

$ ./perl -Ilib -V Summary of my perl5 (revision 5 version 38 subversion 2) configuration:

Platform:
osname=linux
osvers=4.18.0-513.24.1.el8_9.x86_64
archname=x86_64-linux-thread-multi
uname='linux n1549 4.18.0-513.24.1.el8_9.x86_64 #1 smp thu mar 14 14:20:09 edt 2024 x86_64 x86_64 x86_64 gnulinux '
config_args='-de -Dcc=gcc -Dccflags=-O2 -ftree-vectorize -march=native -fno-math-errno -fPIC -Dinc_version_list=none -Dprefix=/perl -Dinstallscript=/perl/bin -Dscriptdir=/perl/bin -Dscriptdirexp=/perl/bin -Dinstallstyle=lib/perl5 -Dusethreads'
hint=recommended
useposix=true
d_sigaction=define
useithreads=define
usemultiplicity=define
use64bitint=define
use64bitall=define
uselongdouble=undef
usemymalloc=n
default_inc_excludes_dot=define
Compiler:
cc='gcc'
ccflags ='-D_REENTRANT -D_GNU_SOURCE -O2 -ftree-vectorize -march=native -fno-math-errno -fPIC -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
optimize='-O2'
cppflags='-D_REENTRANT -D_GNU_SOURCE -O2 -ftree-vectorize -march=native -fno-math-errno -fPIC -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
ccversion=''
gccversion='13.3.0'
gccosandvers=''
intsize=4
longsize=8
ptrsize=8
doublesize=8
byteorder=12345678
doublekind=3
d_longlong=define
longlongsize=8
d_longdbl=define
longdblsize=16
longdblkind=3
ivtype='long'
ivsize=8
nvtype='double'
nvsize=8
Off_t='off_t'
lseeksize=8
alignbytes=8
prototype=define
Linker and Libraries:
ld='gcc'
ldflags =' -fstack-protector-strong -L/usr/local/lib'
libpth=/usr/local/lib /software/zlib/1.3.1-GCCcore-13.3.0/lib/../lib64 /software/binutils/2.42-GCCcore-13.3.0/lib/../lib64 /lib/../lib64 /usr/lib/../lib64 /software/zlib/1.3.1-GCCcore-13.3.0/lib /software/binutils/2.42-GCCcore-13.3.0/lib /lib /usr/lib /lib64 /usr/lib64 /usr/local/lib64
libs=-lpthread -ldl -lm -lcrypt -lutil -lc
perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
libc=libc-2.28.so
so=so
useshrplib=false
libperl=libperl.a
gnulibc_version='2.28'
Dynamic Linking:
dlsrc=dl_dlopen.xs
dlext=so
d_dlsymun=undef
ccdlflags='-Wl,-E'
cccdlflags='-fPIC'
lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector-strong'

Characteristics of this binary (from libperl):
Compile-time options:
HAS_LONG_DOUBLE
HAS_STRTOLD
HAS_TIMES
MULTIPLICITY
PERLIO_LAYERS
PERL_COPY_ON_WRITE
PERL_DONT_CREATE_GVSV
PERL_HASH_FUNC_SIPHASH13
PERL_HASH_USE_SBOX32
PERL_MALLOC_WRAP
PERL_OP_PARENT
PERL_PRESERVE_IVUV
PERL_USE_SAFE_PUTENV
USE_64_BIT_ALL
USE_64_BIT_INT
USE_ITHREADS
USE_LARGE_FILES
USE_LOCALE
USE_LOCALE_COLLATE
USE_LOCALE_CTYPE
USE_LOCALE_NUMERIC
USE_LOCALE_TIME
USE_PERLIO
USE_PERL_ATOF
USE_REENTRANT_API
USE_THREAD_SAFE_LOCALE
Built under linux
Compiled at Jul 31 2024 10:10:40
@inc:
lib
/perl/lib/perl5/site_perl/5.38.2/x86_64-linux-thread-multi
/perl/lib/perl5/site_perl/5.38.2
/perl/lib/perl5/5.38.2/x86_64-linux-thread-multi
/perl/lib/perl5/5.38.2

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

No branches or pull requests

2 participants