Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile fails on 32-bit ARM architecture #488

Open
gregoryleblanc opened this issue Apr 28, 2022 · 2 comments
Open

Compile fails on 32-bit ARM architecture #488

gregoryleblanc opened this issue Apr 28, 2022 · 2 comments

Comments

@gregoryleblanc
Copy link

grafana support sent me an email telling me that my v4 instance will be upgraded to v5, so I am trying to build a new version of carbon-relay-ng (first installed/updated around a year ago).

I can't get carbon-relay-ng to build on a 32-bit raspbian OS. I'm getting the following output at build time:

$ make
cd ui/web && go-bindata -pkg web admin_http_assets/...
find . -name '*.go' | grep -v '^\.\/vendor' | xargs gofmt -w -s
CGO_ENABLED=0 go build -ldflags "-X main.Version=1.2-1-g375f430" ./cmd/carbon-relay-ng
# github.com/grafana/metrictank/util
../../../../pkg/mod/github.com/grafana/metrictank@v1.0.1-0.20210114150051-52835b9a8775/util/flag_parsers.go:32:27: math.MaxUint32 (untyped int constant 4294967295) overflows int
make: *** [Makefile:7: build] Error 2
$

My go version is:
$ go version go version go1.18.1 linux/arm

uname information:
$ uname -a Linux raspberrypi 5.10.52-v7+ #1441 SMP Tue Aug 3 18:10:09 BST 2021 armv7l GNU/Linux

I also tried building metrictank pulled from git, but it returns the same error. I don't think that line in metrictank has been changed in years, so maybe I'm barking up the wrong tree.

@stefan-walluhn
Copy link

Since the underlying project is archived, I don't expect to see any fix for this issue. So this is for anyone stumbling across this: The bug resides within these lines of code: https://github.com/grafana/metrictank/blob/6d15fe1d382fa6a48a3d3f006a4b25dccb5d1952/util/flag_parsers.go#L28-L34

The value for orgID is parsed into a signed integer by Atoi. While integers on 64bit platforms are large enough to hold uint32, this is not the case on 32bit platforms. The maximum value of uint32 fits into a signed int64, but not into a signed int32.

The fix would be to replace line 28 in flag_parsers.go linked above:

orgID, err := strconv.ParseUint(parts[0], 10, 32)

Patching the file locally may be a workaround to build this project on 32bit RaspberryPi. I was able to compile after patching.

@stefan-walluhn
Copy link

...just to see it crashing right after launch. There are tons of atomic 64bit operations within this source code, so I don't think this will ever run on 32bit platforms: https://github.com/search?q=repo%3Agrafana%2Fcarbon-relay-ng%20atomic&type=code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants