]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: pass RULE_LAUNCHER_* to cython
authorKefu Chai <kchai@redhat.com>
Sun, 10 Apr 2016 14:37:59 +0000 (22:37 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 10 Apr 2016 16:46:31 +0000 (00:46 +0800)
* pass the environment variables using `env` to pass environment
  varibles with space(s) in them to the COMMAND in add_custom_target.
  otherwise, cmake will try to quote the space with "\". this breaks the
  generated command line.
* add a comment for ccache to note that we do not expect ccache to speed
  up linking. we use it as the linker's launcher to workaround
  https://bugs.python.org/issue8027. to be specific,
  distutils.UnixCCompiler.link overwrites the first linker CLI's arg
  using the the first C++ compiler's CLI arg, if "env" is not used to
  launch the linker. this breaks the cythonization of our pybind APIs.

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

index 3391b4294b51c778f7a23e5f24551db8751248fa..b36b682734a1fedd4da237f86a33e1b95c01a5d4 100644 (file)
@@ -25,6 +25,9 @@ if(WITH_CCACHE)
   if(CCACHE_FOUND)
     message(STATUS "Building with ccache: ${CCACHE_FOUND}, CCACHE_DIR=$ENV{CCACHE_DIR}")
     set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
+    # ccache does not accelerate link (ld), but let it handle it. by passing it
+    # along with cc to python's distutils, we are able to workaround
+    # https://bugs.python.org/issue8027.
     set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
   else(CCACHE_FOUND)
     message(FATAL_ERROR "Can't find ccache. Is it installed?")
index 5fbbc7f6518b2c0a78cc5c827f1d53cf713808bd..6a4ba94ebd05b9e73ea0819e7c30e9670d1c1d50 100644 (file)
@@ -1,4 +1,9 @@
 set(CYTHON_MODULE_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cython_modules)
+get_property(compiler_launcher GLOBAL PROPERTY RULE_LAUNCH_COMPILE)
+get_property(link_launcher GLOBAL PROPERTY RULE_LAUNCH_LINK)
+set(PY_CC \"${compiler_launcher} ${CMAKE_C_COMPILER}\")
+set(PY_CXX \"${compiler_launcher} ${CMAKE_CXX_COMPILER}\")
+set(PY_LDSHARED \"${link_launcher} ${CMAKE_C_COMPILER} -shared\")
 
 add_subdirectory(rados)
 add_subdirectory(rbd)
index 91d36ceaa9d5ecfad7a5433c7c5a9d21377b7464..b3f4cf44dc37058cf9b827d94abf2ca575bfbad4 100644 (file)
@@ -1,5 +1,9 @@
 add_custom_target(cython_cephfs
   COMMAND
+  env
+  CC=${PY_CC}
+  CXX=${PY_CXX}
+  LDSHARED=${PY_LDSHARED}
   LDFLAGS=-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
   CYTHON_BUILD_DIR=${CMAKE_BINARY_DIR}/src/pybind/cephfs
   CFLAGS=\"-I${CMAKE_SOURCE_DIR}/src -I${CMAKE_BINARY_DIR}/include -I${CMAKE_SOURCE_DIR}/src/include -std=c++11\"
index 3b2cd38ff38e5cab5d2ee9d7a7b51c6e33adc18a..007ff709555b2ffbbed79de149fd27d9969ab456 100644 (file)
@@ -1,5 +1,9 @@
 add_custom_target(cython_rados
   COMMAND
+  env
+  CC=${PY_CC}
+  CXX=${PY_CXX}
+  LDSHARED=${PY_LDSHARED}
   LDFLAGS=-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
   CYTHON_BUILD_DIR=${CMAKE_BINARY_DIR}/src/pybind/rados
   CFLAGS=\"-I${CMAKE_SOURCE_DIR}/src/include -std=c++11\"
index b5881530e049841020921dbd2e8f4bfd7edff094..6afc639333dd7d271ddcc846f56a53cfbd971026 100644 (file)
@@ -1,5 +1,9 @@
 add_custom_target(cython_rbd
   COMMAND
+  env
+  CC=${PY_CC}
+  CXX=${PY_CXX}
+  LDSHARED=${PY_LDSHARED}
   LDFLAGS=-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
   CYTHON_BUILD_DIR=${CMAKE_BINARY_DIR}/src/pybind/rbd
   CFLAGS=\"-I${CMAKE_SOURCE_DIR}/src/include -std=c++11\"