Changeset - r17913:b411192e7742
[Not reviewed]
master
0 1 0
smatz - 13 years ago 2011-08-07 11:18:33
smatz@openttd.org
(svn r22728) -Codechange: add -Wno-narrowing to cxxflags in order to prevent many useless warnings with GCC 4.7
1 file changed with 7 insertions and 0 deletions:
0 comments (0 inline, 0 general)
config.lib
Show inline comments
 
@@ -1254,96 +1254,103 @@ make_compiler_cflags() {
 
		flags="$flags -Wwrite-strings -Wpointer-arith"
 
		flags="$flags -W -Wno-unused-parameter -Wformat=2"
 
		flags="$flags -Wredundant-decls"
 

	
 
		if [ $enable_assert -eq 0 ]; then
 
			# Do not warn about unused variables when building without asserts
 
			flags="$flags -Wno-unused-variable"
 
			if [ $cc_version -ge 46 ]; then
 
				# GCC 4.6 gives more warnings, disable them too
 
				flags="$flags -Wno-unused-but-set-variable"
 
				flags="$flags -Wno-unused-but-set-parameter"
 
			fi
 
		fi
 

	
 
		if [ $cc_version -ge 34 ]; then
 
			# Warn when a variable is used to initialise itself:
 
			# int a = a;
 
			flags="$flags -Winit-self"
 
		fi
 

	
 
		if [ $cc_version -ge 40 ]; then
 
			# GCC 4.0+ complains about that we break strict-aliasing.
 
			#  On most places we don't see how to fix it, and it doesn't
 
			#  break anything. So disable strict-aliasing to make the
 
			#  compiler all happy.
 
			flags="$flags -fno-strict-aliasing"
 
			# Warn about casting-out 'const' with regular C-style cast.
 
			#  The preferred way is const_cast<>() which doesn't warn.
 
			flags="$flags -Wcast-qual"
 
		fi
 

	
 
		if [ $cc_version -ge 42 ]; then
 
			# GCC 4.2+ automatically assumes that signed overflows do
 
			# not occur in signed arithmetics, whereas we are not
 
			# sure that they will not happen. It furthermore complains
 
			# about its own optimized code in some places.
 
			flags="$flags -fno-strict-overflow"
 
			# GCC 4.2 no longer includes -Wnon-virtual-dtor in -Wall.
 
			# Enable it in order to be consistent with older GCC versions.
 
			flags="$flags -Wnon-virtual-dtor"
 
		fi
 

	
 
		if [ $cc_version -ge 43 ]; then
 
			# Use gnu++0x mode so static_assert() is available.
 
			# Don't use c++0x, it breaks mingw (with gcc 4.4.0).
 
			cxxflags="$cxxflags -std=gnu++0x"
 
		fi
 

	
 
		if [ $cc_version -ge 47 ]; then
 
			# Disable -Wnarrowing which gives many warnings, such as:
 
			# warning: narrowing conversion of '...' from 'unsigned int' to 'int' inside { } [-Wnarrowing]
 
			# They are valid according to the C++ standard, but useless.
 
			cxxflags="$cxxflags -Wno-narrowing"
 
		fi
 

	
 
		if [ "$enable_lto" != "0" ]; then
 
			# GCC 4.5 outputs '%{flto}', GCC 4.6 outputs '%{flto*}'
 
			has_lto=`$1 -dumpspecs | grep '\%{flto'`
 
			if [ -n "$has_lto" ]; then
 
				# Use LTO only if we see LTO exists and is requested
 
				if [ $cc_version -lt 46 ]; then
 
					flags="$flags -flto"
 
				else
 
					flags="$flags -flto=jobserver"
 
				fi
 
				ldflags="$ldflags -fwhole-program"
 
				features="$features lto"
 
			fi
 
		fi
 

	
 
		has_rdynamic=`$1 -dumpspecs | grep rdynamic`
 
		if [ -n "$has_rdynamic" ]; then
 
			# rdynamic is used to get useful stack traces from crash reports.
 
			flags="$flags -rdynamic"
 
			ldflags="$ldflags -rdynamic"
 
		fi
 
	fi
 

	
 
	eval "$2=\"$flags\""
 
	eval "$3=\"$cxxflags\""
 
	eval "$4=\"$ldflags\""
 
	eval "$5=\"$features\""
 
}
 

	
 
make_cflags_and_ldflags() {
 
	# General CFlags for BUILD
 
	CFLAGS_BUILD=""
 
	# Special CXXFlags for BUILD
 
	CXXFLAGS_BUILD=""
 
	# LDFLAGS for BUILD
 
	LDFLAGS_BUILD=""
 
	# FEATURES for BUILD (lto)
 
	FEATURES_BUILD=""
 
	# General CFlags for HOST
 
	CFLAGS="$CFLAGS"
 
	# Special CXXFlags for HOST
 
	CXXFLAGS="$CXXFLAGS"
 
	# Libs to compile. In fact this is just LDFLAGS
 
	LIBS="-lstdc++"
 
	# LDFLAGS used for HOST
 
	LDFLAGS="$LDFLAGS"
 
	# FEATURES for HOST (lto)
 
	FEATURES=""
0 comments (0 inline, 0 general)