This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Add -D__PRAGMA_REDEFINE_EXTNAME to Solaris compiler flags


Hi,

PR 5440 on Solaris is quite serious, and makes it very
difficult to work with any code on Solaris that
includes <sys/socket.h>:

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?database=gcc&pr=5440&cmd=view

The problem occurs because for some reason, on Solaris, when
_XOPEN_SOURCE=500 is defined, then the following macros
are defined:

#define bind __xnet_bind
#define connect __xnet_connect

This causes problems for any code which uses sockets,
and prevents compilation of KDE on Solaris with gcc 3.x.

In PR 5798, Markus Breuer found a solution to the problem:

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?database=gcc&pr=5798&cmd=view

===================================================================
* From: "Breuer, Markus" <markus dot breuer at materna dot de>
* Date: Mon, 4 Mar 2002 09:16:57 +0100
* Subject: AW: c/5798: problem with sys/socket.h

Hello,

i followed the thread within the refrenced link. The thread ended with no
real solution or alternative.
Possibly i found out a solution for the problem. The code within
sys/socket.h looks like following:

--- snipp ---
#ifdef  _XPG4_2
#ifdef  __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname bind __xnet_bind
[...]
#else   /* __PRAGMA_REDEFINE_EXTNAME */
#define bind    __xnet_bind
[...]
#endif  /* __PRAGMA_REDEFINE_EXTNAME */
--- snipp ---

When defining -D_XOPEN_SOURCE=500 only, the compiler uses the else branch of
the if-def directive. This uses the preprocessor for replacement. But when
-D__PRAGMA_REDEFINE_EXTNAME is additionally defined, the compiler uses the
#pragma directive. It acts after compiling, when the symbol names are
generated. It replaces the symbolname.

Is there any reason to avoid this workaround? My (sample) application work's
fine when using it.

regards, Markus
===================================================================

I proposed the following patch to Markus, which he successfully
used to bootstrap gcc on Solaris.

I would like to recommend that we apply this patch,
since it is a serious issue for Solaris users of gcc.

Is the following OK for mainline and branch?


2002-03-14  Craig Rodrigues  <rodrigc@gcc.gnu.org>

	PR c++/5440
	* config/sparc/sol2.h: Add -D__PRAGMA_REDEFINE_EXTNAME
	to eliminate macro expansion problems when including
	<sys/socket.h> on Solaris.

Index: sol2.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sol2.h,v
retrieving revision 1.36
diff -u -r1.36 sol2.h
--- sol2.h	2002/02/22 18:43:54	1.36
+++ sol2.h	2002/03/15 03:57:53
@@ -47,7 +47,7 @@
    by the C++ standard library.  */
 #define CPLUSPLUS_CPP_SPEC "\
 -D_XOPEN_SOURCE=500 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 \
--D__EXTENSIONS__ \
+-D__EXTENSIONS__ -D__PRAGMA_REDEFINE_EXTNAME \
 %(cpp) \
 "
 

-- 
Craig Rodrigues        
http://www.gis.net/~craigr    
rodrigc@attbi.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]