]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crc32c,compressor: only compile functions on supported arch
authorKefu Chai <kchai@redhat.com>
Sun, 2 Apr 2017 17:32:18 +0000 (01:32 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 4 Apr 2017 03:38:29 +0000 (11:38 +0800)
so we can still compile if certain header file (<sys/auxv.h>) used
for detecting cpu capabilities on ppc is missing on x86 host machine.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/CMakeLists.txt
src/arch/probe.cc
src/common/crc32c.cc
src/compressor/zlib/CompressionPluginZlib.h
src/test/common/test_crc32c.cc

index 49e2e25a893fb561029346459bca47203c4ea6ad..69401efc062bffe7464f28e7a9bcf031e2fb403f 100644 (file)
@@ -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.")
index 42aabae4ebe4525f75041c52d1fe833093bbfd56..52b913b1b57e33838516e6430f2d67bdee5d6e18 100644 (file)
@@ -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;
 }
index edcaaf690914c5b6aeee2c80fb73a9e5cfbd2960..5e857abb89b1fef7c9d89c98c913a3d83f4ec07a 100644 (file)
@@ -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;
 }
index b27ec87104f563279904c4f474621a6b2d40fdfc..5716e417d22080a89f7ec8f8d1d9170dfc669884 100644 (file)
@@ -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<ZlibCompressor>(isal);
       has_isal = isal;
     }
+#endif
     *cs = compressor;
     return 0;
   }
index 93bdd4385e68a07df59e8e9cacb68b144164d1d1..562ba84a31d5212c19ad9b47b0773e2bf71e231e 100644 (file)
@@ -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
 }