Building go application with jemalloc errors out

What version of Go are you using (go version)?

$ go version 1.17

What operating system are you using?

Rhel 7

What version of Badger are you using?

v3.2103.2

Does this issue reproduce with the latest master?

yes

Steps to Reproduce the issue

install jemalloc
go run -tags=jemalloc main.go

What Badger options were set?

Default options

What did you do?

go run -tags=jemalloc main.go

What did you expect to see?


What did you see instead?

# github.com/dgraph-io/ristretto/z
vendor/github.com/dgraph-io/ristretto/z/calloc_jemalloc.go:73:9: could not determine kind of name for C.je_calloc
vendor/github.com/dgraph-io/ristretto/z/calloc_jemalloc.go:103:3: could not determine kind of name for C.je_free
vendor/github.com/dgraph-io/ristretto/z/calloc_jemalloc.go:143:2: could not determine kind of name for C.je_mallctl
vendor/github.com/dgraph-io/ristretto/z/calloc_jemalloc.go:170:2: could not determine kind of name for C.je_malloc_stats_print

@Dgraph_Admin any update on this?

@Vishal_Jangid did you get the compilation issue fixed?

I am also facing the same issue but on MacOS.

I was unable to resolve the issue on Rhel 7. I haven’t tried it on MacOS.

Hi Abdul, did you use the makefile in badger to install jemalloc? Try running make badger and let us know what happens. Badger compiles with jemalloc on my MacOS machine.

@Vishal_Jangid I can’t speak personally for RHEL but I’d suggest the same advice to compile with make badger and report back what happens.

Hi @joshua,

I cloned the dgraph-io/badger repository and executed make badger command which resulted in same error:

Compiling Badger binary...
# github.com/dgraph-io/ristretto/z
/go/pkg/mod/github.com/dgraph-io/ristretto@v0.1.1/z/calloc_jemalloc.go:73:9: could not determine kind of name for C.je_calloc
/go/pkg/mod/github.com/dgraph-io/ristretto@v0.1.1/z/calloc_jemalloc.go:103:3: could not determine kind of name for C.je_free
/go/pkg/mod/github.com/dgraph-io/ristretto@v0.1.1/z/calloc_jemalloc.go:143:2: could not determine kind of name for C.je_mallctl
/go/pkg/mod/github.com/dgraph-io/ristretto@v0.1.1/z/calloc_jemalloc.go:170:2: could not determine kind of name for C.je_malloc_stats_print
make[1]: *** [badger] Error 2
make: *** [badger] Error 2

It would be awesome, if you can guide us with the exact steps on how to build DGraph with MacOS and explicitly mention any external dependencies required separately.

Thanks!

Hi @Abdul_Aziz ,

Sorry for the delay. That is interesting - usually this error comes the Cgo preamble being misconfigured (e.g. see here) but it doesn’t look like that is the problem here.

Could you try running go install github.com/dgraph-io/badger/v4/badger@latest? This should also install the Badger CLI. Alternatively, if you want to build the CLI locally, you can try running go build . from the Badger subdirectory.

To be clear, if your goal is to build Dgraph from source, you don’t have to first build Badger, since this is just a CLI for debugging (Badger is an embedded key-value store). Instructions for building Dgraph are in the Dgraph readme.