Changeset - r22784:fad699781bcd
[Not reviewed]
master
0 1 0
Charles Pigott - 7 years ago 2018-04-11 11:35:25
charlespigott@googlemail.com
Fix: Resolve symlinks when working out which compiler is being used
1 file changed with 10 insertions and 8 deletions:
0 comments (0 inline, 0 general)
config.lib
Show inline comments
 
@@ -1207,20 +1207,22 @@ make_compiler_cflags() {
 
	# $1 - compiler
 
	# $2 - name of the cflags variable
 
	# $3 - name of the cxxflags variable
 
	# $4 - name of the ldflags variable
 
	# $5 - name of the features variable
 

	
 
	compiler="`realpath \`which $1\``" # resolve symlinks
 

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

	
 
	if [ `basename $1 | cut -c 1-3` = "icc" ]; then
 
	if [ `basename $compiler | cut -c 1-3` = "icc" ]; then
 
		# Enable some things only for certain ICC versions
 
		cc_version=`$1 -dumpversion | cut -c 1-4 | sed s@\\\.@@g`
 
		cc_version=`$compiler -dumpversion | cut -c 1-4 | sed s@\\\.@@g`
 

	
 
		flags="$flags -rdynamic"
 
		ldflags="$ldflags -rdynamic"
 

	
 
		if [ -z "$first_time_icc_check" ]; then
 
			first_time_icc_check=no
 
@@ -1292,22 +1294,22 @@ make_compiler_cflags() {
 
			flags="$flags -wd2259"
 
			# Use c++0x mode so static_assert() is available
 
			cxxflags="$cxxflags -std=c++0x"
 
		fi
 

	
 
		if [ "$enable_lto" != "0" ]; then
 
			has_ipo=`$1 -help ipo | grep '\-ipo'`
 
			has_ipo=`$compiler -help ipo | grep '\-ipo'`
 
			if [ -n "$has_ipo" ]; then
 
				# Use IPO (only if we see IPO exists and is requested)
 
				flags="$flags -ipo"
 
				features="$features lto"
 
			fi
 
		fi
 
	elif [ `basename $1 | grep 'clang'` ]; then
 
	elif [ `basename $compiler | grep 'clang'` ]; then
 
		# Enable some things only for certain clang versions
 
		cc_version="`$1 -v 2>&1 | head -n 1 | sed s@[^0-9]@@g | cut -c 1-2`"
 
		cc_version="`$compiler -v 2>&1 | head -n 1 | sed s@[^0-9]@@g | cut -c 1-2`"
 

	
 
		# aliasing rules are not held in openttd code
 
		flags="$flags -fno-strict-aliasing"
 

	
 
		# -W alone doesn't enable all warnings enabled by -Wall; on the other hand,
 
		# -Weverything enables too many useless warnings that can't be disabled (as of 3.0)
 
@@ -1360,13 +1362,13 @@ make_compiler_cflags() {
 
		# rdynamic is used to get useful stack traces from crash reports.
 
		ldflags="$ldflags -rdynamic"
 
	else
 
		# Enable some things only for certain GCC versions
 
		# cc_version = major_version * 100 + minor_version
 
		# For example: "3.3" -> 303, "4.9.2" -> 409, "6" -> 600, "23.5" -> 2305
 
		cc_version=`$1 -dumpversion | $awk -F . '{printf "%d%02d", $1, $2}'`
 
		cc_version=`$compiler -dumpversion | $awk -F . '{printf "%d%02d", $1, $2}'`
 

	
 
		if [ $cc_version -lt 303 ]; then
 
			log 1 "configure: error: gcc older than 3.3 can't compile OpenTTD because of its poor template support"
 
			exit 1
 
		fi
 

	
 
@@ -1442,26 +1444,26 @@ make_compiler_cflags() {
 
			# well with our custom pool item allocator
 
			cxxflags="$cxxflags -flifetime-dse=1 -std=gnu++14"
 
		fi
 

	
 
		if [ "$enable_lto" != "0" ]; then
 
			# GCC 4.5 outputs '%{flto}', GCC 4.6 outputs '%{flto*}'
 
			has_lto=`$1 -dumpspecs | grep '\%{flto'`
 
			has_lto=`$compiler -dumpspecs | grep '\%{flto'`
 
			if [ -n "$has_lto" ]; then
 
				# Use LTO only if we see LTO exists and is requested
 
				if [ $cc_version -lt 406 ]; 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`
 
		has_rdynamic=`$compiler -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
0 comments (0 inline, 0 general)