dgraph-io / ristretto

A high performance memory-bound Go cache
https://dgraph.io/blog/post/introducing-ristretto-high-perf-go-cache/
Apache License 2.0
5.54k stars 364 forks source link

Unable to override LDFLAGS to point to different jemalloc lib path #383

Open bnp007 opened 2 months ago

bnp007 commented 2 months ago

Have you tried Ristretto before this proposal? and did not find anything similar?

None

What you wanted to do.

Comment or remove #cgo LDFLAGS: line so that go install/build will use CGO_LDFLAGS.

What you actually did.

I have a package A that uses https://github.com/open-policy-agent/opa which internally uses https://github.com/dgraph-io/badger which then uses https://github.com/dgraph-io/ristretto.

A -> https://github.com/open-policy-agent/opa -> https://github.com/dgraph-io/badger ->https://github.com/dgraph-io/ristretto

https://github.com/dgraph-io/ristretto.Z has 2 files z.calloc_nojemalloc and z.calloc_jemalloc . right now when I build package A we are not passing any tag which causes dgraph-io/ristretto to use default calloc implementation. now we want to use jemalloc and thus to enable we need to pass -tags=jemalloc which will build that z.calloc_jemalloc.

z.jemalloc_calloc.go has hardcoded path on how to get libraries once jemalloc is installed (https://github.com/dgraph-io/ristretto/blob/main/z/calloc_jemalloc.go#L10-L12). Since installing jemalloc requires sudo permission as part of ./configure --install-with-prefix=_je, our build system cannot have permission to install and put files under /usr/local/lib. Hence we tried multiple options to use CGO-FLAGS that can override the hardcoded path but it is not getting overriden.

Why wasn't it great, with examples.

No response

Additional information.

No response

github-actions[bot] commented 4 days ago

This issue has been stale for 60 days and will be closed automatically in 7 days. Comment to keep it open.