-
Notifications
You must be signed in to change notification settings - Fork 185
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
Dockerfiles: Improve cross building. #1941
Conversation
Before this commit, it was not possible to build francis-arm64-vm@francis-arm64-vmvm:~/inspektor-gadget$ lscpu | head -1
Architecture: aarch64
francis-arm64-vm@francis-arm64-vmvm:~/inspektor-gadget$ git branch
francis/cross-building
* main
francis-arm64-vm@francis-arm64-vmvm:~/inspektor-gadget$
francis-arm64-vm@francis-arm64-vmvm:~/inspektor-gadget$ make ig-linux-amd64
...
=> ERROR [builder 7/7] RUN export CGO_ENABLED=1 ; if [ "amd64" = 'arm64' ] ; then export CC=aarch64-linux-gnu-gcc ; export PKG_CONFIG_PATH=/usr/lib/aarch64- 10.4s
------
> [builder 7/7] RUN export CGO_ENABLED=1 ; if [ "amd64" = 'arm64' ] ; then export CC=aarch64-linux-gnu-gcc ; export PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig ; fi ; GOOS=linux GOARCH=amd64 go build -ldflags "-X main.version=v0.19.0-19-gf34d53e8 -extldflags '-static'" -o ig-linux-amd64 github.com/inspektor-gadget/inspektor-gadget/cmd/ig:
2.965 # runtime/cgo
2.965 gcc: error: unrecognized command-line option '-m64'
------
ERROR: failed to solve: executor failed running [/bin/sh -c export CGO_ENABLED=1 ; if [ "${TARGETARCH}" = 'arm64' ] ; then export CC=aarch64-linux-gnu-gcc ; export PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig ; fi ; GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags "-X main.version=${VERSION} -extldflags '-static'" -o ig-${TARGETOS}-${TARGETARCH} github.com/inspektor-gadget/inspektor-gadget/cmd/ig]: exit code: 1
make: *** [Makefile:98: ig-linux-amd64] Error 1 It is now possible:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
One comment is that ig-tests.Dockerfile
also has a condition based on arm64
. So maybe there we should also support arm64
->amd64
compiling aswell to be aligned?
Previously to this commit, it was possible to cross build the images from amd64 to arm64. With this commit, cross building can now be done in any direction: 1. From amd64 to arm64. 2. From arm64 to amd64. Signed-off-by: Francis Laniel <flaniel@linux.microsoft.com>
e272531
to
837625d
Compare
Good catch! I added the same logic there! I will just check the result on AKS and ARO before merging. |
Everything is green, let's merge it! |
Previously to this commit, it was possible to cross build the images from amd64 to arm64.
With this commit, cross building can now be done in any direction: