Skip Menu |
 

This queue is for tickets about the Socket CPAN distribution.

Report information
The Basics
Id: 85007
Status: resolved
Priority: 0/
Queue: Socket

People
Owner: Nobody in particular
Requestors: GAAS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 2.009
Fixed in: 2.010

Attachments
0001-The-Sun-C-compiler-optimizes-void-p-inet_aton-void-p.patch



Subject: Socket-2.009's Makefile.PL doesn't discover that inet_aton isn't available on Solaris
Our Solaris builds of Socket-2.009 create a module that fails like this:
$ perl -MSocket=inet_aton -e 'inet_aton("localhost")'
ld.so.1: perl-static: fatal: relocation error: file /tmp/perl/lib/auto/Socket/Socket.so: symbol inet_aton: referenced symbol not found
Solaris provide inet_aton() in libresolv.so, but that library isn't linked by perl by default.

I tracked the problem to the Sun C compiler optimizing "void *p = &inet_aton; (void)p;" in the test program away.  This means that this program compiles and links even if the inet_aton symbol isn't provided.  I attached a patch that fixes the problem.
Subject: 0001-The-Sun-C-compiler-optimizes-void-p-inet_aton-void-p.patch
From 5906e1c72d74539ccdf352cf068bfd50969ce09c Mon Sep 17 00:00:00 2001 From: Gisle Aas <gisle@activestate.com> Date: Thu, 2 May 2013 15:12:23 -0700 Subject: [PATCH] The Sun C compiler optimizes "void *p = &inet_aton; (void)p;" away. Which means that this program compiles and links even if the inet_aton symbol isn't provided. --- Makefile.PL | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index 117d778..f2dfb26 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -30,6 +30,7 @@ sub check_for { open( my $file_source_fh, ">", $file_source ) or die "Cannot write $file_source - $!"; print $file_source_fh <<"EOF"; +#include <stdio.h> #include <sys/types.h> #ifdef WIN32 # include <ws2tcpip.h> @@ -70,7 +71,7 @@ sub check_for_func { my %args = @_; my $func = delete $args{func}; - check_for( %args, main => "void *p = &$func; (void)p;" ); + check_for( %args, main => qq(void *p = &$func; printf("%p", p);) ); } my %defines = ( -- 1.7.0.5
Download (untitled) / with headers
text/plain 1.1k
On Thu May 02 18:35:04 2013, GAAS wrote: Show quoted text
> Our Solaris builds of Socket-2.009 create a module that fails like > this: > > $ perl -MSocket=inet_aton -e 'inet_aton("localhost")' > ld.so.1: perl-static: fatal: relocation error: file > /tmp/perl/lib/auto/Socket/Socket.so: symbol inet_aton: referenced > symbol not found > > Solaris provide inet_aton() in libresolv.so, but that library isn't > linked by > perl by default. > > I tracked the problem to the Sun C compiler optimizing "void *p = > &inet_aton; > (void)p;" in the test program away. This means that this program > compiles and > links even if the inet_aton symbol isn't provided. I attached a patch > that > fixes the problem.
Wow. That's an interesting failure case. I've decided to solve this slightly simpler; by testing if the function pointer is NULL and 'return 1'ing if so: - check_for( %args, main => "void *p = &$func; (void)p;" ); + check_for( %args, main => "void *p = &$func; if(p == NULL) return 1;" ); Hopefully Solaris won't optimise that one away, and has the additional advantages that it doesn't spam up the output, and also returns false if the function should happen to have a defined name that points nowhere. -- Paul Evans
This was released in 2.010 -- Paul Evans


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.