From: Kefu Chai Date: Sun, 2 Apr 2017 17:32:18 +0000 (+0800) Subject: crc32c,compressor: only compile functions on supported arch X-Git-Tag: v12.0.2~209^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7f2ac2334ae72abeb353af9c0dfc52a9a49780f0;p=ceph.git crc32c,compressor: only compile functions on supported arch so we can still compile if certain header file () used for detecting cpu capabilities on ppc is missing on x86 host machine. Signed-off-by: Kefu Chai --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 49e2e25a893..69401efc062 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -290,12 +290,6 @@ configure_file( ${CMAKE_BINARY_DIR}/src/include/ceph_ver.h @ONLY) -set(arch_files - arch/arm.c - arch/intel.c - arch/ppc.c - arch/probe.cc) - set(auth_files auth/AuthAuthorizeHandler.cc auth/AuthClientHandler.cc @@ -516,9 +510,16 @@ set(libcommon_files common/fs_types.cc common/dns_resolve.cc common/hostname.cc - ${arch_files} + arch/probe.cc ${auth_files} ${mds_files}) +if(HAVE_ARM) + list(APPEND libcommon_files arch/arm.c) +elseif(HAVE_INTEL) + list(APPEND libcommon_files arch/intel.c) +elseif(HAVE_POWER8) + list(APPEND libcommon_files arch/ppc.c) +endif() if(LINUX) list(APPEND libcommon_files msg/async/EventEpoll.cc) message(STATUS " Using EventEpoll for events.") diff --git a/src/arch/probe.cc b/src/arch/probe.cc index 42aabae4ebe..52b913b1b57 100644 --- a/src/arch/probe.cc +++ b/src/arch/probe.cc @@ -11,11 +11,13 @@ int ceph_arch_probe(void) { if (ceph_arch_probed) return 1; - +#if defined(__i386__) || defined(__x86_64__) ceph_arch_intel_probe(); +#elif defined(__arm__) || defined(__aarch64__) ceph_arch_arm_probe(); +#elif defined(__powerpc__) || defined(__ppc__) ceph_arch_ppc_probe(); - +#endif ceph_arch_probed = 1; return 1; } diff --git a/src/common/crc32c.cc b/src/common/crc32c.cc index edcaaf69091..5e857abb89b 100644 --- a/src/common/crc32c.cc +++ b/src/common/crc32c.cc @@ -24,18 +24,19 @@ ceph_crc32c_func_t ceph_choose_crc32(void) // if the CPU supports it, *and* the fast version is compiled in, // use that. +#if defined(__i386__) || defined(__x86_64__) if (ceph_arch_intel_sse42 && ceph_crc32c_intel_fast_exists()) { return ceph_crc32c_intel_fast; } - +#elif defined(__arm__) || defined(__aarch64__) if (ceph_arch_aarch64_crc32){ return ceph_crc32c_aarch64; } - +#elif defined(__powerpc__) || defined(__ppc__) if (ceph_arch_ppc_crc32) { return ceph_crc32c_ppc; } - +#endif // default return ceph_crc32c_sctp; } diff --git a/src/compressor/zlib/CompressionPluginZlib.h b/src/compressor/zlib/CompressionPluginZlib.h index b27ec87104f..5716e417d22 100644 --- a/src/compressor/zlib/CompressionPluginZlib.h +++ b/src/compressor/zlib/CompressionPluginZlib.h @@ -35,6 +35,7 @@ public: int factory(CompressorRef *cs, std::ostream *ss) override { +#if defined(__i386__) || defined(__x86_64__) bool isal; if (cct->_conf->compressor_zlib_isal) { ceph_arch_probe(); @@ -46,6 +47,7 @@ public: compressor = std::make_shared(isal); has_isal = isal; } +#endif *cs = compressor; return 0; } diff --git a/src/test/common/test_crc32c.cc b/src/test/common/test_crc32c.cc index 93bdd4385e6..562ba84a31d 100644 --- a/src/test/common/test_crc32c.cc +++ b/src/test/common/test_crc32c.cc @@ -81,6 +81,7 @@ TEST(Crc32c, Performance) { std::cout << "intel baseline = " << rate << " MB/sec" << std::endl; ASSERT_EQ(261108528u, val); } +#if defined(__arm__) || defined(__aarch64__) if (ceph_arch_aarch64_crc32) // Skip if CRC32C instructions are not defined. { utime_t start = ceph_clock_now(); @@ -90,7 +91,7 @@ TEST(Crc32c, Performance) { std::cout << "aarch64 = " << rate << " MB/sec" << std::endl; ASSERT_EQ(261108528u, val); } - +#endif }