Cross compiling for GOARCH=arm int overflow

following issues when compiling for 32 bit arch:

../../go/pkg/mod/github.com/dgraph-io/ristretto@v0.0.4-0.20201007164332-9739cfa2564b/z/buffer.go:73:35: constant 274877906944 overflows int
../../go/pkg/mod/github.com/dgraph-io/badger/v2@v2.0.1-rc1.0.20201007220711-3b5f17cee813/y/bloom.go:122:35: constant 3332679571 overflows int

First i fixed with math.MaxInt32 (Uint32 also overflowed).

We use the constant 256<<30 to initialize the buffer size in ristretto.

In Go, the size of int defaults to the word size of a machine. So on a 32 bit ARM machine, int would be 32 bits. It’s clear that 256 <<30 overflows that.

The fix should be architecture specific files containing architecture specific constants. So, this is a bug. I’m filing as a bug.

Tagging @martinmr

Related Issues (Badger): Fix badger builds on 32 bit machines

Any news on this issue?

Hey @maddie, we haven’t started working on this. This looks like a simple fix. Feel free to send a PR for it.

@maddie This issue has been resolved now.
See fix(build): fix build on non-amd64 architectures by NamanJain8 · Pull Request #238 · dgraph-io/ristretto · GitHub and fix(build): fix 32-bit build by NamanJain8 · Pull Request #1627 · dgraph-io/badger · GitHub
Thanks @jawr for reporting.