Skip to content

Linking compression libraries could be better #197

@psFried

Description

@psFried

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions