Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linking compression libraries could be better #197

Open
psFried opened this issue Jul 6, 2020 · 0 comments
Open

Linking compression libraries could be better #197

psFried opened this issue Jul 6, 2020 · 0 comments

Comments

@psFried
Copy link

psFried commented Jul 6, 2020

Currently, if you want to use rocksdb with compression libraries, you need to set the CGO_LDFLAGS environment variable. Since the order of linker args matters, you need to also specify -lrocksdb or -l:librocksdb.a as part of that, or else linking will fail due to missing compression symbols. At the end of the day, we're left with a situation where you can sometimes rely on cgo comments and build tags to specify linker args, and sometimes not. #167 and #174 removed the compression libraries from the cgo comments because they were unconditional and thus would cause linker failures if you weren't using them.

I'm proposing to add the linker args for compression back into the relevant files, but with tags to make them only used conditionally. So for example go build -t static,z,snappy would use the static linker args and also add the linker args -l:libz.a -l:libsnappy.a using cgo comments like #cgo snappy LDFLAGS: -l:libsnappy.a. These could be put into the proper order in the files, which would allow users of the library to use whatever features they want by only specifying build tags and not needing to set CGO_LDFLAGS at all.

I'd be willing to put up a PR with these changes if that idea sounds good to everyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant