2

I am attempting to compile openssl from source on cygwin. The Configure script that ships with openssl-1.1.0f appears to break on conditional "use if..." inclusion statements when running inside cygwin.

On Linux (succeeds):

$ 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.

On Cygwin (fails):

$ 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/;

Replacing

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

with

use File::Glob qw/glob/;

causes script to succeed until next "use if" statement:

$ 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.

How do I make this cygwin Perl act like this Linux Perl? Is there something else that can be done to make this Configure script succeed?

Here are my installed modules:

$ 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
ikegami
  • 367,544
  • 15
  • 269
  • 518
femtobarn
  • 19
  • 2
  • Did you try to install the `if` module on cygwin (i.e. `cpan if`)? – mob Sep 15 '17 at 18:58
  • @mob `if` ought to be a core module since Perl 5.6.2. If `if.pm` can't be found, something is quite wrong with the Perl installation. – amon Sep 15 '17 at 19:00
  • 1
    What error message does `perl -e 'use if'` print? If the `if` module is installed correctly, it should be something like "`Too few arguments to 'use if'` ...". If it isn't, it should be something like "`Can't locate if.pm in @INC (you may need to install the if module)` ...". – Keith Thompson Sep 15 '17 at 19:03
  • Maybe, but [`if` has a dual-life](https://metacpan.org/pod/if) and it might not hurt to install it again. It would try installing `if` before I tried reinstalling `perl`, at least. – mob Sep 15 '17 at 19:03
  • @mob: I'd check whether it's installed (see my previous comment) before trying to install it again. I don't know what you mean by "dual-life". – Keith Thompson Sep 15 '17 at 19:04
  • https://stackoverflow.com/questions/6009476/what-is-a-dual-life-module – mob Sep 15 '17 at 19:06
  • cpan does not appear to be installed/functioning. Some quick searching turned up no good solutions to this problem. **$ cpan if** **Can't locate App/Cpan.pm in @INC ...** – femtobarn Sep 15 '17 at 19:11
  • @mob: Thanks for the explanation. But if the `if` module is missing, installing it is likely to fix that one problem without correcting some underlying problem with the OP's Perl installation. If `if` is missing, I'd consider (a) trying to track down the cause of the problem, and (b) reinstalling Perl. (Reading the question more closely, I see the OP has Perl 5.22, and the `if` module really is missing.) I wonder if `@INC` could be messed up somehow. – Keith Thompson Sep 15 '17 at 19:12
  • Let's see what modules you have installed. Can you please provide a listing of the `@INC` directories? E.g. like `perl -E'say for @INC' | xargs ls`. – amon Sep 15 '17 at 19:15
  • Some general notes: `use if` refers to a module named `if`, not related to the built-in `if` keyword. That module has been part of the core Perl distribution since 5.6.2, and you're using 5.22. The error message indicates that the `if` module is missing -- which shouldn't be possible. Other `use` statements work, so the problem is specific to the `if` module. Speculation: Your Perl installation is messed up, or your `@INC` is messed up, perhaps due to an incorrect environment variable, or Cygwin has done something weird. – Keith Thompson Sep 15 '17 at 19:17
  • @amon: This is the output of `perl -E'say for @INC' | xargs ls` https://pastebin.com/Bksy51ER – femtobarn Sep 15 '17 at 19:17
  • @amon: The only installed package that matches "perl" is the `perl` package. https://i.imgur.com/SxeuKSo.png – femtobarn Sep 15 '17 at 19:32
  • 1
    It would be most useful for somebody else using Perl under Cygwin to run the same command. – Keith Thompson Sep 15 '17 at 19:38
  • @Keith Thompson, [here you go](https://pastebin.com/Qeu1Sxai). – ikegami Sep 15 '17 at 19:52
  • @femtobarn, You should have a package named `perl-base` installed; it's a dependency of the `perl` package. – ikegami Sep 15 '17 at 19:59
  • @ikegami: `perl-base` is not installed, [nor does it exist in my `Full` package list](https://i.imgur.com/CZxVYtC.png). Something must be very wrong. Is it the [mirror](https://i.imgur.com/LY8YEIU.png) I am using? – femtobarn Sep 15 '17 at 20:09
  • I meant `perl_base`. But ignore that. As I was about to post until matzeri beat me to it, `cygcheck` says the file is in `perl-5.22.4-1`. – ikegami Sep 15 '17 at 20:12
  • @ikegami: The correct name is `perl_base`. It exists, and it was not installed. The reason must be that the wrong version of the perl package was selected. After installation of the `perl_base` package, `perl -v` reported the following: `$ perl -v This is perl 5, version 24, subversion 1 (v5.24.1) built for x86_64-cygwin-threads-multi ` Will write detailed solution. Thanks! – femtobarn Sep 15 '17 at 20:22

2 Answers2

1

if.pm is part of the standard perl package

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

You should check if the package is correctly installed

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

and if not, as it seems, re-install it.

In addition, as you can see also inside setup.ini, on setup-arch.exe there are 3 available package versions and you should note mix them.

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

The current one is the 5.22.4-1 and 5.24.1-1 is a test version for the possible future usage. As you clearly don't need a test version, just use the current stable 5.22.4-1. Mixing up is not good for you...

matzeri
  • 8,062
  • 2
  • 15
  • 16
  • I wish I could find a command to reinstall a package. `cygwin-setup-x86_64.exe -q -P perl-5.22.4-1` doesn't do anything if the package is already installed. – ikegami Sep 15 '17 at 20:25
  • When I installed `perl_base`, the problem went away. Full details provided in my answer. Thanks! – femtobarn Sep 15 '17 at 20:37
  • @femtoban, No, it's when you reinstalled `perl` ("Perl then upgraded to v5.24.1") like matzeri suggested. – ikegami Sep 15 '17 at 20:38
-1

SOLUTION: Wrong version of perl package was installed.

Problem was caused by not selecting perl_base package.

Indicating Symptom:

$ perl -v

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

Problem solved by manually selecting perl_base package. Perl then upgraded to v5.24.1 and included if.pm module in @INC:

enter image description here

Indication of Solution: $ perl -v

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

After installation of perl_base package, the Configure script completed without Can't locate if.pm in @INC errors.

femtobarn
  • 19
  • 2
  • No, it's the reinstallation of the `perl` package ("Perl then upgraded to v5.24.1") that fixed it, like matzeri answered. You just used a convoluted approach to doing so. – ikegami Sep 15 '17 at 20:37
  • I'm not sure if simply selecting the newer version of the `perl` package would have resolved the issue. It appears that a version of `perl` that did not have a correpsonding `perl_base` package was installed. After manually selecting `perl_base`, the newer `perl` was automatically selected, and the issue was resolved. Seems pedantic, but others who run into the same issue may be confused if upgrading `perl` alone does not solve their issue. – femtobarn Sep 15 '17 at 20:42
  • Re "*I'm not sure if simply selecting the newer version of the perl package would have resolved the issue.*", You have it completely backwards. `perl_base` has nothing to do with this. The missing file (`if.pm`) is provided by `perl`, not `perl_base`. So of course reinstalling/upgrading `perl` will solve your problem. – ikegami Sep 15 '17 at 20:51