-
Notifications
You must be signed in to change notification settings - Fork 362
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
Improve asio sys build script #809
Improve asio sys build script #809
Conversation
3545a50
to
ac9b198
Compare
ac9b198
to
f320944
Compare
I've also checked a bit about the reason why #[cfg(target_os = "emscripten")]
impl wasm_bindgen::convert::IntoWasmAbi for BufferSize {
type Abi = wasm_bindgen::convert::WasmOption<u32>;
fn into_abi(self) -> Self::Abi {
match self {
Self::Default => None,
Self::Fixed(fc) => Some(fc),
}
.into_abi()
}
} Has this type But that type does not exist anymore in the module. The changes made to that snippet was 12 months ago and the last time I have checked the CI was green a few weeks ago. I wonder if my changes made a side effect.. I don't know how it is used in the wild but this may provide a solution: #[cfg(target_os = "emscripten")]
impl wasm_bindgen::convert::IntoWasmAbi for BufferSize {
type Abi = u32;
fn into_abi(self) -> Self::Abi {
match self {
Self::Default => 0x00FF_FFFFu32,
Self::Fixed(fc) => fc,
}
.into_abi()
}
} I'm trying to mimic https://github.com/rustwasm/wasm-bindgen/blob/962f580d6f5def2df4223588de96feeb30ce7572/src/convert/impls.rs#L114-L140 Where |
No significant rush but when approximately you may look at this? |
asio-sys/Cargo.toml
Outdated
num-traits = "0.2" | ||
|
||
|
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.
why these blank lines?
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.
Probably forgotten, I'll just remove them.
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.
asio-sys/build.rs
Outdated
} else { | ||
vec!["C:\\Program Files\\Microsoft Visual Studio\\"] | ||
}; | ||
let paths = vec![ |
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.
this can just be a &[...]
right?
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.
Probably it can. 👍
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.
asio-sys/build.rs
Outdated
fn determine_vcvarsall_bat_arch_arg() -> String { | ||
let host_architecture = std::env::consts::ARCH; | ||
|
||
let arch_arg = if cfg!(target_arch = "x86_64") { |
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.
target_arch
in a build script also refers to the arch of the host, as the build scripts are always compiled for the host.
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.
This is indeed confusing. I didn't catch that thanks!
Running this build script on macos aarch64
with the command cargo build --target=x86_64-pc-windows-gnu
:
fn main() {
let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
let host_architecture = std::env::consts::ARCH;
if cfg!(target_arch = "x86_64") {
println!(r#"cfg!(target_arch = "x86_64")"#);
}
if cfg!(target_arch = "aarch64") {
println!(r#"cfg!(target_arch = "aarch64")"#);
}
println!(
"CARGO_CFG_TARGET_ARCH: {}\nstd::env::consts::ARCH: {}",
target_arch, host_architecture
);
panic!();
}
yields
--- stdout
cfg!(target_arch = "aarch64")
CARGO_CFG_TARGET_ARCH: x86_64
std::env::consts::ARCH: aarch64
which indeed proves the target_arch
in the cfg!
macro is actually the host arch from my point of view.
I'll apply the changes accordingly replacing those with the target arch parsed from the triple.
I'll also double check if it usesCARGO_CFG_*
variables.
rust-lang/cargo#4302
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.
2d6b063
Fixes it.
I don't think so.
feel free to make a PR! |
Improvements
vcvarsall.bat
is executed exhaustively for any supported host and target architecture combinations now.README.md
is added which explains cross compilation scenarios forcpal
with theasio
feature.vcvarsall.bat
search is improved greatly to execute smarter and faster to cover for CI scenarios where the disk I/O might be a bottle neck.mingw-w64
tool chain is fixed.With these changes I want to enable:
What I have tried:
If I missed something, I'll correct it along the way.
Thank you for the last merge, and I look forward to your review 🙏