1

I am building a Perl module using Module::Build. The Build.PL file is below:

use strict ;
use warnings ;

use Module::Build;
my $build = Module::Build->new
(
    module_name => 'Company::LDAP::SyncAttr',
    license     => 'perl',
    installdirs  => 'vendor',
    install_path => {
                      'bin'    => '/usr/bin',
                      'script' => '/usr/bin'
                    },
) ;

$build->create_build_script ;

The module itself is here:

# SyncAttr.pm
package Company::LDAP::SyncAttr;
use Authen::Krb5;
1;

I have a test file in t/test.t that looks like this:

# test.t
use Company::LDAP::SyncAttr;

When I run ./Build test I get this error:

t/test.t .. Can't load '/usr/lib/x86_64-linux-gnu/perl5/5.20/auto/Authen/Krb5/Krb5.so' for module Authen::Krb5: /usr/lib/x86_64-linux-gnu/perl5/5.20/auto/Authen/Krb5/Krb5.so: 
undefined symbol: krb5_free_krbhst at /usr/lib/x86_64-linux-gnu/perl/5.20/DynaLoader.pm line 187.
 at /tmp/gg/blib/lib/Company/LDAP/SyncAttr.pm line 3.
Compilation failed in require at /tmp/gg/blib/lib/Company/LDAP/SyncAttr.pm line 3.

If I run the test.t file directly, I get no such error:

perl -Ilib/ t/test.t

What do I have to do to get ./Build test to not error out?

UPDATE: The problem lies with Module::Build. There is a routine do_tests in the Module::Build::Base module that forces the environment variable PERL_DL_NONLAZY to 1. If I change that line to set PERL_DL_NONLAZY to 0, then the tests all pass. The module Module::Build::Base does not provide an option to not set PERL_DL_NONLAZY, so I have submitted a bug report asking them add such an option. In the meantime, I will just have to skip running ./Build test.

rlandster
  • 7,294
  • 14
  • 58
  • 96
  • 1
    `perl -Mblib t/test.t` would be more representative. – ikegami Jun 23 '15 at 17:57
  • Did you run `./Build` before `./Build test`? – Hunter McMillen Jun 23 '15 at 17:57
  • @Hunter McMillen, Isn't the former included in the latter. – ikegami Jun 23 '15 at 17:58
  • @ikegami I would expect that, but I don't see any mention of it in the documentation. Haven't looked at the source yet. – Hunter McMillen Jun 23 '15 at 17:59
  • 1
    Tip: Authen::Krb5 should be listed as a prereq. – ikegami Jun 23 '15 at 19:21
  • The direct problem is that Authen::Krb5 is trying to link to symbol `krb5_free_krbhst` in `libk5crypto` or `libcrypto`, but it can't find it for some reason. It's really wonky that it happens only some circumstances, and might requires extensive debugging. My best guess is a change in environment. Add `BEGIN { warn "$_: $ENV{$_}\n" for sort keys %ENV }` before any `use` statements in `test.t` and run it both ways. – ikegami Jun 23 '15 at 19:31

0 Answers0