Skip to content

Don't panic if WASI_SDK_PATH not set when detecting compiler #143752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/bootstrap/src/utils/cc_detect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,19 @@ fn default_compiler(
}

t if t.contains("-wasi") => {
let root = build
.wasi_sdk_path
.as_ref()
.expect("WASI_SDK_PATH mut be configured for a -wasi target");
let root = build.wasi_sdk_path.as_ref();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the WASI SDK path is missing here, let's just print a warning like "WARNING: WASI_SDK_PATH is not configured, falling back to default C/C++ compiler". If we're on CI (build.config.is_running_on_ci), then panic instead with the original error message.

The case where both the SDK and the root are missing should be handled elsewhere in bootstrap, not here, and it is already handled when copying compiler artifacts, so I think it should be fine.

if root.is_none() {
let cfg = build.config.target_config.get(&target).unwrap();
cfg.wasi_root.as_ref().expect(
"WASI_SDK_PATH or <target>.wasi_root must be configured for a -wasi target",
);
return None;
}
let compiler = match compiler {
Language::C => format!("{t}-clang"),
Language::CPlusPlus => format!("{t}-clang++"),
};
let compiler = root.join("bin").join(compiler);
let compiler = root.unwrap().join("bin").join(compiler);
Some(compiler)
}

Expand Down
Loading