Skip to content

Commit b859fbd

Browse files
author
Paul Murphy
committed
Don't always panic if WASI_SDK_PATH is not set when detecting compiler
If <target>.wasi-root is set, don't panic. It may be the case the default compiler is sufficient or not needed. This is the case when packaging wasm targets on fedora today.
1 parent 25cf7d1 commit b859fbd

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/bootstrap/src/utils/cc_detect.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,19 @@ fn default_compiler(
221221
}
222222

223223
t if t.contains("-wasi") => {
224-
let root = build
225-
.wasi_sdk_path
226-
.as_ref()
227-
.expect("WASI_SDK_PATH mut be configured for a -wasi target");
224+
let root = build.wasi_sdk_path.as_ref();
225+
if root.is_none() {
226+
let cfg = build.config.target_config.get(&target).unwrap();
227+
cfg.wasi_root.as_ref().expect(
228+
"WASI_SDK_PATH or <target>.wasi_root must be configured for a -wasi target",
229+
);
230+
return None;
231+
}
228232
let compiler = match compiler {
229233
Language::C => format!("{t}-clang"),
230234
Language::CPlusPlus => format!("{t}-clang++"),
231235
};
232-
let compiler = root.join("bin").join(compiler);
236+
let compiler = root.unwrap().join("bin").join(compiler);
233237
Some(compiler)
234238
}
235239

0 commit comments

Comments
 (0)