Bug 15174 - libmudflap doesn't compile on Tru64 UNIX
Summary: libmudflap doesn't compile on Tru64 UNIX
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: libmudflap (show other bugs)
Version: tree-ssa
: P3 normal
Target Milestone: ---
Assignee: Frank Ch. Eigler
URL:
Keywords: build
Depends on:
Blocks: 16454
  Show dependency treegraph
 
Reported: 2004-04-27 19:00 UTC by Rainer Orth
Modified: 2011-07-19 11:23 UTC (History)
2 users (show)

See Also:
Host: alpha-dec-osf4.0f
Target: alpha-dec-osf4.0f
Build: alpha-dec-osf4.0f
Known to work:
Known to fail:
Last reconfirmed: 2005-07-12 21:50:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rainer Orth 2004-04-27 19:00:20 UTC
Even after the fix for c/14589

     http://gcc.gnu.org/ml/gcc-patches/2004-04/msg01046.html

a tree-ssa bootstrap on alpha-dec-osf4.0f fails in libmudflap:

$ /vol/gcc/obj/gcc-3.5-tree-ssa-20040416/4.0f-gcc/gcc/xgcc -B/vol/gcc/obj/gcc-3.5-tree-ssa-20040416/4.0f-gcc/gcc/ -B/vol/gcc/share/alpha-dec-osf4.0f/bin/ -B/vol/gcc/share/alpha-dec-osf4.0f/lib/ -isystem /vol/gcc/share/alpha-dec-osf4.0f/include -isystem /vol/gcc/share/alpha-dec-osf4.0f/sys-include -DHAVE_CONFIG_H -I. -I/vol/gnu/src/gcc/gcc-tree-ssa-dist/libmudflap -I. -O2 -g -O2 -mieee -Wall -O2 -g -O2 -mieee -Wp,-MD,.deps/mf-runtime.pp -c /vol/gnu/src/gcc/gcc-tree-ssa-dist/libmudflap/mf-runtime.c -o mf-runtime.o
In file included from /vol/gnu/src/gcc/gcc-tree-ssa-dist/libmudflap/mf-impl.h:41,
                 from /vol/gnu/src/gcc/gcc-tree-ssa-dist/libmudflap/mf-runtime.c:68:
/vol/gcc/obj/gcc-3.5-tree-ssa-20040416/4.0f-gcc/gcc/include/pthread.h:877: error: field `_Pfield' declared as a function
[...]

This happens due to what seems to be a fundamental problem in libmudflap:
currently, mf-runtime.c (and several other files) include a long list of
various feature macros to enable many API definitions on various platforms.

I fear this is fundamentally flawed (at least for the platforms I know
about): with very few exceptions, when not defining any feature test
macros, you get all API definitions available on the platform that don't
conflicts (or where different standards don't prescribe different
signatures).  As soon as you start defining feature test macros, the set of
API definitions is restricted to what is prescribed by those standards.
Those sets are often different on various platforms.

E.g. on Tru64 UNIX, when I remove all the feature test macros in
mf-runtime.c, the file compiles cleanly.

The following hacky patch allowed me to compile all of libmudflag on Tru64
UNIX V4.0F.  I call it hacky for two reasons: 

* I don't like the fundamental approach.  It seems to be much cleaner to
  leave the feature test macros undefined and only define them on platforms
  where they are known to be necessary, with a comment why they are
  necessary.  An example of this is the definition of _POSIX_PII_SOCKET in
  mf-hooks2.c: it is necessary to get a definition of recvfrom (and others)
  that uses socklen_t instead of int for the address_len parameter, as
  required by libmudflap.  Of course this should be commented appropriately
  and only activated if __osf__ or (better) if found necessary by an
  autoconf test.

* The duplication of those lists of feature test macros in mf-hooks*.c and
  mf-runtime.c is a considerable maintenance burden.  They should be
  consolidated in one place instead.

Index: libmudflap/mf-hooks1.c
===================================================================
RCS file: /vol/gnu/src/gcc/.gcc-cvs/gcc/libmudflap/Attic/mf-hooks1.c,v
retrieving revision 1.1.2.7
diff -u -p -r1.1.2.7 mf-hooks1.c
--- libmudflap/mf-hooks1.c	20 Mar 2004 12:33:41 -0000	1.1.2.7
+++ libmudflap/mf-hooks1.c	19 Apr 2004 22:56:15 -0000
@@ -39,9 +39,10 @@ Software Foundation, 59 Temple Place - S
 
 /* These attempt to coax various unix flavours to declare all our
    needed tidbits in the system headers.  */
-#if !defined(__FreeBSD__)  && !defined(__APPLE__)
+#if !defined(__FreeBSD__)  && !defined(__APPLE__) && !defined(__osf__)
 #define _POSIX_SOURCE
 #endif /* Some BSDs break <sys/socket.h> if this is defined. */
+#if !defined(__osf__)
 #define _GNU_SOURCE 
 #define _XOPEN_SOURCE
 #define _BSD_TYPES
@@ -49,6 +50,7 @@ Software Foundation, 59 Temple Place - S
 #define _ALL_SOURCE
 #define _LARGE_FILE_API
 #define _XOPEN_SOURCE_EXTENDED 1
+#endif
 
 #include <string.h>
 #include <stdio.h>
Index: libmudflap/mf-hooks2.c
===================================================================
RCS file: /vol/gnu/src/gcc/.gcc-cvs/gcc/libmudflap/Attic/mf-hooks2.c,v
retrieving revision 1.1.2.9
diff -u -p -r1.1.2.9 mf-hooks2.c
--- libmudflap/mf-hooks2.c	20 Mar 2004 12:33:41 -0000	1.1.2.9
+++ libmudflap/mf-hooks2.c	19 Apr 2004 23:00:54 -0000
@@ -38,9 +38,10 @@ Software Foundation, 59 Temple Place - S
 
 /* These attempt to coax various unix flavours to declare all our
    needed tidbits in the system headers.  */
-#if !defined(__FreeBSD__) && !defined(__APPLE__)
+#if !defined(__FreeBSD__) && !defined(__APPLE__) && !defined(__osf__)
 #define _POSIX_SOURCE
 #endif /* Some BSDs break <sys/socket.h> if this is defined. */
+#if !defined(__osf__)
 #define _GNU_SOURCE 
 #define _XOPEN_SOURCE
 #define _BSD_TYPES
@@ -48,6 +49,8 @@ Software Foundation, 59 Temple Place - S
 #define _ALL_SOURCE
 #define _LARGE_FILE_API
 #define _XOPEN_SOURCE_EXTENDED 1
+#endif
+#define _POSIX_PII_SOCKET
 
 #include <string.h>
 #include <strings.h>
Index: libmudflap/mf-hooks3.c
===================================================================
RCS file: /vol/gnu/src/gcc/.gcc-cvs/gcc/libmudflap/Attic/mf-hooks3.c,v
retrieving revision 1.1.2.7
diff -u -p -r1.1.2.7 mf-hooks3.c
--- libmudflap/mf-hooks3.c	20 Mar 2004 12:33:41 -0000	1.1.2.7
+++ libmudflap/mf-hooks3.c	19 Apr 2004 22:54:22 -0000
@@ -38,9 +38,10 @@ Software Foundation, 59 Temple Place - S
 
 /* These attempt to coax various unix flavours to declare all our
    needed tidbits in the system headers.  */
-#if !defined(__FreeBSD__) && !defined(__APPLE__)
+#if !defined(__FreeBSD__) && !defined(__APPLE__) && !defined(__osf__)
 #define _POSIX_SOURCE
 #endif /* Some BSDs break <sys/socket.h> if this is defined. */
+#if !defined(__osf__)
 #define _GNU_SOURCE 
 #define _XOPEN_SOURCE
 #define _BSD_TYPES
@@ -48,6 +49,7 @@ Software Foundation, 59 Temple Place - S
 #define _ALL_SOURCE
 #define _LARGE_FILE_API
 #define _XOPEN_SOURCE_EXTENDED 1
+#endif
 
 #include <string.h>
 #include <stdio.h>
Index: libmudflap/mf-runtime.c
===================================================================
RCS file: /vol/gnu/src/gcc/.gcc-cvs/gcc/libmudflap/Attic/mf-runtime.c,v
retrieving revision 1.1.2.49
diff -u -p -r1.1.2.49 mf-runtime.c
--- libmudflap/mf-runtime.c	20 Mar 2004 12:33:41 -0000	1.1.2.49
+++ libmudflap/mf-runtime.c	19 Apr 2004 22:49:44 -0000
@@ -33,9 +33,10 @@ Software Foundation, 59 Temple Place - S
 
 /* These attempt to coax various unix flavours to declare all our
    needed tidbits in the system headers.  */
-#if !defined(__FreeBSD__)
+#if !defined(__FreeBSD__) && !defined(__osf__)
 #define _POSIX_SOURCE
 #endif /* Some BSDs break <sys/socket.h> if this is defined. */
+#if !defined(__osf__)
 #define _GNU_SOURCE 
 #define _XOPEN_SOURCE
 #define _BSD_TYPES
@@ -43,6 +44,7 @@ Software Foundation, 59 Temple Place - S
 #define _ALL_SOURCE
 #define _LARGE_FILE_API
 #define _XOPEN_SOURCE_EXTENDED 1
+#endif
 
 #include <stdio.h>
 #include <stdlib.h>

Anyway, I won't push this patch (or even an improved version thereof)
because it is useless: currently there's no way libmudflap can be used on
Tru64 UNIX since the native ld doesn't support the --wrap option.  I'll
report this problem separately.

Environment:
System: OSF1 rimsky V4.0 1229 alpha
Machine: alpha
	
host: alpha-dec-osf4.0f
build: alpha-dec-osf4.0f
target: alpha-dec-osf4.0f
configured with: /vol/gnu/src/gcc/gcc-tree-ssa-dist/configure --prefix=/vol/gcc --with-local-prefix=/vol/gcc --disable-nls --enable-languages=c++,java,objc --host alpha-dec-osf4.0f --build alpha-dec-osf4.0f --target alpha-dec-osf4.0f

How-To-Repeat:
Bootstrap the tree-ssa branch as above.
Comment 1 Andrew Pinski 2004-04-27 19:05:56 UTC
Confirmed.
Comment 2 Frank Ch. Eigler 2004-06-07 15:28:48 UTC
Good points re feature macros.
Comment 3 Andrew Pinski 2004-07-09 22:12:24 UTC
Not as important now that libmudflap is disable on every target except for linux.
Comment 4 Rainer Orth 2011-07-19 11:23:57 UTC
While the fundamental point about defining every feature test macro in sight
remains valid, there's no point in trying to fix this for Tru64 UNIX: gld doesn't
work and the vendor linker has no support for --wrap or equivalent.

  Rainer