diff --git a/lib/rustler_precompiled.ex b/lib/rustler_precompiled.ex index 6572b91..544a77e 100644 --- a/lib/rustler_precompiled.ex +++ b/lib/rustler_precompiled.ex @@ -390,7 +390,7 @@ defmodule RustlerPrecompiled do %{target_system | arch: arch, os: "darwin"} target_system.os =~ "linux" -> - arch = with "amd64" <- target_system.arch, do: "x86_64" + arch = normalize_linux_arch(target_system.arch) vendor = with vendor when vendor in ~w(pc redhat suse) <- target_system.vendor, do: "unknown" @@ -402,6 +402,10 @@ defmodule RustlerPrecompiled do end end + defp normalize_linux_arch("amd64"), do: "x86_64" + defp normalize_linux_arch("riscv64"), do: "riscv64gc" + defp normalize_linux_arch(arch), do: arch + defp system_arch_to_string(system_arch) do values = for key <- [:arch, :vendor, :os, :abi], diff --git a/test/rustler_precompiled_test.exs b/test/rustler_precompiled_test.exs index 14c3819..ba85863 100644 --- a/test/rustler_precompiled_test.exs +++ b/test/rustler_precompiled_test.exs @@ -136,6 +136,34 @@ defmodule RustlerPrecompiledTest do RustlerPrecompiled.target(config, @available_targets) end + test "riscv64 running a Linux OS" do + config = %{ + target_system: %{arch: "riscv64", vendor: "unknown", os: "linux", abi: "gnu"}, + nif_version: "2.16", + os_type: {:unix, :linux} + } + + assert {:ok, "nif-2.16-riscv64gc-unknown-linux-gnu"} = + RustlerPrecompiled.target( + config, + @available_targets ++ ["riscv64gc-unknown-linux-gnu"] + ) + end + + test "riscv64 running a Linux OS with MUSL" do + config = %{ + target_system: %{arch: "riscv64", vendor: "unknown", os: "linux", abi: "musl"}, + nif_version: "2.16", + os_type: {:unix, :linux} + } + + assert {:ok, "nif-2.16-riscv64gc-unknown-linux-musl"} = + RustlerPrecompiled.target( + config, + @available_targets ++ ["riscv64gc-unknown-linux-musl"] + ) + end + test "target not available" do config = %{ target_system: %{arch: "i686", vendor: "unknown", os: "linux", abi: "gnu"},