I’m using the OpenFHE library in my project development, but I’m encountering very slow linking times. This happens regardless of whether I use ld, gold, or lld. Has anyone experienced this and found ways to solve or improve the linking speed?
@yuucyf If you mean the time you need to build OpenFHE, you can improve the time by simply adding these arguments to CMake if you don’t need to build benchmarks, unit tests or examples:
-DBUILD_BENCHMARKS=OFF -DBUILD_UNITTESTS=OFF -DBUILD_EXAMPLES=OFF
and also fully utilize your CPU cores:
make -j$(nproc)
I meant not that building OpenFHE is slow, but that the linking process is very slow when using the OpenFHE library.
e.g.: g++ -std=c++17 -O2 xxx.cpp -lOPENFHEcore -lOPENFHEpke
@yuucyf
OpenFHE may cause longer link times since it’s a large, heavily templated C++ library with many headers that instantiate templates.
In most cases, users don’t run into major link time issues for their apps, but if heavy (or multiple) OpenFHE headers are included across multiple files, the linker may have more work to do.
Using shared libraries (.so
) instead of static (.a
) usually helps in those cases; however, the improvement still depends on code organization, even when using lld
or gold
.
I am using shared libraries for easier testing. My code is extremely simple—it just includes the OpenFHE headers and performs one fhe multiplication operation. Yet the compilation and linking process takes nearly 45 seconds.
@yuucyf I’m using a pretty simple Dell laptop with 32GB RAM and Ubuntu 24. And at the moment, I have 27 Firefox windows open.
I built an executable from a simple file (src/pke/examples/simple-integers.cpp, which you also have access to) against OpenFHE which was previously built and installed. The average build time didn’t exceed 7–8 seconds.
@dsuponitskiy-duality My processor is: 13th Gen Intel(R) Core™ i9-13900H 2.60 GHz, with 32GB RAM and an Ubuntu 22.04 system. When compiling the same file (src/pke/examples/simple-integers.cpp) to generate an executable, the average build time exceeds 40 s.