From 07c2738ffa6bdb21caba5c5f7aa4cfe131d25ba7 Mon Sep 17 00:00:00 2001 From: Andrew Kryczka Date: Fri, 10 Nov 2017 16:53:02 -0800 Subject: [PATCH] prefer enabling cpu features via -march/-mcpu Summary: If possible, use -march or -mcpu to get enable all features available on the local CPU or architecture. Only if this is impossible, we will manually set -msse4.2. It should be safe as there'll be a warning printed if `USE_SSE` is set and the provided flags are insufficient to support SSE4.2. Closes https://github.com/facebook/rocksdb/pull/3156 Differential Revision: D6304703 Pulled By: ajkr fbshipit-source-id: 030a53491263300cae7fafb429114d87acc828ef --- build_tools/build_detect_platform | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/build_tools/build_detect_platform b/build_tools/build_detect_platform index c7ddb7cce..82eaee075 100755 --- a/build_tools/build_detect_platform +++ b/build_tools/build_detect_platform @@ -444,9 +444,7 @@ if test "$USE_HDFS"; then JAVA_LDFLAGS="$JAVA_LDFLAGS $HDFS_LDFLAGS" fi -if test "$USE_SSE"; then - COMMON_FLAGS="$COMMON_FLAGS -msse4.2" -elif test -z "$PORTABLE"; then +if test -z "$PORTABLE"; then if test -n "`echo $TARGET_ARCHITECTURE | grep ^ppc64`"; then # Tune for this POWER processor, treating '+' models as base models POWER=`LD_SHOW_AUXV=1 /bin/true | grep AT_PLATFORM | grep -E -o power[0-9]+` @@ -455,7 +453,11 @@ elif test -z "$PORTABLE"; then COMMON_FLAGS="$COMMON_FLAGS -march=z10 " elif [ "$TARGET_OS" != AIX ] && [ "$TARGET_OS" != SunOS ]; then COMMON_FLAGS="$COMMON_FLAGS -march=native " + elif test "$USE_SSE"; then + COMMON_FLAGS="$COMMON_FLAGS -msse4.2" fi +elif test "$USE_SSE"; then + COMMON_FLAGS="$COMMON_FLAGS -msse4.2" fi $CXX $PLATFORM_CXXFLAGS $COMMON_FLAGS -x c++ - -o /dev/null 2>/dev/null <