【问题标题】:Perl module Config::Augeas with xs won't install on Big Sur带有 xs 的 Perl 模块 Config::Augeas 不会安装在 Big Sur 上
【发布时间】:2021-06-09 13:14:36
【问题描述】:

在我的带有 Catalina (10.15.6) 的 iMac 上,我安装了 augeas brew 包,然后安装了 perl 模块“Config::Augeas”而没有问题。在大苏尔,我没有取得同样的成功。安装 brew 包然后执行“cpanm Config::Augeas”后,我在构建日志中得到以下输出:

 27 Building Config-Augeas
 28 cc -I/Users/me/perl5/perlbrew/perls/perl-5.32.1/lib/5.32.1/darwin-2level/CORE -DVERSION="1.000" -DXS_VERSION="1.000" -I/usr/local/Cellar/augeas/1.12.0/include -Wall -Wformat -Werror=format-security -c -fno-common -DPERL_DARWIN -mmacosx-version-min=11.2 -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -DPERL_USE_SAFE_PUTENV -O3 -o lib/Config/Augeas.o lib/Config/Augeas.c
 29 ExtUtils::Mkbootstrap::Mkbootstrap('blib/arch/auto/Config/Augeas/Augeas.bs')
 30 cc -mmacosx-version-min=11.2 -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector-strong -o blib/arch/auto/Config/Augeas/Augeas.bundle lib/Config/Augeas.o -L/usr/local/Cellar/augeas/1.12.0/lib -laugeas
 31 Can't call method "get" on an undefined value at /Users/me/.cpanm/work/1615471944.29922/Config-Augeas-1.000/blib/lib/Config/Augeas.pm line 227.
 32 # Looks like your test exited with 255 just after 2.
 33 t/Config-Augeas.t ...
 34 Dubious, test returned 255 (wstat 65280, 0xff00)
 35 Failed 28/30 subtests
 36
 37 #   Failed test 'Created new Augeas object without backup file'
 38 #   at t/Config-AugeasC.t line 76.
 39 Can't call method "set" on an undefined value at t/Config-AugeasC.t line 78.
 40 # Looks like your test exited with 255 just after 4.
 41 t/Config-AugeasC.t ..
 42 Dubious, test returned 255 (wstat 65280, 0xff00)
 43 Failed 29/32 subtests
 44 Can't stat config-model-edit: No such file or directory
 45  at /Users/me/perl5/perlbrew/perls/perl-5.32.1/lib/site_perl/5.32.1/Test/Pod.pm line 223.
 46 t/pod.t ............. ok

两台机器都在运行 perlbrew(尽管 perl 版本不同)。我认为 perl 的版本不是问题,Big Sur 更有可能做了一些 perl 模块不喜欢的更改。有什么想法吗?

【问题讨论】:

  • 为了排除 perlbrew 的任何问题,我在较旧的 Mac 上进行了 Big Sur 的全新安装,并尝试在不使用 perlbrew 的情况下安装并遇到了同样的问题。
  • 是的,我也可以在这里看到问题(macOS 11.2,perlbrew perl 5.32)。我可以看到测试t/Config-Augeas.t 失败。似乎问题出在line 39 它在line 116 in Config/Augeas.pm 处调用new() ...
  • ... 在line 142 它调用XS 文件Augeas.xs at line 86 中的aug_init()。这个函数似乎返回一个未定义的值。我正在调查可能是什么问题。
  • 如果我直接从 C 调用 aug_init() 它可以工作(它不返回 NULL)。我用this测试程序,用cc `pkg-config --cflags augeas` `pkg-config --libs augeas` -o anew anew.c编译。所以我的猜测是,问题与 perl 在运行时加载共享库 libaugeas.dylib(间接通过 perl 生成的 Augeas.bundle)有关,而测试 C 程序是用静态库 libaugeas.a 编译的...我是进一步调查
  • 这个补丁有更多细节:github.com/ziglang/zig/pull/6932

标签: macos perl augeas


【解决方案1】:

问题是libtool 中的a bug 导致使用a flat namespace 编译动态库。这再次导致共享库libSystem.B.dyliblibfa.1.dylib 中的两个同名符号之间发生冲突。两个库都声明了一个名为 hash_create() 的符号,但是 Perl 模块需要将该符号解析为 libfa.1.dylib,但 libSystem.B.dylib 总是在 libfa.1.dylib 之前加载,因此使用了错误版本的 hash_create()

这个问题之前也遇到过,见this issue。进一步的解释可以找到here

由于libtool 中的bug 的修复尚未作为libtool 的新版本发布,因此问题并不能简单地通过升级xcode 命令行工具来解决。相反,您可以尝试下载 libaugeas source 并从源代码编译:

$ brew uninstall augeas
$ wget http://download.augeas.net/augeas-1.12.0.tar.gz
$ cd augeas-1.12.0
$ MACOSX_DEPLOYMENT_TARGET=10.15 ./configure
$ make
$ make install

注意:通过在上述命令中指定MACOSX_DEPLOYMENT_TARGET=10.15,我们可以解决该错误,因此不必修补configure

Perl 模块现在应该可以正常安装了。

另一种解决方法:您可以将dynamic linking(而不是dynamic loading)用于libfa.1.dylib。为了实现这一点,我将rewrotemodule 改为ExtUtils::MakeMaker 而不是Module::Build。接下来要使用动态链接安装,您可以这样做:

git clone https://github.com/hakonhagland/Config-Augeas-MM.git
cd https://github.com/hakonhagland/Config-Augeas-MM.git
perl Makefile.PL
make perl
make -f Makefile.aperl inst_perl MAP_TARGET=perl

注意:最后一个命令会覆盖您现有的 perl 二进制文件,因此请小心,请参阅this link 了解更多信息。

现在,模块可以测试安装成功了:

$ make test
"/Users/hakonhaegland/perl5/perlbrew/perls/perl-5.32.0/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Augeas.bs blib/arch/auto/Config/Augeas/Augeas.bs 644
rm -f blib/arch/auto/Config/Augeas/Augeas.bundle
LD_RUN_PATH="/usr/local/lib" cc  -mmacosx-version-min=11.1 -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector-strong  Augeas.o  -o blib/arch/auto/Config/Augeas/Augeas.bundle  \
       -L/usr/local/lib -laugeas   \

chmod 755 blib/arch/auto/Config/Augeas/Augeas.bundle
PERL_DL_NONLAZY=1 "/Users/hakonhaegland/perl5/perlbrew/perls/perl-5.32.0/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/Config-Augeas.t ... ok
t/Config-AugeasC.t .. ok
t/pod.t ............. skipped: Test::Pod 1.00 required for testing POD
All tests successful.
Files=3, Tests=62,  7 wallclock secs ( 0.04 usr  0.02 sys +  5.71 cusr  0.50 csys =  6.27 CPU)
Result: PASS

$ make install
"/Users/hakonhaegland/perl5/perlbrew/perls/perl-5.32.0/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Augeas.bs blib/arch/auto/Config/Augeas/Augeas.bs 644
Manifying 1 pod document
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /Users/hakonhaegland/perl5/perlbrew/perls/perl-5.32.0/lib/site_perl/5.32.0/darwin-2level/auto/Config/Augeas/extralibs.all
Installing /Users/hakonhaegland/perl5/perlbrew/perls/perl-5.32.0/lib/site_perl/5.32.0/darwin-2level/auto/Config/Augeas/Augeas.a
Installing /Users/hakonhaegland/perl5/perlbrew/perls/perl-5.32.0/lib/site_perl/5.32.0/darwin-2level/auto/Config/Augeas/extralibs.ld
Installing /Users/hakonhaegland/perl5/perlbrew/perls/perl-5.32.0/lib/site_perl/5.32.0/darwin-2level/auto/Config/Augeas/Augeas.bundle
Installing /Users/hakonhaegland/perl5/perlbrew/perls/perl-5.32.0/lib/site_perl/5.32.0/darwin-2level/Config/Augeas.pm
Installing /Users/hakonhaegland/perl5/perlbrew/perls/perl-5.32.0/man/man3/Config::Augeas.3
Appending installation info to /Users/hakonhaegland/perl5/perlbrew/perls/perl-5.32.0/lib/5.32.0/darwin-2level/perllocal.pod

$ perl -MConfig::Augeas -E 'say $INC{"Config/Augeas.pm"}'
/Users/hakonhaegland/perl5/perlbrew/perls/perl-5.32.0/lib/site_perl/5.32.0/darwin-2level/Config/Augeas.pm

【讨论】:

  • 哇,很棒的工作!一有机会,我就会试一试。可能需要几天时间,因为我被一堆工作所困。
  • 太棒了!添加了ticket 以通知作者该问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-06-19
  • 2021-08-04
  • 2021-05-31
  • 2021-06-08
  • 2021-04-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多