I'm trying to install Net::SSLeay.

It is failing to test correctly and I've traced the problem to the following.

sub AUTOLOAD { # This AUTOLOAD is used to 'autoload' constants from the constant( +) # XS function. If a constant is not found then control is passed # to the AUTOLOAD in AutoLoader. my $constname; ($constname = $AUTOLOAD) =~ s/.*:://; my $val = constant($constname); if ($! != 0) { if ($! =~ /((Invalid)|(not valid))/i || $!{EINVAL}) { $AutoLoader::AUTOLOAD = $AUTOLOAD; goto &AutoLoader::AUTOLOAD; } else { croak "Your vendor has not defined SSLeay macro $constname"; } } eval "sub $AUTOLOAD { $val }"; goto &$AUTOLOAD; }
Where constant is defined in C as
static double constant(char* name) { errno = 0; switch (*name) { case 'A': if (strEQ(name, "AT_MD5_WITH_RSA_ENCRYPTION")) #ifdef SSL_AT_MD5_WITH_RSA_ENCRYPTION return SSL_AT_MD5_WITH_RSA_ENCRYPTION; #else goto not_there; #endif break; /* Snip similar for B..Z */ case '_': if (strEQ(name, "_TEST_INVALID_CONSTANT")) goto not_there; } errno = EINVAL; return 0; not_there: errno = ENOENT; return 0; }

The problem is that setting errno within the XS code is not propagated to the Perl $! variable.

The build process does keep warning me...

*** Be sure to use the same compiler and options to compile your OpenSSL, perl, and Net::SSLeay. Mixing and matching compilers is not supported.

I guess I shouldn't have ignored that warning. Or rather I shouldn't have thought it meant I should mix GCC v Microsoft v Intel compilers.

My Perl build is a binary from ActiveState, v5.8.8 MSWin32-x86-multi-thread build 820. This was built using the Microsoft compiler. My compiler is Microsoft 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86. I'm guessing these are sufficiently "different" that the errno symbol ends up bound to different variables in auto/Net/SSLeay.dll from it is in perl58.dll. My OpenSSL is a binary download from somewhere.

I've noticed that a lot of people (not just Perl users) seem to use Windows, and many of them download programs/libraries as compiled binaries rather than source. (Indeed I've even noticed that Windows doesn't install the C compiler be default). So how do people get away with such reckless behaviour if Microsoft's compilers are so grossly incompatible between versions?

I've hacked the code of Net::SSLeay so that it doesn't attempt to pass information from the XS code to the Perl via errno and if I get it working I may submit a patch but I can't help wondering if I'm doing the wrong thing.


In reply to errno in XS not propagating to $! - breaks Net::SSLeay by nobull

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.