Skip to content

Commit

Permalink
Try updated build for cross
Browse files Browse the repository at this point in the history
  • Loading branch information
milesgranger committed Sep 21, 2024
1 parent 90694bc commit 242a77e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 25 deletions.
16 changes: 5 additions & 11 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,18 @@ jobs:
matrix:
target:
- x86_64-unknown-linux-musl
# - s390x-unknown-linux-gnu # TODO: won't compile for s390x
- s390x-unknown-linux-gnu # TODO: won't compile for s390x
- aarch64-unknown-linux-musl
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install build deps
run: |
sudo apt update
sudo apt install nasm gcc-s390x-linux-gnu musl-tools
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
- name: Install cross
run: cargo install cross --git https://github.com/cross-rs/cross --rev 6d097fb

- name: Build
run: cargo build --target ${{ matrix.target }} --release
run: cross build --target ${{ matrix.target }} --release

test-wasm32-emscripten:
runs-on: ubuntu-latest
Expand Down
9 changes: 7 additions & 2 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
[target.x86_64-unknown-linux-musl]
pre-build = [
"apt update",
"apt install -y llvm-dev libclang-dev clang nasm"
"apt install -y nasm"
]
[target.s390x-unknown-linux-gnu]
pre-build = [
"apt update",
"apt install -y llvm-dev libclang-dev clang nasm"
"apt install -y nasm"
]
[target.aarch64-unknown-linux-musl]
pre-build = [
"apt update",
"apt install -y nasm"
]
1 change: 1 addition & 0 deletions isal-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ regenerate-bindings = ["dep:bindgen"]
[dependencies]

[build-dependencies]
cc = "^1"
bindgen = { version = "^0.69", optional = true }
copy_dir = "0.1.3"

Expand Down
17 changes: 5 additions & 12 deletions isal-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ fn main() {
let is_static = cfg!(feature = "static");
let is_shared = cfg!(feature = "shared");
let target = std::env::var("TARGET").unwrap();
let profile = std::env::var("PROFILE").unwrap();
let out_dir = PathBuf::from(&std::env::var("OUT_DIR").unwrap());

// Copy isa-l source into out; not allow to modify things outside of out dir
Expand Down Expand Up @@ -41,24 +40,18 @@ fn main() {
panic!("autogen failed");
}

let compiler = cc::Build::new().get_compiler();
let cflags = compiler.cflags_env().into_string().unwrap();

let mut configure_args = vec![
format!("--prefix={}", install_path.display()),
format!("--host={}", target),
format!("--enable-static={}", if is_static { "yes" } else { "no" }),
format!("--enable-shared={}", if is_shared { "yes" } else { "no" }),
format!("CFLAGS={}", cflags),
format!("CC={}", compiler.path().display()),
];
let opt = if profile == "release" { "-O3" } else { "-O1" };
configure_args.push(format!("CFLAGS=-g {}", opt));

if target.starts_with("wasm32") {
configure_args.push("CC=emcc".to_string());
}
if target == "s390x-unknown-linux-gnu" {
configure_args.push("CC=s390x-linux-gnu-gcc".to_string());
}
if target == "x86_64-unknown-linux-musl" {
configure_args.push("CC=musl-gcc".to_string());
}
if !cfg!(target_os = "macos") {
let ldflag = if is_static { "static" } else { "shared" };
configure_args.push(format!("LDFLAGS=-{}", ldflag));
Expand Down

0 comments on commit 242a77e

Please sign in to comment.