This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] cygport: use -Werror=implicit-function-declarations


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
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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]