Skip to content

Commit

Permalink
Allow build with prebuilt NASM objects
Browse files Browse the repository at this point in the history
diff --git a/aws-lc-sys/builder/cmake_builder.rs b/aws-lc-sys/builder/cmake_builder.rs
index b4914d1ebc..9eb4c714a2 100644
--- a/aws-lc-sys/builder/cmake_builder.rs
+++ b/aws-lc-sys/builder/cmake_builder.rs
@@ -3,8 +3,8 @@

 use crate::OutputLib::{Crypto, RustWrapper, Ssl};
 use crate::{
-    cargo_env, emit_warning, execute_command, is_no_asm, option_env, target, target_arch,
-    target_env, target_os, target_underscored, target_vendor, OutputLibType,
+    cargo_env, emit_warning, execute_command, is_no_asm, is_prebuilt_nasm, option_env, target,
+    target_arch, target_env, target_os, target_underscored, target_vendor, OutputLibType,
 };
 use std::env;
 use std::ffi::OsStr;
@@ -168,6 +168,23 @@ impl CmakeBuilder {
             }
         }

+        if target_os() == "windows" && target_arch() == "x86_64" && is_prebuilt_nasm() {
+            emit_warning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+            emit_warning("!!!   Using pre-built NASM binaries   !!!");
+            emit_warning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+
+            let script_path = self
+                .manifest_dir
+                .join("builder")
+                .join("prebuilt-nasm.bat")
+                .display()
+                .to_string();
+            let script_path = script_path.replace(r"\", "/");
+
+            cmake_cfg.define("CMAKE_ASM_NASM_COMPILER", script_path.as_str());
+            cmake_cfg.define("CMAKE_VERBOSE_MAKEFILE", "1");
+        }
+
         if target_underscored() == "aarch64_pc_windows_msvc" {
             cmake_cfg.generator("Ninja");
             cmake_cfg.define("CMAKE_C_COMPILER", "clang-cl");
@@ -212,7 +229,11 @@ impl crate::Builder for CmakeBuilder {
         let mut missing_dependency = false;

         if target_os() == "windows" {
-            if target_arch() == "x86_64" && !test_nasm_command() && !is_no_asm() {
+            if target_arch() == "x86_64"
+                && !test_nasm_command()
+                && !is_no_asm()
+                && !is_prebuilt_nasm()
+            {
                 eprintln!(
                     "Consider setting `AWS_LC_SYS_NO_ASM` in the environment for development builds.\
                 See User Guide about the limitations: https://aws.github.io/aws-lc-rs/index.html"
diff --git a/aws-lc-sys/builder/main.rs b/aws-lc-sys/builder/main.rs
index 866d2055b8..d9936718a6 100644
--- a/aws-lc-sys/builder/main.rs
+++ b/aws-lc-sys/builder/main.rs
@@ -313,6 +313,7 @@ static mut AWS_LC_SYS_NO_PREFIX: bool = false;
 static mut AWS_LC_SYS_INTERNAL_BINDGEN: bool = false;
 static mut AWS_LC_SYS_EXTERNAL_BINDGEN: bool = false;
 static mut AWS_LC_SYS_NO_ASM: bool = false;
+static mut AWS_LC_SYS_PREBUILT_NASM: bool = false;

 fn initialize() {
     unsafe {
@@ -322,6 +323,7 @@ fn initialize() {
         AWS_LC_SYS_EXTERNAL_BINDGEN =
             env_var_to_bool("AWS_LC_SYS_EXTERNAL_BINDGEN").unwrap_or(false);
         AWS_LC_SYS_NO_ASM = env_var_to_bool("AWS_LC_SYS_NO_ASM").unwrap_or(false);
+        AWS_LC_SYS_PREBUILT_NASM = env_var_to_bool("AWS_LC_SYS_PREBUILT_NASM").unwrap_or(false);
     }

     if !is_external_bindgen() && (is_internal_bindgen() || !has_bindgen_feature()) {
@@ -369,6 +371,10 @@ fn is_no_asm() -> bool {
     unsafe { AWS_LC_SYS_NO_ASM }
 }

+fn is_prebuilt_nasm() -> bool {
+    unsafe { AWS_LC_SYS_PREBUILT_NASM }
+}
+
 fn has_bindgen_feature() -> bool {
     cfg!(feature = "bindgen")
 }
diff --git a/aws-lc-sys/builder/prebuilt-nasm.bat b/aws-lc-sys/builder/prebuilt-nasm.bat
new file mode 100644
index 0000000000..9c761db12a
--- /dev/null
+++ b/aws-lc-sys/builder/prebuilt-nasm.bat
@@ -0,0 +1,21 @@
+@echo off
+set "ScriptDir=%~dp0"
+set "ScriptDir=%ScriptDir:~0,-1%"
+:loop
+set "arg1=%~1"
+if "%arg1%"=="-o" goto end
+if "%arg1%"=="" goto failure
+shift
+goto loop
+:end
+shift
+set "path=%~1"
+for %%f in ("%path%") do set "filename=%%~nxf"
+copy "%ScriptDir%\prebuilt-nasm\%filename%" "%path%"
+exit 0
+
+:failure
+echo PATH: %path% 1>&2
+echo FILENAME: %filename% 1>&2
+echo ScriptDir: %ScriptDir% 1>&2
+exit 1
\ No newline at end of file
diff --git a/aws-lc-sys/builder/prebuilt-nasm/aes128gcmsiv-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/aes128gcmsiv-x86_64.obj
new file mode 100644
index 0000000000..3caa1c64f7
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/aes128gcmsiv-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/aesni-gcm-avx512.obj b/aws-lc-sys/builder/prebuilt-nasm/aesni-gcm-avx512.obj
new file mode 100644
index 0000000000..99dff121d2
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/aesni-gcm-avx512.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/aesni-gcm-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/aesni-gcm-x86_64.obj
new file mode 100644
index 0000000000..a40c77f839
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/aesni-gcm-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/aesni-sha1-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/aesni-sha1-x86_64.obj
new file mode 100644
index 0000000000..9b14149bc8
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/aesni-sha1-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/aesni-sha256-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/aesni-sha256-x86_64.obj
new file mode 100644
index 0000000000..de492cd645
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/aesni-sha256-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/aesni-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/aesni-x86_64.obj
new file mode 100644
index 0000000000..77ef35b43f
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/aesni-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/aesni-xts-avx512.obj b/aws-lc-sys/builder/prebuilt-nasm/aesni-xts-avx512.obj
new file mode 100644
index 0000000000..45e257d9ff
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/aesni-xts-avx512.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/chacha-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/chacha-x86_64.obj
new file mode 100644
index 0000000000..37a378b223
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/chacha-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/chacha20_poly1305_x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/chacha20_poly1305_x86_64.obj
new file mode 100644
index 0000000000..05cee5a3d1
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/chacha20_poly1305_x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/ghash-ssse3-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/ghash-ssse3-x86_64.obj
new file mode 100644
index 0000000000..42566f60be
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/ghash-ssse3-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/ghash-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/ghash-x86_64.obj
new file mode 100644
index 0000000000..3706db4563
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/ghash-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/md5-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/md5-x86_64.obj
new file mode 100644
index 0000000000..6ebd3e7916
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/md5-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/p256-x86_64-asm.obj b/aws-lc-sys/builder/prebuilt-nasm/p256-x86_64-asm.obj
new file mode 100644
index 0000000000..ef2ab1e558
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/p256-x86_64-asm.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/p256_beeu-x86_64-asm.obj b/aws-lc-sys/builder/prebuilt-nasm/p256_beeu-x86_64-asm.obj
new file mode 100644
index 0000000000..98b6522f5a
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/p256_beeu-x86_64-asm.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/rdrand-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/rdrand-x86_64.obj
new file mode 100644
index 0000000000..25ecc304a0
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/rdrand-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/rsaz-avx2.obj b/aws-lc-sys/builder/prebuilt-nasm/rsaz-avx2.obj
new file mode 100644
index 0000000000..39d98ee7b7
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/rsaz-avx2.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/sha1-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/sha1-x86_64.obj
new file mode 100644
index 0000000000..28f049ba7f
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/sha1-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/sha256-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/sha256-x86_64.obj
new file mode 100644
index 0000000000..88fa74e3cb
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/sha256-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/sha512-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/sha512-x86_64.obj
new file mode 100644
index 0000000000..258d354f4e
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/sha512-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/trampoline-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/trampoline-x86_64.obj
new file mode 100644
index 0000000000..3370a1073f
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/trampoline-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/vpaes-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/vpaes-x86_64.obj
new file mode 100644
index 0000000000..1e24b23b01
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/vpaes-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/x86_64-mont.obj b/aws-lc-sys/builder/prebuilt-nasm/x86_64-mont.obj
new file mode 100644
index 0000000000..5a841d3ee3
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/x86_64-mont.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/x86_64-mont5.obj b/aws-lc-sys/builder/prebuilt-nasm/x86_64-mont5.obj
new file mode 100644
index 0000000000..135436db3b
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/x86_64-mont5.obj differ

diff --git a/aws-lc-sys/builder/cmake_builder.rs b/aws-lc-sys/builder/cmake_builder.rs
index ce6dec782a..a769d68da1 100644
--- a/aws-lc-sys/builder/cmake_builder.rs
+++ b/aws-lc-sys/builder/cmake_builder.rs
@@ -3,7 +3,7 @@

 use crate::OutputLib::{Crypto, RustWrapper, Ssl};
 use crate::{
-    cargo_env, emit_warning, execute_command, is_crt_static, is_no_asm, option_env, target,
+    cargo_env, emit_warning, execute_command, is_crt_static, is_no_asm, is_prebuilt_nasm, option_env, target,
     target_arch, target_env, target_os, target_underscored, target_vendor, OutputLibType,
 };
 use std::env;
@@ -135,7 +135,7 @@ impl CmakeBuilder {

         // See issue: aws#453
         if target_os() == "windows" {
-            Self::configure_windows(&mut cmake_cfg);
+            self.configure_windows(&mut cmake_cfg);
         }

         // If the build environment vendor is Apple
@@ -162,13 +162,30 @@ impl CmakeBuilder {
         }

         if target_env() == "ohos" {
-            Self::configure_open_harmony(&mut cmake_cfg);
+            self.configure_open_harmony(&mut cmake_cfg);
         }

         cmake_cfg
     }

-    fn configure_windows(cmake_cfg: &mut cmake::Config) {
+    fn configure_windows(&self, cmake_cfg: &mut cmake::Config) {
+        if target_arch() == "x86_64" && is_prebuilt_nasm() {
+            emit_warning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+            emit_warning("!!!   Using pre-built NASM binaries   !!!");
+            emit_warning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+
+            let script_path = self
+                .manifest_dir
+                .join("builder")
+                .join("prebuilt-nasm.bat")
+                .display()
+                .to_string();
+            let script_path = script_path.replace(r"\", "/");
+
+            cmake_cfg.define("CMAKE_ASM_NASM_COMPILER", script_path.as_str());
+            cmake_cfg.define("CMAKE_VERBOSE_MAKEFILE", "1");
+        }
+
         match (target_env().as_str(), target_arch().as_str()) {
             ("msvc", "aarch64") => {
                 cmake_cfg.generator_toolset(format!(
@@ -200,7 +217,7 @@ impl CmakeBuilder {
         }
     }

-    fn configure_open_harmony(cmake_cfg: &mut cmake::Config) {
+    fn configure_open_harmony(&self, cmake_cfg: &mut cmake::Config) {
         const OHOS_NDK_HOME: &str = "OHOS_NDK_HOME";
         if let Ok(ndk) = env::var(OHOS_NDK_HOME) {
             cmake_cfg.define(
@@ -253,7 +270,11 @@ impl crate::Builder for CmakeBuilder {
         let mut missing_dependency = false;

         if target_os() == "windows" {
-            if target_arch() == "x86_64" && !test_nasm_command() && !is_no_asm() {
+            if target_arch() == "x86_64"
+                && !test_nasm_command()
+                && !is_no_asm()
+                && !is_prebuilt_nasm()
+            {
                 eprintln!(
                     "Consider setting `AWS_LC_SYS_NO_ASM` in the environment for development builds.\
                 See User Guide about the limitations: https://aws.github.io/aws-lc-rs/index.html"
diff --git a/aws-lc-sys/builder/main.rs b/aws-lc-sys/builder/main.rs
index 4bf220138b..1241db16b4 100644
--- a/aws-lc-sys/builder/main.rs
+++ b/aws-lc-sys/builder/main.rs
@@ -313,6 +313,7 @@ static mut AWS_LC_SYS_NO_PREFIX: bool = false;
 static mut AWS_LC_SYS_INTERNAL_BINDGEN: bool = false;
 static mut AWS_LC_SYS_EXTERNAL_BINDGEN: bool = false;
 static mut AWS_LC_SYS_NO_ASM: bool = false;
+static mut AWS_LC_SYS_PREBUILT_NASM: bool = false;

 fn initialize() {
     unsafe {
@@ -322,6 +323,7 @@ fn initialize() {
         AWS_LC_SYS_EXTERNAL_BINDGEN =
             env_var_to_bool("AWS_LC_SYS_EXTERNAL_BINDGEN").unwrap_or(false);
         AWS_LC_SYS_NO_ASM = env_var_to_bool("AWS_LC_SYS_NO_ASM").unwrap_or(false);
+        AWS_LC_SYS_PREBUILT_NASM = env_var_to_bool("AWS_LC_SYS_PREBUILT_NASM").unwrap_or(false);
     }

     if !is_external_bindgen() && (is_internal_bindgen() || !has_bindgen_feature()) {
@@ -369,6 +371,10 @@ fn is_no_asm() -> bool {
     unsafe { AWS_LC_SYS_NO_ASM }
 }

+fn is_prebuilt_nasm() -> bool {
+    unsafe { AWS_LC_SYS_PREBUILT_NASM }
+}
+
 fn has_bindgen_feature() -> bool {
     cfg!(feature = "bindgen")
 }
diff --git a/aws-lc-sys/builder/prebuilt-nasm.bat b/aws-lc-sys/builder/prebuilt-nasm.bat
new file mode 100644
index 0000000000..9c761db12a
--- /dev/null
+++ b/aws-lc-sys/builder/prebuilt-nasm.bat
@@ -0,0 +1,21 @@
+@echo off
+set "ScriptDir=%~dp0"
+set "ScriptDir=%ScriptDir:~0,-1%"
+:loop
+set "arg1=%~1"
+if "%arg1%"=="-o" goto end
+if "%arg1%"=="" goto failure
+shift
+goto loop
+:end
+shift
+set "path=%~1"
+for %%f in ("%path%") do set "filename=%%~nxf"
+copy "%ScriptDir%\prebuilt-nasm\%filename%" "%path%"
+exit 0
+
+:failure
+echo PATH: %path% 1>&2
+echo FILENAME: %filename% 1>&2
+echo ScriptDir: %ScriptDir% 1>&2
+exit 1
\ No newline at end of file
diff --git a/aws-lc-sys/builder/prebuilt-nasm/aes128gcmsiv-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/aes128gcmsiv-x86_64.obj
new file mode 100644
index 0000000000..3caa1c64f7
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/aes128gcmsiv-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/aesni-gcm-avx512.obj b/aws-lc-sys/builder/prebuilt-nasm/aesni-gcm-avx512.obj
new file mode 100644
index 0000000000..99dff121d2
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/aesni-gcm-avx512.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/aesni-gcm-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/aesni-gcm-x86_64.obj
new file mode 100644
index 0000000000..a40c77f839
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/aesni-gcm-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/aesni-sha1-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/aesni-sha1-x86_64.obj
new file mode 100644
index 0000000000..9b14149bc8
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/aesni-sha1-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/aesni-sha256-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/aesni-sha256-x86_64.obj
new file mode 100644
index 0000000000..de492cd645
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/aesni-sha256-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/aesni-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/aesni-x86_64.obj
new file mode 100644
index 0000000000..77ef35b43f
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/aesni-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/aesni-xts-avx512.obj b/aws-lc-sys/builder/prebuilt-nasm/aesni-xts-avx512.obj
new file mode 100644
index 0000000000..45e257d9ff
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/aesni-xts-avx512.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/chacha-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/chacha-x86_64.obj
new file mode 100644
index 0000000000..37a378b223
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/chacha-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/chacha20_poly1305_x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/chacha20_poly1305_x86_64.obj
new file mode 100644
index 0000000000..05cee5a3d1
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/chacha20_poly1305_x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/ghash-ssse3-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/ghash-ssse3-x86_64.obj
new file mode 100644
index 0000000000..42566f60be
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/ghash-ssse3-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/ghash-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/ghash-x86_64.obj
new file mode 100644
index 0000000000..3706db4563
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/ghash-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/md5-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/md5-x86_64.obj
new file mode 100644
index 0000000000..6ebd3e7916
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/md5-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/p256-x86_64-asm.obj b/aws-lc-sys/builder/prebuilt-nasm/p256-x86_64-asm.obj
new file mode 100644
index 0000000000..ef2ab1e558
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/p256-x86_64-asm.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/p256_beeu-x86_64-asm.obj b/aws-lc-sys/builder/prebuilt-nasm/p256_beeu-x86_64-asm.obj
new file mode 100644
index 0000000000..98b6522f5a
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/p256_beeu-x86_64-asm.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/rdrand-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/rdrand-x86_64.obj
new file mode 100644
index 0000000000..25ecc304a0
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/rdrand-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/rsaz-avx2.obj b/aws-lc-sys/builder/prebuilt-nasm/rsaz-avx2.obj
new file mode 100644
index 0000000000..39d98ee7b7
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/rsaz-avx2.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/sha1-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/sha1-x86_64.obj
new file mode 100644
index 0000000000..28f049ba7f
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/sha1-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/sha256-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/sha256-x86_64.obj
new file mode 100644
index 0000000000..88fa74e3cb
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/sha256-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/sha512-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/sha512-x86_64.obj
new file mode 100644
index 0000000000..258d354f4e
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/sha512-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/trampoline-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/trampoline-x86_64.obj
new file mode 100644
index 0000000000..3370a1073f
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/trampoline-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/vpaes-x86_64.obj b/aws-lc-sys/builder/prebuilt-nasm/vpaes-x86_64.obj
new file mode 100644
index 0000000000..1e24b23b01
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/vpaes-x86_64.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/x86_64-mont.obj b/aws-lc-sys/builder/prebuilt-nasm/x86_64-mont.obj
new file mode 100644
index 0000000000..5a841d3ee3
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/x86_64-mont.obj differ
diff --git a/aws-lc-sys/builder/prebuilt-nasm/x86_64-mont5.obj b/aws-lc-sys/builder/prebuilt-nasm/x86_64-mont5.obj
new file mode 100644
index 0000000000..135436db3b
Binary files /dev/null and b/aws-lc-sys/builder/prebuilt-nasm/x86_64-mont5.obj differ
  • Loading branch information
justinwsmith authored and justsmth committed Jul 16, 2024
1 parent 280be9d commit 57f7b6e
Show file tree
Hide file tree
Showing 26 changed files with 54 additions and 6 deletions.
33 changes: 27 additions & 6 deletions aws-lc-sys/builder/cmake_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use crate::OutputLib::{Crypto, RustWrapper, Ssl};
use crate::{
cargo_env, emit_warning, execute_command, is_crt_static, is_no_asm, option_env, target,
cargo_env, emit_warning, execute_command, is_crt_static, is_no_asm, is_prebuilt_nasm, option_env, target,
target_arch, target_env, target_os, target_underscored, target_vendor, OutputLibType,
};
use std::env;
Expand Down Expand Up @@ -135,7 +135,7 @@ impl CmakeBuilder {

// See issue: https://github.com/aws/aws-lc-rs/issues/453
if target_os() == "windows" {
Self::configure_windows(&mut cmake_cfg);
self.configure_windows(&mut cmake_cfg);
}

// If the build environment vendor is Apple
Expand All @@ -162,13 +162,30 @@ impl CmakeBuilder {
}

if target_env() == "ohos" {
Self::configure_open_harmony(&mut cmake_cfg);
self.configure_open_harmony(&mut cmake_cfg);
}

cmake_cfg
}

fn configure_windows(cmake_cfg: &mut cmake::Config) {
fn configure_windows(&self, cmake_cfg: &mut cmake::Config) {
if target_arch() == "x86_64" && is_prebuilt_nasm() {
emit_warning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
emit_warning("!!! Using pre-built NASM binaries !!!");
emit_warning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");

let script_path = self
.manifest_dir
.join("builder")
.join("prebuilt-nasm.bat")
.display()
.to_string();
let script_path = script_path.replace(r"\", "/");

cmake_cfg.define("CMAKE_ASM_NASM_COMPILER", script_path.as_str());
cmake_cfg.define("CMAKE_VERBOSE_MAKEFILE", "1");
}

match (target_env().as_str(), target_arch().as_str()) {
("msvc", "aarch64") => {
cmake_cfg.generator_toolset(format!(
Expand Down Expand Up @@ -200,7 +217,7 @@ impl CmakeBuilder {
}
}

fn configure_open_harmony(cmake_cfg: &mut cmake::Config) {
fn configure_open_harmony(&self, cmake_cfg: &mut cmake::Config) {
const OHOS_NDK_HOME: &str = "OHOS_NDK_HOME";
if let Ok(ndk) = env::var(OHOS_NDK_HOME) {
cmake_cfg.define(
Expand Down Expand Up @@ -253,7 +270,11 @@ impl crate::Builder for CmakeBuilder {
let mut missing_dependency = false;

if target_os() == "windows" {
if target_arch() == "x86_64" && !test_nasm_command() && !is_no_asm() {
if target_arch() == "x86_64"
&& !test_nasm_command()
&& !is_no_asm()
&& !is_prebuilt_nasm()
{
eprintln!(
"Consider setting `AWS_LC_SYS_NO_ASM` in the environment for development builds.\
See User Guide about the limitations: https://aws.github.io/aws-lc-rs/index.html"
Expand Down
6 changes: 6 additions & 0 deletions aws-lc-sys/builder/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ static mut AWS_LC_SYS_NO_PREFIX: bool = false;
static mut AWS_LC_SYS_INTERNAL_BINDGEN: bool = false;
static mut AWS_LC_SYS_EXTERNAL_BINDGEN: bool = false;
static mut AWS_LC_SYS_NO_ASM: bool = false;
static mut AWS_LC_SYS_PREBUILT_NASM: bool = false;

fn initialize() {
unsafe {
Expand All @@ -322,6 +323,7 @@ fn initialize() {
AWS_LC_SYS_EXTERNAL_BINDGEN =
env_var_to_bool("AWS_LC_SYS_EXTERNAL_BINDGEN").unwrap_or(false);
AWS_LC_SYS_NO_ASM = env_var_to_bool("AWS_LC_SYS_NO_ASM").unwrap_or(false);
AWS_LC_SYS_PREBUILT_NASM = env_var_to_bool("AWS_LC_SYS_PREBUILT_NASM").unwrap_or(false);
}

if !is_external_bindgen() && (is_internal_bindgen() || !has_bindgen_feature()) {
Expand Down Expand Up @@ -369,6 +371,10 @@ fn is_no_asm() -> bool {
unsafe { AWS_LC_SYS_NO_ASM }
}

fn is_prebuilt_nasm() -> bool {
unsafe { AWS_LC_SYS_PREBUILT_NASM }
}

fn has_bindgen_feature() -> bool {
cfg!(feature = "bindgen")
}
Expand Down
21 changes: 21 additions & 0 deletions aws-lc-sys/builder/prebuilt-nasm.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@echo off
set "ScriptDir=%~dp0"
set "ScriptDir=%ScriptDir:~0,-1%"
:loop
set "arg1=%~1"
if "%arg1%"=="-o" goto end
if "%arg1%"=="" goto failure
shift
goto loop
:end
shift
set "path=%~1"
for %%f in ("%path%") do set "filename=%%~nxf"
copy "%ScriptDir%\prebuilt-nasm\%filename%" "%path%"
exit 0

:failure
echo PATH: %path% 1>&2
echo FILENAME: %filename% 1>&2
echo ScriptDir: %ScriptDir% 1>&2
exit 1
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added aws-lc-sys/builder/prebuilt-nasm/aesni-x86_64.obj
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added aws-lc-sys/builder/prebuilt-nasm/ghash-x86_64.obj
Binary file not shown.
Binary file added aws-lc-sys/builder/prebuilt-nasm/md5-x86_64.obj
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added aws-lc-sys/builder/prebuilt-nasm/rsaz-avx2.obj
Binary file not shown.
Binary file added aws-lc-sys/builder/prebuilt-nasm/sha1-x86_64.obj
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added aws-lc-sys/builder/prebuilt-nasm/vpaes-x86_64.obj
Binary file not shown.
Binary file added aws-lc-sys/builder/prebuilt-nasm/x86_64-mont.obj
Binary file not shown.
Binary file added aws-lc-sys/builder/prebuilt-nasm/x86_64-mont5.obj
Binary file not shown.

0 comments on commit 57f7b6e

Please sign in to comment.