In an attempt to speed up the development process, I have been looking to try using either the 'gold' linker or the multithreaded 'lld' linker in place of the GNU linker when compiling some cython extensions. In my setup.py I have tried something like the following:
lld_linker = shutil.which('ld.lld')
if lld_linker:
print("Using LLD Linker in place of GNU LD")
os.environ['LDSHARED'] = lld_linker
However, this causes the linking process to fail with a large number of "/usr/bin/ld: ..... undefined reference to ....." errors. (Build works fine without adding this LDSHARED envvar). The failure behavior is the same whether using this internal os.environ, or exporting the envvar before calling setup.py. I have a hunch that perhaps Cython's multiprocessing approach to distributing compile jobs is not keeping the environment variable everywhere, leading to this mix of linkers?
How can I properly specify the linker, so that the setting sticks and builds the same as with the GNU ld linker?
There is a related question here: How do I specify the linker when building python extensions? ; however, it did not solve my issue, as mentioned earlier.