configure: detect ifunc and avx2 attribute
Detect if the compiler can support the ifun and avx2, if so, set CONFIG_AVX2_OPT which will be used to turn on the avx2 instruction optimization. Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Suggested-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Liang Li <liang.z.li@intel.com> Message-Id: <1457416397-26671-2-git-send-email-liang.z.li@intel.com> Signed-off-by: Amit Shah <amit.shah@redhat.com>
This commit is contained in:
		
							parent
							
								
									614e8018ed
								
							
						
					
					
						commit
						99f2dbd343
					
				| 
						 | 
					@ -280,6 +280,7 @@ libusb=""
 | 
				
			||||||
usb_redir=""
 | 
					usb_redir=""
 | 
				
			||||||
opengl=""
 | 
					opengl=""
 | 
				
			||||||
opengl_dmabuf="no"
 | 
					opengl_dmabuf="no"
 | 
				
			||||||
 | 
					avx2_opt="no"
 | 
				
			||||||
zlib="yes"
 | 
					zlib="yes"
 | 
				
			||||||
lzo=""
 | 
					lzo=""
 | 
				
			||||||
snappy=""
 | 
					snappy=""
 | 
				
			||||||
| 
						 | 
					@ -1773,6 +1774,21 @@ EOF
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
##########################################
 | 
					##########################################
 | 
				
			||||||
 | 
					# avx2 optimization requirement check
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cat > $TMPC << EOF
 | 
				
			||||||
 | 
					static void bar(void) {}
 | 
				
			||||||
 | 
					static void *bar_ifunc(void) {return (void*) bar;}
 | 
				
			||||||
 | 
					static void foo(void) __attribute__((ifunc("bar_ifunc")));
 | 
				
			||||||
 | 
					int main(void) { foo(); return 0; }
 | 
				
			||||||
 | 
					EOF
 | 
				
			||||||
 | 
					if compile_prog "-mavx2" "" ; then
 | 
				
			||||||
 | 
					    if readelf --syms $TMPE |grep "IFUNC.*foo" >/dev/null 2>&1; then
 | 
				
			||||||
 | 
					        avx2_opt="yes"
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#########################################
 | 
				
			||||||
# zlib check
 | 
					# zlib check
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if test "$zlib" != "no" ; then
 | 
					if test "$zlib" != "no" ; then
 | 
				
			||||||
| 
						 | 
					@ -4790,6 +4806,7 @@ echo "bzip2 support     $bzip2"
 | 
				
			||||||
echo "NUMA host support $numa"
 | 
					echo "NUMA host support $numa"
 | 
				
			||||||
echo "tcmalloc support  $tcmalloc"
 | 
					echo "tcmalloc support  $tcmalloc"
 | 
				
			||||||
echo "jemalloc support  $jemalloc"
 | 
					echo "jemalloc support  $jemalloc"
 | 
				
			||||||
 | 
					echo "avx2 optimization $avx2_opt"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if test "$sdl_too_old" = "yes"; then
 | 
					if test "$sdl_too_old" = "yes"; then
 | 
				
			||||||
echo "-> Your SDL version is too old - please upgrade to have SDL support"
 | 
					echo "-> Your SDL version is too old - please upgrade to have SDL support"
 | 
				
			||||||
| 
						 | 
					@ -5178,6 +5195,10 @@ if test "$opengl" = "yes" ; then
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if test "$avx2_opt" = "yes" ; then
 | 
				
			||||||
 | 
					  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if test "$lzo" = "yes" ; then
 | 
					if test "$lzo" = "yes" ; then
 | 
				
			||||||
  echo "CONFIG_LZO=y" >> $config_host_mak
 | 
					  echo "CONFIG_LZO=y" >> $config_host_mak
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue