From d6fdd59c63754c8f6daf6c4768830a2eab977435 Mon Sep 17 00:00:00 2001 From: Kamalalochana Subbaiah Date: Tue, 23 Jan 2018 16:44:09 -0800 Subject: [PATCH] CMake changes for CRC32 Optimization on PowerPC Summary: Closes https://github.com/facebook/rocksdb/pull/2869 Differential Revision: D6791359 Pulled By: ajkr fbshipit-source-id: fdd38df603d84bbcce8d85dd1729d5caa256e6be --- CMakeLists.txt | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a68b16056..1395952c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,9 @@ cmake_minimum_required(VERSION 2.8.12) project(rocksdb) +enable_language(CXX) +enable_language(C) +enable_language(ASM) if(POLICY CMP0042) cmake_policy(SET CMP0042 NEW) @@ -177,6 +180,18 @@ else() endif() endif() +include(CheckCCompilerFlag) +if(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le") + CHECK_C_COMPILER_FLAG("-maltivec" HAS_ALTIVEC) + if(HAS_ALTIVEC) + message(STATUS " HAS_ALTIVEC yes") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maltivec") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maltivec") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=power8") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=power8") + endif(HAS_ALTIVEC) +endif(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le") + option(PORTABLE "build a portable binary" OFF) option(FORCE_SSE42 "force building with SSE4.2, even when PORTABLE=ON" OFF) if(PORTABLE) @@ -189,7 +204,9 @@ else() if(MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") + if(NOT HAVE_POWER8) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") + endif() endif() endif() @@ -625,6 +642,12 @@ set_source_files_properties( endif() endif() +if(HAVE_POWER8) + list(APPEND SOURCES + util/crc32c_ppc.c + util/crc32c_ppc_asm.S) +endif(HAVE_POWER8) + if(WIN32) list(APPEND SOURCES port/win/io_win.cc