【问题标题】:Perl "use if" statements in cygwin break Configure scriptcygwin中的Perl“use if”语句中断配置脚本
【发布时间】:2017-09-16 14:00:29
【问题描述】:

我正在尝试从 cygwin 上的源代码编译 openssl。在 cygwin 中运行时,openssl-1.1.0f 附带的配置脚本似乎在条件“use if...”包含语句上中断。

在 Linux 上(成功):

$ perl -v

This is perl 5, version 26, subversion 0 (v5.26.0) built for i686-linux-gnu-
thread-multi-64int
....
$ CC='/usr/bin/gcc -static' ./Configure no-shared no-async linux-x86_64
File::Glob::glob() will disappear in perl 5.30. Use File::Glob::bsd_glob() 
instead. at ./Configure line 272.
Configuring OpenSSL version 1.1.0f (0x1010006fL)
    no-asan         [default]  OPENSSL_NO_ASAN
....
Configured for linux-x86_64.

在 Cygwin 上(失败):

$ perl -v

This is perl 5, version 22, subversion 4 (v5.22.4) built for cygwin-thread-
multi
...
$ CC='/usr/bin/gcc -static' ./Configure no-shared no-async mingw
Can't locate if.pm in @INC (you may need to install the if module) (@INC 
contains: /usr/lib/perl5/site_perl/5.22/x86_64-cygwin-threads 
/usr/lib/perl5/site_perl/5.22 /usr/lib/perl5/vendor_perl/5.22/x86_64-cygwin-
threads /usr/lib/perl5/vendor_perl/5.22 /usr/lib/perl5/5.22/x86_64-cygwin-
threads /usr/lib/perl5/5.22 .) at ./Configure line 17.
BEGIN failed--compilation aborted at ./Configure line 17.

$ head -n 17 Configure
#! /usr/bin/env perl
# -*- mode: perl; -*-
# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the OpenSSL license (the "License").  You may not use
# this file except in compliance with the License.  You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html

##  Configure -- OpenSSL source tree configuration script

use 5.10.0;
use strict;
use File::Basename;
use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
use File::Path qw/mkpath/;
use if $^O ne "VMS", 'File::Glob' => qw/glob/;

替换

use if $^O ne "VMS", 'File::Glob' => qw/glob/;

use File::Glob qw/glob/;

导致脚本成功直到下一个“use if”语句:

$ head -n 17 Configure
#! /usr/bin/env perl
# -*- mode: perl; -*-
# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the OpenSSL license (the "License").  You may not use
# this file except in compliance with the License.  You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html

##  Configure -- OpenSSL source tree configuration script

use 5.10.0;
use strict;
use File::Basename;
use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
use File::Path qw/mkpath/;
use File::Glob qw/glob/;

$ CC='/usr/bin/gcc -static' ./Configure no-shared no-async mingw
CC='/usr/bin/gcc -static' ./Configure no-shared no-async mingw
Configuring OpenSSL version 1.1.0f (0x1010006fL)
no-asan         [default]  OPENSSL_NO_ASAN
...
no-zlib-dynamic [default]
Configuring for mingw
Warning: failed to load Config_git.pl, something strange about this perl...
Something wrong with this line:
Program fragment delivered error ``Can't locate if.pm in @INC (you may need 
to install the if module) (@INC contains: util 
/usr/lib/perl5/site_perl/5.22/x86_64-cygwin-threads 
/usr/lib/perl5/site_perl/5.22 /usr/lib/perl5/vendor_perl/5.22/x86_64-cygwin-
threads /usr/lib/perl5/vendor_perl/5.22 /usr/lib/perl5/5.22/x86_64-cygwin-
threads /usr/lib/perl5/5.22 .) at /home/tester/socat/build/openssl-
1.1.0f/test/build.info line 296.
at /home/tester/socat/build/openssl-1.1.0f/test/build.info at ./Configure 
line 1616.

如何让这个 cygwin Perl 像这个 Linux Perl 一样工作?是否还有其他方法可以使此配置脚本成功?

这是我安装的模块:

$ perl -E'say for @INC' | xargs ls
ls: cannot access '/usr/lib/perl5/site_perl/5.22/x86_64-cygwin-threads': No such file or directory
ls: cannot access '/usr/lib/perl5/site_perl/5.22': No such file or directory
ls: cannot access '/usr/lib/perl5/vendor_perl/5.22/x86_64-cygwin-threads': No such file or directory
.:
(redacted)

/usr/lib/perl5/5.22:
AutoLoader.pm   Carp.pm      DirHandle.pm  FileHandle.pm  Locale          Params     SelectSaver.pm  Tie            version
AutoSplit.pm    Class        Exporter      FindBin.pm     locale.pm       parent.pm  SelfLoader.pm   Time           version.pm
B               Config       Exporter.pm   Getopt         Math            Parse      strict.pm       unicore        warnings
base.pm         constant.pm  ExtUtils      I18N           Module          PerlIO     Symbol.pm       UNIVERSAL.pm   warnings.pm
bytes.pm        CPAN         feature.pm    integer.pm     overload        PerlIO.pm  Term            utf8.pm        Win32API
bytes_heavy.pl  Digest       fields.pm     IO             overload.pm     Pod        Test            utf8_heavy.pl  x86_64-cygwin-threads
Carp            Digest.pm    File          IPC            overloading.pm  Safe.pm    Text            vars.pm        XSLoader.pm

/usr/lib/perl5/5.22/x86_64-cygwin-threads:
attributes.pm  Config.pm        Data           Encode     Fcntl.pm  IO      List    Opcode.pm  re.pm      Storable.pm  Win32API
auto           Config_heavy.pl  Digest         Encode.pm  File      IO.pm   MIME    PerlIO     Scalar     Time
B.pm           Cwd.pm           DynaLoader.pm  Errno.pm   I18N      lib.pm  mro.pm  POSIX.pm   Socket.pm  Win32.pm

/usr/lib/perl5/vendor_perl/5.22:
CPAN

【问题讨论】:

  • 您是否尝试在 cygwin 上安装 if 模块(即 cpan if)?
  • @mob if 应该是自 Perl 5.6.2 以来的核心模块。如果找不到if.pm,则说明Perl 安装有问题。
  • perl -e 'use if' 打印什么错误信息?如果if 模块安装正确,它应该类似于“Too few arguments to 'use if' ...”。如果不是,它应该类似于“Can't locate if.pm in @INC (you may need to install the if module) ...”。
  • 也许可以,但是if has a dual-life 并且重新安装它可能不会有什么坏处。在我尝试重新安装perl之前,它会尝试安装if,至少。
  • 对于在 Cygwin 下使用 Perl 运行相同命令的其他人来说,这将是最有用的。

标签: perl cygwin packages package-managers


【解决方案1】:

if.pm 是标准 perl 包的一部分

$ cygcheck -f /usr/lib/perl5/5.22/if.pm
perl-5.22.4-1

你应该检查包是否安装正确

$ cygcheck -c perl
Cygwin Package Information
Package              Version        Status
perl                 5.22.4-1       OK

如果没有,请重新安装它。

此外,您还可以在setup.ini 中看到,在 setup-arch.exe 上有 3 个可用的软件包版本,您应该注意混合使用它们。

@ perl
sdesc: "Perl programming language interpreter"
...
version: 5.22.4-1
...
[prev]
version: 5.22.3-1
..
[test]
version: 5.24.1-1

当前版本是5.22.4-15.24.1-1 是未来可能使用的测试版本。由于您显然不需要test 版本,只需使用当前稳定的5.22.4-1。 混在一起对你不好……

【讨论】:

  • 我希望我能找到重新安装软件包的命令。如果软件包已经安装,cygwin-setup-x86_64.exe -q -P perl-5.22.4-1 不会做任何事情。
  • 当我安装了perl_base,问题就消失了。我的回答中提供了完整的详细信息。谢谢!
【解决方案2】:

解决方案:安装了错误版本的 perl 软件包。

问题是由于未选择 perl_base 包引起的。

表示症状:

$ perl -v

This is perl 5, version 22, subversion 4 (v5.22.4) built for cygwin-
thread-multi

通过手动选择 perl_base 包解决了问题。然后 Perl 升级到 v5.24.1 并在 @INC 中包含 if.pm 模块:

解决方案的指示: $ perl -v

This is perl 5, version 24, subversion 1 (v5.24.1) built for x86_64-cygwin-
threads-multi

安装perl_base 包后,配置脚本完成,没有Can't locate if.pm in @INC 错误。

【讨论】:

  • 不,是 perl 软件包的重新安装(“Perl 然后升级到 v5.24.1”)修复了它,就像 matzeri 回答的那样。您只是使用了一种复杂的方法。
  • 我不确定是否只需选择较新版本的 perl 软件包就可以解决问题。似乎安装了没有对应 perl_base 软件包的 perl 版本。手动选择perl_base后,自动选择较新的perl,问题解决。看起来很迂腐,但如果单独升级 perl 并不能解决他们的问题,遇到相同问题的其他人可能会感到困惑。
  • Re "我不确定是否简单地选择更新版本的 perl 包就可以解决问题。",你完全倒退了。 perl_base 与此无关。丢失的文件 (if.pm) 由 perl 提供,而不是 perl_base。所以当然重新安装/升级perl 会解决你的问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-13
  • 2012-11-19
  • 2013-11-15
  • 2017-12-06
相关资源
最近更新 更多