From 3258f022e0ed2b8d28b8177686dc81a575a97a4d Mon Sep 17 00:00:00 2001 From: Justin Smith Date: Wed, 18 Sep 2024 17:46:34 -0400 Subject: [PATCH 1/2] Support cross compiling to x86_64-pc-windows-gnu --- .github/workflows/cross.yml | 17 +++++++++++++++++ aws-lc-sys/builder/cmake_builder.rs | 8 +++++++- aws-lc-sys/builder/prebuilt-nasm.sh | 27 +++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100755 aws-lc-sys/builder/prebuilt-nasm.sh diff --git a/.github/workflows/cross.yml b/.github/workflows/cross.yml index 09425941acd..b00dbeabeda 100644 --- a/.github/workflows/cross.yml +++ b/.github/workflows/cross.yml @@ -265,3 +265,20 @@ jobs: . "$HOME/.cargo/env" cargo test -p aws-lc-rs cargo test -p aws-lc-rs --no-default-features --features=fips + cross-x86_64-pc-windows-gnu: + if: github.repository_owner == 'aws' + name: cross (prebuilt nasm) - x86_64-pc-windows-gnu + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + - uses: dtolnay/rust-toolchain@stable + id: toolchain + with: + toolchain: 'stable' + target: x86_64-pc-windows-gnu + - name: Install mingw + run: sudo apt-get update && sudo apt-get install --assume-yes mingw-w64 + - name: Run cargo test + run: cargo build -p aws-lc-rs --features prebuilt-nasm --target x86_64-pc-windows-gnu diff --git a/aws-lc-sys/builder/cmake_builder.rs b/aws-lc-sys/builder/cmake_builder.rs index c5930e6fdba..389a5fbf8a7 100644 --- a/aws-lc-sys/builder/cmake_builder.rs +++ b/aws-lc-sys/builder/cmake_builder.rs @@ -264,10 +264,16 @@ impl CmakeBuilder { emit_warning("!!! Using pre-built NASM binaries !!!"); emit_warning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + let script_name = if cfg!(target_os = "windows") { + "prebuilt-nasm.bat" + } else { + "prebuilt-nasm.sh" + }; + let script_path = self .manifest_dir .join("builder") - .join("prebuilt-nasm.bat") + .join(script_name) .display() .to_string(); let script_path = script_path.replace('\\', "/"); diff --git a/aws-lc-sys/builder/prebuilt-nasm.sh b/aws-lc-sys/builder/prebuilt-nasm.sh new file mode 100755 index 00000000000..a678d0a5dfe --- /dev/null +++ b/aws-lc-sys/builder/prebuilt-nasm.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 OR ISC + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +while [[ $# -gt 0 ]]; do + case "$1" in + -o) + shift + path="$1" + filename="$(basename "$path")" + filename="$(echo "$filename" | cut -f 1 -d '.')" + cp "$SCRIPT_DIR/prebuilt-nasm/${filename}".obj "$path" + exit 0 + ;; + *) + shift + ;; + esac +done + +# If we reach here, it means we didn't find the -o option +echo "PATH: $path" >&2 +echo "FILENAME: $filename" >&2 +echo "SCRIPT_DIR: $SCRIPT_DIR" >&2 +exit 1 From 706b01f7f248131117724b4996fc81d1ed9d29e1 Mon Sep 17 00:00:00 2001 From: Justin W Smith <103147162+justsmth@users.noreply.github.com> Date: Thu, 26 Sep 2024 15:12:27 -0400 Subject: [PATCH 2/2] Update aws-lc-sys/builder/prebuilt-nasm.sh Co-authored-by: Sean McGrail <549813+skmcgrail@users.noreply.github.com> --- aws-lc-sys/builder/prebuilt-nasm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws-lc-sys/builder/prebuilt-nasm.sh b/aws-lc-sys/builder/prebuilt-nasm.sh index a678d0a5dfe..541f70c338e 100755 --- a/aws-lc-sys/builder/prebuilt-nasm.sh +++ b/aws-lc-sys/builder/prebuilt-nasm.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 OR ISC