Skip to content

Commit 8a7b489

Browse files
bors[bot]nlewyckysyrusakbary
authored
Merge #1044
1044: Initial commit for support of AArch64 in the llvm backend. r=syrusakbary a=nlewycky # Description Enables AArch64 in the llvm backend, and inkwell when the target_arch is aarch64. Adds relevant failing spectests to the excludes.txt. # Review - [x] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Nick Lewycky <nick@wasmer.io> Co-authored-by: Syrus Akbary <me@syrusakbary.com>
2 parents 17aecf9 + 952309a commit 8a7b489

File tree

7 files changed

+35
-8
lines changed

7 files changed

+35
-8
lines changed

.azure/install-llvm.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ steps:
3131
3232
- bash: |
3333
set -ex
34-
curl -OL https://github.com/wasmerio/windows-llvm-build/releases/download/v8.0.0/llvm-8.0.0-install.zip
35-
7z x llvm-8.0.0-install.zip
36-
llvm=`pwd`/llvm-8.0.0-install
34+
curl -OL https://github.com/wasmerio/llvm-build/releases/download/8.x/Win64_Release.zip
35+
7z x Win64_Release.zip
36+
llvm=`pwd`/Win64_Release
3737
echo "##vso[task.prependpath]$llvm/bin"
3838
echo "##vso[task.setvariable variable=LLVM_SYS_80_PREFIX;]$llvm"
3939
displayName: "Install LLVM (Windows)"

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- [#1052](https://github.com/wasmerio/wasmer/pull/1052) Fix minor panic and improve Error handling in singlepass backend.
1212
- [#1050](https://github.com/wasmerio/wasmer/pull/1050) Attach C & C++ headers to releases.
1313
- [#1033](https://github.com/wasmerio/wasmer/pull/1033) Set cranelift backend as default compiler backend again, require at least one backend to be enabled for Wasmer CLI
14+
- [#1044](https://github.com/wasmerio/wasmer/pull/1044) Enable AArch64 support in the LLVM backend.
1415
- [#1030](https://github.com/wasmerio/wasmer/pull/1030) Ability to generate `ImportObject` for a specific version WASI version with the C API.
1516
- [#1028](https://github.com/wasmerio/wasmer/pull/1028) Introduce strict/non-strict modes for `get_wasi_version`
1617
- [#1029](https://github.com/wasmerio/wasmer/pull/1029) Add the “floating” `WasiVersion::Latest` version.

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ wasitests: wasitests-unit wasitests-singlepass wasitests-cranelift wasitests-llv
8989
# Backends
9090
singlepass: spectests-singlepass emtests-singlepass middleware-singlepass wasitests-singlepass
9191
cargo test -p wasmer-singlepass-backend --release
92-
cargo test -p wasmer-runtime-core-tests --release --no-default-features --features backend-singlepass
92+
cargo test --manifest-path lib/runtime-core-tests/Cargo.toml --release --no-default-features --features backend-singlepass
9393

9494
cranelift: spectests-cranelift emtests-cranelift middleware-cranelift wasitests-cranelift
9595
cargo test -p wasmer-clif-backend --release
@@ -98,7 +98,7 @@ cranelift: spectests-cranelift emtests-cranelift middleware-cranelift wasitests-
9898
llvm: spectests-llvm emtests-llvm wasitests-llvm
9999
cargo test -p wasmer-llvm-backend --release
100100
cargo test -p wasmer-llvm-backend-tests --release
101-
cargo test -p wasmer-runtime-core-tests --release --no-default-features --features backend-llvm
101+
cargo test --manifest-path lib/runtime-core-tests/Cargo.toml --release --no-default-features --features backend-llvm
102102

103103

104104
# All tests

lib/llvm-backend/Cargo.toml

+7-1
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,18 @@ goblin = "0.0.24"
1717
libc = "0.2.60"
1818
byteorder = "1"
1919

20-
[dependencies.inkwell]
20+
[target.'cfg(target_arch = "x86_64")'.dependencies.inkwell]
2121
git = "https://github.com/TheDan64/inkwell"
2222
rev = "781620e9fa30e51a6e03bd0d49b5f5bb7a782520"
2323
default-features = false
2424
features = ["llvm8-0", "target-x86"]
2525

26+
[target.'cfg(target_arch = "aarch64")'.dependencies.inkwell]
27+
git = "https://github.com/TheDan64/inkwell"
28+
rev = "781620e9fa30e51a6e03bd0d49b5f5bb7a782520"
29+
default-features = false
30+
features = ["llvm8-0", "target-aarch64"]
31+
2632
[target.'cfg(unix)'.dependencies]
2733
nix = "0.15"
2834

lib/llvm-backend/src/code.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -8465,6 +8465,7 @@ impl<'ctx> ModuleCodeGenerator<LLVMFunctionCodeGenerator<'ctx>, LLVMBackend, Cod
84658465
let triple = triple.unwrap_or(TargetMachine::get_default_triple().to_string());
84668466

84678467
match triple {
8468+
#[cfg(target_arch = "x86_64")]
84688469
_ if triple.starts_with("x86") => Target::initialize_x86(&InitializationConfig {
84698470
asm_parser: true,
84708471
asm_printer: true,
@@ -8473,7 +8474,18 @@ impl<'ctx> ModuleCodeGenerator<LLVMFunctionCodeGenerator<'ctx>, LLVMBackend, Cod
84738474
info: true,
84748475
machine_code: true,
84758476
}),
8476-
_ => unimplemented!("compile to target other than x86-64 is not supported"),
8477+
#[cfg(target_arch = "aarch64")]
8478+
_ if triple.starts_with("aarch64") => {
8479+
Target::initialize_aarch64(&InitializationConfig {
8480+
asm_parser: true,
8481+
asm_printer: true,
8482+
base: true,
8483+
disassembler: true,
8484+
info: true,
8485+
machine_code: true,
8486+
})
8487+
}
8488+
_ => unimplemented!("target {} not supported", triple),
84778489
}
84788490

84798491
let target = Target::from_triple(&triple).unwrap();

lib/llvm-backend/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
unused_unsafe,
77
unreachable_patterns
88
)]
9-
#![cfg_attr(not(target_os = "windows"), deny(dead_code))]
9+
#![cfg_attr(
10+
all(not(target_os = "windows"), not(target_arch = "aarch64")),
11+
deny(dead_code)
12+
)]
1013
#![cfg_attr(nightly, feature(unwind_attributes))]
1114
#![doc(html_favicon_url = "https://wasmer.io/static/icons/favicon.ico")]
1215
#![doc(html_logo_url = "https://avatars3.githubusercontent.com/u/44205449?s=200&v=4")]

lib/spectests/tests/excludes.txt

+5
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,11 @@ llvm:fail:f64.wast:1621 # AssertReturn - result F64(0) ("0x0") does not match ex
273273
llvm:fail:f64.wast:2020 # AssertReturn - result F64(9223372036854775808) ("0x8000000000000000") does not match expected F64(0) ("0x0")
274274
llvm:fail:linking.wast:388 # AssertReturn - Call failed RuntimeError: WebAssembly trap occurred during runtime: incorrect `call_indirect` signature
275275

276+
# LLVM AArch64
277+
llvm:skip:atomic.wast:*:*:aarch64 # Out of range relocations.
278+
llvm:skip:skip-stack-guard-page.wast:2275:*:aarch64 # Uncaught SIGSEGV only in release builds
279+
llvm:skip:skip-stack-guard-page.wast:2282:*:aarch64 # Uncaught SIGSEGV only in release builds
280+
276281
# LLVM Windows
277282
llvm:skip:address.wast:*:windows
278283
llvm:skip:align.wast:*:windows

0 commit comments

Comments
 (0)