From c8acf766d82e3e5f17b04e0cef2db7fd306f8548 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Tue, 26 Sep 2023 14:04:47 +0100 Subject: [PATCH] Compile cdef public functions from torch_allocator with C ABI (#1350) Since Cython 3, we must explicitly request a C ABI with `-DCYTHON_EXTERN_C='extern "C"'` for `cdef public` functions. - Closes #1349 Before: ``` $ nm -D .../rmm/python/rmm/_lib/torch_allocator.cpython-310-x86_64-linux-gnu.so | grep allocate 00000000000071c0 T _Z10deallocatePvlS_ 0000000000007500 T _Z8allocateliPv ... ``` After: ``` $ nm -D .../rmm/python/rmm/_lib/torch_allocator.cpython-310-x86_64-linux-gnu.so | grep allocate 0000000000007500 T allocate 00000000000071c0 T deallocate ... ``` Authors: - Lawrence Mitchell (https://github.com/wence-) Approvers: - Ashwin Srinath (https://github.com/shwina) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1350 --- python/rmm/_lib/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/rmm/_lib/CMakeLists.txt b/python/rmm/_lib/CMakeLists.txt index 9e90d7e99..61caa0e7e 100644 --- a/python/rmm/_lib/CMakeLists.txt +++ b/python/rmm/_lib/CMakeLists.txt @@ -19,3 +19,5 @@ set(linked_libraries rmm::rmm) # Build all of the Cython targets rapids_cython_create_modules(SOURCE_FILES "${cython_sources}" LINKED_LIBRARIES "${linked_libraries}" CXX) +# The cdef public functions in this file need to have a C ABI +target_compile_definitions(torch_allocator PRIVATE CYTHON_EXTERN_C=extern\ "C")