Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 63db26f

Browse files
committedMar 3, 2025
fix(bootstrap): change compiler detection to clang
1 parent 4c129c0 commit 63db26f

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed
 

‎src/bootstrap/src/core/sanity.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,9 @@ than building it.
319319
&& (build.config.optimized_compiler_builtins(*target)
320320
|| build.config.rust_std_features.contains("compiler-builtins-c"))
321321
{
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");
322+
let is_clang = is_clang_compiler(build.cc(*target), build);
323+
if !is_clang {
324+
panic!("only clang supports building c code for wasm targets");
325325
}
326326
}
327327

@@ -388,7 +388,15 @@ $ pacman -R cmake && pacman -S mingw-w64-x86_64-cmake
388388
}
389389
}
390390

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")
391+
/// checks if the compiler at `path` is clang by looking at defined macros
392+
fn is_clang_compiler(path: PathBuf, build: &Build) -> bool {
393+
let cc_output = command(&path)
394+
.arg("-E") // preprocess only
395+
.arg("-dM") // dump defines
396+
.arg("-x")
397+
.arg("c")
398+
.arg("/dev/null")
399+
.run_capture_stdout(build)
400+
.stdout();
401+
cc_output.contains("#define __clang__ 1")
394402
}

0 commit comments

Comments
 (0)
Failed to load comments.