-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix querying emcc on windows #4248
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
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @tgross35 (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
build.rs
Outdated
#[cfg(target_os = "windows")] | ||
let output = Command::new("emcc.bat").arg("-dumpversion").output().ok()?; | ||
|
||
#[cfg(not(target_os = "windows"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: could you use if cfg!(target_os = "windows") { ... }
here instead? cfg!(...)
is slightly preferred over #[cfg(...)]
where possible since it allows the code to be checked on all OSs.
Otherwise lgtm, please squash with the change.
Fyi @hoodmane.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied this
Could this go on 0.2 as well once it's merged? |
Cc @messense maybe we want this change in maturin too? |
Done in PyO3/maturin#2478 |
Fyi anyone can add the label, it's just @rustbot label +stable-nominated |
Looks like this needs a rebase, could you do that? |
@rustbot author for the rebase |
build.rs
Outdated
let output = if cfg!(target_os = "windows") { | ||
std::process::Command::new("emcc.bat") | ||
.arg("-dumpversion") | ||
.output() | ||
.ok() | ||
} else { | ||
std::process::Command::new("emcc") | ||
.arg("-dumpversion") | ||
.output() | ||
.ok() | ||
}?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this could be cleaned up a bit, we already have Command
imported and the two commands are identical except for the executable name:
let emcc = if cfg!(target_os = "windows") {
"emcc.bat"
} else {
"emcc"
};
Command::new(emcc).arg("-dumpversion").output()?;
Yeah I will do that when I have a moment. |
Head branch was pushed to by a user without write access
Ah sorry I haven't looked at this in a while. Actually I revised it slightly locally because I realized It doesn't really make sense to silently set version to None in case emcc is not found, so having an error in this case is better I think. It would work something like this
EDIT: so I also added the RUST_LIBC_UNSTABLE_EMCC_VERSION=30142 variable as a workaround for when emscripten is somehow not installed but you're building for it anyways (like in the CI runs) |
Well you updating makes things easier, thanks :) Panicing isn't really an option here unfortunately, we need to just pick a suitable default version. Otherwise that breaks anyone who might be running |
Hmm yeah I see how that could break cargo check (specifically |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates!
I think this is probably unlikely because on machines where this will be linking far enough that it matters, emcc is likely installed. However, if emscripten allows breaking ABI changes at regular releases, it may be worth splitting the target into multiple that have a version differentiator. Currently this is only done for qnx, but we would like to do it for others (like OpenBSD) https://doc.rust-lang.org/nightly/rustc/platform-support.html. |
Pretty minor change, just queries emcc.bat since
emcc
will not work on windowsFor example this simple script will output this on windows