alexcrichton / openssl-src-rs

Source code and logic to build OpenSSL from source
Apache License 2.0
68 stars 113 forks source link

Fix MSVC Host Cross Compilation #218

Closed nathaniel-daniel closed 9 months ago

nathaniel-daniel commented 9 months ago

Closes #118

Without this patch, cross compilation on MSVC seems to directly embed backslashes from the prefix argument as various string constants in a C file via defines, like ENGINESDIR. This causes a build failure, as these backslashes get picked up as escape sequences.

Windows GNU targets are not affected by this issue, as they already do something similar to this patch within sanitize_sh.

I think this issue is caused by OpenSSL using the unix makefile template for cross-building to Linux, which I believe is not capable of escaping backslashes in the prefix argument. I believe that this is why a normal MSVC build works and why cross builds fail.

I have tested that this on Windows 11; this patch allows me to cross compile from x86_64-pc-windows-msvc to x86_64-unknown-linux-gnu and aarch64-unknown-linux-gnu.

nathaniel-daniel commented 9 months ago

Added a comment, let me know if it should be more/less detailed.