New cxx_library 'static_pic_lib' option not properly supported
Created by: voznesenskym
I am working on upgrading our BUCK to the latest version, and when making a prebuilt_cxx_library, the static_pic_lib command does not work properly.
Example:
prebuilt_cxx_library ( name = 'icu', static_pic_lib = 'linux/x86/libicu/libicuuc.a', exported_deps = [ ':icuuc_headers', ], header_namespace = '', visibility = [ 'PUBLIC' ], )
Context This lib is included with other libs into a top level static pic library. However, when I attempt to link it into a shared library with -fPIC flags (for JNI), it tells me that the generated library is invalid and that I should recompile with -fPIC.
Investigation This means that the static_pic_lib command does not actually do anything, it just makes a static_lib.
I decided to dig into the BUCK source code to find the issue, and it appears as though everything is wired up under the hood, except the getStaticPicLibrary method in AbstractNewPrebuiltCxxLibraryPaths never gets called.
This is because of line 740 in CxxDescriptionEnhancer, args.getLinkStyle().orElse(Linker.LinkableDepType.STATIC),
basically forces any cxx_prebuilt_library to be static. The args.getLinkStyle() it checks (CxxBinaryDescription.CommonArg) always seems to return null and does not even appear to be implemented.
Solution? Changing line 740 mentioned above to force a Linker.LinkableDepType.STATIC_PIC does work. This means everything is indeed wired up properly under the hood, there just needs to be some resolution at wherever we parse the BUCK files.
I plan to have a fix up in the next few days, but wanted to open this issue up as soon as I found it.