facebook / CacheLib

Pluggable in-process caching engine to build and scale high performance services

Home Page:https://www.cachelib.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can cachelib compile and produce a static library to replace a pile of dynamic libraries?

GavinMar opened this issue · comments

commented
How can cachelib compile and produce a static library to replace a pile of dynamic libraries?

Hi . Quickly checking the build outputs on my development machine, it looks like the cachelib libraries are all built as the static libraries. Instead, all other dependent libraries are being built as the shared library, so I think you are referring to those dependent libraries including libfolly and libthrift. Is that right?

$ ls opt/cachelib/lib/libcachelib*
opt/cachelib/lib/libcachelib_allocator.a  opt/cachelib/lib/libcachelib_common.a  opt/cachelib/lib/libcachelib_datatype.a  opt/cachelib/lib/libcachelib_navy.a  opt/cachelib/lib/libcachelib_shm.a

Is this question related to #162? (Sorry for the delay; it seems that we have not followed this up)

@agordon It seems like they are struggling with importing the cachelib in their build system. Is there anything we can help here?

commented

Hi . Quickly checking the build outputs on my development machine, it looks like the cachelib libraries are all built as the static libraries. Instead, all other dependent libraries are being built as the shared library, so I think you are referring to those dependent libraries including libfolly and libthrift. Is that right?

$ ls opt/cachelib/lib/libcachelib*
opt/cachelib/lib/libcachelib_allocator.a  opt/cachelib/lib/libcachelib_common.a  opt/cachelib/lib/libcachelib_datatype.a  opt/cachelib/lib/libcachelib_navy.a  opt/cachelib/lib/libcachelib_shm.a

Is this question related to #162? (Sorry for the delay; it seems that we have not followed this up)

@agordon It seems like they are struggling with importing the cachelib in their build system. Is there anything we can help here?

Thank you for your reply. Yes, I mean the other dependent libraries. Because cachelib build takes a long time, and if we want to build it on centos7, some system libraries also need to be updated manually. We choose to import cachelib output directly to our project. But we need to copy lots of dynamic dependent library together, which makes our project output complex and affects portability. In the other hand, the cachelib build output contains many local absolute file path, especially in pkgconfig and cmake files, which makes it difficult to be used in other machines only if creating the same path. So, Is it possible to compile cachelib and its dependency into a static library and use it directly in other projects?

I think you meant statically linking all dependent libraries with cachelib as a single static library. I feel this might not be a right choice, but the dynamic linking is more appropriate. However, I am not familiar with this topic, so let me get back to you after some discussion with other folks. (CC @agordon)

commented

I think you meant statically linking all dependent libraries with cachelib as a single static library. I feel this might not be a right choice, but the dynamic linking is more appropriate. However, I am not familiar with this topic, so let me get back to you after some discussion with other folks. (CC @agordon)

OK, thanks a lot!

I think adding a feature to take the PREFIX parameter in our build script should work. I made a quick fix and uploaded the code here https://github.com/jaesoo-fb/CacheLib.git. Please checkout the branch build_prefix.

After cherry-picking this, you can build the cachelib as follows for example:

$ contrib/build.sh -jO -p /opt/cachelib

@GavinMar Could you confirm if the proposed solution works? I just created a pull request internally #174