Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions .gitlab-ci.d/buildtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -787,11 +787,29 @@ coverity:
# Always manual on forks even if $QEMU_CI == "2"
- when: manual

build-wasm:
build-wasm32:
extends: .wasm_build_job_template
timeout: 2h
needs:
job: wasm-emsdk-cross-container
job: wasm32-emsdk-cross-container
variables:
IMAGE: emsdk-wasm32-cross
CONFIGURE_ARGS: --static --disable-tools --enable-debug --enable-tcg-interpreter
CONFIGURE_ARGS: --static --cpu=wasm32 --disable-tools --enable-debug --enable-tcg-interpreter

build-wasm-wasm64:
extends: .wasm_build_job_template
timeout: 2h
needs:
job: wasm64-emsdk-cross-container
variables:
IMAGE: emsdk-wasm64-cross
CONFIGURE_ARGS: --static --cpu=wasm64 --disable-tools --enable-debug --enable-tcg-interpreter

build-wasm-wasm64l:
extends: .wasm_build_job_template
timeout: 2h
needs:
job: wasm64l-emsdk-cross-container
variables:
IMAGE: emsdk-wasm64l-cross
CONFIGURE_ARGS: --static --cpu=wasm64 --wasm64-32bit-address-limit --disable-tools --enable-debug --enable-tcg-interpreter
18 changes: 17 additions & 1 deletion .gitlab-ci.d/container-cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,23 @@ win64-fedora-cross-container:
variables:
NAME: fedora-win64-cross

wasm-emsdk-cross-container:
wasm32-emsdk-cross-container:
extends: .container_job_template
variables:
NAME: emsdk-wasm32-cross
BUILD_ARGS: --build-arg TARGET_CPU=wasm32
DOCKERFILE: emsdk-wasm-cross

wasm64-emsdk-cross-container:
extends: .container_job_template
variables:
NAME: emsdk-wasm64-cross
BUILD_ARGS: --build-arg TARGET_CPU=wasm64 --build-arg WASM64_MEMORY64=1
DOCKERFILE: emsdk-wasm-cross

wasm64l-emsdk-cross-container:
extends: .container_job_template
variables:
NAME: emsdk-wasm64l-cross
BUILD_ARGS: --build-arg TARGET_CPU=wasm64 --build-arg WASM64_MEMORY64=2
DOCKERFILE: emsdk-wasm-cross
4 changes: 3 additions & 1 deletion .gitlab-ci.d/container-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
- export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/qemu/$NAME:latest"
- docker login $CI_REGISTRY -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
- until docker info; do sleep 1; done
- export DOCKERFILE_NAME=${DOCKERFILE:-$NAME}
script:
- echo "TAG:$TAG"
- echo "COMMON_TAG:$COMMON_TAG"
- docker build --tag "$TAG" --cache-from "$TAG" --cache-from "$COMMON_TAG"
--build-arg BUILDKIT_INLINE_CACHE=1
-f "tests/docker/dockerfiles/$NAME.docker" "."
$BUILD_ARGS
-f "tests/docker/dockerfiles/$DOCKERFILE_NAME.docker" "."
- docker push "$TAG"
after_script:
- docker logout
2 changes: 1 addition & 1 deletion MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ F: include/system/os-wasm.h
F: os-wasm.c
F: util/coroutine-wasm.c
F: configs/meson/emscripten.txt
F: tests/docker/dockerfiles/emsdk-wasm32-cross.docker
F: tests/docker/dockerfiles/emsdk-wasm-cross.docker

Alpha Machines
--------------
Expand Down
16 changes: 15 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ EXTRA_CXXFLAGS=""
EXTRA_OBJCFLAGS=""
EXTRA_LDFLAGS=""

# The value is propagated to Emscripten's "-sMEMORY64" flag.
# https://emscripten.org/docs/tools_reference/settings_reference.html#memory64
wasm64_memory64=1

# Default value for a variable defining feature "foo".
# * foo="no" feature will only be used if --enable-foo arg is given
# * foo="" feature will be searched for, and if found, will be used
Expand Down Expand Up @@ -239,6 +243,8 @@ for opt do
;;
--without-default-features) default_feature="no"
;;
--wasm64-32bit-address-limit) wasm64_memory64="2"
;;
esac
done

Expand Down Expand Up @@ -365,7 +371,6 @@ elif check_define __APPLE__; then
host_os=darwin
elif check_define EMSCRIPTEN ; then
host_os=emscripten
cpu=wasm32
cross_compile="yes"
else
# This is a fatal error, but don't report it yet, because we
Expand Down Expand Up @@ -425,6 +430,8 @@ elif check_define __aarch64__ ; then
cpu="aarch64"
elif check_define __loongarch64 ; then
cpu="loongarch64"
elif check_define EMSCRIPTEN ; then
error_exit "wasm32 or wasm64 must be specified to the cpu flag"
else
# Using uname is really broken, but it is just a fallback for architectures
# that are going to use TCI anyway
Expand Down Expand Up @@ -535,6 +542,9 @@ case "$cpu" in
wasm32)
CPU_CFLAGS="-m32"
;;
wasm64)
CPU_CFLAGS="-m64 -sMEMORY64=$wasm64_memory64"
;;
esac

if test -n "$host_arch" && {
Expand Down Expand Up @@ -791,6 +801,8 @@ for opt do
;;
--disable-rust) rust=disabled
;;
--wasm64-32bit-address-limit)
;;
# everything else has the same name in configure and meson
--*) meson_option_parse "$opt" "$optarg"
;;
Expand Down Expand Up @@ -916,6 +928,8 @@ Advanced options (experts only):
--disable-containers don't use containers for cross-building
--container-engine=TYPE which container engine to use [$container_engine]
--gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
--wasm64-32bit-address-limit Restrict wasm64 address space to 32-bit (default
is to use the whole 64-bit range).
EOF
meson_options_help
cat << EOF
Expand Down
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ qapi_trace_events = []
bsd_oses = ['gnu/kfreebsd', 'freebsd', 'netbsd', 'openbsd', 'dragonfly', 'darwin']
supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux', 'emscripten']
supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv32', 'riscv64', 'x86', 'x86_64',
'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc64', 'wasm32']
'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc64', 'wasm32', 'wasm64']

cpu = host_machine.cpu_family()

Expand Down Expand Up @@ -916,7 +916,7 @@ if have_tcg
if not get_option('tcg_interpreter')
error('Unsupported CPU @0@, try --enable-tcg-interpreter'.format(cpu))
endif
elif host_arch == 'wasm32'
elif host_arch == 'wasm32' or host_arch == 'wasm64'
if not get_option('tcg_interpreter')
error('WebAssembly host requires --enable-tcg-interpreter')
endif
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# syntax = docker/dockerfile:1.5

ARG EMSDK_VERSION_QEMU=3.1.50
ARG EMSDK_VERSION_QEMU=4.0.10
ARG ZLIB_VERSION=1.3.1
ARG GLIB_MINOR_VERSION=2.84
ARG GLIB_VERSION=${GLIB_MINOR_VERSION}.0
ARG PIXMAN_VERSION=0.44.2
ARG FFI_VERSION=v3.4.7
ARG FFI_VERSION=v3.5.2
ARG MESON_VERSION=1.5.0
ARG TARGET_CPU=wasm32
ARG WASM64_MEMORY64=0

FROM emscripten/emsdk:$EMSDK_VERSION_QEMU AS build-base
FROM emscripten/emsdk:$EMSDK_VERSION_QEMU AS build-base-common
ARG TARGET_CPU
ARG MESON_VERSION
ENV TARGET=/builddeps/target
ENV CPATH="$TARGET/include"
Expand All @@ -33,8 +36,8 @@ RUN <<EOF
cat <<EOT > /cross.meson
[host_machine]
system = 'emscripten'
cpu_family = 'wasm32'
cpu = 'wasm32'
cpu_family = '${TARGET_CPU}'
cpu = '${TARGET_CPU}'
endian = 'little'

[binaries]
Expand All @@ -46,6 +49,16 @@ pkgconfig = ['pkg-config', '--static']
EOT
EOF

FROM build-base-common AS build-base-wasm32

FROM build-base-common AS build-base-wasm64
ARG WASM64_MEMORY64
ENV CFLAGS="$CFLAGS -sMEMORY64=${WASM64_MEMORY64}"
ENV CXXFLAGS="$CXXFLAGS -sMEMORY64=${WASM64_MEMORY64}"
ENV LDFLAGS="$LDFLAGS -sMEMORY64=${WASM64_MEMORY64}"

FROM build-base-${TARGET_CPU} AS build-base

FROM build-base AS zlib-dev
ARG ZLIB_VERSION
RUN mkdir -p /zlib
Expand All @@ -56,17 +69,19 @@ RUN emconfigure ./configure --prefix=$TARGET --static
RUN emmake make install -j$(nproc)

FROM build-base AS libffi-dev
ARG TARGET_CPU
ARG WASM64_MEMORY64
ARG FFI_VERSION
RUN mkdir -p /libffi
RUN git clone https://github.com/libffi/libffi /libffi
WORKDIR /libffi
RUN git checkout $FFI_VERSION
RUN autoreconf -fiv
RUN emconfigure ./configure --host=wasm32-unknown-linux \
RUN emconfigure ./configure --host=${TARGET_CPU}-unknown-linux \
--prefix=$TARGET --enable-static \
--disable-shared --disable-dependency-tracking \
--disable-builddir --disable-multi-os-directory \
--disable-raw-api --disable-docs
--disable-raw-api --disable-docs WASM64_MEMORY64=${WASM64_MEMORY64}
RUN emmake make install SUBDIRS='include' -j$(nproc)

FROM build-base AS pixman-dev
Expand Down