nginx / unit

NGINX Unit - universal web app server - a lightweight and versatile open source server that simplifies the application stack by natively executing application code across eight different programming language runtimes.
https://unit.nginx.org
Apache License 2.0
5.37k stars 323 forks source link

Building Containers for amd64 on ARM instances fails #1353

Closed akamoroz closed 2 months ago

akamoroz commented 3 months ago

Steps to Reproduce:

  1. Use any ARM instance: Mac M chips, Hetzner Cloud ARM, or Oracle ARM.
  2. Run docker buildx build --platform=linux/arm64/v8,linux/amd64 --no-cache -f Dockerfile.python3.11 .
  3. Observe the segmentation fault:
#9 188.8    src/njs_md5.c
#9 190.6 cc -c -pipe -fPIC -fvisibility=hidden -O -W -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wmissing-prototypes -Werror -g -fexcess-precision=standard -O    \
#9 190.6    -Isrc -Ibuild -Injs \
#9 190.6    -o build/src/njs_sha1.o \
#9 190.6    -MMD -MF build/src/njs_sha1.dep -MT build/src/njs_sha1.o \
#9 190.6    src/njs_sha1.c
#9 191.8 cc -c -pipe -fPIC -fvisibility=hidden -O -W -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wmissing-prototypes -Werror -g -fexcess-precision=standard -O    \
#9 191.8    -Isrc -Ibuild -Injs \
#9 191.8    -o build/src/njs_sha2.o \
#9 191.8    -MMD -MF build/src/njs_sha2.dep -MT build/src/njs_sha2.o \
#9 191.8    src/njs_sha2.c
#9 191.8 cc -c -pipe -fPIC -fvisibility=hidden -O -W -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wmissing-prototypes -Werror -g -fexcess-precision=standard -O    \
#9 191.8    -Isrc -Ibuild -Injs \
#9 191.8    -o build/src/njs_time.o \
#9 191.8    -MMD -MF build/src/njs_time.dep -MT build/src/njs_time.o \
#9 191.8    src/njs_time.c
#9 192.1 cc: internal compiler error: Segmentation fault signal terminated program cc1

Building containers on amd64 instances (even for ARM) works just fine.

ac000 commented 3 months ago

Nice! The compiler broke!

What version of Clang or GCC are you using?

akamoroz commented 3 months ago

I've used gcc-12 12.2.0 arm64 from debian bookworm main repo.

ac000 commented 3 months ago

That version of GCC is nearly two years old. Has there not been any update for it?

thresheek commented 2 months ago

Hi @akamoroz long time no see!

I don't think we can do anything about this issue, to be honest, as compiler issues when launched through an emulation layer arent exactly something to be fixed in our code or images...

ac000 commented 2 months ago

Yeah, I'm going to close this.

GCC 12.2.0 is a couple of years old and arm64 is relatively new and you're doing something which probably isn't that well trodden.

If current versions of GCC and/or Clang still barf on it, then it's perhaps worth while submitting bugs to GCC/Clang, though they will likely want minimal reproducers...

I'm assuming this code has been successfully compiled many times before with a variety of compilers without warnings/errors on both arm64 and x86_64.

(Out of interest, does using --platform=linux/arm64,linux/amd64, dropping the /v8, make any difference?)