Use global_asm! instead of external assembly files (#4306)
* Use `global_asm!` instead of external assembly files This commit moves the external assembly files of the `wasmtime-fiber` crate into `global_asm!` blocks defined in Rust. The motivation for doing this is not very strong at this time, but the points in favor of this are: * One less tool needed to cross-compile Wasmtime. A linker is still needed but perhaps one day that will improve as well. * A "modern" assembler, built-in to LLVM, is used instead of whatever appears on the system. The first point hasn't really cropped up that much and typically getting an assembler is just as hard as getting a linker nowadays. The second point though has us using `hint #xx` in aarch64 assembly instead of the actual instructions for assembler compatibility, and I believe that's no longer necessary because the LLVM assembler supports the modern instruction names. The translation of the x86/x86_64 assembly has been done to Intel syntax as well as opposed to the old AT&T syntax since that's Rust's default. Additionally s390x still remains in an external assembler file because `global_asm!` is still unstable in Rust on that platform. * Simplify alignment specification * Temporarily disable fail-fast * Add `.cfi_def_cfa_offset 0` to fix CI * Turn off fail-fast * Review comments
This commit is contained in:
@@ -1,23 +1,18 @@
|
||||
use std::env;
|
||||
use std::fs;
|
||||
|
||||
fn main() {
|
||||
let mut build = cc::Build::new();
|
||||
let arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
||||
let family = env::var("CARGO_CFG_TARGET_FAMILY").unwrap();
|
||||
let os = env::var("CARGO_CFG_TARGET_OS").unwrap();
|
||||
|
||||
let family_file = format!("src/arch/{}.c", family);
|
||||
let arch_file = format!("src/arch/{}.S", arch);
|
||||
if fs::metadata(&family_file).is_ok() {
|
||||
build.file(&family_file);
|
||||
} else if fs::metadata(&arch_file).is_ok() {
|
||||
build.file(&arch_file);
|
||||
if os == "windows" {
|
||||
build.file("src/windows.c");
|
||||
} else if arch == "s390x" {
|
||||
build.file("src/unix/s390x.S");
|
||||
} else {
|
||||
panic!(
|
||||
"wasmtime doesn't support fibers on platform: {}",
|
||||
env::var("TARGET").unwrap()
|
||||
);
|
||||
// assume that this is included via inline assembly in the crate itself,
|
||||
// and the crate will otherwise have a `compile_error!` for unsupported
|
||||
// platforms.
|
||||
return;
|
||||
}
|
||||
build.define(&format!("CFG_TARGET_OS_{}", os), None);
|
||||
build.define(&format!("CFG_TARGET_ARCH_{}", arch), None);
|
||||
|
||||
Reference in New Issue
Block a user