confluentinc / confluent-kafka-go

Confluent's Apache Kafka Golang client
Apache License 2.0
4.66k stars 658 forks source link

impossible to link statically with custom librdkafka #565

Open man0xff opened 4 years ago

man0xff commented 4 years ago

Description

Precompiled librdkafka bundle depends on particular version of glibc. If I have no ability to update glibc the common practice is to build library from source code and link it with an application. This can be done with '-tags dynamic'. But this doesn't allow to link statically. BTW, there was such ability in the past (before this commit 4e1fb798f5823007c179818a5c8c9c0830132a5f).

Checklist

edenhill commented 4 years ago

What's your use-case for linking a custom librdkafka library?

man0xff commented 4 years ago

I need to build and run application under CentOS 6, but building with provided bundle ends with errors:

(.text+0x66a3): undefined reference to `timespec_get'
(.text+0x1): undefined reference to `secure_getenv'
gshanemiller commented 3 years ago

I am in the same box. I thought this was fixed as per

https://github.com/edenhill/librdkafka/issues/2461

but somehow the go's standardly shipped .a files here still refers to timespec_get. Indeed running nm on the enclosed. a files gives timespec_get as 'U'. I haven't even gotten into secure_getenv yet. I hope importing a customized librdkafka.a isn't a 10yr 4 Phd project (nuget/README.md) to work around this. In fact shipping a static .a seems ill-conceived. The default should be to use librdkafka pre-installed.

I worked around this by using an internally provisioned version of this lib.

ottaviohartman commented 3 years ago

My use case for this is building librdkafka for ARM and linking statically. It would be also be awesome to include ARM libraries in this project.

Maleandr commented 3 years ago

Same here. We want to use ARM instances as well.

joaosa commented 2 years ago

Same usecase here. This would be incredibly useful 👍

edenhill commented 2 years ago

It should be fairly straight forward to make build_..go files that match on a static_external tag that links librdkafka-static.a from a system location rather then librdkafka_vendor.