Thanks

We need absl only for  protobuf  and grpc. Right now  we plan to build abls 
static  libraries and link the same files to both protobuf  and  grpc. When 
this  will not work  we  can try building shared libarary.

Adam

piątek, 16 czerwca 2023 o 19:04:02 UTC+2 Mike Kruskal napisał(a):

> Hey Adam,
>
> You can try to set `POSITION_INDEPENDENT_CODE` in the Abseil build.  That 
> should at least get around the error you're seeing here.  However, the 
> reason we don't explicitly support this is because in many situations it's 
> an ODR violation.  If two shared libraries both use Abseil via static 
> linkage, there will be two definitions of absl.  Assuming they're both 
> identical, this isn't a problem in most of the absl code.  However, when it 
> comes to things like the hash seed you can end up breaking every hash table 
> in very difficult to debug ways.  I think the only way this could work is 
> if none of the other shared libraries (and the code that's using them) were 
> using Abseil, and you don't need protoc (which also uses Abseil).
>
> That seems like a pretty brittle requirement to place on anyone, and I 
> think a feature request for Abseil to ship a single shared library might be 
> a better approach.  They already do this for windows, but not on linux or 
> mac.
>
> -Mike
>
> On Friday, June 16, 2023 at 2:59:43 AM UTC-7 Adam Dembek wrote:
>
>> We want to use shared libprotobuf.so for many tools to not increase size 
>> of each binary. 
>> We know we can build protobuf with -Dprotobuf_BUILD_SHARED_LIBS=ON 
>> -Dprotobuf_INSTALL_SUPPORTED_FROM_MODULE=ON -Dprotobuf_ABSL_PROVIDER=module 
>> but then both protobuf and absl are build as shared library.
>> We need to deliver over 80 libraries.  It would easier if we could only 
>> deliver single libprotobuf.so file like in the past when protobuf was not 
>> using absl. 
>>
>> Is it possible to use static absl libraies and link it libprotobuf.so ? 
>> I tried firts build abls independentlay with
>>
>> cmake -S ${ABSL_SOURCE} -B ${ABSL_PROD_DIR} 
>> -DCMAKE_PREFIX_PATH=${ABSL_PROD_DIR} 
>> -DCMAKE_INSTALL_PREFIX=${ABSL_PROD_DIR} -DABSL_ENABLE_INSTALL=ON 
>> -DABSL_USE_EXTERNAL_GOOGLETEST=OFF -DABSL_FIND_GOOGLETEST=OFF
>>
>> This created static absl libraries.
>>
>> And then build protobuf  with 
>>  -DCMAKE_PREFIX_PATH=${ABSL_PROD_DIR}/lib64/cmake/absl 
>> -Dprotobuf_ABSL_PROVIDER=package-DCMAKE_CXX_STANDARD=14 
>> -Dprotobuf_BUILD_SHARED_LIBS=ON 
>>
>> But it fails  with 
>>
>> [ 36%] Linking CXX shared library libprotobuf.so
>> /usr/bin/ld: 
>> /user/adembek/PROD/absl/build/absl_2023_01_25/lib64/libabsl_cord.a(cord.cc.o):
>>  
>> relocation R_X86_64_32 against `.rodata' can not be used when making a 
>> shared object; recompile with -fPIC
>> /usr/bin/ld: 
>> /user/adembek/PROD/absl/build/absl_2023_01_25/lib64/libabsl_cord.a(cord_analysis.cc.o):
>>  
>> relocation R_X86_64_32 against `.rodata' can not be used when making a 
>> shared object; recompile with -fPIC
>> /usr/bin/ld: 
>> /user/adembek/PROD/absl/build/absl_2023_01_25/lib64/libabsl_die_if_null.a(die_if_null.cc.o):
>>  
>> relocation R_X86_64_32 against `.rodata' can not be used when making a 
>> shared object; recompile with -fPIC
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/199dfedb-71ce-47b1-975d-2e4b9c63f303n%40googlegroups.com.

Reply via email to