Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f624850

Browse files
committed
fix(bootstrap): hard error with GCC on bare WASM builds with c
1 parent 28b83ee commit f624850

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/bootstrap/src/core/sanity.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,17 @@ than building it.
314314
.entry(*target)
315315
.or_insert_with(|| Target::from_triple(&target.triple));
316316

317+
// compiler-rt c fallbacks for wasm cannot be built with gcc
318+
if (target.triple == "wasm32-unknown-unknown" || target.triple == "wasm32v1-none") // bare metal targets without wasi sdk
319+
&& (build.config.optimized_compiler_builtins(*target)
320+
|| build.config.rust_std_features.contains("compiler-builtins-c"))
321+
{
322+
let is_gcc = is_gcc_compiler(build.cc(*target), build);
323+
if is_gcc {
324+
panic!("GCC does not support building c code for bare wasm");
325+
}
326+
}
327+
317328
if (target.contains("-none-") || target.contains("nvptx"))
318329
&& build.no_std(*target) == Some(false)
319330
{
@@ -376,3 +387,8 @@ $ pacman -R cmake && pacman -S mingw-w64-x86_64-cmake
376387
cmd_finder.must_have(s);
377388
}
378389
}
390+
391+
fn is_gcc_compiler(path: PathBuf, build: &Build) -> bool {
392+
let cc_output = command(&path).arg("--version").run_capture_stdout(build).stdout();
393+
cc_output.contains("GCC")
394+
}

0 commit comments

Comments
 (0)