diff options
author | Siva Chandra <sivachandra@google.com> | 2020-06-10 10:55:00 -0700 |
---|---|---|
committer | Siva Chandra Reddy <sivachandra@google.com> | 2020-06-10 11:11:04 -0700 |
commit | c76a1d0fc0c148c8642397a6ec8a589256eb1dc2 (patch) | |
tree | c1072a5262df6054c420c42ab7763cf575bfd1f0 /libc | |
parent | 8b6821a5843bb321b3738e2519beae7142e62928 (diff) | |
download | llvm-c76a1d0fc0c148c8642397a6ec8a589256eb1dc2.zip llvm-c76a1d0fc0c148c8642397a6ec8a589256eb1dc2.tar.gz llvm-c76a1d0fc0c148c8642397a6ec8a589256eb1dc2.tar.bz2 |
[libc][NFC] Make cpu feature check tolerate non-x86 architectures.
The feature check should probably be enhanced for non-x86 architectures,
but this change shields them from x86 specific pieces until then.
This patch has been split out from https://reviews.llvm.org/D81533.
Diffstat (limited to 'libc')
-rw-r--r-- | libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake b/libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake index 0bb4af8..86c3822c 100644 --- a/libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake +++ b/libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake @@ -4,10 +4,9 @@ if(${LIBC_TARGET_MACHINE} MATCHES "x86|x86_64") set(ALL_CPU_FEATURES SSE SSE2 AVX AVX2 AVX512F) + list(SORT ALL_CPU_FEATURES) endif() -list(SORT ALL_CPU_FEATURES) - # Function to check whether the host supports the provided set of features. # Usage: # host_supports( @@ -126,4 +125,11 @@ function(_check_defined_cpu_feature output_var) endfunction() # Populates the HOST_CPU_FEATURES list. -_check_defined_cpu_feature(HOST_CPU_FEATURES MARCH native) +# Use -march=native only when the compiler supports it. +include(CheckCXXCompilerFlag) +CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE) +if(COMPILER_SUPPORTS_MARCH_NATIVE) + _check_defined_cpu_feature(HOST_CPU_FEATURES MARCH native) +else() + _check_defined_cpu_feature(HOST_CPU_FEATURES) +endif() |