This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: HP-UX: Problem building socket
Type: Stage:
Components: Build Versions:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: nnorwitz Nosy List: gvanrossum, loewis, nnorwitz, nobody
Priority: normal Keywords:

Created on 2001-10-29 10:15 by anonymous, last changed 2022-04-10 16:04 by admin. This issue is now closed.

Messages (9)
msg7231 - (view) Author: Nobody/Anonymous (nobody) Date: 2001-10-29 10:15
On HP-UX 11, I get errors compiling Python 2.1.1 from
source.
It crashes when parsing sys/socket.h
Here's the offending code:
   extern sbsize_t sendfile __((int, int, off_t,
bsize_t, 
                               const struct iovec *,
int));
   extern sbsize_t sendpath __((int, char *, off_t,
bsize_t, 
                               const struct iovec *,
int));

When I switch from gcc to cc (native c compiler) the
socket
library compiles, but many other libs don't.
(sidenote: when using cc, cc is noteably faster than
gcc)
msg7232 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2001-10-29 12:59
Logged In: YES 
user_id=6380

Please try again with Python 2.2b1 (http://python.org/2.2/).
We've done a lot of work and we've got at least one report
that it now works out of the box on HP-UX 11.  I'd like to
hear if that solves your problems (and if 2.2b1 builds with
either compiler).
msg7233 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2001-10-30 08:56
Logged In: YES 
user_id=21627

It would be helpful if you would provide all details in a 
report also. When you say "it crashes", did you really 
mean "it crashes" (i.e. with a core dump, machine reboot, 
or the like)?
If the compiler merely rejected the code, it would be good 
to see what the error message was.

Please also report version numbers: HP-UX version, gcc 
version, etc. Are you sure you are using a gcc built for 
your OS version? If the gcc doesn't get prototypes right, 
this often comes from having fixincluded header files of a 
different OS version.
msg7234 - (view) Author: Nobody/Anonymous (nobody) Date: 2001-11-01 15:41
Logged In: NO 

gcc version is 2.95.3
HP-UX hp18 B.11.11 U 9000/785 2011589119
both Python 2.1.1 and 2.2b1 do not compile ootb here.

Error messages during compile are 

building '_socket' extension
gcc -g -O3 -Wall -Wstrict-prototypes -fPIC -I.
-I/utmnt/ut/si/dv0216/Python-2.2b1/./Include
-I/usr/local/include -IInclude/ -c
/utmnt/ut/si/dv0216/Python-2.2b1/Modules/socketmodule.c -o
build/temp.hp-ux-B.11.11-9000/785-2.2/socketmodule.o
In file included from
/utmnt/ut/si/dv0216/Python-2.2b1/Include/Python.h:42,
                 from
/utmnt/ut/si/dv0216/Python-2.2b1/Modules/socketmodule.c:77:
/opt/gcc/lib/gcc-lib/hppa2.0n-hp-hpux11.00/2.95.3/include/stdio.h:30:
warning: `__va__list' redefined
/usr/include/sys/stdsyms.h:422: warning: this is the
location of the previous definition
In file included from
/utmnt/ut/si/dv0216/Python-2.2b1/Include/Python.h:47,
                 from
/utmnt/ut/si/dv0216/Python-2.2b1/Modules/socketmodule.c:77:
/opt/gcc/lib/gcc-lib/hppa2.0n-hp-hpux11.00/2.95.3/include/string.h:26:
warning: `__va__list' redefined
/opt/gcc/lib/gcc-lib/hppa2.0n-hp-hpux11.00/2.95.3/include/stdio.h:30:
warning: this is the location of the previous definition
In file included from /usr/include/netdb.h:72,
                 from
/utmnt/ut/si/dv0216/Python-2.2b1/Modules/socketmodule.c:152:
/usr/include/sys/socket.h:439: parse error before `sendfile'
/usr/include/sys/socket.h:439: parse error before `bsize_t'
/usr/include/sys/socket.h:440: warning: data definition has
no type or storage class
/usr/include/sys/socket.h:441: parse error before `sendpath'
/usr/include/sys/socket.h:441: parse error before `bsize_t'
/usr/include/sys/socket.h:442: warning: data definition has
no type or storage class
/usr/include/sys/socket.h:456: parse error before
`__sendfile64'
/usr/include/sys/socket.h:456: parse error before `bsize_t'
/usr/include/sys/socket.h:456: warning: data definition has
no type or storage class
/usr/include/sys/socket.h:457: parse error before
`__sendpath64'
/usr/include/sys/socket.h:457: parse error before `bsize_t'
/usr/include/sys/socket.h:457: warning: data definition has
no type or storage class
/usr/include/sys/socket.h:459: parse error before `sendfile'
/usr/include/sys/socket.h:459: warning: function declaration
isn't a prototype
/usr/include/sys/socket.h: In function `sendfile':
/usr/include/sys/socket.h:459: parse error before `bsize_t'
/usr/include/sys/socket.h: At top level:
/usr/include/sys/socket.h:460: parse error before `sendpath'
/usr/include/sys/socket.h:460: warning: function declaration
isn't a prototype
/usr/include/sys/socket.h: In function `sendpath':
/usr/include/sys/socket.h:460: parse error before `bsize_t'
In file included from
/utmnt/ut/si/dv0216/Python-2.2b1/Modules/socketmodule.c:238:
/utmnt/ut/si/dv0216/Python-2.2b1/Modules/getaddrinfo.c: At
top level:
/utmnt/ut/si/dv0216/Python-2.2b1/Modules/getaddrinfo.c:203:
warning: function declaration isn't a prototype
/utmnt/ut/si/dv0216/Python-2.2b1/Modules/getaddrinfo.c:212:
warning: function declaration isn't a prototype
/utmnt/ut/si/dv0216/Python-2.2b1/Modules/getaddrinfo.c: In
function `freeaddrinfo':
/utmnt/ut/si/dv0216/Python-2.2b1/Modules/getaddrinfo.c:219:
warning: implicit declaration of function `free'
/utmnt/ut/si/dv0216/Python-2.2b1/Modules/getaddrinfo.c: In
function `str_isnumber':
/utmnt/ut/si/dv0216/Python-2.2b1/Modules/getaddrinfo.c:231:
warning: subscript has type `char'
/utmnt/ut/si/dv0216/Python-2.2b1/Modules/getaddrinfo.c: In
function `getaddrinfo':
/utmnt/ut/si/dv0216/Python-2.2b1/Modules/getaddrinfo.c:345:
warning: implicit declaration of function `atoi'
/utmnt/ut/si/dv0216/Python-2.2b1/Modules/getaddrinfo.c:396:
warning: implicit declaration of function `malloc'
WARNING: building of extension "_socket" failed: command
'gcc' failed with exit status 1

I now thought that since the errors happen in a system
header that compiles with
cc and not gcc, why not copy <sys/socket.h> to "socket.h"
and delete the two offending lines. 
However, as you see, <sys/socket.h> is still included (why
?).

Another option is using cc just for this library, but I'm
not sure, that the object files are compatible. Using cc
alone creates a lot of non-working modules, although it is
in (extended) ANSI mode.

I also tried the HP Porting centre (http://hpux.asknet.de)
but the Python 2.1 package there -just like mine- does crash
on importing socket (too with 2.2b1)

hp18: Python-2.2b1 % ./python
Python 2.2b1 (#4, Nov  1 2001, 16:36:54) [C] on hp-uxB
Type "help", "copyright", "credits" or "license" for more
information.
>>> import socket
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/utmnt/ut/si/dv0216/Python-2.2b1/Lib/socket.py",
line 41, in ?
    from _socket import *
ImportError: No module named _socket
>>> 
msg7235 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2001-11-01 16:57
Logged In: YES 
user_id=21627

gcc 2.95 does not support HP-UX 11; this appears to be an
instance of that problem. The __va__list problem is not at
all Python-specific; it occurs in many packages (just search
Google for "HP-UX __va__list"). With such problems, there is
no point into looking further into the problem; just drop
the compiler. If you want to port Python to HP-UX and gcc
2.95, you are on your own.

Notice that gcc 3.0.1 *does* support HP-UX 11; I recommend
to upgrade.
msg7236 - (view) Author: Nobody/Anonymous (nobody) Date: 2001-11-06 12:42
Logged In: NO 

gcc --version is now 3.0.1 

The problem however is still there:
building '_socket' extension
gcc -g -O2 -Wall -Wstrict-prototypes -fpic -I.
-I/utmnt/ut/si/dv0216/Python-2.1.1/./Include
-I/usr/local/include -IInclude/ -c
/utmnt/ut/si/dv0216/Python-2.1.1/Modules/socketmodule.c -o
build/temp.hp-ux-B.11.11-9000/785-2.1/socketmodule.o
In file included from /usr/include/netdb.h:72,
                 from
/utmnt/ut/si/dv0216/Python-2.1.1/Modules/socketmodule.c:145:
/usr/include/sys/socket.h:439: parse error before "sendfile"
/usr/include/sys/socket.h:439: parse error before "bsize_t"
/usr/include/sys/socket.h:441: parse error before "sendpath"
/usr/include/sys/socket.h:441: parse error before "bsize_t"
/utmnt/ut/si/dv0216/Python-2.1.1/Modules/socketmodule.c: In
function `PySocketSock_accept':
/utmnt/ut/si/dv0216/Python-2.1.1/Modules/socketmodule.c:795:
warning: passing arg 3 of `accept' from incompatible pointer
type
/utmnt/ut/si/dv0216/Python-2.1.1/Modules/socketmodule.c: In
function `PySocketSock_getsockopt':
/utmnt/ut/si/dv0216/Python-2.1.1/Modules/socketmodule.c:978:
warning: passing arg 5 of `getsockopt' from incompatible
pointer type
/utmnt/ut/si/dv0216/Python-2.1.1/Modules/socketmodule.c:992:
warning: passing arg 5 of `getsockopt' from incompatible
pointer type
/utmnt/ut/si/dv0216/Python-2.1.1/Modules/socketmodule.c: In
function `PySocketSock_getsockname':
/utmnt/ut/si/dv0216/Python-2.1.1/Modules/socketmodule.c:1188:
warning: passing arg 3 of `getsockname' from incompatible
pointer type
/utmnt/ut/si/dv0216/Python-2.1.1/Modules/socketmodule.c: In
function `PySocketSock_getpeername':
/utmnt/ut/si/dv0216/Python-2.1.1/Modules/socketmodule.c:1218:
warning: passing arg 3 of `getpeername' from incompatible
pointer type
/utmnt/ut/si/dv0216/Python-2.1.1/Modules/socketmodule.c: In
function `PySocketSock_recvfrom':
/utmnt/ut/si/dv0216/Python-2.1.1/Modules/socketmodule.c:1376:
warning: passing arg 6 of `recvfrom' from incompatible
pointer type
WARNING: building of extension "_socket" failed: command
'gcc' failed with exit status 1

Here are the offending lines from socket.h
   extern sbsize_t sendfile __((int, int, off_t, bsize_t, 
                               const struct iovec *, int));
   extern sbsize_t sendpath __((int, char *, off_t, bsize_t, 
                               const struct iovec *, int));

However, my medium c skills tell me that the lines are ok.
I cannot offer an explanation why gcc fails here.
msg7237 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2001-11-06 19:12
Logged In: YES 
user_id=21627

The likely cause is that sbsize_t is not defined. Please try
to find out what header file of HP-UX defines sbsize_t, and
under what conditions?

Outright including that header file probably is the wrong
solution, so please also find out where it is included from,
tracking it eventually back to socket.h. It appears that a
certain #define is missing to cause a proper definition of
sbsize_t. We must find out what that define is, and why it
is not set when compiling with gcc.

Also, could you please identify yourself?
msg7238 - (view) Author: Nobody/Anonymous (nobody) Date: 2001-11-12 08:51
Logged In: NO 

'sbsize_t' is an HPUX11i issue - possible solution see below.
I can't test it, I have only 11 without 'i'.

More important is the fact, that Python uses UNIX style
sockets as far as i understand. HPUX offers two types of
sockets: BSD-style via libc and UNIX style via libxnet.
The HPUX11 python build is linked against libxti (not xnet) 
via libnsl.
Compilation of socketmodule.c  HAS TO BE DONE with 
_XOPEN_SOURCE_EXTENDED defined - see below.
With this one gets rid of a lot of compiler warnings
with socketmodule.c

However, my poor C skills don't tell me if  -lxnet should be added 
additionally at link time or not.

Carl  cmkleffner.gmx.de

 --------------

The following article on devresource is a must for all HPUX porters:

  http://devresource.hp.com/STKL/inhibitors.html
  'Linux porting inhibitors'

>   socket flavors
> 
> HP-UX supports two types of sockets - BSD 4.2 style sockets in libc and UNIX95/98
> style sockets in libxnet. Linux's socket is a UNIX98 style socket, so the path of least
> resistance would be to use the UNIX95/98 style socket in HP-UX. However, since
> socklen_t in Linux is typedef to int while socklen_t in HP-UX is typedef to size_t, some
> additional reconciliation may still be needed. Note, socklen_t is used in places where
> "len" objects are defined. An example of its use is shown below.
> 
> To use UNIX95/98 style sockets in HP-UX, the libxnet library needs to be added to the
> link line. Also, the macro, _XOPEN_SOURCE, needs to be defined, and the macro,
> _XOPEN_SOURCE_EXTENDED, needs to be defined as 1. Refer to HP-UX manpage,
> xopen_networking(7) for further details.


http://gcc.gnu.org/ml/gcc-prs/2001-07/msg00527.html

 . . . . .
> HPUX 11i is quite different from HPUX 11 because many of the 
> header files have been changed and new types are used such as 
> sbsize_t and bsize_t.

http://gcc.gnu.org/ml/gcc-bugs/2001-09/msg00139.html

> To: hpux at connect dot org dot uk, gcc-bugs at gcc dot gnu dot org 
> Subject: GCC 3.0.1 on HP-UX 11i 
> From: Remi COLLET <root at iut-info dot ens dot univ-reims dot fr> 
> Date: Wed, 05 Sep 2001 17:40:33 +0200 
> Organization: IUT de Reims - Departement Informatique 
> 
 . . . . .
> 3) non ANSI declaration of sendfile and sendpath (C++) in socket.h
> 
> Copy socket.h in
> /opt/gcc/lib/gcc-lib/hppa2.0n-hp-hpux11.00/3.0.1/include/sys
> 
> Replace (line 470)
> 
> > inline sbsize_t sendfile(a,b,c,d,e,f) int a,b,f; off_t c; bsize_t d; const struct iovec * e; { return 
__sendfile64(a,b,c,d,e,f); }
> > inline sbsize_t sendpath(a,b,c,d,e,f) int a,f; char *b; off_t c; bsize_t d; const struct iovec * e; { 
return __sendpath64(a,b,c,d,e,f); }
> >
> >
> With:
> 
> > inline sbsize_t sendfile(int a,int b,off_t c,bsize_t d,const struct iovec *e,int f)
> >  { return __sendfile64(a,b,c,d,e,f); }
> > inline sbsize_t sendpath(int a,char *b,off_t c,bsize_t d,const struct iovec *e,int f)
> >  { return __sendpath64(a,b,c,d,e,f); }
> >
> >
> Then, all works fine !

msg7239 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-11-03 02:28
Logged In: YES 
user_id=33168

Since 2.2.2 and 2.3 both build (and test successfully) on
HP-UX 11, I'm closing this bug.  Carl, if you still have a
problem re-open this bug report or open a new one.
History
Date User Action Args
2022-04-10 16:04:35adminsetgithub: 35420
2001-10-29 10:15:51anonymouscreate