]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: pass cflags to disutils using CC instead of CFLAGS
authorKefu Chai <kchai@redhat.com>
Mon, 22 Oct 2018 04:28:01 +0000 (12:28 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 22 Oct 2018 06:40:03 +0000 (14:40 +0800)
in python's distutils.ccompiler, linker_exe is composed using CC instead
of LDFLAGS. the latter only effects how it builds (shared) library.

and put CMAKE_C_FLAGS into the cflags for the compiler for building
python C extensions, it's more consistent this way. more importantly,
if we build with ASan enabled, the canary program, a.k.a. rados_dummy.c,
won't link without proper CFLAGS.

without this change, rados.so fails to build with errors like:

/usr/bin/ld: /var/ssd/ceph/build/lib/librados.so: undefined reference to
`__asan_stack_free_10'
/usr/bin/ld: /var/ssd/ceph/build/lib/librados.so: undefined reference to
`__asan_report_exp_store8'
...
...

clang: error: linker command failed with exit code 1 (use -v to see
invocation)

Link Error: RADOS library not found
make[3]: ***
[src/pybind/rados/CMakeFiles/cython_rados.dir/build.make:57:
src/pybind/rados/CMakeFiles/cython_rados] Error 1

Signed-off-by: Kefu Chai <kchai@redhat.com>
cmake/modules/Distutils.cmake

index 2cd7ff369ae4475c9ca32903155a8fe625b88075..69519a7316a4b511e739fda062f650b92e9a4722 100644 (file)
@@ -45,7 +45,9 @@ function(distutils_add_cython_module name src)
   string(STRIP "${CMAKE_CXX_COMPILER_ARG1}" cxx_compiler_arg1)
   # Note: no quotes, otherwise distutils will execute "/usr/bin/ccache gcc"
   # CMake's implicit conversion between strings and lists is wonderful, isn't it?
-  set(PY_CC ${compiler_launcher} ${CMAKE_C_COMPILER} ${c_compiler_arg1})
+  string(REPLACE " " ";" cflags ${CMAKE_C_FLAGS})
+  list(APPEND cflags -iquote${CMAKE_SOURCE_DIR}/src/include -w)
+  set(PY_CC ${compiler_launcher} ${CMAKE_C_COMPILER} ${c_compiler_arg1} ${cflags})
   set(PY_CXX ${compiler_launcher} ${CMAKE_CXX_COMPILER} ${cxx_compiler_arg1})
   set(PY_LDSHARED ${link_launcher} ${CMAKE_C_COMPILER} ${c_compiler_arg1} "-shared")
   add_custom_target(${name} ALL
@@ -58,7 +60,6 @@ function(distutils_add_cython_module name src)
     LDFLAGS=-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
     CYTHON_BUILD_DIR=${CMAKE_CURRENT_BINARY_DIR}
     CEPH_LIBDIR=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
-    CFLAGS=\"-iquote${CMAKE_SOURCE_DIR}/src/include -w\"
     ${PYTHON${PYTHON_VERSION}_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/setup.py
     build --verbose --build-base ${CYTHON_MODULE_DIR}
     --build-platlib ${CYTHON_MODULE_DIR}/lib.${PYTHON${PYTHON_VERSION}_VERSION_MAJOR}