shawnlaffan / perl-alien-proj

Perl Alien package to compile the Proj library
GNU Lesser General Public License v3.0
3 stars 1 forks source link

PDL::GIS::Proj using Alien::proj->libs gets dynamic-load failure on Perl 5.34 FreeBSD 14.0-current of sqlite #7

Closed mohawk2 closed 1 year ago

mohawk2 commented 2 years ago

http://www.cpantesters.org/cpan/report/5df1fefe-81b1-11ec-b66f-0a451f24ea8f shows:

"/usr/perl5.34.0p/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Proj.bs ../../../blib/arch/auto/PDL/GIS/Proj/Proj.bs 644
Manifying 1 pod document
"/usr/perl5.34.0p/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Proj.bs ../../../blib/arch/auto/PDL/GIS/Proj/Proj.bs 644
PERL_DL_NONLAZY=1 "/usr/perl5.34.0p/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, '../../../blib/lib', '../../../blib/arch')" t/*.t
Can't load '/usr/home/cpansand/.cpan/build/2022013003/PDL-2.072-0/Libtmp/GIS/Proj/../../../blib/arch/auto/PDL/GIS/Proj/Proj.so' for module PDL::GIS::Proj: Shared object "libsqlite3.so.0" not found, required by "Proj.so" at /usr/perl5.34.0p/lib/5.34.0/amd64-freebsd/DynaLoader.pm line 193.
 at t/gis_proj.t line 13.
Compilation failed in require at t/gis_proj.t line 13.
BEGIN failed--compilation aborted at t/gis_proj.t line 13.
t/gis_proj.t .. 
Dubious, test returned 2 (wstat 512, 0x200)
No subtests run 

Does it maybe need an LD_RUN_PATH and/or -r flag? Does PROJ actually need sqlite?

shawnlaffan commented 2 years ago

The coordinate definitions have been stored as an sqlite database since Proj version 6, so it does need it.

As for flags and variables, I'm open to a PR. Ideally the code will work across different OSes as there are downstream failures that are probably due to the same issue. See CI runs for https://github.com/shawnlaffan/geo-gdal-ffi-canary

The run_utility code already adds to LD_LIBRARY_PATH and DYLD_LIBRARY_PATH, and it would be nice to generalise. https://github.com/shawnlaffan/perl-alien-proj/blob/855c4002e15487cecbf246f8ff961d9ad117e350/lib/Alien/proj.pm#L50

mohawk2 commented 2 years ago

I confess I don't really know. Does FreeBSD have pkg-config? Does this module on that platform use it?

@plicease Do you have any ideas?

plicease commented 2 years ago

FreeBSD ports has pkgconf (pkg-config implementation), but since it isn't part of the core OS you can't guarantee that it will be there.

shawnlaffan commented 2 years ago

FWIW, PkgConfig is a dependency. https://github.com/shawnlaffan/perl-alien-proj/blob/855c4002e15487cecbf246f8ff961d9ad117e350/Makefile.PL#L26-L29

shawnlaffan commented 2 years ago

This should be the corresponding install of Alien::proj on that system: http://www.cpantesters.org/cpan/report/2286be24-5b99-11ec-bf39-74791f24ea8f

Some key parts are reproduced below.

A common issue with these modules on CPAN Testers is where the libs and cflags settings for the Alien are their final destination, but the make install step has not been run yet so the files are still under their respective blib dirs. This might be what is happening in this case.

# Install type is share
# Proj version is 8.2.0
# Aliens:
# Alien::sqlite: version: 3.31.1, install type: share
t/00-load.t ....... ok
# NAME=proj
# VERSION=8.2.0
# CFLAGS: -I/usr/perl5.34.0p/lib/site_perl/5.34.0/amd64-freebsd/auto/share/dist/Alien-sqlite/include -I/usr/home/cpansand/.cpan/build/2021121222/Alien-proj-1.16-0/blib/lib/auto/share/dist/Alien-proj/include
t/01-config.t ..... ok
# libs: -L/usr/perl5.34.0p/lib/site_perl/5.34.0/amd64-freebsd/auto/share/dist/Alien-sqlite/lib -lsqlite3 -lz -lm -lpthread -L/usr/home/cpansand/.cpan/build/2021121222/Alien-proj-1.16-0/blib/lib/auto/share/dist/Alien-proj/lib -lproj
# cflags: -I/usr/perl5.34.0p/lib/site_perl/5.34.0/amd64-freebsd/auto/share/dist/Alien-sqlite/include -I/usr/home/cpansand/.cpan/build/2021121222/Alien-proj-1.16-0/blib/lib/auto/share/dist/Alien-proj/include
# Dynamic libs: /usr/home/cpansand/.cpan/build/2021121222/Alien-proj-1.16-0/blib/lib/auto/share/dist/Alien-proj/lib/libproj.so:/usr/home/cpansand/.cpan/build/2021121222/Alien-proj-1.16-0/blib/lib/auto/share/dist/Alien-proj/lib/libproj.so.22:/usr/home/cpansand/.cpan/build/2021121222/Alien-proj-1.16-0/blib/lib/auto/share/dist/Alien-proj/lib/libproj.so.22.2.0:/usr/perl5.34.0p/lib/site_perl/5.34.0/amd64-freebsd/auto/share/dist/Alien-sqlite/lib/libsqlite3.so:/usr/perl5.34.0p/lib/site_perl/5.34.0/amd64-freebsd/auto/share/dist/Alien-sqlite/lib/libsqlite3.so.0:/usr/perl5.34.0p/lib/site_perl/5.34.0/amd64-freebsd/auto/share/dist/Alien-sqlite/lib/libsqlite3.so.0.8.6
# bin dir: /usr/home/cpansand/.cpan/build/2021121222/Alien-proj-1.16-0/blib/lib/auto/share/dist/Alien-proj/bin
t/02-use.t ........ ok
# 
shawnlaffan commented 2 years ago

To continue the incomplete (and now deleted) point in the previous comment, it might be worth adding some instrumentation to PDL::GIS::Proj to say where it thinks it is getting things from.

mohawk2 commented 2 years ago

That sounds sensible, and would probably help with https://github.com/PDLPorters/pdl/issues/391. @shawnlaffan What would it be useful to dump out?

shawnlaffan commented 2 years ago

I would guess some printing of the common env vars that might be in use.

LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, LDFLAGS, CFLAGS, CXXFLAGS

Note that the first two are currently set in the test file: https://github.com/shawnlaffan/perl-alien-proj/blob/4850586752a5631837ccc3ac1854a3d9f0b1cbd7/t/02-use.t#L10-L12

mohawk2 commented 2 years ago

I wonder if setting those env-vars more globally (and probably joining with join $Config{path_sep}, grep defined, $ENV{LD_LIBRARY_PATH}, $newvalue) wouldn't be useful.

mohawk2 commented 2 years ago

I would guess some printing of the common env vars that might be in use.

LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, LDFLAGS, CFLAGS, CXXFLAGS

Added (with a couple of bonus ones in case) on git master.

shawnlaffan commented 2 years ago

Alien::proj 1.23 now sets the rpath in the compilation phase. @mohawk2 - Can you give it a try?

Details in 680e259043862a6166b056483983a66ece267c2b

shawnlaffan commented 1 year ago

I think this is fixed now but please re-open if not.