viig99 / SymSpellCppPy

Fast SymSpell written in c++ and exposes to python via pybind11
https://symspellcpppy.readthedocs.io
Apache License 2.0
39 stars 7 forks source link

Add -ffat-lto-objects compile option #14

Closed marcoffee closed 2 years ago

marcoffee commented 2 years ago

Recently, I started using lld as the default linker for my applications. It is a very faster replacement for the default gold linker, included at the binutils package.

After first compilation using lld as the linker, this package started giving ImportErrors such as this one:

ImportError: dynamic module does not define module export function (PyInit_SymSpellCppPy)

This error can be reproduced by installing lld and adding the following line before target_compile_options (currently, line 28) on CMakeLists.txt:

target_link_options(SymSpellCppPy PRIVATE -fuse-ld=lld)

After playing a little with the compilation flags, it seems that adding the flag -ffat-lto-objects to target_compile_options on CMakeLists.txt fixes the problem.

This pull request addresses this issue, while keeping backward compatibility with other linkers.