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

RESOLVED FIXED in 4.6.2

Status

defect
RESOLVED FIXED
14 years ago
14 years ago

People

(Reporter: kaie, Assigned: wtc)

Tracking

({fixed1.8.1})

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(3 attachments)

Reporter

Description

14 years ago
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
Assignee

Comment 1

14 years ago
Kai, could you test this patch?  Remember to run
autoconf in mozilla/nsprpub to regenerate
mozilla/nsprpub/configure.
Attachment #207570 - Flags: review?(kengert)
Reporter

Comment 3

14 years ago
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).
Assignee

Comment 4

14 years ago
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+
Assignee

Comment 5

14 years ago
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).
Assignee

Comment 6

14 years ago
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.
Reporter

Updated

14 years ago
Attachment #207570 - Flags: review?(kengert) → review+
Assignee

Comment 7

14 years ago
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
Assignee

Comment 8

14 years ago
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)
Reporter

Comment 9

14 years ago
> 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

Reporter

Updated

14 years ago
Attachment #207784 - Flags: review?(kengert) → review+
Assignee

Comment 10

14 years ago
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
Assignee

Updated

14 years ago
Status: NEW → RESOLVED
Last Resolved: 14 years ago
Resolution: --- → FIXED
Target Milestone: --- → 4.7
Reporter

Updated

14 years ago
Attachment #207570 - Attachment description: Proposed patch → Patch for NSPR head + NSPR client branch
Reporter

Updated

14 years ago
Attachment #207676 - Attachment description: Patch for 4.6.1 → Patch for NSPR 4.6.1 and Mozilla 1.8 branch
Reporter

Updated

14 years ago
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
Reporter

Updated

14 years ago
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
Reporter

Updated

14 years ago
Attachment #207676 - Flags: approval1.8.1?
Reporter

Updated

14 years ago
Attachment #207784 - Flags: approval1.8.1?

Updated

14 years ago
Attachment #207676 - Flags: approval1.8.1? → branch-1.8.1?(wtchang)

Updated

14 years ago
Attachment #207784 - Flags: approval1.8.1? → branch-1.8.1?(wtchang)
Assignee

Updated

14 years ago
Attachment #207676 - Flags: branch-1.8.1?(wtchang) → branch-1.8.1+
Assignee

Updated

14 years ago
Attachment #207784 - Flags: branch-1.8.1?(wtchang) → branch-1.8.1+
Reporter

Updated

14 years ago
Keywords: fixed1.8.1
Assignee

Comment 11

14 years ago
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.