Skip to content

Commit 7804d94

Browse files
committed
fix: wasm-bare targets compiling x86 builtins
Added sanity check to bootstrap to hard error on wasm builds without clang, and changed distribution image `dist-various-2` to use clang to build for official targets.
1 parent c65dcca commit 7804d94

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/bootstrap/src/core/sanity.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,17 @@ than building it.
328328
.entry(*target)
329329
.or_insert_with(|| Target::from_triple(&target.triple));
330330

331+
// compiler-rt c fallbacks for wasm cannot be built with gcc
332+
if target.contains("wasm") // bare metal targets without wasi sdk
333+
&& (build.config.optimized_compiler_builtins(*target)
334+
|| build.config.rust_std_features.contains("compiler-builtins-c"))
335+
{
336+
let is_clang = build.cc_tool(*target).is_like_clang();
337+
if !is_clang {
338+
panic!("only clang supports building c code for wasm targets");
339+
}
340+
}
341+
331342
if (target.contains("-none-") || target.contains("nvptx"))
332343
&& build.no_std(*target) == Some(false)
333344
{

src/ci/docker/host-x86_64/dist-various-2/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ ENV \
5959
CXX_i686_unknown_uefi=clang++-11 \
6060
CC_x86_64_unknown_uefi=clang-11 \
6161
CXX_x86_64_unknown_uefi=clang++-11 \
62+
CC_wasm32_unknown_unknown=clang-11 \
63+
CXX_wasm32_unknown_unknown=clang++-11 \
64+
CC_wasm32v1_none=clang-11 \
65+
CXX_wasm32v1_none=clang++-11 \
6266
CC=gcc-9 \
6367
CXX=g++-9
6468

src/ci/docker/host-x86_64/test-various/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ ARG DEBIAN_FRONTEND=noninteractive
44
RUN apt-get update && apt-get install -y --no-install-recommends \
55
clang-11 \
66
llvm-11 \
7+
gcc-multilib \
78
g++ \
89
make \
910
ninja-build \
@@ -59,8 +60,8 @@ RUN curl -L https://github.com/bytecodealliance/wasmtime/releases/download/v19.0
5960
tar -xJ
6061
ENV PATH "$PATH:/wasmtime-v19.0.0-x86_64-linux"
6162

62-
ENV WASM_TARGETS=wasm32-wasip1
63-
ENV WASM_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $WASM_TARGETS \
63+
ENV WASM_WASIP_TARGET=wasm32-wasip1
64+
ENV WASM_WASIP_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $WASM_WASIP_TARGET \
6465
tests/run-make \
6566
tests/ui \
6667
tests/mir-opt \
@@ -90,4 +91,4 @@ ENV UEFI_TARGETS=aarch64-unknown-uefi,i686-unknown-uefi,x86_64-unknown-uefi \
9091
ENV UEFI_SCRIPT python3 /checkout/x.py --stage 2 build --host='' --target $UEFI_TARGETS && \
9192
python3 -u /uefi_qemu_test/run.py
9293

93-
ENV SCRIPT $WASM_SCRIPT && $NVPTX_SCRIPT && $MUSL_SCRIPT && $UEFI_SCRIPT
94+
ENV SCRIPT $WASM_WASIP_SCRIPT && $NVPTX_SCRIPT && $MUSL_SCRIPT && $UEFI_SCRIPT

0 commit comments

Comments
 (0)