Skip to content

Commit 6cd0bf5

Browse files
authored
Add support for precompiled ARM 64-bits on Linux (#30)
This is needed for the Raspberry Pi 4 that has a different architecture from the other versions.
1 parent be3c19d commit 6cd0bf5

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

.github/workflows/release.yml

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
job:
2525
# NIF version 2.16
2626
- { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04 , nif: "2.16", use-cross: true }
27+
- { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04 , nif: "2.16", use-cross: true }
2728
- { target: aarch64-apple-darwin , os: macos-10.15 , nif: "2.16" }
2829
- { target: x86_64-apple-darwin , os: macos-10.15 , nif: "2.16" }
2930
- { target: x86_64-unknown-linux-gnu , os: ubuntu-20.04 , nif: "2.16" }
@@ -32,6 +33,7 @@ jobs:
3233
- { target: x86_64-pc-windows-msvc , os: windows-2019 , nif: "2.16" }
3334
# NIF version 2.15
3435
- { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04 , nif: "2.15", use-cross: true }
36+
- { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04 , nif: "2.15", use-cross: true }
3537
- { target: aarch64-apple-darwin , os: macos-10.15 , nif: "2.15" }
3638
- { target: x86_64-apple-darwin , os: macos-10.15 , nif: "2.15" }
3739
- { target: x86_64-unknown-linux-gnu , os: ubuntu-20.04 , nif: "2.15" }
@@ -40,6 +42,7 @@ jobs:
4042
- { target: x86_64-pc-windows-msvc , os: windows-2019 , nif: "2.15" }
4143
# NIF version 2.14
4244
- { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04 , nif: "2.14", use-cross: true }
45+
- { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04 , nif: "2.14", use-cross: true }
4346
- { target: aarch64-apple-darwin , os: macos-10.15 , nif: "2.14" }
4447
- { target: x86_64-apple-darwin , os: macos-10.15 , nif: "2.14" }
4548
- { target: x86_64-unknown-linux-gnu , os: ubuntu-20.04 , nif: "2.14" }

lib/html5ever/precompiled.ex

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ defmodule Html5ever.Precompiled do
99
x86_64-unknown-linux-gnu
1010
x86_64-unknown-linux-musl
1111
arm-unknown-linux-gnueabihf
12+
aarch64-unknown-linux-gnu
1213
x86_64-pc-windows-msvc
1314
x86_64-pc-windows-gnu
1415
)
@@ -171,7 +172,7 @@ defmodule Html5ever.Precompiled do
171172

172173
# Fix vendor for Nerves
173174
vendor =
174-
if arch == "arm" and vendor == "buildroot" do
175+
if arch in ["arm", "aarch64"] and vendor == "buildroot" do
175176
"unknown"
176177
else
177178
vendor

test/html5ever/precompiled_test.exs

+9-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ defmodule Html5ever.PrecompiledTest do
4242

4343
assert {:ok, "nif-2.16-arm-unknown-linux-gnueabihf"} = Precompiled.target(config)
4444

45+
config = %{
46+
system_arch: %{arch: "aarch64", vendor: "buildroot", os: "linux", abi: "gnu"},
47+
nif_version: "2.16",
48+
os_type: {:unix, :linux}
49+
}
50+
51+
assert {:ok, "nif-2.16-aarch64-unknown-linux-gnu"} = Precompiled.target(config)
52+
4553
config = %{
4654
system_arch: %{},
4755
word_size: 8,
@@ -58,7 +66,7 @@ defmodule Html5ever.PrecompiledTest do
5866
}
5967

6068
error_message =
61-
"precompiled NIF is not available for this target: \"i686-unknown-linux-gnu\".\nThe available targets are:\n - aarch64-apple-darwin\n - x86_64-apple-darwin\n - x86_64-unknown-linux-gnu\n - x86_64-unknown-linux-musl\n - arm-unknown-linux-gnueabihf\n - x86_64-pc-windows-msvc\n - x86_64-pc-windows-gnu"
69+
"precompiled NIF is not available for this target: \"i686-unknown-linux-gnu\".\nThe available targets are:\n - aarch64-apple-darwin\n - x86_64-apple-darwin\n - x86_64-unknown-linux-gnu\n - x86_64-unknown-linux-musl\n - arm-unknown-linux-gnueabihf\n - aarch64-unknown-linux-gnu\n - x86_64-pc-windows-msvc\n - x86_64-pc-windows-gnu"
6270

6371
assert {:error, ^error_message} = Precompiled.target(config)
6472
end

0 commit comments

Comments
 (0)