Bug 38738 - libmudflap could be enabled for Solaris when using GNU ld
Summary: libmudflap could be enabled for Solaris when using GNU ld
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libmudflap (show other bugs)
Version: 4.4.0
: P3 enhancement
Target Milestone: 4.7.0
Assignee: Rainer Orth
URL: http://gcc.gnu.org/ml/gcc-patches/201...
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-06 02:35 UTC by Rob
Modified: 2011-06-29 10:10 UTC (History)
2 users (show)

See Also:
Host:
Target: *-*-solaris*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-06-20 11:23:10


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rob 2009-01-06 02:35:55 UTC
Enable mudflaps for Solaris _IF_ gcc is configured to use GNU's ld .


Here is the final result:

# make check
...
		=== libmudflap Summary ===
# of expected passes		1131
# of unexpected failures	293


I am running i386-pc-solaris2.11 (OpenSolaris 2008.11) and configured the
trunk like this:

# /usr/local/bin/gcc -v
Using built-in specs.
Target: i386-pc-solaris2.11
Configured with: ../gcc_trunk/configure --enable-languages=ada,c,c++,fortran,java,objc,obj-c++ --enable-shared --disable-static --enable-decimal-float --enable-nls --without-system-libunwind --with-gnu-as --with-as=/usr/local/bin/as --with-gnu-ld --with-ld=/usr/local/bin/ld
Thread model: posix
gcc version 4.4.0 20090104 (experimental) (GCC) 

# /usr/local/bin/ld -v
GNU ld (GNU Binutils) 2.19

# /usr/local/bin/as -v
GNU assembler version 2.19 (i386-pc-solaris2.11) using BFD version (GNU Binutils) 2.19


I modified "gcc_build/i386-pc-solaris2.11/libmudflap/Makefile" to add
"-lsocket" to LIBS which allows most of the tests to work. This was not
necessary for any other testsuites, they worked as-is.

# LIBS = -ldl 
LIBS = -ldl -lsocket



Some of the "unexpected failures" are simple compilation errors in the
tests which, when fixed, will likely become "expected passes". Example:
...
output is:
/usr/share/src/gcc_trunk/libmudflap/testsuite/libmudflap.c/pass47-frag.c:10: warning: mudflap cannot track unknown size extern '__ctype'
_or_
Excess errors:
/usr/share/src/gcc_trunk/libmudflap/testsuite/libmudflap.c/pass-stratcliff.c:261: error: invalid operands to binary - (have 'int' and 'char *')
/usr/share/src/gcc_trunk/libmudflap/testsuite/libmudflap.c/pass-stratcliff.c:281: error: invalid operands to binary - (have 'int' and 'char *')
/usr/share/src/gcc_trunk/libmudflap/testsuite/libmudflap.c/pass-stratcliff.c:309: warning: comparison between pointer and integer
...

A few of the "unexpected failures" are only in the "execution test" and
are the result of a Segmentation Fault. For the most part it is working.


The root configure script needs to be modified to allow mudflaps on this
platform _IF_ gcc is configured to use GNU ld (usually it does not) and
there needs a bit of fixing in the Makefile of libmudflap's testsuite.

Thanks,
Rob
Comment 1 Andrew Pinski 2009-01-06 02:41:53 UTC
for the pass-stratcliff.c failure, change:
#ifndef __FreeBSD__
to
#ifdef __gnu_linux__

And this should fix the issue there.

For pass47-frag.c failure, you need to either do a { dg-warning "__ctype" "" { target *-*-solaris* } or prune the output of the warning.
Comment 2 Rob 2009-01-06 04:21:11 UTC
There is one other change I made, add this to the top of libmudflaps/mf-hooks2.c :


/* OpenSolaris */
struct mntent {
	char	*mnt_fsname;	/* file system name */
	char	*mnt_dir;	/* file system path prefix */
	char	*mnt_type;	/* 4.3, nfs, dos, macintosh, cfs, or ignore */
	char	*mnt_opts;	/* ro, etc. */
	int	mnt_freq;	/* dump frequency, in days */
	int	mnt_passno;	/* pass number on parallel fsck */
};


Full results are here: http://gcc.gnu.org/ml/gcc-testresults/2009-01/msg00488.html

Rob
Comment 3 Rob 2009-01-18 12:52:31 UTC
(In reply to comment #1)
> for the pass-stratcliff.c failure, change:
> #ifndef __FreeBSD__
> to
> #ifdef __gnu_linux__
> 
> And this should fix the issue there.
> 
> For pass47-frag.c failure, you need to either do a { dg-warning "__ctype" "" {
> target *-*-solaris* } or prune the output of the warning.
> 

I will add those to my next run.


I could not decide where or how to fix the Testsuite with a trivial
patch (that addressed a single issue) to provide the greatest benefit
so for myself I tried something like this:


# svn diff libmudflap/testsuite/mfconfig.exp.in
Index: libmudflap/testsuite/mfconfig.exp.in
===================================================================
--- libmudflap/testsuite/mfconfig.exp.in	(revision 143454)
+++ libmudflap/testsuite/mfconfig.exp.in	(working copy)
@@ -1,4 +1,13 @@
+# We need libsocket to link successfully on OpenSolaris, set default-extra-flags
+proc solaris_libmudflap_need_lsocket {} {
+  if { [istarget "*-*-solaris*"] } {
+    lappend uselsocket "-lsocket"
+  }
+  return $uselsocket
+}
+
 global mfconfig_libs
-set mfconfig_libs "@LIBS@"
+set uselsocket [solaris_libmudflap_need_lsocket]
+set mfconfig_libs "@LIBS@ $uselsocket "
 global libmudflapth
 set libmudflapth "@build_libmudflapth@"



The code was derived by reading "gcc_trunk/libjava/testsuite/libjava.jni/jni.exp"
(line 263). The file contains no copyright info whatsoever but it is yours.


That gives us this result:

		=== libmudflap Summary ===

# of expected passes		1107
# of unexpected failures	317


Full results are here:

Results for 4.4.0 20090117 (experimental) [trunk revision 143454] (GCC) testsuite on i386-pc-solaris2.11
http://gcc.gnu.org/ml/gcc-testresults/2009-01/msg01790.html

Rob
Comment 4 Rob 2009-03-10 04:27:34 UTC
(In reply to comment #3)
> (In reply to comment #1)

MIRO: Mudflap Improved with Referent Objects - Works on OpenSolaris also.
http://gcc.gnu.org/wiki/MIRO

Results for gcc version 4.4.0 20080520 (experimental) [miro revision 144368] (GCC) testsuite on i386-pc-solaris2.11
http://gcc.gnu.org/ml/gcc-testresults/2009-02/msg02215.html

Rob
Comment 5 Rainer Orth 2011-06-20 11:23:10 UTC
It doesn't even depend on GNU ld, though: newer versions of Sun ld support
--wrap (resp. -z wrap), too.

I'm working to get this fixed.

  Rainer
Comment 6 Rainer Orth 2011-06-20 11:47:05 UTC
Initial patch posted.
Comment 7 Rainer Orth 2011-06-27 16:21:02 UTC
Author: ro
Date: Mon Jun 27 16:20:47 2011
New Revision: 175537

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175537
Log:
	gcc:
	PR libmudflap/38738
	* config/sol2.h [!USE_GLD] (MFLIB_SPEC): Define.

	libmudflap:
	PR libmudflap/38738
	* configure.ac: Check for sys/mnttab.h.
	Check for library containing connect.
	* configure: Regenerate.
	* config.h.in: Regenerate.
	* mf-hooks2.c [HAVE_SYS_MNTTAB_H]: Include <sys/mnttab.h>.
	* testsuite/libmudflap.c/pass-stratcliff.c (main) [__sun__ &&
	__svr4__]: Disable rawmemchr, stpcpy, mempcpy tests.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/sol2.h
    trunk/libmudflap/ChangeLog
    trunk/libmudflap/config.h.in
    trunk/libmudflap/configure
    trunk/libmudflap/configure.ac
    trunk/libmudflap/mf-hooks2.c
    trunk/libmudflap/testsuite/libmudflap.c/pass-stratcliff.c
Comment 8 Rob 2011-06-28 06:18:04 UTC
Thanks for FIXing, every little bit helps.
Rob
Comment 9 Rainer Orth 2011-06-29 10:10:02 UTC
Initial fix installed, further improvements will be handled within separate PRs.