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 faddfc1

Browse files
committedMar 10, 2025
feat(bootstrap): update wasm sanity check to use cc::Tool::is_like_clang
1 parent f04c929 commit faddfc1

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed
 

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

+1-15
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ than building it.
319319
&& (build.config.optimized_compiler_builtins(*target)
320320
|| build.config.rust_std_features.contains("compiler-builtins-c"))
321321
{
322-
let is_clang = is_clang_compiler(build.cc(*target), build);
322+
let is_clang = build.cc_tool(*target).is_like_clang();
323323
if !is_clang {
324324
panic!("only clang supports building c code for wasm targets");
325325
}
@@ -387,17 +387,3 @@ $ pacman -R cmake && pacman -S mingw-w64-x86_64-cmake
387387
cmd_finder.must_have(s);
388388
}
389389
}
390-
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-
.allow_failure()
395-
.arg("-E") // preprocess only
396-
.arg("-dM") // dump defines
397-
.arg("-x")
398-
.arg("c")
399-
.arg("/dev/null")
400-
.run_capture_stdout(build)
401-
.stdout();
402-
cc_output.contains("#define __clang__ 1")
403-
}

‎src/bootstrap/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use std::{env, fs, io, str};
2727

2828
use build_helper::ci::gha;
2929
use build_helper::exit;
30+
use cc::Tool;
3031
use termcolor::{ColorChoice, StandardStream, WriteColor};
3132
use utils::build_stamp::BuildStamp;
3233
use utils::channel::GitInfo;
@@ -1198,6 +1199,11 @@ Executed at: {executed_at}"#,
11981199
self.cc.borrow()[&target].path().into()
11991200
}
12001201

1202+
/// Returns the internal `cc::Tool`
1203+
fn cc_tool(&self, target: TargetSelection) -> Tool {
1204+
self.cc.borrow()[&target].clone()
1205+
}
1206+
12011207
/// Returns C flags that `cc-rs` thinks should be enabled for the
12021208
/// specified target by default.
12031209
fn cc_handled_clags(&self, target: TargetSelection, c: CLang) -> Vec<String> {

0 commit comments

Comments
 (0)
Failed to load comments.