Opened 8 years ago

Closed 7 years ago

#51708 closed defect (fixed)

libassuan @2.4.2 does not build on PPC Tiger, Mac OS X 10.4.11 because of macro INADDR_LOOPBACK inside #ifndef _POSIX_C_SOURCE

Reported by: ballapete (Peter "Pete" Dyballa) Owned by: larryv (Lawrence Velázquez)
Priority: Normal Milestone:
Component: ports Version: 2.3.4
Keywords: powerpc tiger Cc:
Port: libassuan

Description

This is the error:

:info:build /bin/sh ../libtool  --tag=CC   --mode=compile /opt/local/bin/gcc-apple-4.2 -DHAVE_CONFIG_H -I. -I..  -I.. -I/opt/local/include -I/opt/local/include  -pipe -Os -arch ppc -Wall -Wcast-align -Wshadow -Wstrict-prototypes -Wpointer-arith -MT libassuan_la-assuan-socket.lo -MD -MP -MF .deps/libassuan_la-assuan-socket.Tpo -c -o libassuan_la-assuan-socket.lo `test -f 'assuan-socket.c' || echo './'`assuan-socket.c
:info:build libtool: compile:  /opt/local/bin/gcc-apple-4.2 -DHAVE_CONFIG_H -I. -I.. -I.. -I/opt/local/include -I/opt/local/include -pipe -Os -arch ppc -Wall -Wcast-align -Wshadow -Wstrict-prototypes -Wpointer-arith -MT libassuan_la-assuan-socket.lo -MD -MP -MF .deps/libassuan_la-assuan-socket.Tpo -c assuan-socket.c  -fno-common -DPIC -o .libs/libassuan_la-assuan-socket.o
:info:build assuan-socket.c: In function 'socks5_connect':
:info:build assuan-socket.c:732: error: 'INADDR_LOOPBACK' undeclared (first use in this function)
:info:build assuan-socket.c:732: error: (Each undeclared identifier is reported only once
:info:build assuan-socket.c:732: error: for each function it appears in.)
:info:build make[3]: *** [libassuan_la-assuan-socket.lo] Error 1
:info:build make[3]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_lil.fr.rsync.macports.org_release_tarballs_ports_devel_libassuan/libassuan/work/libassuan-2.4.2/src'

When the source file is compiled these C header files are included:

. ../config.h
. /usr/include/stdio.h
.. /usr/include/_types.h
... /usr/include/sys/_types.h
.... /usr/include/sys/cdefs.h
.... /usr/include/machine/_types.h
..... /usr/include/ppc/_types.h
. /usr/include/stdlib.h
.. /usr/include/sys/wait.h
... /usr/include/sys/signal.h
.... /usr/include/sys/appleapiopts.h
.... /usr/include/machine/signal.h
..... /usr/include/ppc/signal.h
... /usr/include/sys/resource.h
. /usr/include/sys/types.h
.. /usr/include/machine/types.h
... /usr/include/ppc/types.h
.... /usr/include/ppc/_types.h
.. /usr/include/machine/endian.h
... /usr/include/ppc/endian.h
. /usr/include/sys/socket.h
.. /usr/include/machine/param.h
... /usr/include/ppc/param.h
. /usr/include/netinet/in.h
.. /usr/include/sys/_endian.h
... /opt/local/lib/apple-gcc42/gcc/powerpc-apple-darwin8/4.2.4/include/stdint.h
... /usr/include/libkern/OSByteOrder.h
.... /usr/include/libkern/ppc/OSByteOrder.h
.. /usr/include/netinet6/in6.h
. /usr/include/arpa/inet.h
.. /usr/include/sys/param.h
... /usr/include/sys/syslimits.h
... /opt/local/lib/apple-gcc42/gcc/powerpc-apple-darwin8/4.2.4/include/limits.h
.... /opt/local/lib/apple-gcc42/gcc/powerpc-apple-darwin8/4.2.4/include/syslimits.h
.... /usr/include/limits.h
..... /usr/include/machine/limits.h
...... /usr/include/ppc/limits.h
....... /usr/include/ppc/_limits.h
. /usr/include/errno.h
.. /usr/include/sys/errno.h
. /usr/include/sys/stat.h
. /usr/include/fcntl.h
.. /usr/include/sys/fcntl.h
. /usr/include/assert.h
. assuan-defs.h
.. /usr/include/sys/un.h
.. /usr/include/unistd.h
... /usr/include/sys/unistd.h
.. assuan.h
... /opt/local/lib/apple-gcc42/gcc/powerpc-apple-darwin8/4.2.4/include/stdarg.h
... /opt/local/include/gpg-error.h
.... /opt/local/lib/apple-gcc42/gcc/powerpc-apple-darwin8/4.2.4/include/stddef.h
. debug.h
.. /usr/include/string.h
.. /usr/include/inttypes.h

so /usr/include/netinet/in.h is included, but INADDR_LOOPBACK is excluded because of undefined guard _POSIX_C_SOURCE:

  309	#ifndef _POSIX_C_SOURCE
  310	#define	IN_CLASSA(i)		(((u_int32_t)(i) & 0x80000000) == 0)
  311	#define	IN_CLASSA_NET		0xff000000
  312	#define	IN_CLASSA_NSHIFT	24
  313	#define	IN_CLASSA_HOST		0x00ffffff
  314	#define	IN_CLASSA_MAX		128
  315	
  316	#define	IN_CLASSB(i)		(((u_int32_t)(i) & 0xc0000000) == 0x80000000)
  317	#define	IN_CLASSB_NET		0xffff0000
  318	#define	IN_CLASSB_NSHIFT	16
  319	#define	IN_CLASSB_HOST		0x0000ffff
  320	#define	IN_CLASSB_MAX		65536
  321	
  322	#define	IN_CLASSC(i)		(((u_int32_t)(i) & 0xe0000000) == 0xc0000000)
  323	#define	IN_CLASSC_NET		0xffffff00
  324	#define	IN_CLASSC_NSHIFT	8
  325	#define	IN_CLASSC_HOST		0x000000ff
  326	
  327	#define	IN_CLASSD(i)		(((u_int32_t)(i) & 0xf0000000) == 0xe0000000)
  328	#define	IN_CLASSD_NET		0xf0000000	/* These ones aren't really */
  329	#define	IN_CLASSD_NSHIFT	28		/* net and host fields, but */
  330	#define	IN_CLASSD_HOST		0x0fffffff	/* routing needn't know.    */
  331	#define	IN_MULTICAST(i)		IN_CLASSD(i)
  332	
  333	#define	IN_EXPERIMENTAL(i)	(((u_int32_t)(i) & 0xf0000000) == 0xf0000000)
  334	#define	IN_BADCLASS(i)		(((u_int32_t)(i) & 0xf0000000) == 0xf0000000)
  335	
  336	#define	INADDR_LOOPBACK		(u_int32_t)0x7f000001
  337	#define	INADDR_NONE		0xffffffff		/* -1 return */
  338	
  339	#define	INADDR_UNSPEC_GROUP	(u_int32_t)0xe0000000	/* 224.0.0.0 */
  340	#define	INADDR_ALLHOSTS_GROUP	(u_int32_t)0xe0000001	/* 224.0.0.1 */
  341	#define	INADDR_ALLRTRS_GROUP	(u_int32_t)0xe0000002	/* 224.0.0.2 */
  342	#define	INADDR_MAX_LOCAL_GROUP	(u_int32_t)0xe00000ff	/* 224.0.0.255 */
  343	
  344	#ifdef __APPLE__
  345	#define IN_LINKLOCALNETNUM	(u_int32_t)0xA9FE0000 /* 169.254.0.0 */
  346	#define IN_LINKLOCAL(i)		(((u_int32_t)(i) & IN_CLASSB_NET) == IN_LINKLOCALNETNUM)
  347	#endif
  348	
  349	#define	IN_LOOPBACKNET		127			/* official! */
  350	#endif	/* !_POSIX_C_SOURCE */

Attachments (3)

main.log (40.8 KB) - added by ballapete (Peter "Pete" Dyballa) 8 years ago.
libassuan-portfile-tiger-fix.diff (551 bytes) - added by kenneth.f.cunningham@… 8 years ago.
portfile diff to allow patch on tiger
tiger-posix-in-h-fix.diff (329 bytes) - added by kenneth.f.cunningham@… 8 years ago.
patch to allow non-POSIX in.h extensions to load

Download all attachments as: .zip

Change History (18)

Changed 8 years ago by ballapete (Peter "Pete" Dyballa)

Attachment: main.log added

comment:1 Changed 8 years ago by mf2k (Frank Schima)

Keywords: powerpc tiger added

comment:2 Changed 8 years ago by kenneth.f.cunningham@…

Hi,

I made this work a few months back by adding the definition directly to assuan-socket.c -- it all compiled after that, and the port that requested it (which I don't recall just now) seems to work OK. Not a proper fix, but it got things moving.

/* assuan-socket.c - Socket wrapper
   Copyright (C) 2004, 2005, 2009 Free Software Foundation, Inc.
   Copyright (C) 2001-2015 g10 Code GmbH

   This file is part of Assuan.

 */
 
 //Kenhack
 #define	INADDR_LOOPBACK		(u_int32_t)0x7f000001

Last edited 8 years ago by kenneth.f.cunningham@… (previous) (diff)

comment:3 Changed 8 years ago by rickyzhang82 (Ricky Zhang)

In 10.11, condition is little bit different from in.h in tiger:

313 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)

I changed tiger in.h and report to upstream libassuan about this.

Last edited 8 years ago by rickyzhang82 (Ricky Zhang) (previous) (diff)

comment:4 Changed 8 years ago by larryv (Lawrence Velázquez)

Owner: changed from macports-tickets@… to larryv@…
Status: newassigned

Please report all these issues to upstream. Given that this is a critical component of GnuPG, I will not be hotfixing the port. Feel free to Cc me on any upstream bugs.

comment:5 Changed 8 years ago by kenneth.f.cunningham@…

Editing <netinet/in.h> is an interesting idea I hadn't considered before, but it is admittedly tempting... blasphemy to edit the system SDK of course, and all manner of unpredictably bad things might happen. However, updating the header files in Tiger to the version that includes _DARWIN_C_SOURCE in the guards would fix some ports broken on Tiger, including libassuan.

And indeed, changing that one line in <netinet/in.h> from this

  309	#ifndef _POSIX_C_SOURCE

to this

  309	#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)

allows libassuan to build. and would seem to me to be likely to be irrelevant to the Tiger SDK, looking at how the guard works, and thinking about all the darwin systems that followed it that use that guard.

The only other visible option, of somehow undefining _POSIX_C_SOURCE to make the guard succeed, sounds like it would cause a lot more trouble and may not even be possible... And otherwise you're into piecemealing in the missing #defines like I did previously.

I'm very tempted at the moment to (backup the /usr/include directory, of course) and then do a global search and replace on the whole Tiger /usr/include/* directory for that line and then see what then works and what breaks -- if anything breaks...I would hazard a bet that nothing breaks, although it would all be untested territory, to be sure -- although I can't help but think that someone must have thought to do this before.

Changed 8 years ago by kenneth.f.cunningham@…

portfile diff to allow patch on tiger

Changed 8 years ago by kenneth.f.cunningham@…

Attachment: tiger-posix-in-h-fix.diff added

patch to allow non-POSIX in.h extensions to load

comment:6 Changed 8 years ago by kenneth.f.cunningham@…

Larry - I know you said you wouldn't be hot fixing this. INADDR_LOOPBACK was not standard POSIX_C in 2004 and so it was guarded in the Tiger block. The DARWIN_C_SOURCE override did not exist in Tiger. I don't know how upstream would fix this, so in case you ever change your mind about the hot fix for Darwin 8, here's the port file diff and the small source diff to allow it to build.

comment:7 Changed 8 years ago by JR1994

I am also seeing this issue in Tiger and can verify the patch worked to get libassuan installed.

comment:8 Changed 8 years ago by ballapete (Peter "Pete" Dyballa)

This patch allows the build of libassuan, for me too.

comment:9 Changed 8 years ago by ballapete (Peter "Pete" Dyballa)

libassuan @2.4.3 is out and installed, so this ticket can be closed as being fixed.

comment:10 Changed 8 years ago by kencu (Ken)

I think it's not fixed in the original source -- I suspect you're using my patch still. It's still manually applied, as it has not been accepted into macports. Perhaps it can be sent upstream as a patch to be added to assuan-socket.c, something like this, maybe:

//fix missing define in MacOSX 10.4 Tiger
#ifndef INADDR_LOOPBACK
  #define INADDR_LOOPBACK (u_int32_t)0x7f000001
#endif

perhaps they might be receptive.

Last edited 8 years ago by kencu (Ken) (previous) (diff)

comment:11 Changed 8 years ago by ballapete (Peter "Pete" Dyballa)

The bug report already exists at GnuPG: https://bugs.gnupg.org/gnupg/issue2447

comment:12 in reply to:  11 Changed 8 years ago by ballapete (Peter "Pete" Dyballa)

Replying to ballapete:

The bug report already exists at GnuPG: https://bugs.gnupg.org/gnupg/issue2447

I could enhance that bug report a bit…

comment:13 Changed 7 years ago by ballapete (Peter "Pete" Dyballa)

libassuan @2.4.3_2 still fails to build on Tiger PPC, Mac OS X 10.4.11.

The is reported to being fixed in 2.4.4.

comment:14 Changed 7 years ago by kencu (Ken)

well done, Pete -- this has been a PITA for a long time -- glad to see they listened to your suggestion and got it implemented!

comment:15 Changed 7 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: fixed
Status: assignedclosed

In 588871b6cc3fdc133781cc034419dc6bd7edde7b/macports-ports:

libassuan: Fix build on Tiger using upstream fix

Closes: #51708

Note: See TracTickets for help on using tickets.