From 06f9c019864a0fd3f832d42101897fee8c27a7cb Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Tue, 27 Sep 2016 01:05:42 +0100 Subject: [PATCH] Fix CPU pointer width detection in configure script. --- config.lib | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/config.lib b/config.lib index ae9b5be2c1..91b710252a 100644 --- a/config.lib +++ b/config.lib @@ -3123,24 +3123,40 @@ detect_nforenum() { log 1 "checking nforenum... found" } -detect_cputype() { - if [ -n "$cpu_type" ] && [ "$cpu_type" != "DETECT" ]; then - log 1 "forcing cpu-type... $cpu_type bits" - return; - fi - echo "#define _SQ64 1" > tmp.64bit.cpp - echo "#include \"src/stdafx.h\"" >> tmp.64bit.cpp - echo "assert_compile(sizeof(size_t) == 8);" >> tmp.64bit.cpp - echo "int main() { return 0; }" >> tmp.64bit.cpp - execute="$cxx_host $CFLAGS tmp.64bit.cpp -o tmp.64bit -DTESTING 2>&1" +_detect_cputype_width() { + echo "#define _SQ64 1" > $1.cpp + echo "#include \"src/stdafx.h\"" >> $1.cpp + echo "assert_compile(sizeof(size_t) == $2);" >> $1.cpp + echo "int main() { return 0; }" >> $1.cpp + execute="$cxx_host $CFLAGS -std=c++11 $1.cpp -o $1 -DTESTING 2>&1" cpu_type="`eval $execute 2>/dev/null`" ret=$? log 2 "executing $execute" log 2 " returned $cpu_type" log 2 " exit code $ret" - if [ "$ret" = "0" ]; then cpu_type="64"; else cpu_type="32"; fi + rm -f $1 $1.cpp + return $ret +} + +detect_cputype() { + if [ -n "$cpu_type" ] && [ "$cpu_type" != "DETECT" ]; then + log 1 "forcing cpu-type... $cpu_type bits" + return; + fi + _detect_cputype_width tmp.32bit 4 + result32=$? + _detect_cputype_width tmp.64bit 8 + result64=$? + + if [ "$result32" = 0 ] && [ "$result64" != 0 ]; then + cpu_type="32" + elif [ "$result32" != 0 ] && [ "$result64" = 0 ]; then + cpu_type="64" + else + log 1 "configure: unable to determine cpu-type (pointer width)" + exit 1 + fi log 1 "detecting cpu-type... $cpu_type bits" - rm -f tmp.64bit tmp.64bit.cpp } detect_sse_capable_architecture() {