mattn / p5-devel-checklib Goto Github PK
View Code? Open in Web Editor NEWcheck that a library is available
Home Page: http://search.cpan.org/dist/Devel-CheckLib/
check that a library is available
Home Page: http://search.cpan.org/dist/Devel-CheckLib/
This module provides a way of checking whether a particular library and its headers are available, by attempting to compile a simple program and link against it. To install, do the usual dance: perl Makefile.PL make make test make install
What is the status of this repo? The version on CPAN is 1.16:
https://metacpan.org/pod/Devel::CheckLib
but this repo says it is 1.14. Is this the correct repo to file a PR against?
I wanted to push a patch to remove the CVS markers from the files that have them.
In issue #4 commit 74a1a8b was added. I have narrowed this commit down to causing crashes in the executable created by tests like cmdline-LIBS-INC.t
.
I also needed to add some extra code to allow ranlib to be found on ActivePerl, so here are two branches to illustrate the issue:
In this branch, all tests pass.
In this branch, some tests fail, as described above.
The only difference between these two is a single commit: 74a1a8b
Hi, I don't seem to be able to re-open #19
Thank you for the merge and publish. This however did not fix things.
In my example, this failed:
$> LD_RUN_PATH=/usr/local/cpanel/3rdparty/lib64/mariadb: /usr/bin/gcc -DPERL_DISABLE_PMC -fPIC -DPIC -I/usr/local/cpanel/3rdparty/perl/524/include -L/usr/local/cpanel/3rdparty/perl/524/lib64 -I/usr/local/cpanel/3rdparty/include -L/usr/local/cpanel/3rdparty/lib64 -m64 -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -Wl,-rpath -Wl,/usr/local/cpanel/3rdparty/perl/524/lib64 -L/usr/local/cpanel/3rdparty/perl/524/lib64 -L/usr/local/cpanel/3rdparty/lib64 -L/usr/local/cpanel/3rdparty/perl/524/lib64 -L/usr/local/cpanel/3rdparty/lib64 -L/usr/lib64 -L/lib64 -lgdbm -fstack-protector-strong -L/usr/local/lib assertlibD1k4j0NX.c -o assertlibOns3ONwl -L/usr/local/cpanel/3rdparty/lib64/mariadb -lmariadb
$> ldd assertlibOns3ONwl
linux-vdso.so.1 => (0x00007fff825fe000)
libgdbm.so.4 => /lib64/libgdbm.so.4 (0x00007f63e71b8000)
libmariadb.so.1 => not found
libc.so.6 => /lib64/libc.so.6 (0x00007f63e6df6000)
/lib64/ld-linux-x86-64.so.2 (0x00007f63e73d0000)
However this succeeded
$> LD_RUN_PATH=/usr/local/cpanel/3rdparty/lib64/mariadb: /usr/bin/gcc -DPERL_DISABLE_PMC -fPIC -DPIC -I/usr/local/cpanel/3rdparty/perl/524/include -L/usr/local/cpanel/3rdparty/perl/524/lib64 -I/usr/local/cpanel/3rdparty/include -L/usr/local/cpanel/3rdparty/lib64 -m64 -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -L/usr/local/cpanel/3rdparty/perl/524/lib64 -L/usr/local/cpanel/3rdparty/lib64 -L/usr/local/cpanel/3rdparty/perl/524/lib64 -L/usr/local/cpanel/3rdparty/lib64 -L/usr/lib64 -L/lib64 -lgdbm -fstack-protector-strong -L/usr/local/lib assertlibD1k4j0NX.c -o assertlibOns3ONwl -L/usr/local/cpanel/3rdparty/lib64/mariadb -lmariadb
$> ldd assertlibOns3ONwl
linux-vdso.so.1 => (0x00007ffff95ac000)
libgdbm.so.4 => /lib64/libgdbm.so.4 (0x00007f880f663000)
libmariadb.so.1 => /usr/local/cpanel/3rdparty/lib64/mariadb/libmariadb.so.1 (0x00007f880f40f000)
libc.so.6 => /lib64/libc.so.6 (0x00007f880f04e000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f880ee32000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f880ec2d000)
libssl.so.10 => /lib64/libssl.so.10 (0x00007f880e9c1000)
libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007f880e5dc000)
libm.so.6 => /lib64/libm.so.6 (0x00007f880e2d9000)
/lib64/ld-linux-x86-64.so.2 (0x00007f880f87b000)
libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f880e08f000)
libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f880ddaf000)
libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f880dbaa000)
libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f880d975000)
libz.so.1 => /lib64/libz.so.1 (0x00007f880d75f000)
libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f880d550000)
libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f880d34c000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f880d132000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f880cf0a000)
libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f880cca9000)
The difference is that I removed this:
-Wl,-rpath -Wl,/usr/local/cpanel/3rdparty/perl/524/lib64
My guess is that LD_RUN_PATH is incompatible with -rpath so we need to correct this in one direction or another.
I'm using NetBSD 7.1. (This regression is almost certainly not limited to NetBSD.)
Last week, I had no trouble installing (for example) p5-Crypt-DH-GMP. This week, it complained like so, and failed to write its Makefile
:
Writing ppport.h
Shared object "libgmp.so.10" not found
wrong result: 'gmp'
(libgmp
is exactly as present as it was last week, and other configury things continue to find it just fine.)
In 1.09, when my build last worked, @ldflags
was getting set to -Wl,-rpath,/usr/pkg/lib -fstack-protector -L/usr/pkg/lib
.
In 1.10, when I get the above error, @ldflags
is getting set to -fstack-protector -L/usr/pkg/lib
.
The change was introduced in this commit.
I'm having trouble imagining a rationale for the change that makes sense to me, and I suspect there's a better way to get the result you were after. What was the problem the change was intended to solve? Maybe I can help solve it another way.
Thanks!
When some dynamic library is in a custom directory (not in the default library search path as declared in env LD_LIBRARY_PATH
or in ld.so.conf), passed in
incpathand
libpath`, the library is able to compile and link the binary. But then, in the case of using some custom function that really needs the library loaded at runtime when the generated program is executed, it fails because the dynamic library can not be found.
For a real example of this happening see the following script: unrpath.t. In my Linux box I have libssh2 compiled as a dynamic library at /usr/local/libssh2
and when the test program generated by Devel::CheckLib is run, it fails to find it:
$ perl -Ilib broken/unrpath.t
# Compiler seems to be /usr/bin/x86_64-linux-gnu-gcc
# /usr/bin/x86_64-linux-gnu-gcc -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fstack-protector-strong -L/usr/local/lib assertlibR8LAj8Q5.c -I/usr/local/libssh2/include -o assertlibvAhBNj9x
# /usr/bin/x86_64-linux-gnu-gcc -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fstack-protector-strong -L/usr/local/lib assertlibLQ9tqTOC.c -o assertlibGdSMn__w -I/usr/local/libssh2/include -L/usr/local/libssh2/lib -lssh2
/home/salva/g/perl/p5-Devel-CheckLib/assertlibGdSMn__w: error while loading shared libraries: libssh2.so.1: cannot open shared object file: No such file or directory
wrong result: 'ssh2'
As a workaround, using the ldflags
feature I have just submitted in a pull request, I can tell Devel::CheckLib to link with -rpath=$libpath
:
$ perl -Ilib broken/unrpath.t 1
# Compiler seems to be /usr/bin/x86_64-linux-gnu-gcc
# /usr/bin/x86_64-linux-gnu-gcc -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fstack-protector-strong -L/usr/local/lib -Wl,-rpath=/usr/local/libssh2/lib assertlibK3ufAM2E.c -I/usr/local/libssh2/include -o assertlibLKT2h60Q
# /usr/bin/x86_64-linux-gnu-gcc -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fstack-protector-strong -L/usr/local/lib -Wl,-rpath=/usr/local/libssh2/lib assertlibkU0crzZC.c -o assertlibqBzLfxar -I/usr/local/libssh2/include -L/usr/local/libssh2/lib -lssh2
But this is just a workaround. I don't really know how this issue could be fixed in a generic way. Also, it should be noted that, any custom flags required to compile the program should also be passed back to the program calling the library because otherwise the same logic should also be replicated there.
What is this bazban library? :)
+ /usr/bin/make -O -j48 V=1 VERBOSE=1 test
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00-load.t ................... ok
t/analyze-binary.t ............ ok
t/bad-single-word-compiler.t .. ok
t/cmdline-LIBS-INC.t .......... ok
# Failed test 'failed to build: wrong result'
# at t/custom-function.t line 75.
#
# incpath => 't/inc',
# libpath => 'Devel-Assert-testlib-srjQT5Jt',
# lib => 'bazbam',
# header => 'headerfile.h',
# # libversion returns wrong result
# function => 'foo();if(libversion() < 5) return 0; else return 1;'
#
# Can't link/include C library 'bazbam', aborting.
#
# STDOUT:
# STDERR:
# Looks like you failed 1 test of 5.
t/custom-function.t ...........
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/5 subtests
t/dash-l-libs.t ............... ok
t/exit_with_message.t ......... ok
t/flags.t ..................... ok
t/found.t ..................... ok
t/headers.t ................... ok
t/multi-word-compiler.t ....... ok
t/not_found.t ................. ok
Test Summary Report
-------------------
t/custom-function.t (Wstat: 256 Tests: 5 Failed: 1)
Failed test: 2
Non-zero exit status: 1
Files=12, Tests=42, 9 wallclock secs ( 0.09 usr 0.05 sys + 5.11 cusr 5.22 csys = 10.47 CPU)
Result: FAIL
Failed 1/12 test programs. 1/42 subtests failed.
make: *** [Makefile:865: test_dynamic] Error 255
I have a system where:
which ar gcc cc ranlib
which: no ar in (/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/usr/lib/llvm/10/bin:/usr/lib/llvm/9/bin)
which: no gcc in (/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/usr/lib/llvm/10/bin:/usr/lib/llvm/9/bin)
which: no cc in (/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/usr/lib/llvm/10/bin:/usr/lib/llvm/9/bin)
which: no ranlib in (/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/usr/lib/llvm/10/bin:/usr/lib/llvm/9/bin)
And the correct values for each are passed either by ENV, or by implication due to having perl compiled explicitly for this:
/usr/bin//perl -V:config_arg\\d+
...
config_arg13='-Darchname=x86_64-linux';
config_arg14='-Dcc=x86_64-pc-linux-gnu-gcc';
config_arg15='-Dar=x86_64-pc-linux-gnu-ar';
config_arg16='-Dnm=x86_64-pc-linux-gnu-nm';
config_arg17='-Dcpp=x86_64-pc-linux-gnu-gcc -E';
config_arg18='-Dranlib=x86_64-pc-linux-gnu-ranlib';
...
Most of perl is just fine with this configuration, but the way its done in Devel-CheckLib's tests is very sub-par
For starters, Helper::create_testlib is unable to handle a compiler named anything other than a very short list.
And Helper::_gcc_lib also fails due to trying to run find_binary('ar')
, which doesn't exist ( and provides no way to override the ar ), and if I could get it past that issue, the same problem would occur with ranlib.
The consequence is somewhat beneficial in that it doesn't cause a complete testing catastrophe, but the downside is none of the compilation tests get run, which makes it harder to assure Devel-CheckLib works as intended on the target system.
My automated scripted builds of DBD::mysql
failed because they added assert_lib
to their Makefile.PL
in 4.050 or thereabouts:
assert_lib(
LIBS => ($opt->{'embedded'} ? $opt->{'embedded'} : $opt->{libs}),
);
and assert_lib
neither honors LDFLAGS
nor does it accept -L
or -Wl,-R
in LIBS
to supply custom locations for the libraries and force their RPATH
.
My work-around was to strip the assert_lib
calls from DBD::mysql's Makefile.PL
using a sed script, but you really need to provide a way, preferably through environment variables, to control or override flags in the build process.
bin/use-devel-checklib and lib/Devel/CheckLib.pm both say
Bug reports should be made using L<http://rt.cpan.org/> or by email.
but rt.cpan.org will shut down March 1, 2021. You should update those instructions. Presumably you would like users to file issues here on GitHub instead.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.