Skip to content
Permalink
Browse files

perform compile test to select -march or -mcpu for clang

  • Loading branch information
anbe42 authored and Michal Babej committed Sep 17, 2019
1 parent f97288d commit ffa98c2c71fe95c898afceba054b31eba51e374a
Showing with 20 additions and 9 deletions.
  1. +20 −9 cmake/LLVM.cmake
@@ -486,15 +486,6 @@ if(NOT DEFINED CLANG_NEEDS_RTLIB)

endif()

####################################################################
#X86 has -march and -mcpu reversed, for clang

if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "(powerpc|arm|aarch64)")
set(CLANG_MARCH_FLAG "-mcpu=")
else()
set(CLANG_MARCH_FLAG "-march=")
endif()

####################################################################

macro(CHECK_ALIGNOF TYPE TYPEDEF OUT_VAR)
@@ -699,6 +690,26 @@ else()
endif()


####################################################################
# Some architectures have -march and -mcpu reversed

if(NOT DEFINED ${CLANG_MARCH_FLAG})
message(STATUS "Checking clang -march vs. -mcpu flag")
custom_try_compile_clang_silent("" "return 0;" RES ${CLANG_TARGET_OPTION}${LLC_TRIPLE} -march=${LLC_HOST_CPU})
if(NOT RES)
set(CLANG_MARCH_FLAG "-march=")
else()
custom_try_compile_clang_silent("" "return 0;" RES ${CLANG_TARGET_OPTION}${LLC_TRIPLE} -mcpu=${LLC_HOST_CPU})
if(NOT RES)
set(CLANG_MARCH_FLAG "-mcpu=")
else()
message(FATAL_ERROR "Could not determine whether to use -march or -mcpu with clang")
endif()
endif()

set(CLANG_MARCH_FLAG ${CLANG_MARCH_FLAG} CACHE INTERNAL "Clang option used to specify the target cpu")
endif()

####################################################################

# This tests that we can actually link to the llvm libraries.

0 comments on commit ffa98c2

Please sign in to comment.
You can’t perform that action at this time.