Bug 11673 - libmudflap does not compile on freebsd
Summary: libmudflap does not compile on freebsd
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: other (show other bugs)
Version: tree-ssa
: P2 normal
Target Milestone: tree-ssa
Assignee: Frank Ch. Eigler
URL:
Keywords: build
Depends on:
Blocks:
 
Reported: 2003-07-25 14:12 UTC by Linus Sjöberg
Modified: 2003-07-29 21:19 UTC (History)
2 users (show)

See Also:
Host: i386-unknown-freebsd4.8
Target: *-*-* except *-*-linux-gnu
Build: i386-unknown-freebsd4.8
Known to work:
Known to fail:
Last reconfirmed: 2003-07-25 14:34:53


Attachments
MAP_ANON support (552 bytes, patch)
2003-07-25 15:03 UTC, Frank Ch. Eigler
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Linus Sjöberg 2003-07-25 14:12:36 UTC
There are a numerous number of problems with libmudflap which break FreeBSD bootstrapping.

See http://gcc.gnu.org/ml/gcc/2003-06/msg02511.html for details.


Furthermore the current cvs-version also bangs with
/stuff/gcc.obj/gcc/xgcc -B/stuff/gcc.obj/gcc/ -B/stuff/gcc.install/i386-unknown-freebsd4.8/bin/ -B/stuff/gcc.install/i386-unknown-freebsd4.8/lib/ -isystem /stuff/gcc.install/i386-unknown-freebsd4.8/include -isystem /stuff/gcc.install/i386-unknown-freebsd4.8/sys-include -DHAVE_CONFIG_H -I. -I../../../gcc/libmudflap -I. -O2 -g -O2 -Wall -O2 -g -O2 -DLIBMUDFLAPTH -DWRAP_pthreadstuff -c ../../../gcc/libmudflap/mf-hooks3.c  -fPIC -DPIC -o pth/.libs/pthreadstuff-hook.o
../../../gcc/libmudflap/mf-hooks3.c: In function `pthread_create':
../../../gcc/libmudflap/mf-hooks3.c:404: error: `MAP_ANONYMOUS' undeclared (first use in this function)
../../../gcc/libmudflap/mf-hooks3.c:404: error: (Each undeclared identifier is reported only once
../../../gcc/libmudflap/mf-hooks3.c:404: error: for each function it appears in.)


[linus@hal9000 ~]$ uname -a
FreeBSD hal9000.alcom.aland.fi 4.8-STABLE FreeBSD 4.8-STABLE #5: Fri Jul  4 11:24:45 EEST 2003     root@hal9000.alcom.aland.fi:/usr/obj/usr/src/sys/HAL  i386
[linus@hal9000 ~]$
Comment 1 Andrew Pinski 2003-07-25 14:34:53 UTC
Looks like libmudflap is only supported on GNU/Linux and does not have enough 
configure magic to support it on other targets because I have the same problem on 
powerpc-apple-darwin6.6.
Comment 2 Frank Ch. Eigler 2003-07-25 15:03:21 UTC
Created attachment 4478 [details]
MAP_ANON support
Comment 3 Frank Ch. Eigler 2003-07-25 15:05:13 UTC
The previous summary line was rather pessimistic.  The code is periodically
tested on other platforms, but clearly not all.  That's why we need the
help of people that try to build on oddball :-) hosts.
Please try the attached patch.
Comment 4 Linus Sjöberg 2003-07-25 15:47:11 UTC
With the patch applied that specific wrapper compiles fine.

The remaining problems are:
* WRAP_stat64 failes since there is no syscall stat64
* WRAP_fseeko64 failes since there is no syscall fseeko64
* WRAP_ftello64 failes since there is no syscall ftello64
* WRAP_semctl gives a 'error: redefinition of `union semun''
* _POSIX_SOURCE introduces a problem with sa_family_t since u_char is undefined.

See 
http://gcc.gnu.org/ml/gcc/2003-06/msg02490.html
http://gcc.gnu.org/ml/gcc/2003-06/msg02490.html
for all the details.
Comment 5 Frank Ch. Eigler 2003-07-25 15:51:37 UTC
Most of the remaining problems relate to the lack of Large File Support
in freebsd.  I'm investigating how to selectively leave these bits out
of libmudflap.
Comment 6 Andrew Pinski 2003-07-25 15:54:40 UTC
No it is not related to the Lack of Large File Support but rather the Large File Support is support is 
not need as the regular ones are the 64bit ones so there is no need for the extra 64bit ones. All 
*BSD are this way including Darwin.
Comment 7 Frank Ch. Eigler 2003-07-25 18:13:24 UTC
Linux, how do you propose the _POSIX_SOURCE issue be solved?
Is there another bsd header worth #include'ing?
(I see how to autoconf the rest.)
Comment 8 Linus Sjöberg 2003-07-25 22:48:40 UTC
Subject: Re:  libmudflap does not compile on freebsd

From types.h:
#ifndef _POSIX_SOURCE
typedef unsigned char   u_char;
typedef unsigned short  u_short;
(...)
#endif

Not much to do there...

The code compiles with _POSIX_SOURCE undefined (that's how I have been solving
the problem temporarly), so an ugly fix is something like
diff -u -u -r1.1.2.1 mf-hooks2.c
--- mf-hooks2.c 4 Jul 2003 23:10:09 -0000       1.1.2.1
+++ mf-hooks2.c 25 Jul 2003 18:30:05 -0000
@@ -11,7 +11,9 @@
 
 /* These attempt to coax various unix flavours to declare all our
    needed tidbits in the system headers.  */
+#ifndef _FREEBSD  /* Or some other magic that detects FreeBSD (prob. *BSD) */
 #define _POSIX_SOURCE
+#endif
 #define _GNU_SOURCE 
 #define _XOPEN_SOURCE
 #define _BSD_TYPES
Comment 9 Gerald Pfeifer 2003-07-29 13:39:50 UTC
I experienced (and hack around) this before noticing this PR, so here are some
comments on suggested resolutions:

 1. The MAP_ANON patch looks good; would you mind applying it, Frank?
 2. The _POSIX issue should be resolved as in
     http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11673#c8
    but using __FreeBSD__ instead.
    Still, it would be good to note (in comments) which platforms require _POSIX.
 3. I agree that autoconf-ing the *64 functions is the best approach, 
 4. and similarly for union semun.
Comment 10 Frank Ch. Eigler 2003-07-29 18:13:08 UTC
Please try out the patch just committed.
Comment 11 GCC Commits 2003-07-29 19:32:42 UTC
Subject: Bug 11673

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	tree-ssa-20020619-branch
Changes by:	gerald@gcc.gnu.org	2003-07-29 19:32:40

Modified files:
	libmudflap     : ChangeLog mf-hooks2.c 

Log message:
	PR other/11673
	* mf-hooks2.c [WRAP_semctl]: Fix check for HAVE_UNION_SEMUN.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libmudflap/ChangeLog.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.69&r2=1.1.2.70
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libmudflap/mf-hooks2.c.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.2&r2=1.1.2.3

Comment 12 Frank Ch. Eigler 2003-07-29 21:12:40 UTC
WORKSFORGERALD
Comment 13 Linus Sjöberg 2003-07-29 21:19:12 UTC
Confirmed.