From a817dc3b3b5a0efc95aaca366875eac67607cd5b Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 6 Mar 2018 14:28:16 -0700 Subject: [PATCH] Default to building native code If the local compiler supports it, use -march=native to ensure we take full advantage of a local build. If building distro packages, or otherwise for a different platform than the host, then use --disable-native with configure to remove this optimization. Signed-off-by: Jens Axboe --- Makefile | 3 +++ configure | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Makefile b/Makefile index c25b4222..19ba40a0 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,9 @@ SCRIPTS = $(addprefix $(SRCDIR)/,tools/fio_generate_plots tools/plot/fio2gnuplot ifndef CONFIG_FIO_NO_OPT CFLAGS += -O3 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 endif +ifdef CONFIG_BUILD_NATIVE + CFLAGS += -march=native +endif ifdef CONFIG_GFIO PROGS += gfio diff --git a/configure b/configure index 2e8eb180..eb673adc 100755 --- a/configure +++ b/configure @@ -145,6 +145,7 @@ devdax="no" pmem="no" disable_lex="" disable_pmem="no" +disable_native="no" prefix=/usr/local # parse options @@ -195,6 +196,8 @@ for opt do ;; --enable-cuda) enable_cuda="yes" ;; + --disable-native) disable_native="yes" + ;; --help) show_help="yes" ;; @@ -224,6 +227,7 @@ if test "$show_help" = "yes" ; then echo "--disable-shm Disable SHM support" echo "--disable-optimizations Don't enable compiler optimizations" echo "--enable-cuda Enable GPUDirect RDMA support" + echo "--disable-native Don't build for native host" exit $exit_val fi @@ -2131,6 +2135,20 @@ if compile_prog "" "" "mkdir(a, b)"; then fi print_config "mkdir(a, b)" "$mkdir_two" +########################################## +# check for cc -march=native +build_native="no" +cat > $TMPC << EOF +int main(int argc, char **argv) +{ + return 0; +} +EOF +if test "$disable_native" = "no" && compile_prog "-march=native" "" "march=native"; then + build_native="yes" +fi +print_config "Build march=native" "$build_native" + ############################################################################# if test "$wordsize" = "64" ; then @@ -2377,6 +2395,9 @@ fi if test "$mkdir_two" = "yes" ; then output_sym "CONFIG_HAVE_MKDIR_TWO" fi +if test "$build_native" = "yes" ; then + output_sym "CONFIG_BUILD_NATIVE" +fi echo "LIBS+=$LIBS" >> $config_host_mak echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak -- 2.25.1