Skip to content
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

Re-enable wasm32-unknown-emscripten target. #840

Merged
merged 2 commits into from
Jun 24, 2022
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ jobs:
- { target: x86_64-linux-android, os: ubuntu-latest, cpp: 1, std: 1, run: 1, runners: qemu-user }
- { target: x86_64-pc-windows-gnu, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
- { target: i686-pc-windows-gnu, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
# Disabled for now, see https://github.com/rust-lang/rust/issues/85821
# Disabled for now, see https://github.com/rust-lang/rust/issues/98216
#- { target: asmjs-unknown-emscripten, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
#- { target: wasm32-unknown-emscripten, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
- { target: wasm32-unknown-emscripten, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
- { target: x86_64-unknown-dragonfly, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, build-std: 1 }
- { target: i686-unknown-freebsd, os: ubuntu-latest, dylib: 1, std: 1 }
- { target: x86_64-unknown-freebsd, os: ubuntu-latest, dylib: 1, std: 1 }
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,24 +355,24 @@ terminate.
| `riscv64gc-unknown-linux-gnu` | 2.27 | 7.5.0 | ✓ | 6.1.0 | ✓ |
| `s390x-unknown-linux-gnu` | 2.23 | 5.4.0 | ✓ | 5.1.0 | ✓ |
| `sparc64-unknown-linux-gnu` | 2.23 | 5.4.0 | ✓ | 5.1.0 | ✓ |
| `sparcv9-sun-solaris` | 1.22.7 | 8.4.0 | ✓ | N/A | |
| `thumbv6m-none-eabi` [4] | 2.2.0 | 4.9.3 | | N/A | |
| `thumbv7em-none-eabi` [4] | 2.2.0 | 4.9.3 | | N/A | |
| `thumbv7em-none-eabihf` [4] | 2.2.0 | 4.9.3 | | N/A | |
| `thumbv7m-none-eabi` [4] | 2.2.0 | 4.9.3 | | N/A | |
| `thumbv7neon-linux-androideabi` [1] | 9.0.8 | 9.0.8 | ✓ | 6.1.0 | ✓ |
| `thumbv7neon-unknown-linux-gnueabihf`| 2.23 | 5.4.0 | ✓ | 5.1.0 | ✓ |
| `wasm32-unknown-emscripten` [6] | 3.1.10 | 15.0.0 | ✓ | N/A | ✓ |
| `x86_64-linux-android` [1] | 9.0.8 | 9.0.8 | ✓ | 6.1.0 | ✓ |
| `x86_64-pc-windows-gnu` | N/A | 7.3 | ✓ | N/A | ✓ |
| `x86_64-sun-solaris` | 1.22.7 | 8.4.0 | ✓ | N/A | |
| `x86_64-unknown-freebsd` | 1.5 | 6.4.0 | ✓ | N/A | |
| `x86_64-unknown-dragonfly` [2] [3] | 6.0.1 | 5.3.0 | ✓ | N/A | |
| `x86_64-unknown-linux-gnu` | 2.23 | 5.4.0 | ✓ | 5.1.0 | ✓ |
| `x86_64-unknown-linux-gnu:centos` [5] | 2.17 | 4.8.5 | ✓ | 4.2.1 | ✓ |
| `x86_64-unknown-linux-musl` | 1.1.24 | 9.2.0 | ✓ | N/A | ✓ |
| `x86_64-unknown-netbsd` [3] | 9.2.0 | 9.4.0 | ✓ | N/A | |
<!--| `asmjs-unknown-emscripten` [6] | 1.2.2 | 3.1.10 | ✓ | N/A | ✓ |-->
<!--| `wasm32-unknown-emscripten` [6] | 1.2.2 | 3.1.10 | ✓ | N/A | ✓ |-->
<!--| `sparcv9-sun-solaris` [3] | 2.11 | 5.3.0 | ✓ | N/A | |-->
<!--| `x86_64-sun-solaris` [3] | 2.11 | 5.3.0 | ✓ | N/A | |-->
<!--| `asmjs-unknown-emscripten` [7] | 1.2.2 | 3.1.10 | ✓ | N/A | ✓ |-->

[1] libc = bionic; Only works with native tests, that is, tests that do not depends on the
Android Runtime. For i686 some tests may fails with the error `assertion
Expand All @@ -389,8 +389,10 @@ terminate.

[5] Must change `image = "x86_64-unknown-linux-gnu:main-centos"` in `Cross.toml` for `[target.x86_64-unknown-linux-gnu]` to use the CentOS7-compatible target.

<!--[6] libc = musl, gcc = emcc. The Docker images for these targets are currently not built automatically
due to a [compiler bug](https://github.com/rust-lang/rust/issues/85821), you will have to build them yourself for now.-->
[6] libc = emscripten and GCC = clang

<!--[7] libc = emscripten and GCC = clang. The Docker images for these targets are currently not built automatically
due to a [compiler bug](https://github.com/rust-lang/rust/issues/98216), you will have to build them yourself for now.-->

Additional Dockerfiles for other targets can be found in [cross-toolchains](https://github.com/cross-rs/cross-toolchains).

Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile.wasm32-unknown-emscripten
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
python

ENV CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_RUNNER=node \
BINDGEN_EXTRA_CLANG_ARGS_wasm32_unknown_emscripten="--sysroot=/emsdk/upstream/emscripten/cache/sysroot"
BINDGEN_EXTRA_CLANG_ARGS_wasm32_unknown_emscripten="--sysroot=/emsdk/upstream/emscripten/cache/sysroot" \
EMCC_CFLAGS="-s ERROR_ON_UNDEFINED_SYMBOLS=0 --no-entry ${EMCC_CFLAGS}"
78 changes: 77 additions & 1 deletion xtask/src/target_info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,48 @@ max_glibc_version() {
echo "${major}.${minor}"
}

max_solaris_libc_version() {
# solaris libc versions have the following format:
# 67: 0000000000000000 0 OBJECT GLOBAL DEFAULT ABS SUNW_1.21.1
local major=0
local minor=0
local patch=0
local version
local x
local y
local z
local is_larger

for version in "${@}"; do
x=$(echo "${version}" | cut -d '.' -f 1)
y=$(echo "${version}" | cut -d '.' -f 2)
z=$(echo "${version}" | cut -d '.' -f 3)
is_larger=

if [ "${x}" -gt "${major}" ]; then
is_larger=1
elif [ "${x}" -eq "${major}" ] && [ "${y}" -gt "${minor}" ]; then
is_larger=1
elif [ -z "${patch}" ]; then
is_larger=1
elif [ -n "${z}" ] && [ "${x}" -eq "${major}" ] && [ "${y}" -eq "${minor}" ] && [ "${z}" -gt "${patch}" ]; then
is_larger=1
fi

if [ -n "${is_larger}" ]; then
major="${x}"
minor="${y}"
patch="${z}"
fi
done

result="${major}.${minor}"
if [ -n "${patch}" ]; then
result="${result}.${patch}"
fi
echo "${result}"
}

readelf_all() {
# weirdly, readelf -a can produce a non-zero error code.
set +e
Expand Down Expand Up @@ -104,6 +146,12 @@ case "${target}" in
*-*-dragonfly)
cc_regex=".*gcc \(GCC\) ([0-9]+.[0-9]+.[0-9]+).*"
;;
*-*-solaris)
cc_regex=".*gcc \(GCC\) ([0-9]+.[0-9]+.[0-9]+).*"
;;
*-*-emscripten)
cc_regex="clang version ([0-9]+.[0-9]+.[0-9]+).*"
;;
*-none-*)
cc_regex=".*gcc \(.*\) ([0-9]+.[0-9]+.[0-9]+).*"
;;
Expand Down Expand Up @@ -150,11 +198,14 @@ case "${target}" in
cc_bin=arm-none-eabi-gcc
cxx_bin=arm-none-eabi-g++
;;
*-*-emscripten)
cc_bin="${EMSDK}/upstream/bin/clang"
cxx_bin="${cc_bin}"
;;
*)
cc_bin="${!cc_var}"
cxx_bin="${!cxx_var}"
;;

esac
cc=$(extract_regex_version "${cc_bin}" "${cc_regex}" compiler)
if command -v "${cxx_bin}" &>/dev/null; then
Expand All @@ -169,6 +220,12 @@ EOT
if [[ "${target}" == *-none-* ]]; then
cxx_flags=("${cxx_flags[@]}" "-nostartfiles")
fi
if [[ "${target}" == *-*-emscripten ]]; then
# need to switch to the real c++ compiler here, not the wrapper
cxx_bin=emcc
# shellcheck disable=SC2206
cxx_flags=($EMCC_CFLAGS)
fi
if "${cxx_bin}" "${cxx_flags[@]}" main.cc >/dev/null 2>&1; then
cxx=1
fi
Expand Down Expand Up @@ -287,6 +344,25 @@ case "${target}" in
exit 1
fi
;;
*-*-solaris)
# we can read the libc version from the libc symbols
# first, we need to use our compiler name to get the libdir
# 67: 0000000000000000 0 OBJECT GLOBAL DEFAULT ABS SUNW_1.21.1
# there will be many of these, so we want to grab the highest one.
prefix="${cc_bin//-gcc/}"
libdir="/usr/local/${prefix}/lib"
lines=$(readelf_all "${libdir}"/libc.so | grep 'ABS SUNW_')
lines=$(echo "${lines}" | grep -o 'ABS .*')
# shellcheck disable=SC2207
libc_versions=($(echo "$lines" | cut -d ' ' -f 2 | cut -d '_' -f 2))
libc=$(max_solaris_libc_version "${libc_versions[@]}")
;;
*-*-emscripten)
# we want the emsdk version, which is the image version
libc_cmd=emcc
libc_regex="emcc \(.* GNU ld) ([0-9]+.[0-9]+.[0-9]+).*"
libc=$(extract_regex_version "${libc_cmd}" "${libc_regex}" libc)
;;
thumb*-none-eabi* | arm*-none-eabi*)
# newlib kinda sucks. just query for the install package
pkg=$(dpkg --get-selections | grep -v deinstall | grep newlib | head -n 1)
Expand Down