]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: remove cython 0.29's subinterpreter check
authorTim Serong <tserong@suse.com>
Mon, 17 Dec 2018 11:01:25 +0000 (22:01 +1100)
committerNathan Cutler <ncutler@suse.com>
Thu, 11 Jul 2019 08:47:45 +0000 (10:47 +0200)
cython 0.29 introduced a check which prevents multiple python
subinterpreters from loading the same module:

https://github.com/cython/cython/commit/7e27c7c

Unfortunately, this completely breaks ceph-mgr.  Until we can
figure out a better long term solution, this commit removes
cython's subinterpreter check, via some careful abuse of the
C preprocessor.

This works because when cython is invoked, it first generates
some C code, then compiles it.  We know it's going to generate
C code including:

  int __Pyx_check_single_interpreter(void) { ... }

and:

  if (__Pyx_check_single_interpreter())
      return NULL;

So, we can do the following:

  #define void0 dead_function(void)
  #define __Pyx_check_single_interpreter(ARG)=ARG ## 0

This replaces the call to __Pyx_check_single_interpreter()
with a literal 0, removing the subinterpreter check.

The void0 dead_function(void) thing is necessary because
the __Pyx_check_single_interpreter() macro also clobbers
that function definition, so we need to make sure it's
replaced with something that works as a function definition.

Fixes: https://tracker.ceph.com/issues/37472
Signed-off-by: Tim Serong <tserong@suse.com>
(cherry picked from commit 3bde34af8a84d76744887b2cf10ee4ef36e3925b)

Conflicts:
cmake/modules/Distutils.cmake
- mimic doesn't have the immediately preceding ccache stuff

cmake/modules/Distutils.cmake

index d6e9f3817c3d7a235cb6f15881a97eba318e0728..19de89f97f25ce432fa0ca08c1d4826e9cd0017e 100644 (file)
@@ -34,6 +34,9 @@ endfunction(distutils_install_module)
 function(distutils_add_cython_module name src)
   get_property(compiler_launcher GLOBAL PROPERTY RULE_LAUNCH_COMPILE)
   get_property(link_launcher GLOBAL PROPERTY RULE_LAUNCH_LINK)
+  # This little bit of magic wipes out __Pyx_check_single_interpreter()
+  list(APPEND cflags -D'void0=dead_function\(void\)')
+  list(APPEND cflags -D'__Pyx_check_single_interpreter\(ARG\)=ARG \#\# 0')
   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\")