Skip to content

Ristretto Jemalloc linking error when running ./tesh.sh #2226

@kianmeng

Description

@kianmeng

Describe the bug

Building projects that depend on dgraph-io/ristretto/v2 (such as dgraph-io/badger/v4 in this case) fails on a standard Ubuntu installation due to a CGO linking error with the jemalloc library, even when libjemalloc-dev is installed.

To Reproduce

Steps to reproduce the behavior:

  1. sudo apt install libjemalloc-dev
  2. git clone https://github.com/hypermodeinc/badger.git
  3. cd badger
  4. ./tesh.sh
  5. See error

Expected behavior

The Ristretto library should compile successfully with the standard go build command when libjemalloc-dev is installed. The CGO configuration should automatically include the required linker flags to resolve the C function symbols.

Screenshots

$ ./test.sh 
go version go1.25.0 linux/amd64
./test.sh: line 8: [: =: unary operator expected
/tmp/badger/badger /tmp/badger
github.com/dgraph-io/ristretto/v2/z
# github.com/dgraph-io/ristretto/v2/z
/home/foobar/go/pkg/mod/github.com/dgraph-io/ristretto/[email protected]/z/calloc_jemalloc.go:74:9: could not determine what C.je_calloc refers to
/home/foobar/go/pkg/mod/github.com/dgraph-io/ristretto/[email protected]/z/calloc_jemalloc.go:104:3: could not determine what C.je_free refers to
/home/foobar/go/pkg/mod/github.com/dgraph-io/ristretto/[email protected]/z/calloc_jemalloc.go:144:2: could not determine what C.je_mallctl refers to
/home/foobar/go/pkg/mod/github.com/dgraph-io/ristretto/[email protected]/z/calloc_jemalloc.go:171:2: could not determine what C.je_malloc_stats_print refers to

Environment

  • OS: Ubuntu 25.04
  • Language: go version go1.25.0 linux/amd64

Additional context

None.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions