Closed demangejeremy closed 1 year ago
@demangejeremy Does the following Dockerfile diff (for container2wasm v0.5.1 and without --target-arch=arm
) solve the build error?
$ c2w --show-dockerfile > /tmp/org-dockerfile
$ cat <<'EOF' > /tmp/dockerfile.diff
--- a/Dockerfile
+++ b/Dockerfile
@@ -328,13 +328,13 @@ RUN mkdir -p /out/usr/share/udhcpc/ && cp ./examples/udhcp/simple.script /out/us
FROM golang-base AS runc-amd64-dev
ARG RUNC_VERSION
-RUN apt-get update -y && apt-get install -y git make gperf
+RUN apt-get update -y && apt-get install -y gcc-x86-64-linux-gnu libc-dev-amd64-cross git make gperf
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
git clone https://github.com/opencontainers/runc.git /go/src/github.com/opencontainers/runc && \
cd /go/src/github.com/opencontainers/runc && \
git checkout "${RUNC_VERSION}" && \
- make static GOARCH=amd64 CC=gcc EXTRA_LDFLAGS='-s -w' BUILDTAGS="" EXTRA_LDFLAGS='-s -w' BUILDTAGS="" && \
+ make static GOARCH=amd64 CC=x86_64-linux-gnu-gcc EXTRA_LDFLAGS='-s -w' BUILDTAGS="" EXTRA_LDFLAGS='-s -w' BUILDTAGS="" && \
mkdir -p /out/ && mv runc /out/runc
FROM gcc-x86-64-linux-gnu-base AS tini-amd64-dev
EOF
$ patch -o /tmp/new-dockerfile /tmp/org-dockerfile /tmp/dockerfile.diff
$ c2w --dockerfile /tmp/new-dockerfile alpine:3.18 /tmp/out/out.wasm
Thank you @ktock.
With version v0.5.1 and the proposed patch, it still doesn't work. Here's the error:
...
#43 [runc-amd64-dev 1/2] RUN apt-get update -y && apt-get install -y gcc-x86-64-linux-gnu libc-dev-amd64-cross git make gperf
#43 0.537 Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]
#43 0.570 Get:2 http://deb.debian.org/debian-security bullseye-security InRelease [48.4 kB]
#43 0.587 Get:3 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]
#43 0.721 Get:4 http://deb.debian.org/debian bullseye/main arm64 Packages [7951 kB]
#43 0.885 Get:5 http://deb.debian.org/debian-security bullseye-security/main arm64 Packages [250 kB]
#43 CANCELED
#34 [bochs-dev-common 4/25] RUN curl -o wasi-sdk.tar.gz -fSL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz && tar xvf wasi-sdk.tar.gz && rm wasi-sdk.tar.gz
#34 CANCELED
------
> [bios-amd64-dev 5/7] RUN CC="x86_64-linux-gnu-gcc" ./configure --enable-x86-64 --with-nogui:
0.732 checking build system type... aarch64-unknown-linux-gnu
0.772 checking host system type... aarch64-unknown-linux-gnu
0.774 checking target system type... aarch64-unknown-linux-gnu
0.775 checking if you are configuring for another platform... no
0.775 checking for standard CFLAGS on this platform...
0.785 checking for gcc... x86_64-linux-gnu-gcc
0.835 checking whether the C compiler works... no
0.850 configure: error: in `/Bochs/bochs':
0.851 configure: error: C compiler cannot create executables
0.851 See `config.log' for more details
------
new-dockerfile:370
--------------------
368 | COPY --link --from=assets ./patches/bochs/Bochs /Bochs
369 | WORKDIR /Bochs/bochs
370 | >>> RUN CC="x86_64-linux-gnu-gcc" ./configure --enable-x86-64 --with-nogui
371 | RUN make -j$(nproc) bios/BIOS-bochs-latest bios/VGABIOS-lgpl-latest
372 | RUN mkdir /out/ && mv bios/BIOS-bochs-latest bios/VGABIOS-lgpl-latest /out/
--------------------
ERROR: failed to solve: process "/bin/sh -c CC=\"x86_64-linux-gnu-gcc\" ./configure --enable-x86-64 --with-nogui" did not complete successfully: exit code: 77
exit status 1
Thanks again for your time. For my part, I tried a few tests (activation of new features in docker desktop, tried with Orbstack, no positive results yet).
@demangejeremy Thanks for trying that. The errors seem to be caused by the architecture difference. What do you get from the following Dockerfile diff?
$ c2w --show-dockerfile > /tmp/org-dockerfile
$ cat <<'EOF' > /tmp/dockerfile.diff
--- a/Dockerfile
+++ b/Dockerfile
@@ -328,13 +328,13 @@ RUN mkdir -p /out/usr/share/udhcpc/ && cp ./examples/udhcp/simple.script /out/us
FROM golang-base AS runc-amd64-dev
ARG RUNC_VERSION
-RUN apt-get update -y && apt-get install -y git make gperf
+RUN apt-get update -y && apt-get install -y gcc-x86-64-linux-gnu libc-dev-amd64-cross git make gperf
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
git clone https://github.com/opencontainers/runc.git /go/src/github.com/opencontainers/runc && \
cd /go/src/github.com/opencontainers/runc && \
git checkout "${RUNC_VERSION}" && \
- make static GOARCH=amd64 CC=gcc EXTRA_LDFLAGS='-s -w' BUILDTAGS="" EXTRA_LDFLAGS='-s -w' BUILDTAGS="" && \
+ make static GOARCH=amd64 CC=x86_64-linux-gnu-gcc EXTRA_LDFLAGS='-s -w' BUILDTAGS="" EXTRA_LDFLAGS='-s -w' BUILDTAGS="" && \
mkdir -p /out/ && mv runc /out/runc
FROM gcc-x86-64-linux-gnu-base AS tini-amd64-dev
@@ -363,7 +363,7 @@ COPY --link --from=assets ./patches/bochs/grub.cfg.template /
RUN cat /grub.cfg.template | LOGLEVEL=$LINUX_LOGLEVEL envsubst > /iso/boot/grub/grub.cfg
RUN mkdir /out && grub-mkrescue --directory ./grub-core -o /out/boot.iso /iso
-FROM ubuntu AS bios-amd64-dev
+FROM gcc-x86-64-linux-gnu-base AS bios-amd64-dev
RUN apt-get update && apt-get install -y build-essential
COPY --link --from=assets ./patches/bochs/Bochs /Bochs
WORKDIR /Bochs/bochs
EOF
$ patch -o /tmp/new-dockerfile /tmp/org-dockerfile /tmp/dockerfile.diff
$ c2w --dockerfile /tmp/new-dockerfile alpine:3.18 /tmp/out/out.wasm
I get exactly the same error as above. I'm not a specialist, but could this be related? : https://github.com/docker/roadmap/issues/384
I also tried this: https://github.com/messense/homebrew-macos-cross-toolchains
No results either :/
@demangejeremy Sorry for the slow reply. I believe #155 fixed this issue. Please try the latest commit in the main branch.
I'm trying to run c2w on Mac M1. Here are the errors I get:
c2w ubuntu:22.04 out.wasm
This gives me this error:
And with a target arm :
c2w --target-arch=arm ubuntu:22.04 out.wasm
This gives me this error:
This doesn't work with other containers (like Python, for example).
If you have any idea how to solve this problem, I'd love to hear from you. I'm trying to find a solution myself, and if I do, I'll update this page.
Many thanks :)