I coerced Cython to use clang by specifying the CC environment variable:
import os
os.environ['CC'] = 'clang'
I have a standard build:
EXT_MODULES = [Extension('example.src.ex',
sources=['example/src/ex.pyx'])]
setup_info = dist(
...
ext_modules=cythonize(EXT_MODULES,
compiler_directives={'language_level': '3'}),
...
)
setup(**setup_info)
However it seems like Cython is somehow using both clang and gcc in different parts of the build step, in particular it's using gcc to build the shared libraries:
running build_ext
building 'example.src.ex' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/example
creating build/temp.linux-x86_64-3.8/example/src
clang -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/local/include/python3.8 -c example/src/ex.c -o build/temp.linux-x86_64-3.8/example/src/ex.o
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/example
creating build/lib.linux-x86_64-3.8/example/src
gcc -shared -Wl,--strip-all build/temp.linux-x86_64-3.8/example/src/ex.o -L/usr/local/lib -o build/lib.linux-x86_64-3.8/example/src/ex.cpython-38-x86_64-linux-gnu.so
How do I get Cython to use clang on both steps?
I realized distutils needs an override of the linker as well