public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* [RFC] cygport: use -Werror=implicit-function-declarations
@ 2013-10-16 23:42 Yaakov (Cygwin/X)
  2013-10-17  9:38 ` Corinna Vinschen
  0 siblings, 1 reply; 4+ messages in thread
From: Yaakov (Cygwin/X) @ 2013-10-16 23:42 UTC (permalink / raw)
  To: cygwin-apps

[-- Attachment #1: Type: text/plain, Size: 1051 bytes --]

One of the more common causes of SEGVs with x86_64-cygwin packages 
occurs when an implicit function declaration causes an assumption that 
all arguments and the return value are of type 'int' (32 bits) where 
some or all of these are longs or pointers (64 bits on x86_64).  One way 
of avoiding such errors is to add -Werror=implicit-function-declarations 
to the default CFLAGS/OBJCFLAGS, and in my brief testing to date, this 
has already caught a number of cases where this would have broken the 
package on x86_64.

One potential drawback is that this flag may cause false negatives in 
poorly written configure tests; without extensive testing, I can't say 
yet how prevalent this would be, but I think that making this an error 
and perusing config.log is generally easier than making it just a 
warning and having to sift through the entire output of make.

My proposed patch for cygport git master is attached.  Any thoughts? 
And are there any other warning flags which cause similar errors on 
x86_64 that should be added as well?


Yaakov

[-- Attachment #2: cygport-Werror-implicit-decls.patch --]
[-- Type: text/x-patch, Size: 2165 bytes --]

diff --git a/lib/compilers.cygpart b/lib/compilers.cygpart
index d2c9449..91fc16d 100644
--- a/lib/compilers.cygpart
+++ b/lib/compilers.cygpart
@@ -31,9 +31,9 @@ declare -x CC="gcc";
 #  Flags passed to CC when compiling C code.  Individual packages may append
 #  or override this value if they will not build correctly without it.
 #  DEFAULT VALUE
-#  -ggdb -O2 -pipe
+#  -ggdb -O2 -pipe -Werror=implicit-function-declaration
 #****
-declare -x CFLAGS="-ggdb -O2 -pipe";
+declare -x CFLAGS="-ggdb -O2 -pipe -Werror=implicit-function-declaration";
 
 #****v* Compiling/CPPFLAGS
 #  DESCRIPTION
@@ -55,7 +55,7 @@ declare -x CXX="g++";
 #  DEFAULT VALUE
 #  -ggdb -O2 -pipe
 #****
-declare -x CXXFLAGS="${CFLAGS}";
+declare -x CXXFLAGS="-ggdb -O2 -pipe";
 
 #****d* Compiling/F77
 #  DESCRIPTION
@@ -72,7 +72,7 @@ declare -x F77="gfortran";
 #  DEFAULT VALUE
 #  -ggdb -O2 -pipe
 #****
-declare -x FFLAGS="${CFLAGS}";
+declare -x FFLAGS="-ggdb -O2 -pipe";
 
 #****d* Compiling/FC
 #  DESCRIPTION
@@ -89,7 +89,7 @@ declare -x FC="gfortran";
 #  DEFAULT VALUE
 #  -ggdb -O2 -pipe
 #****
-declare -x FCFLAGS="${CFLAGS}";
+declare -x FCFLAGS="-ggdb -O2 -pipe";
 
 #****d* Compiling/GCJ
 #  DESCRIPTION
@@ -106,7 +106,7 @@ declare -x GCJ="gcj";
 #  DEFAULT VALUE
 #  -ggdb -O2 -pipe
 #****
-declare -x GCJFLAGS="${CFLAGS}";
+declare -x GCJFLAGS="-ggdb -O2 -pipe";
 
 #****d* Compiling/GOC
 #  DESCRIPTION
@@ -121,7 +121,7 @@ declare -x GOC="gccgo";
 #  DEFAULT VALUE
 #  -ggdb -O2 -pipe
 #****
-declare -x GOFLAGS="${CFLAGS}";
+declare -x GOFLAGS="-ggdb -O2 -pipe";
 
 #****d* Compiling/OBJC
 #  DESCRIPTION
@@ -134,7 +134,7 @@ declare -x OBJC="${CC}";
 #  Flags passed to OBJC when compiling Objective C code.  Individual packages
 #  may append or override this value if they will not build correctly without it.
 #  DEFAULT VALUE
-#  -ggdb -O2 -pipe
+#  -ggdb -O2 -pipe -Werror=implicit-function-declaration
 #****
 declare -x OBJCFLAGS="${CFLAGS}";
 
@@ -151,7 +151,7 @@ declare -x OBJCXX="${CXX}";
 #  DEFAULT VALUE
 #  -ggdb -O2 -pipe
 #****
-declare -x OBJCXXFLAGS="${CFLAGS}";
+declare -x OBJCXXFLAGS="${CXXFLAGS}";
 
 #****v* Compiling/LDFLAGS
 #  DESCRIPTION

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-10-17 19:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-16 23:42 [RFC] cygport: use -Werror=implicit-function-declarations Yaakov (Cygwin/X)
2013-10-17  9:38 ` Corinna Vinschen
2013-10-17 17:06   ` Yaakov (Cygwin/X)
2013-10-17 19:14     ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).