Skip to content

Commit 8ba144a

Browse files
committed
dockerfiles: Add support for wasm64 to the wasm Dockerfile
This commit fixes Dockerfile of the wasm build to support both of wasm32 and wasm64 build. Dockerfile takes the following build arguments and use these values for building dependencies. - TARGET_CPU: target wasm arch (wasm32 or wasm64) - WASM64_MEMORY64: target -sMEMORY64 mode (1 or 2) Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
1 parent 9271dae commit 8ba144a

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ F: include/system/os-wasm.h
647647
F: os-wasm.c
648648
F: util/coroutine-wasm.c
649649
F: configs/meson/emscripten.txt
650-
F: tests/docker/dockerfiles/emsdk-wasm32-cross.docker
650+
F: tests/docker/dockerfiles/emsdk-wasm-cross.docker
651651

652652
Alpha Machines
653653
--------------

tests/docker/dockerfiles/emsdk-wasm32-cross.docker renamed to tests/docker/dockerfiles/emsdk-wasm-cross.docker

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
# syntax = docker/dockerfile:1.5
22

3-
ARG EMSDK_VERSION_QEMU=3.1.50
3+
ARG EMSDK_VERSION_QEMU=4.0.10
44
ARG ZLIB_VERSION=1.3.1
55
ARG GLIB_MINOR_VERSION=2.84
66
ARG GLIB_VERSION=${GLIB_MINOR_VERSION}.0
77
ARG PIXMAN_VERSION=0.44.2
8-
ARG FFI_VERSION=v3.4.7
8+
ARG FFI_VERSION=v3.5.2
99
ARG MESON_VERSION=1.5.0
10+
ARG TARGET_CPU=wasm32
11+
ARG WASM64_MEMORY64=0
1012

11-
FROM emscripten/emsdk:$EMSDK_VERSION_QEMU AS build-base
13+
FROM emscripten/emsdk:$EMSDK_VERSION_QEMU AS build-base-common
14+
ARG TARGET_CPU
1215
ARG MESON_VERSION
1316
ENV TARGET=/builddeps/target
1417
ENV CPATH="$TARGET/include"
@@ -33,8 +36,8 @@ RUN <<EOF
3336
cat <<EOT > /cross.meson
3437
[host_machine]
3538
system = 'emscripten'
36-
cpu_family = 'wasm32'
37-
cpu = 'wasm32'
39+
cpu_family = '${TARGET_CPU}'
40+
cpu = '${TARGET_CPU}'
3841
endian = 'little'
3942

4043
[binaries]
@@ -46,6 +49,16 @@ pkgconfig = ['pkg-config', '--static']
4649
EOT
4750
EOF
4851

52+
FROM build-base-common AS build-base-wasm32
53+
54+
FROM build-base-common AS build-base-wasm64
55+
ARG WASM64_MEMORY64
56+
ENV CFLAGS="$CFLAGS -sMEMORY64=${WASM64_MEMORY64}"
57+
ENV CXXFLAGS="$CXXLAGS -sMEMORY64=${WASM64_MEMORY64}"
58+
ENV LDFLAGS="$LDFLAGS -sMEMORY64=${WASM64_MEMORY64}"
59+
60+
FROM build-base-${TARGET_CPU} AS build-base
61+
4962
FROM build-base AS zlib-dev
5063
ARG ZLIB_VERSION
5164
RUN mkdir -p /zlib
@@ -56,17 +69,19 @@ RUN emconfigure ./configure --prefix=$TARGET --static
5669
RUN emmake make install -j$(nproc)
5770

5871
FROM build-base AS libffi-dev
72+
ARG TARGET_CPU
73+
ARG WASM64_MEMORY64
5974
ARG FFI_VERSION
6075
RUN mkdir -p /libffi
6176
RUN git clone https://github.com/libffi/libffi /libffi
6277
WORKDIR /libffi
6378
RUN git checkout $FFI_VERSION
6479
RUN autoreconf -fiv
65-
RUN emconfigure ./configure --host=wasm32-unknown-linux \
80+
RUN emconfigure ./configure --host=${TARGET_CPU}-unknown-linux \
6681
--prefix=$TARGET --enable-static \
6782
--disable-shared --disable-dependency-tracking \
6883
--disable-builddir --disable-multi-os-directory \
69-
--disable-raw-api --disable-docs
84+
--disable-raw-api --disable-docs WASM64_MEMORY64=${WASM64_MEMORY64}
7085
RUN emmake make install SUBDIRS='include' -j$(nproc)
7186

7287
FROM build-base AS pixman-dev

0 commit comments

Comments
 (0)