Skip to content

Commit

Permalink
Add cross testing for linux arm64 & armhf (#402)
Browse files Browse the repository at this point in the history
* Fix mozjs for arm

Co-authored-by: =?UTF-8?q?Fabrice=20Desr=C3=A9?= <[email protected]>

* Add cross configuration and cross testing in CI

* Update readme for linux

* build_result needs cross

* try

* re

* fix ci

* use servo docker images

* Update Cross.toml

* Apply suggestions from code review

Co-authored-by: Martin Robinson <[email protected]>

---------

Co-authored-by: =?UTF-8?q?Fabrice=20Desr=C3=A9?= <[email protected]>
Co-authored-by: Martin Robinson <[email protected]>
  • Loading branch information
3 people authored Sep 19, 2023
1 parent b6246b2 commit d968433
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,24 @@ jobs:
run: |
./android-build cargo build --target="armv7-linux-androideabi"
linux-cross-compile:
name: linux (${{ matrix.target }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- aarch64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
container: ghcr.io/servo/cross-${{ matrix.target }}:main
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- run: cargo test --target ${{ matrix.target }}

# The integrity check is currently broken. See issue #345.
#
# Integrity:
Expand All @@ -135,7 +153,7 @@ jobs:
build_result:
name: Result
runs-on: ubuntu-latest
needs: ["mac", "linux", "windows", "android"]
needs: ["android", "linux", "linux-cross-compile", "mac", "windows"]
if: ${{ always() }}
steps:
- name: Mark the job as successful
Expand Down
5 changes: 5 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[target.aarch64-unknown-linux-gnu]
image = "ghcr.io/servo/cross-aarch64-unknown-linux-gnu:main"

[target.armv7-unknown-linux-gnueabihf]
image = "ghcr.io/servo/cross-armv7-unknown-linux-gnueabihf:main"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ are in the [rust-mozjs directory][r-m].

## Linux

Install Clang and `build-essential`, for example on a Debian-based Linux:
Install Python, Clang and `build-essential`, for example on a Debian-based Linux:

```sh
sudo apt-get install clang build-essential
sudo apt-get install build-essential python3 python3-distutils llvm libclang-dev clang
```

If you have more than one version of Clang installed, you can set the `LIBCLANG_PATH`
Expand Down
14 changes: 10 additions & 4 deletions mozjs/makefile.cargo
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ endif
ifneq ($(HOST),$(TARGET))

ifeq (armv7-linux-androideabi,$(TARGET))
# Reset TARGET variable because armv7 target name used by Rust is not
# Reset TARGET variable because armv7 target name used by Rust is not
# the same as the target name needed for the CXX toolchain.
TARGET = armv7a-linux-androideabi
CONFIGURE_FLAGS += \
Expand All @@ -54,13 +54,19 @@ ifneq ($(HOST),$(TARGET))
$(NULL)
endif

ifeq (armv7-unknown-linux-gnueabihf,$(TARGET))
# Reset TARGET variable because armv7 target name used by Rust is not
# the same as the target name needed for the CXX toolchain.
TARGET = arm-linux-gnueabihf
CONFIGURE_FLAGS += \
--with-arch=armv7-a \
$(NULL)
endif

ifeq (aarch64-unknown-linux-gnu,$(TARGET))
# Reset TARGET variable because aarch64 target name used by Rust is not
# the same as the target name needed for the CXX toolchain.
TARGET = aarch64-linux-gnu
CONFIGURE_FLAGS += \
--with-arch=armv8-a \
$(NULL)
endif

ifeq (android,$(findstring android,$(TARGET)))
Expand Down
3 changes: 2 additions & 1 deletion mozjs/tests/evaluate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use mozjs_sys::jsapi::JSCLASS_GLOBAL_FLAGS;

use std::mem;
use std::ptr;
use core::ffi::c_char;

// The class operations for the global object.
static GLOBAL_CLASS_OPS: JSClassOps = JSClassOps {
Expand All @@ -37,7 +38,7 @@ static GLOBAL_CLASS_OPS: JSClassOps = JSClassOps {

// The class of the global object.
static GLOBAL_CLASS: JSClass = JSClass {
name: "global\0" as *const str as *const i8,
name: "global\0" as *const str as *const c_char,
flags: JSCLASS_GLOBAL_FLAGS,
cOps: &GLOBAL_CLASS_OPS,
spec: ptr::null(),
Expand Down

0 comments on commit d968433

Please sign in to comment.