Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cross compiling aws-lc-sys for windows using nix, mingw and crane

This is a small project to demonstrate how to cross compile aws-lc-sys for windows using nix and crane. It works even when putting aws-lc-sys into both dependencies and build-dependencies.

Building

You can build this demo using nix, or cargo directly.

nix build will build the crate for the windows target.

Alternatively, you can use the devshell: nix develop, which will put you into a cross-compilation environment. You can then cargo build to build the crate for windows.

Trivia

This took me a while to figure out. Compiling aws-lc-sys for windows is difficult, because it's build process uses some test binaries that verify compiler features. In a cross compilation environment, these are a problem, because the C compiler needs to be specified explicitly. My special situation was that I needed the crate in both dependencies and build-dependencies. This causes issues as it was picking up either the mingw or the native linux compiler for both, which is incorrect, as the normal dependency needs mingw (for cross-compilation) and the build-dependency needs the native linux compiler.

The solution was to explicitly set CC_x86_64_unknown_linux_gnu to the native compiler.

Another issue was that it could not properly use the prebuilt nasm script, so I made it assemble the objects.

A big issue while debugging this was, that aws-lc-sys gives you very misleading errors, e.g. saying that the compiler has a bug that was fixed back in gcc version 10. This happens because mingw compiles the test binary correctly, but then the build process tries to execute it on linux, which fails, leading to the wrong assumption that the bug check failed.

Note

If you copy this setup, and you still get weird/misleading errors, check your versions of nixpkgs, crane and aws-lc-sys. The versions pinned in flake.lock and Cargo.lock work.

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages