]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: check for good yasm 5504/head
authorKefu Chai <kchai@redhat.com>
Fri, 7 Aug 2015 05:56:52 +0000 (13:56 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 8 Aug 2015 04:49:50 +0000 (12:49 +0800)
this enables faster crc32 calculation on x64 intel platforms,
see common/crc32c_intel_fast.c

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/CMakeLists.txt

index 00981bd97c66640edcbb34c6168fc147afc9d6df..da78bfafad03392e6d8f10bbf23f509bb9554f41 100644 (file)
@@ -17,6 +17,38 @@ message(status " ams compiler ${CMAKE_ASM_COMPILER}")
 set(CMAKE_ASM_FLAGS "-f elf64")
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -rdynamic -Wall -Wtype-limits -Wignored-qualifiers -Winit-self -Wpointer-arith -Werror=format-security -fno-strict-aliasing -fsigned-char -fPIC")
 
+execute_process(
+  COMMAND "yasm -f elf64 ${CMAKE_SOURCE_DIR}/src/common/crc32c_intel_fast_asm.S -o /dev/null"
+  RETURN_VALUE no_yasm
+  OUTPUT_QUIET)
+if(no_yasm)
+  message("we do not have a modern/working yasm")
+else(no_yasm)
+  message("we have a modern and working yasm")
+  execute_process(
+    COMMAND "arch"
+    OUTPUT_VARIABLE arch
+    OUTPUT_STRIP_TRAILING_WHITESPACE)
+  if(arch STREQUAL "x86_64")
+    message("we are x84_64")
+    include(CheckCXXSourceCompiles)
+    check_cxx_source_compiles("
+      #if defined(__x86_64__) && defined(__ILP32__)
+      #error x32
+      #endif
+      int main() {}
+      " not_arch_x32)
+    if(not_arch_x32)
+      message("we are not x32")
+      add_definitions("-DHAVE_GOOD_YASM_ELF64")
+    else(not_arch_x32)
+      message("we are x32; no yasm for you")
+    endif(not_arch_x32)
+  else(arch STREQUAL "x86_64")
+    message("we are not x86_64 && !x32")
+  endif(arch STREQUAL "x86_64")
+endif(no_yasm)
+
 execute_process(COMMAND yasm -f elf64 -i ${CMAKE_SOURCE_DIR}/src/erasure-code/isa/isa-l/include/ ${CMAKE_SOURCE_DIR}/src/erasure-code/isa/isa-l/erasure_code/gf_vect_dot_prod_avx2.asm.s -o /dev/null
   RESULT_VARIABLE rc
   OUTPUT_QUIET)