Post

exec format error is never what you think it is

Building JuiceFS and GeeseFS on ARM64. GLIBC versions, CGO, arch detection, and why exec format error is never what you think.

Oracle’s free tier gives you four ARM cores and 24GB of RAM, which is a good deal. I moved a storage stack onto it. Then I spent a day finding out which of my dependencies had ever been built for ARM.

I hit three failures with three different causes.

exec format error on a binary that exists. The file is there, it’s executable, and the kernel refuses it. That means the binary is for a different architecture. Usually you pulled an image without checking its platform. Or a Dockerfile did curl on a release URL with linux-amd64 hardcoded in the path. Check with file. ls only tells you the file exists.

GLIBC version mismatch. The binary is ARM, and it still won’t run. It was built against a newer GLIBC than the base image ships. Debian Bullseye has 2.31. Something compiled on a current Ubuntu wants 2.35 and will say so. You can build in the same image family you deploy to, use a static build, or move the base image forward.

CGO. Go cross-compiles cleanly until a dependency needs C. Then you need a C toolchain for the target architecture. JuiceFS and GeeseFS both bind to native code. CGO_ENABLED=0 gets you a build and silently drops the feature you wanted.

Two things made the rest easier.

Pin your base images by digest. Bitnami moves tags around, and one of my pinned tags 404’d a month later.

Do the platform check in CI. docker buildx will tell you what you produced.

This post is licensed under CC BY 4.0 by the author.