Skip to content

Allow prebuilt-NASM w/ Cmake toolchain #852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,39 @@ jobs:
unset AWS_LC_SYS_EXTERNAL_BINDGEN
cross test -p aws-lc-sys --release "${CROSS_TEST_EXTRA_FLAG}" --features ssl --target ${{ matrix.target[0] }}

aws-lc-rs-cross-prebuilt-nasm:
if: github.repository_owner == 'aws'
name: cross prebuilt-NASM - ${{ matrix.target[0] }}
runs-on: ubuntu-latest
env:
AWS_LC_SYS_PREBUILT_NASM: 1
strategy:
fail-fast: false
matrix:
target:
- [ x86_64-pc-windows-gnu, 0, 1 ]
steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: "stable"
- name: Install cross
run: cargo install cross --git https://github.com/cross-rs/cross
- uses: dtolnay/rust-toolchain@master
id: toolchain
with:
toolchain: "stable"
target: ${{ matrix.target[0] }}
- name: Set Rust toolchain override
run: rustup override set ${{ steps.toolchain.outputs.name }}
- if: ${{ !startsWith(matrix.target[0], 'x86_64') }}
run: |
echo 'AWS_LC_RS_DISABLE_SLOW_TESTS=1' >> "$GITHUB_ENV"
- name: Cross-compilation (test release)
run: CROSS_CONFIG=$(pwd)/Cross.toml.passthrough-only cross test -p aws-lc-rs --no-run --features unstable --target ${{ matrix.target[0] }}

aws-lc-rs-cross-0_2_5-test:
if: github.repository_owner == 'aws'
name: cross tests ${{ matrix.target }}
Expand Down
1 change: 1 addition & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ passthrough = [
"AWS_LC_SYS_CMAKE_BUILDER",
"AWS_LC_SYS_EXTERNAL_BINDGEN",
"AWS_LC_SYS_NO_PREFIX",
"AWS_LC_SYS_PREBUILT_NASM",
"AWS_LC_SYS_PREGENERATING_BINDINGS",
"AWS_LC_SYS_STATIC",
"BINDGEN_EXTRA_CLANG_ARGS",
Expand Down
19 changes: 19 additions & 0 deletions Cross.toml.passthrough-only
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

[build.env]
passthrough = [
"AWS_LC_FIPS_SYS_EXTERNAL_BINDGEN",
"AWS_LC_FIPS_SYS_NO_PREFIX",
"AWS_LC_FIPS_SYS_PREGENERATING_BINDINGS",
"AWS_LC_FIPS_SYS_STATIC",
"AWS_LC_RS_DISABLE_SLOW_TESTS",
"AWS_LC_SYS_CC_SRC_COLLECTOR",
"AWS_LC_SYS_CFLAGS",
"AWS_LC_SYS_CMAKE_BUILDER",
"AWS_LC_SYS_EXTERNAL_BINDGEN",
"AWS_LC_SYS_NO_PREFIX",
"AWS_LC_SYS_PREBUILT_NASM",
"AWS_LC_SYS_PREGENERATING_BINDINGS",
"AWS_LC_SYS_STATIC",
"BINDGEN_EXTRA_CLANG_ARGS",
"GOPROXY",
]
Empty file.
76 changes: 42 additions & 34 deletions aws-lc-sys/builder/cmake_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ impl CmakeBuilder {
// Allow environment to specify CMake toolchain.
if let Some(toolchain) = optional_env_optional_crate_target("CMAKE_TOOLCHAIN_FILE") {
set_env_for_target("CMAKE_TOOLCHAIN_FILE", toolchain);
// Only setup if allowed by environment variable
if use_prebuilt_nasm() && Some(true) == allow_prebuilt_nasm() {
self.configure_prebuilt_nasm(&mut cmake_cfg);
}
return cmake_cfg;
}
// We only consider compiler CFLAGS when no cmake toolchain is set
Expand Down Expand Up @@ -244,7 +248,7 @@ impl CmakeBuilder {
};
emit_warning(
&format!(
"Neither script could be tested for execution, falling back to target-based selection: {}",
"Neither script could be tested for execution, falling back to target-based selection: {}",
fallback_script.file_name().unwrap().to_str().unwrap()));
fallback_script
}
Expand Down Expand Up @@ -304,42 +308,46 @@ impl CmakeBuilder {
}
}
if use_prebuilt_nasm() {
emit_warning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
emit_warning("!!! Using pre-built NASM binaries !!!");
emit_warning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");

let script_path = self.select_prebuilt_nasm_script();
let script_path = script_path.display().to_string();
let script_path = script_path.replace('\\', "/");

cmake_cfg.define("CMAKE_ASM_NASM_COMPILER", script_path.as_str());
// Without the following definition, the build fails with a message similar to the one
// reported here: https://gitlab.kitware.com/cmake/cmake/-/issues/19453
// The variables below were found in the associated fix:
// https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4257/diffs
cmake_cfg.define(
"CMAKE_ASM_NASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded",
"",
);
cmake_cfg.define(
"CMAKE_ASM_NASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL",
"",
);
cmake_cfg.define(
"CMAKE_ASM_NASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug",
"",
);
cmake_cfg.define(
"CMAKE_ASM_NASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL",
"",
);
cmake_cfg.define(
"CMAKE_ASM_NASM_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase",
"",
);
self.configure_prebuilt_nasm(cmake_cfg);
}
}

fn configure_prebuilt_nasm(&self, cmake_cfg: &mut cmake::Config) {
emit_warning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
emit_warning("!!! Using pre-built NASM binaries !!!");
emit_warning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");

let script_path = self.select_prebuilt_nasm_script();
let script_path = script_path.display().to_string();
let script_path = script_path.replace('\\', "/");

cmake_cfg.define("CMAKE_ASM_NASM_COMPILER", script_path.as_str());
// Without the following definition, the build fails with a message similar to the one
// reported here: https://gitlab.kitware.com/cmake/cmake/-/issues/19453
// The variables below were found in the associated fix:
// https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4257/diffs
cmake_cfg.define(
"CMAKE_ASM_NASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded",
"",
);
cmake_cfg.define(
"CMAKE_ASM_NASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL",
"",
);
cmake_cfg.define(
"CMAKE_ASM_NASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug",
"",
);
cmake_cfg.define(
"CMAKE_ASM_NASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL",
"",
);
cmake_cfg.define(
"CMAKE_ASM_NASM_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase",
"",
);
}

fn configure_open_harmony(cmake_cfg: &mut cmake::Config) {
let mut cflags = vec!["-Wno-unused-command-line-argument"];
let mut asmflags = vec![];
Expand Down
Loading