Skip to content

Commit

Permalink
Remove riscv64gc-specific CI logic
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Aug 22, 2024
1 parent 505c6bf commit 0d7ff14
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 17 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ env:
jobs:
aws-lc-rs-cross-test:
if: github.repository_owner == 'aws'
name: aws-lc-rs cross tests
runs-on: ${{ matrix.os }}
name: cross tests ${{ matrix.target }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
os: [ ubuntu-22.04 ]
target:
- aarch64-linux-android
- aarch64-unknown-linux-gnu
Expand All @@ -51,18 +50,21 @@ jobs:
with:
toolchain: 'stable'
- name: Install cross
run: cargo install cross ${{ (matrix.target == 'riscv64gc-unknown-linux-gnu' && '--locked') || '' }} --git https://github.com/cross-rs/cross
run: cargo install cross --git https://github.com/cross-rs/cross
- uses: dtolnay/rust-toolchain@master
id: toolchain
with:
toolchain: ${{ (matrix.target == 'riscv64gc-unknown-linux-gnu' && '1.72.1') || 'stable' }}
toolchain: 'stable'
target: ${{ matrix.target }}
- name: Set Rust toolchain override
run: rustup override set ${{ steps.toolchain.outputs.name }}
# The flag below is set to avoid the following error with GCC 11.4.0 on the riscv64 platform:
# /home/runner/work/aws-lc-rs/aws-lc-rs/aws-lc-sys/aws-lc/crypto/pem/pem_lib.c:707:11: error: 'strncmp' of strings of length 1 and 9 and bound of 9 evaluates to nonzero [-Werror=string-compare]
# 707 | if (strncmp(buf, "-----END ", 9) == 0) {
# | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
- if: ${{ matrix.target == 'riscv64gc-unknown-linux-gnu' }}
run: |
cargo update
cargo update -p clap --precise 4.4.18
echo 'AWS_LC_SYS_CFLAGS="-Wno-string-compare"' >> "$GITHUB_ENV"
- name: Cross-compilation (build debug)
run: cross build -p aws-lc-rs --features unstable --target ${{ matrix.target }}
- name: Cross-compilation (test release)
Expand Down
2 changes: 1 addition & 1 deletion Cross.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ passthrough = [
"AWS_LC_SYS_EXTERNAL_BINDGEN", "AWS_LC_FIPS_SYS_EXTERNAL_BINDGEN",
"AWS_LC_SYS_STATIC", "AWS_LC_FIPS_SYS_STATIC",
"AWS_LC_SYS_CMAKE_BUILDER", "AWS_LC_SYS_CC_SRC_COLLECTOR",
"GOPROXY",
"GOPROXY", "AWS_LC_SYS_CFLAGS"
]
10 changes: 8 additions & 2 deletions aws-lc-sys/builder/cc_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ mod x86_64_unknown_linux_gnu;
mod x86_64_unknown_linux_musl;

use crate::{
cargo_env, env_var_to_bool, execute_command, out_dir, target, target_arch, target_os,
target_vendor, OutputLibType,
cargo_env, env_var_to_bool, execute_command, get_cflags, out_dir, target, target_arch,
target_os, target_vendor, OutputLibType,
};
use std::path::PathBuf;

Expand Down Expand Up @@ -125,6 +125,12 @@ impl CcBuilder {
}
}

if !get_cflags().is_empty() {
get_cflags().split(' ').for_each(|flag| {
cc_build.flag_if_supported(flag);
});
}

self.add_includes(&mut cc_build);
cc_build
}
Expand Down
8 changes: 6 additions & 2 deletions aws-lc-sys/builder/cmake_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

use crate::OutputLib::{Crypto, RustWrapper, Ssl};
use crate::{
cargo_env, emit_warning, execute_command, is_crt_static, is_no_asm, option_env, target,
target_arch, target_env, target_family, target_os, target_underscored, target_vendor,
cargo_env, emit_warning, execute_command, get_cflags, is_crt_static, is_no_asm, option_env,
target, target_arch, target_env, target_family, target_os, target_underscored, target_vendor,
OutputLibType,
};
use std::env;
Expand Down Expand Up @@ -140,6 +140,10 @@ impl CmakeBuilder {
cmake_cfg.define("ASAN", "1");
}

if !get_cflags().is_empty() {
cmake_cfg.cflag(get_cflags());
}

// Allow environment to specify CMake toolchain.
if let Some(toolchain) = option_env("CMAKE_TOOLCHAIN_FILE").or(option_env(format!(
"CMAKE_TOOLCHAIN_FILE_{}",
Expand Down
14 changes: 10 additions & 4 deletions aws-lc-sys/builder/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ fn generate_src_bindings(manifest_dir: &Path, prefix: &Option<String>, src_bindi
..Default::default()
},
)
.write_to_file(src_bindings_path.join(format!("{}.rs", target_platform_prefix("crypto"))))
.expect("write bindings");
.write_to_file(src_bindings_path.join(format!("{}.rs", target_platform_prefix("crypto"))))
.expect("write bindings");

bindgen::generate_bindings(
manifest_dir,
Expand All @@ -215,8 +215,8 @@ fn generate_src_bindings(manifest_dir: &Path, prefix: &Option<String>, src_bindi
..Default::default()
},
)
.write_to_file(src_bindings_path.join(format!("{}.rs", target_platform_prefix("crypto_ssl"))))
.expect("write bindings");
.write_to_file(src_bindings_path.join(format!("{}.rs", target_platform_prefix("crypto_ssl"))))
.expect("write bindings");
}

fn emit_rustc_cfg(cfg: &str) {
Expand Down Expand Up @@ -318,6 +318,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_CFLAGS: String = String::new();

fn initialize() {
unsafe {
Expand All @@ -327,6 +328,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_CFLAGS = option_env("AWS_LC_SYS_CFLAGS").unwrap_or(String::new());
}

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

fn get_cflags() -> &'static str {
unsafe { AWS_LC_SYS_CFLAGS.as_str() }
}

fn has_bindgen_feature() -> bool {
cfg!(feature = "bindgen")
}
Expand Down
2 changes: 1 addition & 1 deletion docker/linux-cross/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM $CROSS_BASE_IMAGE
ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install --assume-yes --no-install-recommends software-properties-common && \
apt-get install --assume-yes --no-install-recommends gpg-agent software-properties-common && \
add-apt-repository --yes ppa:longsleep/golang-backports && \
apt-get update && \
apt-get install --assume-yes --no-install-recommends build-essential cmake golang-go clang && \
Expand Down

0 comments on commit 0d7ff14

Please sign in to comment.