Skip to content

Commit

Permalink
Support riscv64 platform (#375)
Browse files Browse the repository at this point in the history
* Support riscv64 platform

* Pirate Base.BinaryPlatform functions to add riscv64 support

* Add riscv64 artifacts

* Add riscv64 artifacts

* Bump version

* Overwrite more BinaryPlatform functions

* Overwrite more BinaryPlatform functions

* Overwrite more BinaryPlatform functions

* Overwrite more BinaryPlatform functions

* More riscv64 support

* More riscv64 support

* More riscv64 support

* More riscv64 support

* More riscv64 support

* More riscv64 support

* More riscv64 support

* More riscv64 support

* More riscv64 support

* More riscv64 support

* More riscv64 support

* More riscv64 support

* More riscv64 support

* More riscv64 support

* More riscv64 support

* More riscv64 support

* More riscv64 support

* More riscv64 support

* More riscv64 support

* More riscv64 support

* More riscv64 support

* Update tests for riscv64

* Update tests for riscv64

* Make changes requested in code review

* Make changes requested in code review

* Support riscv64 for Go

* Specify riscv64 ABI

* Don't use experimental platforms

* Correct doctests

* Correct doctests

* Update default riscv64 ABI

* Remove outdated and unnecessary artifacts

* Correct typo in comment
  • Loading branch information
eschnett authored Dec 23, 2024
1 parent ed9eeeb commit a548ba2
Show file tree
Hide file tree
Showing 11 changed files with 376 additions and 13 deletions.
132 changes: 132 additions & 0 deletions Artifacts.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1956,6 +1956,94 @@ os = "linux"
sha256 = "d49106316ef5a4dc8cbce8665e720526a921cbba89dc38be41d53fc65c18007f"
url = "https://github.com/JuliaPackaging/Yggdrasil/releases/download/GCCBootstrap-v9.1.0+2/GCCBootstrap-powerpc64le-linux-gnu.v9.1.0.x86_64-linux-musl.unpacked.tar.gz"

[["GCCBootstrap-riscv64-linux-gnu.v12.1.0.x86_64-linux-musl.squashfs"]]
arch = "x86_64"
git-tree-sha1 = "0e0e172850698ee5784355eebeaf661278cfc489"
lazy = true
libc = "musl"
os = "linux"

[["GCCBootstrap-riscv64-linux-gnu.v12.1.0.x86_64-linux-musl.squashfs".download]]
sha256 = "a51037a3b4eff64d08f63c48d16a5b873833d83a2085ac365cf11b0918c503cf"
url = "https://github.com/JuliaPackaging/Yggdrasil/releases/download/GCCBootstrap-v12.1.0/GCCBootstrap-riscv64-linux-gnu.v12.1.0.x86_64-linux-musl.squashfs.tar.gz"

[["GCCBootstrap-riscv64-linux-gnu.v12.1.0.x86_64-linux-musl.unpacked"]]
arch = "x86_64"
git-tree-sha1 = "55460cf13be2ec9fe829768b49ea5b2ba49954ef"
lazy = true
libc = "musl"
os = "linux"

[["GCCBootstrap-riscv64-linux-gnu.v12.1.0.x86_64-linux-musl.unpacked".download]]
sha256 = "671879f013264f1627b5bff6ec246fd2806b4bc1ae9db74390df7004e00891d5"
url = "https://github.com/JuliaPackaging/Yggdrasil/releases/download/GCCBootstrap-v12.1.0/GCCBootstrap-riscv64-linux-gnu.v12.1.0.x86_64-linux-musl.unpacked.tar.gz"

[["GCCBootstrap-riscv64-linux-gnu.v13.2.0.x86_64-linux-musl.squashfs"]]
arch = "x86_64"
git-tree-sha1 = "83e2aeef1b7ff0abe246d83065877e36f270bb32"
lazy = true
libc = "musl"
os = "linux"

[["GCCBootstrap-riscv64-linux-gnu.v13.2.0.x86_64-linux-musl.squashfs".download]]
sha256 = "a23f65e83be13b0eed7614b77e484dced1db4192732000edc1d4e52e39e4732e"
url = "https://github.com/JuliaPackaging/Yggdrasil/releases/download/GCCBootstrap-v13.2.0/GCCBootstrap-riscv64-linux-gnu.v13.2.0.x86_64-linux-musl.squashfs.tar.gz"

[["GCCBootstrap-riscv64-linux-gnu.v13.2.0.x86_64-linux-musl.unpacked"]]
arch = "x86_64"
git-tree-sha1 = "f62985d28a28baf1017c91dbd9f7fe504a718c12"
lazy = true
libc = "musl"
os = "linux"

[["GCCBootstrap-riscv64-linux-gnu.v13.2.0.x86_64-linux-musl.unpacked".download]]
sha256 = "fc2b0c57b83c22416cdab285b8e3efaa3c55988d1a771e2ade6308d6b24674f5"
url = "https://github.com/JuliaPackaging/Yggdrasil/releases/download/GCCBootstrap-v13.2.0/GCCBootstrap-riscv64-linux-gnu.v13.2.0.x86_64-linux-musl.unpacked.tar.gz"

[["GCCBootstrap-riscv64-linux-musl.v12.1.0.x86_64-linux-musl.squashfs"]]
arch = "x86_64"
git-tree-sha1 = "0a988108fd945733a2b493ae398b67588abc0e32"
lazy = true
libc = "musl"
os = "linux"

[["GCCBootstrap-riscv64-linux-musl.v12.1.0.x86_64-linux-musl.squashfs".download]]
sha256 = "2fe11e0f794df6af2ab39b8e6d1c4efc32cdb792fd045409cdcedd96d643a1c5"
url = "https://github.com/JuliaPackaging/Yggdrasil/releases/download/GCCBootstrap-v12.1.0/GCCBootstrap-riscv64-linux-musl.v12.1.0.x86_64-linux-musl.squashfs.tar.gz"

[["GCCBootstrap-riscv64-linux-musl.v12.1.0.x86_64-linux-musl.unpacked"]]
arch = "x86_64"
git-tree-sha1 = "a10265906d9a12bbc7a2a9a6ed0a4d67cb6a3ad0"
lazy = true
libc = "musl"
os = "linux"

[["GCCBootstrap-riscv64-linux-musl.v12.1.0.x86_64-linux-musl.unpacked".download]]
sha256 = "d958a67682d30ea9e04116db4f463c17f0bf63823e352692d5fe7982da86e220"
url = "https://github.com/JuliaPackaging/Yggdrasil/releases/download/GCCBootstrap-v12.1.0/GCCBootstrap-riscv64-linux-musl.v12.1.0.x86_64-linux-musl.unpacked.tar.gz"

[["GCCBootstrap-riscv64-linux-musl.v13.2.0.x86_64-linux-musl.squashfs"]]
arch = "x86_64"
git-tree-sha1 = "fa8d3617b8a7a823076c43315b19eea746e61ea0"
lazy = true
libc = "musl"
os = "linux"

[["GCCBootstrap-riscv64-linux-musl.v13.2.0.x86_64-linux-musl.squashfs".download]]
sha256 = "0b1e047575add41887b4706971bc36d34c235a0561e8e03b03698d76b61c7262"
url = "https://github.com/JuliaPackaging/Yggdrasil/releases/download/GCCBootstrap-v13.2.0/GCCBootstrap-riscv64-linux-musl.v13.2.0.x86_64-linux-musl.squashfs.tar.gz"

[["GCCBootstrap-riscv64-linux-musl.v13.2.0.x86_64-linux-musl.unpacked"]]
arch = "x86_64"
git-tree-sha1 = "87d33912a955c60bda8476493049f905092cd1db"
lazy = true
libc = "musl"
os = "linux"

[["GCCBootstrap-riscv64-linux-musl.v13.2.0.x86_64-linux-musl.unpacked".download]]
sha256 = "a45d64532488eccb57d65b1dc3fbc5aa65b1204a327f05a0db14d4ff582b2b59"
url = "https://github.com/JuliaPackaging/Yggdrasil/releases/download/GCCBootstrap-v13.2.0/GCCBootstrap-riscv64-linux-musl.v13.2.0.x86_64-linux-musl.unpacked.tar.gz"

[["GCCBootstrap-x86_64-apple-darwin14.v10.2.0.x86_64-linux-musl.squashfs"]]
arch = "x86_64"
git-tree-sha1 = "ceb591a6cf8b32224a2a62cf3d8a9572c1c83e62"
Expand Down Expand Up @@ -4068,6 +4156,50 @@ os = "linux"
sha256 = "5368cefab3e9ebd704d60f13fa5982d1d8566d9025c47ad6288c0c4f3f02efb7"
url = "https://github.com/JuliaPackaging/Yggdrasil/releases/download/PlatformSupport-v2024.8.10/PlatformSupport-powerpc64le-linux-gnu.v2024.8.10.x86_64-linux-musl.unpacked.tar.gz"

[["PlatformSupport-riscv64-linux-gnu.v2024.12.21.x86_64-linux-musl.squashfs"]]
arch = "x86_64"
git-tree-sha1 = "b176fca4332dbcd60e0f4195feafef712394be6d"
lazy = true
libc = "musl"
os = "linux"

[["PlatformSupport-riscv64-linux-gnu.v2024.12.21.x86_64-linux-musl.squashfs".download]]
sha256 = "6348339e933ca990739e4328a4bcf449cb2944feea590f84ca9b25a6dfba6cb4"
url = "https://github.com/JuliaPackaging/Yggdrasil/releases/download/PlatformSupport-v2024.12.21/PlatformSupport-riscv64-linux-gnu.v2024.12.21.x86_64-linux-musl.squashfs.tar.gz"

[["PlatformSupport-riscv64-linux-gnu.v2024.12.21.x86_64-linux-musl.unpacked"]]
arch = "x86_64"
git-tree-sha1 = "5b9695b4efe229b51926b4c9ffb9a0c891e8ccdd"
lazy = true
libc = "musl"
os = "linux"

[["PlatformSupport-riscv64-linux-gnu.v2024.12.21.x86_64-linux-musl.unpacked".download]]
sha256 = "757fe58ba7561cb61051ef22e8a36f3066fb63b0978cf14ad276313368c43a5f"
url = "https://github.com/JuliaPackaging/Yggdrasil/releases/download/PlatformSupport-v2024.12.21/PlatformSupport-riscv64-linux-gnu.v2024.12.21.x86_64-linux-musl.unpacked.tar.gz"

[["PlatformSupport-riscv64-linux-musl.v2024.12.21.x86_64-linux-musl.squashfs"]]
arch = "x86_64"
git-tree-sha1 = "72708b43067d2c5b35e46fee91fc1f1164f540af"
lazy = true
libc = "musl"
os = "linux"

[["PlatformSupport-riscv64-linux-musl.v2024.12.21.x86_64-linux-musl.squashfs".download]]
sha256 = "a8330a71a91ada1eebad7874911ca51cdba7cef5ad0512495384e44fea564507"
url = "https://github.com/JuliaPackaging/Yggdrasil/releases/download/PlatformSupport-v2024.12.21/PlatformSupport-riscv64-linux-musl.v2024.12.21.x86_64-linux-musl.squashfs.tar.gz"

[["PlatformSupport-riscv64-linux-musl.v2024.12.21.x86_64-linux-musl.unpacked"]]
arch = "x86_64"
git-tree-sha1 = "e15c076bcd4f0ed54f8c7db8bded7da61d6eab30"
lazy = true
libc = "musl"
os = "linux"

[["PlatformSupport-riscv64-linux-musl.v2024.12.21.x86_64-linux-musl.unpacked".download]]
sha256 = "e9f16e6893bf2815a975ffd37ae12b8f74f81e2da5b2d061126fee62833a2bab"
url = "https://github.com/JuliaPackaging/Yggdrasil/releases/download/PlatformSupport-v2024.12.21/PlatformSupport-riscv64-linux-musl.v2024.12.21.x86_64-linux-musl.unpacked.tar.gz"

[["PlatformSupport-x86_64-apple-darwin14.v2021.8.10.x86_64-linux-musl.squashfs"]]
arch = "x86_64"
git-tree-sha1 = "bc7f1d08ee0ff50a8665304159d0038d4ece04eb"
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "BinaryBuilderBase"
uuid = "7f725544-6523-48cd-82d1-3fa08ff4056e"
authors = ["Elliot Saba <[email protected]>"]
version = "1.32.0"
version = "1.33.0"

[deps]
Bzip2_jll = "6e34b625-4abd-537c-b88f-471c36dfa7a0"
Expand Down
2 changes: 2 additions & 0 deletions src/BinaryBuilderBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export AbstractSource, AbstractDependency, SetupSource, PatchSource,

include("compat.jl")

include("riscv64.jl")

include("ArchiveUtils.jl")
include("Sources.jl")
include("Dependencies.jl")
Expand Down
2 changes: 2 additions & 0 deletions src/BuildToolchains.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ function meson_cpu_family(p::AbstractPlatform)
return "aarch64"
elseif startswith(arch(p)::String, "arm")
return "arm"
elseif arch(p) == "riscv64"
return "riscv64"
end
end

Expand Down
7 changes: 5 additions & 2 deletions src/Platforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const ARCHITECTURE_FLAGS = Dict(
"arm1176jzfs" => ["-mcpu=arm1176jzf-s", "-mfpu=vfp", "-mfloat-abi=hard"],
),
"armv7l" => OrderedDict(
# Base armv7l architecture, with the most basic of FPU's
# Base armv7l architecture, with the most basic of FPUs
"armv7l" => ["-march=armv7-a", "-mtune=generic-armv7-a", "-mfpu=vfpv3", "-mfloat-abi=hard"],
# armv7l plus NEON and vfpv4, (Raspberry Pi 2B+, RK3328, most boards Elliot has access to)
"neonvfpv4" => ["-mcpu=cortex-a53", "-mfpu=neon-vfpv4", "-mfloat-abi=hard"],
Expand All @@ -158,7 +158,10 @@ const ARCHITECTURE_FLAGS = Dict(
#"power9" => ["-mcpu=power9", "-mtune=power9"],
# Eventually, we'll support power10, once we have compilers that support it.
#"power10" => ["-mcpu=power10", "-mtune=power10"],
)
),
"riscv64" => OrderedDict(
"riscv64" => ["-march=rv64gc", "-mabi=lp64d"],
),
),
"gcc" => Dict(
"aarch64" => OrderedDict(
Expand Down
29 changes: 23 additions & 6 deletions src/Rootfs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@ the only GCC versions available to be picked from are `4.8.5` and `5.2.0`, it
will return `4.8.5`, as binaries compiled with that version will run on this
platform, whereas binaries compiled with `5.2.0` may not.
"""
function gcc_version(p::AbstractPlatform,GCC_builds::Vector{GCCBuild},
function gcc_version(p::AbstractPlatform,
GCC_builds::Vector{GCCBuild},
compilers::Vector{Symbol}=[:c];
llvm_version::Union{Nothing,VersionNumber}=nothing)
# First, filter by libgfortran version.
Expand Down Expand Up @@ -471,6 +472,12 @@ function gcc_version(p::AbstractPlatform,GCC_builds::Vector{GCCBuild},
GCC_builds = filter(b -> getversion(b) v"7", GCC_builds)
end

# We only have GCC 12 or newer for RISC-V.
# (This could be changed down to GCC 7.1.)
if arch(p) == "riscv64"
GCC_builds = filter(b -> getversion(b) v"12", GCC_builds)
end

# Rust on Windows requires binutils 2.25 (it invokes `ld` with `--high-entropy-va`),
# which we bundle with GCC 5.
if :rust in compilers && Sys.iswindows(p)
Expand Down Expand Up @@ -525,6 +532,7 @@ function llvm_version(p::AbstractPlatform, LLVM_builds::Vector{LLVMBuild})
# The target `apple-m1` was introduced in LLVM 13
LLVM_builds = filter(b -> getversion(b) >= v"13.0", LLVM_builds)
end

return getversion.(LLVM_builds)
end

Expand Down Expand Up @@ -631,9 +639,11 @@ function choose_shards(p::AbstractPlatform;
)

# We _always_ need Rootfs and PlatformSupport for our target, at least
# We don't have old platform support for riscv64. Remove this once all platform support is aligned in time.
ps_build_new = arch(p) == "riscv64" ? max(ps_build, v"2024.12.21") : ps_build
append!(shards, [
find_shard("Rootfs", rootfs_build, archive_type),
find_shard("PlatformSupport", ps_build, archive_type; target=p)
find_shard("PlatformSupport", ps_build_new, archive_type; target=p)
])

if :c in compilers
Expand Down Expand Up @@ -719,6 +729,7 @@ function supported_platforms(;exclude::Union{Vector{<:Platform},Function}=Return
Platform("armv6l", "linux"),
Platform("armv7l", "linux"),
Platform("powerpc64le", "linux"),
Platform("riscv64", "linux"),

# musl Linuces
Platform("i686", "linux"; libc="musl"),
Expand Down Expand Up @@ -773,6 +784,9 @@ function expand_gfortran_versions(platform::AbstractPlatform)
libgfortran_versions = [v"5"]
elseif Sys.isfreebsd(platform) && arch(platform) == "aarch64"
libgfortran_versions = [v"4", v"5"]
elseif arch(platform) == "riscv64"
# We don't have older GCC versions
libgfortran_versions = [v"5"]
else
libgfortran_versions = [v"3", v"4", v"5"]
end
Expand Down Expand Up @@ -810,7 +824,7 @@ function expand_cxxstring_abis(platform::AbstractPlatform; skip=Sys.isbsd)

if sanitize(platform) == "memory"
p = deepcopy(platform)
p["cxxstring_abi"] = "cxx11" #Clang only seems to generate cxx11 abi
p["cxxstring_abi"] = "cxx11" # Clang only seems to generate cxx11 abi
return [p]
end

Expand Down Expand Up @@ -913,7 +927,7 @@ argument.
julia> using BinaryBuilderBase
julia> expand_microarchitectures(filter!(p -> Sys.islinux(p) && libc(p) == "glibc", supported_platforms()))
14-element Vector{Platform}:
15-element Vector{Platform}:
Linux i686 {libc=glibc, march=pentium4}
Linux i686 {libc=glibc, march=prescott}
Linux x86_64 {libc=glibc, march=x86_64}
Expand All @@ -928,19 +942,21 @@ julia> expand_microarchitectures(filter!(p -> Sys.islinux(p) && libc(p) == "glib
Linux armv7l {call_abi=eabihf, libc=glibc, march=armv7l}
Linux armv7l {call_abi=eabihf, libc=glibc, march=neonvfpv4}
Linux powerpc64le {libc=glibc, march=power8}
Linux riscv64 {libc=glibc, march=riscv64}
julia> expand_microarchitectures(filter!(p -> Sys.islinux(p) && libc(p) == "glibc", supported_platforms()), ["x86_64", "avx2"])
7-element Vector{Platform}:
8-element Vector{Platform}:
Linux i686 {libc=glibc}
Linux x86_64 {libc=glibc, march=x86_64}
Linux x86_64 {libc=glibc, march=avx2}
Linux aarch64 {libc=glibc}
Linux armv6l {call_abi=eabihf, libc=glibc}
Linux armv7l {call_abi=eabihf, libc=glibc}
Linux powerpc64le {libc=glibc}
Linux riscv64 {libc=glibc}
julia> expand_microarchitectures(filter!(p -> Sys.islinux(p) && libc(p) == "glibc", supported_platforms()); filter=p->arch(p)=="x86_64")
9-element Vector{Platform}:
10-element Vector{Platform}:
Linux i686 {libc=glibc}
Linux x86_64 {libc=glibc, march=x86_64}
Linux x86_64 {libc=glibc, march=avx}
Expand All @@ -950,6 +966,7 @@ julia> expand_microarchitectures(filter!(p -> Sys.islinux(p) && libc(p) == "glib
Linux armv6l {call_abi=eabihf, libc=glibc}
Linux armv7l {call_abi=eabihf, libc=glibc}
Linux powerpc64le {libc=glibc}
Linux riscv64 {libc=glibc}
```
"""
function expand_microarchitectures(ps::Vector{<:AbstractPlatform},
Expand Down
7 changes: 6 additions & 1 deletion src/Runner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const default_host_platform = Platform("x86_64", "linux"; libc="musl", cxxstring
function nbits(p::AbstractPlatform)
if arch(p) in ("i686", "armv6l", "armv7l")
return 32
elseif arch(p) in ("x86_64", "aarch64", "powerpc64le")
elseif arch(p) in ("x86_64", "aarch64", "powerpc64le", "riscv64")
return 64
else
error("Unknown bitwidth for architecture $(arch(p))")
Expand All @@ -32,6 +32,8 @@ function proc_family(p::AbstractPlatform)
return "arm"
elseif arch(p) == "powerpc64le"
return "power"
elseif arch(p) == "riscv64"
return "riscv"
else
error("Unknown processor family for architecture $(arch(p))")
end
Expand Down Expand Up @@ -662,6 +664,7 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
"x86_64" => "amd64",
"i686" => "386",
"powerpc64le" => "ppc64le",
"riscv64" => "riscv64",
)
return arch_mapping[arch(p)]
end
Expand Down Expand Up @@ -1288,6 +1291,8 @@ function platform_envs(platform::AbstractPlatform, src_name::AbstractString;
mapping["GNU_LIBC_VERSION"] = "glibc 2.19"
elseif arch(platform) in ("x86_64", "i686", "powerpc64le")
mapping["GNU_LIBC_VERSION"] = "glibc 2.17"
elseif arch(platform) in ("riscv64",)
mapping["GNU_LIBC_VERSION"] = "glibc 2.35"
end
end

Expand Down
Loading

2 comments on commit a548ba2

@giordano
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/121903

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.33.0 -m "<description of version>" a548ba29890d3182961d6e477578beea8ffc3e27
git push origin v1.33.0

Please sign in to comment.