Skip to content

Commit

Permalink
build: Don't overwrite clang-cl with clang for ARM64 Windows builds
Browse files Browse the repository at this point in the history
When cross-compiling for Windows, it's common to use the `clang-cl`
driver which supports parsing `cl.exe`-like arguments.  When `ring`
however overwrites this compiler with `clang`, existing user arguments
in i.e. `CFLAGS` are not compatible resulting in various "unknown
argument" errors such as for `-vctoolsdir` and `-winsdkdir`.

As pointed out in the original ARM64 Windows support PR, compiling
`ring` with `clang-cl` works equally well as `clang`: allow that by not
overwriting the compiler with `clang` if it's already `clang-cl`, to not
have to sort out incompatible arguments.
  • Loading branch information
MarijnS95 committed Jan 10, 2025
1 parent d2e401f commit a7686d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,7 @@ default-members = [
".",
"cavp"
]

[patch.crates-io]
# https://github.com/rust-lang/cc-rs/pull/1357
cc = { git = "https://github.com/rust-lang/cc-rs", rev = "5f58a7c" }
10 changes: 7 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,9 +547,13 @@ fn obj_path(out_dir: &Path, src: &Path) -> PathBuf {

fn configure_cc(c: &mut cc::Build, target: &Target, c_root_dir: &Path, include_dir: &Path) {
let compiler = c.get_compiler();
// FIXME: On Windows AArch64 we currently must use Clang to compile C code
let compiler = if target.os == WINDOWS && target.arch == AARCH64 && !compiler.is_like_clang() {
let _ = c.compiler("clang");
// FIXME: On Windows AArch64 we currently must use clang or clang-cl to compile C code
let compiler = if target.os == WINDOWS
&& target.arch == AARCH64
&& !compiler.is_like_clang()
&& !compiler.is_like_clang_cl()
{
c.compiler("clang");
c.get_compiler()
} else {
compiler
Expand Down

0 comments on commit a7686d9

Please sign in to comment.