Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gcc on IRIX64 breaks inet_ntoa #4479

Open
p5pRT opened this issue Oct 4, 2001 · 2 comments
Open

gcc on IRIX64 breaks inet_ntoa #4479

p5pRT opened this issue Oct 4, 2001 · 2 comments

Comments

@p5pRT
Copy link

p5pRT commented Oct 4, 2001

Migrated from rt.perl.org#7790 (status was 'open')

Searchable as RT7790$

@p5pRT
Copy link
Author

p5pRT commented Oct 4, 2001

From starksb@ebi.ac.uk

Greetings,

I install/maintain perl on Linux, Solaris, Tru64 and IRIX at our site.

It's rather well known that gcc on IRIX64 has problems passing small
structures properly. There is a good description of the problem at
<http​://groups.google.com/groups?oi=djq&selm=an_586981842>.

There is already a something in hints/irix_6.sh for this​:

# Check for which compiler we're using

case "$cc" in
...
*gcc*)
...
case "`uname -s`" in
# Without the -mabi=64 gcc in 64-bit IRIX has problems passing
# and returning small structures. This affects inet_*() and semctl().
# See http​://reality.sgi.com/ariel/freeware/gcc-2.8.1-notes.html
# for more information. Reported by Lionel Cons <lionel.cons@​cern.ch>.
IRIX64) ccflags="$ccflags -mabi=64"
ldflags="$ldflags -mabi=64 -L/usr/lib64"
lddlflags="$lddlflags -mabi=64"
;;
*) ccflags="$ccflags -DIRIX32_SEMUN_BROKEN_BY_GCC"
;;
esac
;;

Perhaps that works if you've built gcc with mabi=64 support. We have
not, so the above hint breaks our build. We can only apply the
hint -DIRIX32_SEMUN_BROKEN_BY_GCC. This presumably solves the problem
with semctl in perl.h​:

# ifdef USE_SEMCTL_SEMUN
# ifdef IRIX32_SEMUN_BROKEN_BY_GCC
union gccbug_semun {
int val;
struct semid_ds *buf;
unsigned short *array;
char __dummy[5];
};
# define semun gccbug_semun
# endif
# define Semctl(id, num, cmd, semun) semctl(id, num, cmd, semun)

But that leaves us with a broken inet_ntoa, reflected by failing tests
3 and 4 in lib/io_multihomed.t.

The fix is very simple, just "roll your own" inet_ntoa, as described
by Stuart Levy in the above-referenced comp.sys.sgi.admin article.
Here's the patch I've used​:

===========================================================================

Inline Patch
--- ext/Socket/Socket.xs.orig   Sun Apr  8 07:09:16 2001
+++ ext/Socket/Socket.xs        Thu Oct  4 14:06:12 2001
@@ -166,6 +166,18 @@
 
 #endif /* ! HAS_INET_ATON */
 
+#if defined(sgi) && defined(__GNUC__)
+char *inet_ntoa(struct in_addr sa)
+{
+  static char addr[20];
+  sprintf(addr, "%d.%d.%d.%d",
+         ((unsigned char *)&sa.s_addr)[0],
+         ((unsigned char *)&sa.s_addr)[1],
+         ((unsigned char *)&sa.s_addr)[2],
+         ((unsigned char *)&sa.s_addr)[3]);
+  return addr;
+}
+#endif
 
 static int
 not_here(char *s)
===========================================================================

Could this be incorporated?

Please CC me on any followups, as I am not subscribed to any perl
mailing lists.

Thanks for your consideration.

Kind regards,
David

-------------------------------------------------------------------
  David Starks-Browning | starksb@​ebi.ac.uk
  EMBL Outstation -- |
  The European Bioinformatics Institute |
  Wellcome Trust Genome Campus | tel​: +44 (1223) 494 616
  Hinxton, Cambridge, CB10 1SD, UK | fax​: +44 (1223) 494 468
-------------------------------------------------------------------


Flags​:
  category=core
  severity=high


Site configuration information for perl v5.6.1​:

Configured by starksb at Thu Oct 4 14​:07​:08 BST 2001.

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration​:
  Platform​:
  osname=irix, osvers=6.5, archname=IP27-irix
  uname='irix64 talisker 6.5 10120104 ip27 '
  config_args='-de -Dprefix=/sw/common/test-patched -Dbin=/sw/arch/bin/test-patched -Dscriptdir=/sw/arch/bin/test-patched -Dprivlib=/sw/common/test-patched/share/perl/5.6.1 -Darchlib=/sw/common/test-patched/share/perl/5.6.1/mips-irix -Dsitebin=/sw/arch/bin/test-patched -Dsitescript=/sw/arch/bin/test-patched -Dsitelib=/sw/common/test-patched/share/perl/site-perl/5.6.1 -Dsitearch=/sw/common/test-patched/share/perl/site-perl/5.6.1/mips-irix -Dinstallusrbinperl=no -Dperlpath=/sw/arch/bin/test-patched/perl5.6.1 -Dstartperl=#!/sw/arch/bin/test-patched/perl5.6.1 -Dcc=gcc -Dld=gcc -Dcf_email=starksb@​ebi.ac.uk -Dloclibpth=/sw/arch/lib -Dlocincpth=/sw/common/include -Dldflags=-Wl,-rpath,/sw/arch/lib'
  hint=recommended, useposix=true, d_sigaction=define
  usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
  useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
  use64bitint=undef use64bitall=undef uselongdouble=undef
  Compiler​:
  cc='gcc', ccflags ='-D_BSD_TYPES -D_BSD_TIME -D_POSIX_C_SOURCE -DIRIX32_SEMUN_BROKEN_BY_GCC -fno-strict-aliasing -I/sw/common/include -DLANGUAGE_C',
  optimize='-O3',
  cppflags='-D_BSD_TYPES -D_BSD_TIME -D_POSIX_C_SOURCE -DIRIX32_SEMUN_BROKEN_BY_GCC -fno-strict-aliasing -I/sw/common/include -DLANGUAGE_C'
  ccversion='', gccversion='2.95.3 20010315 (release)', gccosandvers='irix6.5'
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
  alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries​:
  ld='gcc', ldflags ='-Wl,-rpath,/sw/arch/lib -Wl,-woff,84 -L/sw/arch/lib'
  libpth=/sw/arch/lib /usr/lib /usr/local/lib /lib
  libs=-lgdbm -ldb -lm -lc
  perllibs=-lm -lc
  libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
  cccdlflags='-fpic', lddlflags='-shared -L/sw/arch/lib'

Locally applied patches​:
 


@​INC for perl v5.6.1​:
  /sw/common/test-patched/share/perl/5.6.1/mips-irix
  /sw/common/test-patched/share/perl/5.6.1
  /sw/common/test-patched/share/perl/site-perl/5.6.1/mips-irix
  /sw/common/test-patched/share/perl/site-perl/5.6.1
  /sw/common/test-patched/share/perl/site-perl
  .


Environment for perl v5.6.1​:
  HOME=/homes/starksb
  LANG (unset)
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/sw/arch/corba/ORBit-0.5.7/bin​:/sw/arch/pkg/MySQL/3.22.32/bin​:/homes/starksb/bin​:/homes/starksb/bin/IRIX64​:/sw/arch/bin​:/usr/sbin​:/usr/bsd​:/sbin​:/usr/bin​:/bin​:/usr/bin/X11​:/usr/etc​:/usr/local/bin​:/sw/common/share/parallel/pvm3/lib​:/homes/starksb/pvm3/bin/SGI6​:/sw/common/share/parallel/pvm3/bin/SGI6​:/sw/arch/lib/parallel/LAM/bin​:/sw/arch/bin/EMBOSS
  PERL_BADLANG (unset)
  SHELL=/usr/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Oct 4, 2001

From @jhi

Okay, the -mabi=64 needs obviously be tested for existence.

+#if defined(sgi) && defined(__GNUC__)
+char *inet_ntoa(struct in_addr sa)

I think static char *my_inet_ntoa() + #define inet_ntoa my_inet_ntoa
would be better.

Isn't the rolling-your-own redundant *with* -mabi=64? In other words,
if one has -mabi=64, one doesn't *need* to roll-his-own? But, on the
other, hand, if one had -mabi=64, one *could* use the self-rolled?

I can see two options​:

#1 we add the roll-your-own (though a generalized a bit​:
  #ifdef NEED_OWN_INET_NTOA, and then IRIX hints define that)
  but also make the hints file to test whether -mabi=64 works
  and if it does, the NEED_OWN_INET_NTOA should be undef
#2 we add the roll-your-own (as in #1) but if the roll-your-own
  version works even with -mabi=64, we can drop the -mabi=64
  logic from the hints and just always use the self-rolled

Now, the problem with both of these options is that to test whether
our solution works, we need two gccs​: one built with -mabi=64 and one
without.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants