-
Notifications
You must be signed in to change notification settings - Fork 459
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
Failed to cross compile rust-openssl(openssl-src-rs) for windows msvc targets via cross-rs #797
Comments
According to the docs, all Technically |
I'm so sorry. I think my description is wrong. We should use /// Similar to the `find` function above, this function will attempt the same
/// operation (finding a MSVC tool in a local install) but instead returns a
/// `Tool` which may be introspected.
#[cfg(not(windows))]
pub fn find_tool(_target: &str, _tool: &str) -> Option<Tool> {
// print some information for debugging
println!("cargo:warning=target is not windows, but env `CARGO_CFG_TARGET_OS` is {:?}", "", std::env::var("CARGO_CFG_TARGET_OS"));
None
} When I call
But I hope it will follow the code, because it is needed to find the wine and msvc toolchain that I have installed on Ubuntu /// Documented above
#[cfg(windows)]
pub fn find_tool(_target: &str, _tool: &str) -> Option<Tool> {
...
} |
I think |
These will not work either. Note that inside a build script the Anyway, the code inside the Given that the nmake error you mention is in the branch of the code that is for When cross compiling from linux to windows, you must use the |
I see that, despite this, we still cannot compile openssl with the target of msvc on a Linux host. So I have to give up and use Windows image to build openssl. |
It works for me: /// Attempts to find a tool within an MSVC installation using the Windows
/// registry as a point to search from.
///
/// The `target` argument is the target that the tool should work for (e.g.
/// compile or link for) and the `tool` argument is the tool to find (e.g.
/// `cl.exe` or `link.exe`).
///
/// This function will return `None` if the tool could not be found, or it will
/// return `Some(cmd)` which represents a command that's ready to execute the
/// tool with the appropriate environment variables set.
///
/// Note that this function always returns `None` for non-MSVC targets.
pub fn find(target: &str, tool: &str) -> Option<Command> {
// old version:
// find_tool(target, tool).map(|c| c.to_command())
// patch version:
use std::env;
// This logic is all tailored for MSVC, if we're not that then bail out
// early.
if !target.contains("msvc") {
return None;
}
// Early return if it the current target is not a windows target.
if let Ok(target) = env::var("CARGO_CFG_TARGET_FAMILY") {
if target != "windows" {
return None;
}
}
// Early return if the environment doesn't contain a VC install.
env::var_os("VCINSTALLDIR")?;
env::var_os("VSINSTALLDIR")?;
// Fallback to simply using the current environment.
env::var_os("PATH")
.and_then(|path| {
env::split_paths(&path)
.map(|p| p.join(tool))
.find(|p| p.exists())
})
.map(|path| std::process::Command::new(path))
} |
Wine can run the windows tools, but it seems to go to the |
is there a reason Lines 42 to 49 in 2447a2b
CARGO_CFG_TARGET_OS here?
|
Because if the host is not Windows-like then using COM or the Windows registry won't work. Which is the point of |
would it be possible to implement the ability to specifically point out the tools via an env-var that we can then set on non-windows if we do have the tools and emulation needed? would the project be open to such a change? |
Instead of the current EDIT: The simplest way would be to test for |
cross-rs
: At present, cross-rs uses the Docker Ubuntu environment when compiling, and will download the wine and msvc tool chain in Ubuntu container to compile by mapping the source code into the container.openssl
: When the vendored feature is enabled, rust-openssl will call the openssl-src-rs to build the openssl c library.openssl-src-rs
usesrust-lang/cc-rs
to find the msvc tool when compiling the openssl library.Although the correct VC environment has been set, the find result is still None. Then I checked ` find_tool' function:
When compiling cross platforms, should we use below the code to check?
Or should we manually pass
--cfg windows
to compile?The text was updated successfully, but these errors were encountered: