Skip to content

Commit

Permalink
Fix CI on wasm32-wasi
Browse files Browse the repository at this point in the history
The cc dependency doesn't compile on wasi, so only include it for
windows targets.
  • Loading branch information
Amanieu committed Aug 11, 2023
1 parent bd2a215 commit 0b341de
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 26 deletions.
4 changes: 3 additions & 1 deletion crates/stdarch-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ edition = "2021"
[dependencies]
assert-instr-macro = { path = "../assert-instr-macro" }
simd-test-macro = { path = "../simd-test-macro" }
cc = "1.0"
lazy_static = "1.0"
rustc-demangle = "0.1.8"
cfg-if = "1.0"

[target.'cfg(windows)'.dependencies]
cc = "1.0"

# We use a crates.io dependency to disassemble wasm binaries to look for
# instructions for `#[assert_instr]`. Note that we use an `=` dependency here
# instead of a floating dependency because the text format for wasm changes over
Expand Down
58 changes: 33 additions & 25 deletions crates/stdarch-test/src/disassembly.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Disassembly calling function for most targets.

use crate::Function;
use std::{collections::HashSet, env, process::Command, str};
use std::{collections::HashSet, env, str};

// Extracts the "shim" name from the `symbol`.
fn normalize(mut symbol: &str) -> String {
Expand Down Expand Up @@ -39,10 +39,11 @@ fn normalize(mut symbol: &str) -> String {
symbol
}

#[cfg(windows)]
pub(crate) fn disassemble_myself() -> HashSet<Function> {
let me = env::current_exe().expect("failed to get current exe");

let disassembly = if cfg!(target_os = "windows") && cfg!(target_env = "msvc") {
let disassembly = if cfg!(target_env = "msvc") {
let target = if cfg!(target_arch = "x86_64") {
"x86_64-pc-windows-msvc"
} else if cfg!(target_arch = "x86") {
Expand All @@ -65,32 +66,39 @@ pub(crate) fn disassemble_myself() -> HashSet<Function> {
assert!(output.status.success());
// Windows does not return valid UTF-8 output:
String::from_utf8_lossy(Vec::leak(output.stdout))
} else if cfg!(target_os = "windows") {
panic!("disassembly unimplemented")
} else {
let objdump = env::var("OBJDUMP").unwrap_or_else(|_| "objdump".to_string());
let add_args = if cfg!(target_os = "macos") && cfg!(target_arch = "aarch64") {
// Target features need to be enabled for LLVM objdump on Macos ARM64
vec!["--mattr=+v8.6a,+crypto,+tme"]
} else {
vec![]
};
let output = Command::new(objdump.clone())
.arg("--disassemble")
.arg("--no-show-raw-insn")
.args(add_args)
.arg(&me)
.output()
.unwrap_or_else(|_| panic!("failed to execute objdump. OBJDUMP={objdump}"));
println!(
"{}\n{}",
output.status,
String::from_utf8_lossy(&output.stderr)
);
assert!(output.status.success());
panic!("disassembly unimplemented")
};

String::from_utf8_lossy(Vec::leak(output.stdout))
parse(&disassembly)
}

#[cfg(not(windows))]
pub(crate) fn disassemble_myself() -> HashSet<Function> {
let me = env::current_exe().expect("failed to get current exe");

let objdump = env::var("OBJDUMP").unwrap_or_else(|_| "objdump".to_string());
let add_args = if cfg!(target_os = "macos") && cfg!(target_arch = "aarch64") {
// Target features need to be enabled for LLVM objdump on Macos ARM64
vec!["--mattr=+v8.6a,+crypto,+tme"]
} else {
vec![]
};
let output = std::process::Command::new(objdump.clone())
.arg("--disassemble")
.arg("--no-show-raw-insn")
.args(add_args)
.arg(&me)
.output()
.unwrap_or_else(|_| panic!("failed to execute objdump. OBJDUMP={objdump}"));
println!(
"{}\n{}",
output.status,
String::from_utf8_lossy(&output.stderr)
);
assert!(output.status.success());

let disassembly = String::from_utf8_lossy(Vec::leak(output.stdout));

parse(&disassembly)
}
Expand Down

0 comments on commit 0b341de

Please sign in to comment.