Closed Bug 322427 Opened 19 years ago Closed 19 years ago

remove -ansi when compiling NSPR with gcc on Linux, because it's not needed and causes failures

Categories

(NSPR :: NSPR, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: KaiE, Assigned: wtc)

Details

(Keywords: fixed1.8.1)

Attachments

(3 files)

When trying to build NSPR with most recent glibc and gcc, I ran into a build failure, involving anonymous unions.

This feature does not seem to work when compiling with -ansi, a flag that NSPR is currently using.

After a discussion we think it's ok to remove the -ansi flag when compiling NSPR.

Wan-Teh asked me to do a test with a minimal C file, here are the results:


[root@js20-bc1-12 misc]# cat test2.c
#include <pthread.h>
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;

[root@js20-bc1-12 misc]# gcc -o test2.o -c -ansi -D_POSIX_SOURCE=1 -D_BSD_SOURCE=1 -D_SVID_SOURCE=1 -D_LARGEFILE64_SOURCE=1 test2.c
test2.c:2: error: extra brace group at end of initializer
test2.c:2: error: (near initialization for ‘lock.__data’)
test2.c:2: warning: excess elements in struct initializer
test2.c:2: warning: (near initialization for ‘lock.__data’)

[root@js20-bc1-12 misc]# gcc -o test2.o -c -D_POSIX_SOURCE=1 -D_BSD_SOURCE=1 -D_SVID_SOURCE=1 -D_LARGEFILE64_SOURCE=1 test2.c
Kai, could you test this patch?  Remember to run
autoconf in mozilla/nsprpub to regenerate
mozilla/nsprpub/configure.
Attachment #207570 - Flags: review?(kengert)
Wan-Teh, your patch does not apply to NSPR 4.6.1, the release I'm working with.
It seems in the latest version of nspr you combined several architecture targets into common rules.
However, nspr 4.6.1 uses separate linux and bsd rules.

As I currently work on linux only, I have ported your patch to that older version and tested it, changed the linux section only, and have attached the patch to this bug.

It compiled fine (although I'm still waiting for a s390 test result).
Comment on attachment 207676 [details] [diff] [review]
Patch for NSPR 4.6.1 and Mozilla 1.8 branch

r=wtc.  This patch for the NSPR_4_6_BRANCH is correct.
Attachment #207676 - Flags: review+
We may want to back out this old checkin:

Index: prinet.h
===================================================================
RCS file: /cvsroot/mozilla/nsprpub/pr/include/prinet.h,v
retrieving revision 3.6
retrieving revision 3.7
diff -u -r3.6 -r3.7
--- prinet.h    21 Apr 1999 21:38:18 -0000      3.6
+++ prinet.h    14 Sep 1999 19:39:46 -0000      3.7
@@ -41,7 +41,10 @@
 #define prinet_h__

 #if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS)
-
+#ifdef linux
+#undef __STRICT_ANSI__
+#define __STRICT_ANSI__
+#endif
 #include <sys/types.h>
 #include <sys/socket.h>                /* AF_INET */
 #include <netinet/in.h>         /* INADDR_ANY, ..., ntohl(), ... */

Unfortunately, I can't find the bug number, so I don't know
exactly what the problem was.  The CVS commit comment says:

revision 3.7
date: 1999/09/14 19:39:46;  author: srinivas%netscape.com;  state: Exp;  lines:
+4 -1
branches:  3.7.38;
Define __STRICT_ANSI__ for Linux to eliminate spurious warnings. Checkin
for Chris Seawood <cls@seawood.org>.
----------------------------
revision 3.6.24.1
date: 1999/09/12 14:16:20;  author: cls%seawood.org;  state: Exp;  lines: +4 -1
define __STRICT_ANSI__ for linux to suppress useless warnings when compiling mozilla

The only mention of this checkin I can find is bug 17040
comment 4, and I believe the "spurious/useless" warning is
the one in bug 18647 (that bug seems to be about an unrelated
build failure).
Note that bug 17040 that I mentioned in the previous comment
is about the various _XXX_SOURCE macro definitions that we
want to remove in this bug.
Attachment #207570 - Flags: review?(kengert) → review+
Comment on attachment 207570 [details] [diff] [review]
Patch for NSPR head + NSPR client branch

I checked in this patch on the NSPR trunk (NSPR 4.7):

Checking in configure;
/cvsroot/mozilla/nsprpub/configure,v  <--  configure
new revision: 1.209; previous revision: 1.208
done
Checking in configure.in;
/cvsroot/mozilla/nsprpub/configure.in,v  <--  configure.in
new revision: 1.211; previous revision: 1.210
done
Checking in pr/src/linking/Makefile.in;
/cvsroot/mozilla/nsprpub/pr/src/linking/Makefile.in,v  <--  Makefile.in
new revision: 1.18; previous revision: 1.17
done
Checking in pr/src/pthreads/Makefile.in;
/cvsroot/mozilla/nsprpub/pr/src/pthreads/Makefile.in,v  <--  Makefile.in
new revision: 1.14; previous revision: 1.13
done

and on the NSPRPUB_PRE_4_2_CLIENT_BRANCH (Gecko 1.9 alpha):

Checking in configure;
/cvsroot/mozilla/nsprpub/configure,v  <--  configure
new revision: 1.78.2.127; previous revision: 1.78.2.126
done
Checking in configure.in;
/cvsroot/mozilla/nsprpub/configure.in,v  <--  configure.in
new revision: 1.83.2.125; previous revision: 1.83.2.124
done
Checking in pr/src/linking/Makefile.in;
/cvsroot/mozilla/nsprpub/pr/src/linking/Makefile.in,v  <--  Makefile.in
new revision: 1.10.2.7; previous revision: 1.10.2.6
done
Checking in pr/src/pthreads/Makefile.in;
/cvsroot/mozilla/nsprpub/pr/src/pthreads/Makefile.in,v  <--  Makefile.in
new revision: 1.11.2.3; previous revision: 1.11.2.2
done
Kai, please test this patch on Linux and see if you
see a lot of warnings about a zero-size array in
<sys/socket.h> when the Mozilla (not NSPR) files are
compiled.  Thanks.
Attachment #207784 - Flags: review?(kengert)
> Kai, please test this patch on Linux and see if you
> see a lot of warnings about a zero-size array in
> <sys/socket.h> when the Mozilla (not NSPR) files are
> compiled.  Thanks.

I did, there are no warnings that contain the text "zero", nor mention file sys/socket.h

Attachment #207784 - Flags: review?(kengert) → review+
Comment on attachment 207784 [details] [diff] [review]
Remove ancient workaround for a zero-size array in <sys/socket.h> on Linux.
Patch for NSPR trunk + NSPR client branch + Mozilla 1.8 branch

I checked in this patch on the NSPR trunk (NSPR 4.7)
and the NSPRPUB_PRE_4_2_CLIENT_BRANCH (Gecko 1.9 alpha).

Checking in prinet.h;
/cvsroot/mozilla/nsprpub/pr/include/prinet.h,v  <--  prinet.h
new revision: 3.13; previous revision: 3.12
done

Checking in prinet.h;
/cvsroot/mozilla/nsprpub/pr/include/prinet.h,v  <--  prinet.h
new revision: 3.10.2.3; previous revision: 3.10.2.2
done
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Target Milestone: --- → 4.7
Attachment #207570 - Attachment description: Proposed patch → Patch for NSPR head + NSPR client branch
Attachment #207676 - Attachment description: Patch for 4.6.1 → Patch for NSPR 4.6.1 and Mozilla 1.8 branch
Attachment #207784 - Attachment description: Remove ancient workaround for a zero-size array in <sys/socket.h> on Linux → Remove ancient workaround for a zero-size array in <sys/socket.h> on Linux. Patch for NSPR trunk + NSPR client branch + Mozilla 1.8 branch
Attachment #207784 - Attachment description: Remove ancient workaround for a zero-size array in <sys/socket.h> on Linux. Patch for NSPR trunk + NSPR client branch + Mozilla 1.8 branch → Remove ancient workaround for a zero-size array in <sys/socket.h> on Linux. Patch for NSPR trunk + NSPR client branch + Mozilla 1.8 branch
Attachment #207676 - Flags: approval1.8.1?
Attachment #207784 - Flags: approval1.8.1?
Attachment #207676 - Flags: approval1.8.1? → branch-1.8.1?(wtchang)
Attachment #207784 - Flags: approval1.8.1? → branch-1.8.1?(wtchang)
Attachment #207676 - Flags: branch-1.8.1?(wtchang) → branch-1.8.1+
Attachment #207784 - Flags: branch-1.8.1?(wtchang) → branch-1.8.1+
Keywords: fixed1.8.1
I ported the patches back to the NSPR_4_6_BRANCH for NSPR 4.6.2.

Checking in configure;
/cvsroot/mozilla/nsprpub/configure,v  <--  configure
new revision: 1.197.2.3; previous revision: 1.197.2.2
done
Checking in configure.in;
/cvsroot/mozilla/nsprpub/configure.in,v  <--  configure.in
new revision: 1.199.2.3; previous revision: 1.199.2.2
done
Checking in pr/include/prinet.h;
/cvsroot/mozilla/nsprpub/pr/include/prinet.h,v  <--  prinet.h
new revision: 3.12.2.1; previous revision: 3.12
done
Checking in pr/src/linking/Makefile.in;
/cvsroot/mozilla/nsprpub/pr/src/linking/Makefile.in,v  <--  Makefile.in
new revision: 1.14.2.2; previous revision: 1.14.2.1
done
Checking in pr/src/pthreads/Makefile.in;
/cvsroot/mozilla/nsprpub/pr/src/pthreads/Makefile.in,v  <--  Makefile.in
new revision: 1.13.2.1; previous revision: 1.13
done
Target Milestone: 4.7 → 4.6.2
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: