Skip to content

Commit

Permalink
Support riscv64 as binary platform (#54011)
Browse files Browse the repository at this point in the history
This patch adds support for `riscv64` as binary platform.

Note: This only allows Julia to handle `riscv64` in `BinaryPlatforms`
and `CPUID`. There is no support for either code generation or building
Julia on RISC-V systems. This is only a necessary first step towards
these goals. In particular, this is necessary to support building
external libraries for RISC-V via BinaryBuilder as described in
JuliaPackaging/BinaryBuilderBase.jl#374.

---------

Co-authored-by: Oscar Smith <oscardssmith@gmail.com>
  • Loading branch information
eschnett and oscardssmith authored Apr 29, 2024
1 parent 68da780 commit 71f4548
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions base/binaryplatforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ end
function validate_tags(tags::Dict)
throw_invalid_key(k) = throw(ArgumentError("Key \"$(k)\" cannot have value \"$(tags[k])\""))
# Validate `arch`
if tags["arch"] ("x86_64", "i686", "armv7l", "armv6l", "aarch64", "powerpc64le")
if tags["arch"] ("x86_64", "i686", "armv7l", "armv6l", "aarch64", "powerpc64le", "riscv64")
throw_invalid_key("arch")
end
# Validate `os`
Expand Down Expand Up @@ -597,6 +597,7 @@ const arch_mapping = Dict(
"armv7l" => "arm(v7l)?", # if we just see `arm-linux-gnueabihf`, we assume it's `armv7l`
"armv6l" => "armv6l",
"powerpc64le" => "p(ower)?pc64le",
"riscv64" => "riscv64",
)
# Keep this in sync with `CPUID.ISAs_by_family`
# These are the CPUID side of the microarchitectures targeted by GCC flags in BinaryBuilder.jl
Expand Down Expand Up @@ -632,7 +633,10 @@ const arch_march_isa_mapping = let
],
"powerpc64le" => [
"power8" => get_set("powerpc64le", "power8"),
]
],
"riscv64" => [
"riscv64" => get_set("riscv64", "riscv64"),
],
)
end
const os_mapping = Dict(
Expand Down
6 changes: 5 additions & 1 deletion base/cpuid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ const ISAs_by_family = Dict(
"powerpc64le" => [
# We have no way to test powerpc64le features yet, so we're only going to declare the lowest ISA:
"power8" => ISA(Set{UInt32}()),
]
],
"riscv64" => [
# We have no way to test riscv64 features yet, so we're only going to declare the lowest ISA:
"riscv64" => ISA(Set{UInt32}()),
],
)

# Test a CPU feature exists on the currently-running host
Expand Down

0 comments on commit 71f4548

Please sign in to comment.