From: Kefu Chai Date: Mon, 22 Oct 2018 04:28:01 +0000 (+0800) Subject: cmake: pass cflags to disutils using CC instead of CFLAGS X-Git-Tag: v14.1.0~1119^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=38e7686a37373e993210b0c6554d52e281d95c19;p=ceph.git cmake: pass cflags to disutils using CC instead of CFLAGS 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 --- diff --git a/cmake/modules/Distutils.cmake b/cmake/modules/Distutils.cmake index 2cd7ff369ae4..69519a7316a4 100644 --- a/cmake/modules/Distutils.cmake +++ b/cmake/modules/Distutils.cmake @@ -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}