Skip to content

Commit a548ba2

Browse files
authored
Support riscv64 platform (#375)
* 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
1 parent ed9eeeb commit a548ba2

11 files changed

+376
-13
lines changed

Artifacts.toml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,6 +1956,94 @@ os = "linux"
19561956
sha256 = "d49106316ef5a4dc8cbce8665e720526a921cbba89dc38be41d53fc65c18007f"
19571957
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"
19581958

1959+
[["GCCBootstrap-riscv64-linux-gnu.v12.1.0.x86_64-linux-musl.squashfs"]]
1960+
arch = "x86_64"
1961+
git-tree-sha1 = "0e0e172850698ee5784355eebeaf661278cfc489"
1962+
lazy = true
1963+
libc = "musl"
1964+
os = "linux"
1965+
1966+
[["GCCBootstrap-riscv64-linux-gnu.v12.1.0.x86_64-linux-musl.squashfs".download]]
1967+
sha256 = "a51037a3b4eff64d08f63c48d16a5b873833d83a2085ac365cf11b0918c503cf"
1968+
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"
1969+
1970+
[["GCCBootstrap-riscv64-linux-gnu.v12.1.0.x86_64-linux-musl.unpacked"]]
1971+
arch = "x86_64"
1972+
git-tree-sha1 = "55460cf13be2ec9fe829768b49ea5b2ba49954ef"
1973+
lazy = true
1974+
libc = "musl"
1975+
os = "linux"
1976+
1977+
[["GCCBootstrap-riscv64-linux-gnu.v12.1.0.x86_64-linux-musl.unpacked".download]]
1978+
sha256 = "671879f013264f1627b5bff6ec246fd2806b4bc1ae9db74390df7004e00891d5"
1979+
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"
1980+
1981+
[["GCCBootstrap-riscv64-linux-gnu.v13.2.0.x86_64-linux-musl.squashfs"]]
1982+
arch = "x86_64"
1983+
git-tree-sha1 = "83e2aeef1b7ff0abe246d83065877e36f270bb32"
1984+
lazy = true
1985+
libc = "musl"
1986+
os = "linux"
1987+
1988+
[["GCCBootstrap-riscv64-linux-gnu.v13.2.0.x86_64-linux-musl.squashfs".download]]
1989+
sha256 = "a23f65e83be13b0eed7614b77e484dced1db4192732000edc1d4e52e39e4732e"
1990+
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"
1991+
1992+
[["GCCBootstrap-riscv64-linux-gnu.v13.2.0.x86_64-linux-musl.unpacked"]]
1993+
arch = "x86_64"
1994+
git-tree-sha1 = "f62985d28a28baf1017c91dbd9f7fe504a718c12"
1995+
lazy = true
1996+
libc = "musl"
1997+
os = "linux"
1998+
1999+
[["GCCBootstrap-riscv64-linux-gnu.v13.2.0.x86_64-linux-musl.unpacked".download]]
2000+
sha256 = "fc2b0c57b83c22416cdab285b8e3efaa3c55988d1a771e2ade6308d6b24674f5"
2001+
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"
2002+
2003+
[["GCCBootstrap-riscv64-linux-musl.v12.1.0.x86_64-linux-musl.squashfs"]]
2004+
arch = "x86_64"
2005+
git-tree-sha1 = "0a988108fd945733a2b493ae398b67588abc0e32"
2006+
lazy = true
2007+
libc = "musl"
2008+
os = "linux"
2009+
2010+
[["GCCBootstrap-riscv64-linux-musl.v12.1.0.x86_64-linux-musl.squashfs".download]]
2011+
sha256 = "2fe11e0f794df6af2ab39b8e6d1c4efc32cdb792fd045409cdcedd96d643a1c5"
2012+
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"
2013+
2014+
[["GCCBootstrap-riscv64-linux-musl.v12.1.0.x86_64-linux-musl.unpacked"]]
2015+
arch = "x86_64"
2016+
git-tree-sha1 = "a10265906d9a12bbc7a2a9a6ed0a4d67cb6a3ad0"
2017+
lazy = true
2018+
libc = "musl"
2019+
os = "linux"
2020+
2021+
[["GCCBootstrap-riscv64-linux-musl.v12.1.0.x86_64-linux-musl.unpacked".download]]
2022+
sha256 = "d958a67682d30ea9e04116db4f463c17f0bf63823e352692d5fe7982da86e220"
2023+
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"
2024+
2025+
[["GCCBootstrap-riscv64-linux-musl.v13.2.0.x86_64-linux-musl.squashfs"]]
2026+
arch = "x86_64"
2027+
git-tree-sha1 = "fa8d3617b8a7a823076c43315b19eea746e61ea0"
2028+
lazy = true
2029+
libc = "musl"
2030+
os = "linux"
2031+
2032+
[["GCCBootstrap-riscv64-linux-musl.v13.2.0.x86_64-linux-musl.squashfs".download]]
2033+
sha256 = "0b1e047575add41887b4706971bc36d34c235a0561e8e03b03698d76b61c7262"
2034+
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"
2035+
2036+
[["GCCBootstrap-riscv64-linux-musl.v13.2.0.x86_64-linux-musl.unpacked"]]
2037+
arch = "x86_64"
2038+
git-tree-sha1 = "87d33912a955c60bda8476493049f905092cd1db"
2039+
lazy = true
2040+
libc = "musl"
2041+
os = "linux"
2042+
2043+
[["GCCBootstrap-riscv64-linux-musl.v13.2.0.x86_64-linux-musl.unpacked".download]]
2044+
sha256 = "a45d64532488eccb57d65b1dc3fbc5aa65b1204a327f05a0db14d4ff582b2b59"
2045+
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"
2046+
19592047
[["GCCBootstrap-x86_64-apple-darwin14.v10.2.0.x86_64-linux-musl.squashfs"]]
19602048
arch = "x86_64"
19612049
git-tree-sha1 = "ceb591a6cf8b32224a2a62cf3d8a9572c1c83e62"
@@ -4068,6 +4156,50 @@ os = "linux"
40684156
sha256 = "5368cefab3e9ebd704d60f13fa5982d1d8566d9025c47ad6288c0c4f3f02efb7"
40694157
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"
40704158

4159+
[["PlatformSupport-riscv64-linux-gnu.v2024.12.21.x86_64-linux-musl.squashfs"]]
4160+
arch = "x86_64"
4161+
git-tree-sha1 = "b176fca4332dbcd60e0f4195feafef712394be6d"
4162+
lazy = true
4163+
libc = "musl"
4164+
os = "linux"
4165+
4166+
[["PlatformSupport-riscv64-linux-gnu.v2024.12.21.x86_64-linux-musl.squashfs".download]]
4167+
sha256 = "6348339e933ca990739e4328a4bcf449cb2944feea590f84ca9b25a6dfba6cb4"
4168+
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"
4169+
4170+
[["PlatformSupport-riscv64-linux-gnu.v2024.12.21.x86_64-linux-musl.unpacked"]]
4171+
arch = "x86_64"
4172+
git-tree-sha1 = "5b9695b4efe229b51926b4c9ffb9a0c891e8ccdd"
4173+
lazy = true
4174+
libc = "musl"
4175+
os = "linux"
4176+
4177+
[["PlatformSupport-riscv64-linux-gnu.v2024.12.21.x86_64-linux-musl.unpacked".download]]
4178+
sha256 = "757fe58ba7561cb61051ef22e8a36f3066fb63b0978cf14ad276313368c43a5f"
4179+
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"
4180+
4181+
[["PlatformSupport-riscv64-linux-musl.v2024.12.21.x86_64-linux-musl.squashfs"]]
4182+
arch = "x86_64"
4183+
git-tree-sha1 = "72708b43067d2c5b35e46fee91fc1f1164f540af"
4184+
lazy = true
4185+
libc = "musl"
4186+
os = "linux"
4187+
4188+
[["PlatformSupport-riscv64-linux-musl.v2024.12.21.x86_64-linux-musl.squashfs".download]]
4189+
sha256 = "a8330a71a91ada1eebad7874911ca51cdba7cef5ad0512495384e44fea564507"
4190+
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"
4191+
4192+
[["PlatformSupport-riscv64-linux-musl.v2024.12.21.x86_64-linux-musl.unpacked"]]
4193+
arch = "x86_64"
4194+
git-tree-sha1 = "e15c076bcd4f0ed54f8c7db8bded7da61d6eab30"
4195+
lazy = true
4196+
libc = "musl"
4197+
os = "linux"
4198+
4199+
[["PlatformSupport-riscv64-linux-musl.v2024.12.21.x86_64-linux-musl.unpacked".download]]
4200+
sha256 = "e9f16e6893bf2815a975ffd37ae12b8f74f81e2da5b2d061126fee62833a2bab"
4201+
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"
4202+
40714203
[["PlatformSupport-x86_64-apple-darwin14.v2021.8.10.x86_64-linux-musl.squashfs"]]
40724204
arch = "x86_64"
40734205
git-tree-sha1 = "bc7f1d08ee0ff50a8665304159d0038d4ece04eb"

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "BinaryBuilderBase"
22
uuid = "7f725544-6523-48cd-82d1-3fa08ff4056e"
33
authors = ["Elliot Saba <staticfloat@gmail.com>"]
4-
version = "1.32.0"
4+
version = "1.33.0"
55

66
[deps]
77
Bzip2_jll = "6e34b625-4abd-537c-b88f-471c36dfa7a0"

src/BinaryBuilderBase.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export AbstractSource, AbstractDependency, SetupSource, PatchSource,
2727

2828
include("compat.jl")
2929

30+
include("riscv64.jl")
31+
3032
include("ArchiveUtils.jl")
3133
include("Sources.jl")
3234
include("Dependencies.jl")

src/BuildToolchains.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ function meson_cpu_family(p::AbstractPlatform)
170170
return "aarch64"
171171
elseif startswith(arch(p)::String, "arm")
172172
return "arm"
173+
elseif arch(p) == "riscv64"
174+
return "riscv64"
173175
end
174176
end
175177

src/Platforms.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ const ARCHITECTURE_FLAGS = Dict(
135135
"arm1176jzfs" => ["-mcpu=arm1176jzf-s", "-mfpu=vfp", "-mfloat-abi=hard"],
136136
),
137137
"armv7l" => OrderedDict(
138-
# Base armv7l architecture, with the most basic of FPU's
138+
# Base armv7l architecture, with the most basic of FPUs
139139
"armv7l" => ["-march=armv7-a", "-mtune=generic-armv7-a", "-mfpu=vfpv3", "-mfloat-abi=hard"],
140140
# armv7l plus NEON and vfpv4, (Raspberry Pi 2B+, RK3328, most boards Elliot has access to)
141141
"neonvfpv4" => ["-mcpu=cortex-a53", "-mfpu=neon-vfpv4", "-mfloat-abi=hard"],
@@ -158,7 +158,10 @@ const ARCHITECTURE_FLAGS = Dict(
158158
#"power9" => ["-mcpu=power9", "-mtune=power9"],
159159
# Eventually, we'll support power10, once we have compilers that support it.
160160
#"power10" => ["-mcpu=power10", "-mtune=power10"],
161-
)
161+
),
162+
"riscv64" => OrderedDict(
163+
"riscv64" => ["-march=rv64gc", "-mabi=lp64d"],
164+
),
162165
),
163166
"gcc" => Dict(
164167
"aarch64" => OrderedDict(

src/Rootfs.jl

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,8 @@ the only GCC versions available to be picked from are `4.8.5` and `5.2.0`, it
431431
will return `4.8.5`, as binaries compiled with that version will run on this
432432
platform, whereas binaries compiled with `5.2.0` may not.
433433
"""
434-
function gcc_version(p::AbstractPlatform,GCC_builds::Vector{GCCBuild},
434+
function gcc_version(p::AbstractPlatform,
435+
GCC_builds::Vector{GCCBuild},
435436
compilers::Vector{Symbol}=[:c];
436437
llvm_version::Union{Nothing,VersionNumber}=nothing)
437438
# First, filter by libgfortran version.
@@ -471,6 +472,12 @@ function gcc_version(p::AbstractPlatform,GCC_builds::Vector{GCCBuild},
471472
GCC_builds = filter(b -> getversion(b) v"7", GCC_builds)
472473
end
473474

475+
# We only have GCC 12 or newer for RISC-V.
476+
# (This could be changed down to GCC 7.1.)
477+
if arch(p) == "riscv64"
478+
GCC_builds = filter(b -> getversion(b) v"12", GCC_builds)
479+
end
480+
474481
# Rust on Windows requires binutils 2.25 (it invokes `ld` with `--high-entropy-va`),
475482
# which we bundle with GCC 5.
476483
if :rust in compilers && Sys.iswindows(p)
@@ -525,6 +532,7 @@ function llvm_version(p::AbstractPlatform, LLVM_builds::Vector{LLVMBuild})
525532
# The target `apple-m1` was introduced in LLVM 13
526533
LLVM_builds = filter(b -> getversion(b) >= v"13.0", LLVM_builds)
527534
end
535+
528536
return getversion.(LLVM_builds)
529537
end
530538

@@ -631,9 +639,11 @@ function choose_shards(p::AbstractPlatform;
631639
)
632640

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

639649
if :c in compilers
@@ -719,6 +729,7 @@ function supported_platforms(;exclude::Union{Vector{<:Platform},Function}=Return
719729
Platform("armv6l", "linux"),
720730
Platform("armv7l", "linux"),
721731
Platform("powerpc64le", "linux"),
732+
Platform("riscv64", "linux"),
722733

723734
# musl Linuces
724735
Platform("i686", "linux"; libc="musl"),
@@ -773,6 +784,9 @@ function expand_gfortran_versions(platform::AbstractPlatform)
773784
libgfortran_versions = [v"5"]
774785
elseif Sys.isfreebsd(platform) && arch(platform) == "aarch64"
775786
libgfortran_versions = [v"4", v"5"]
787+
elseif arch(platform) == "riscv64"
788+
# We don't have older GCC versions
789+
libgfortran_versions = [v"5"]
776790
else
777791
libgfortran_versions = [v"3", v"4", v"5"]
778792
end
@@ -810,7 +824,7 @@ function expand_cxxstring_abis(platform::AbstractPlatform; skip=Sys.isbsd)
810824

811825
if sanitize(platform) == "memory"
812826
p = deepcopy(platform)
813-
p["cxxstring_abi"] = "cxx11" #Clang only seems to generate cxx11 abi
827+
p["cxxstring_abi"] = "cxx11" # Clang only seems to generate cxx11 abi
814828
return [p]
815829
end
816830

@@ -913,7 +927,7 @@ argument.
913927
julia> using BinaryBuilderBase
914928
915929
julia> expand_microarchitectures(filter!(p -> Sys.islinux(p) && libc(p) == "glibc", supported_platforms()))
916-
14-element Vector{Platform}:
930+
15-element Vector{Platform}:
917931
Linux i686 {libc=glibc, march=pentium4}
918932
Linux i686 {libc=glibc, march=prescott}
919933
Linux x86_64 {libc=glibc, march=x86_64}
@@ -928,19 +942,21 @@ julia> expand_microarchitectures(filter!(p -> Sys.islinux(p) && libc(p) == "glib
928942
Linux armv7l {call_abi=eabihf, libc=glibc, march=armv7l}
929943
Linux armv7l {call_abi=eabihf, libc=glibc, march=neonvfpv4}
930944
Linux powerpc64le {libc=glibc, march=power8}
945+
Linux riscv64 {libc=glibc, march=riscv64}
931946
932947
julia> expand_microarchitectures(filter!(p -> Sys.islinux(p) && libc(p) == "glibc", supported_platforms()), ["x86_64", "avx2"])
933-
7-element Vector{Platform}:
948+
8-element Vector{Platform}:
934949
Linux i686 {libc=glibc}
935950
Linux x86_64 {libc=glibc, march=x86_64}
936951
Linux x86_64 {libc=glibc, march=avx2}
937952
Linux aarch64 {libc=glibc}
938953
Linux armv6l {call_abi=eabihf, libc=glibc}
939954
Linux armv7l {call_abi=eabihf, libc=glibc}
940955
Linux powerpc64le {libc=glibc}
956+
Linux riscv64 {libc=glibc}
941957
942958
julia> expand_microarchitectures(filter!(p -> Sys.islinux(p) && libc(p) == "glibc", supported_platforms()); filter=p->arch(p)=="x86_64")
943-
9-element Vector{Platform}:
959+
10-element Vector{Platform}:
944960
Linux i686 {libc=glibc}
945961
Linux x86_64 {libc=glibc, march=x86_64}
946962
Linux x86_64 {libc=glibc, march=avx}
@@ -950,6 +966,7 @@ julia> expand_microarchitectures(filter!(p -> Sys.islinux(p) && libc(p) == "glib
950966
Linux armv6l {call_abi=eabihf, libc=glibc}
951967
Linux armv7l {call_abi=eabihf, libc=glibc}
952968
Linux powerpc64le {libc=glibc}
969+
Linux riscv64 {libc=glibc}
953970
```
954971
"""
955972
function expand_microarchitectures(ps::Vector{<:AbstractPlatform},

src/Runner.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const default_host_platform = Platform("x86_64", "linux"; libc="musl", cxxstring
1818
function nbits(p::AbstractPlatform)
1919
if arch(p) in ("i686", "armv6l", "armv7l")
2020
return 32
21-
elseif arch(p) in ("x86_64", "aarch64", "powerpc64le")
21+
elseif arch(p) in ("x86_64", "aarch64", "powerpc64le", "riscv64")
2222
return 64
2323
else
2424
error("Unknown bitwidth for architecture $(arch(p))")
@@ -32,6 +32,8 @@ function proc_family(p::AbstractPlatform)
3232
return "arm"
3333
elseif arch(p) == "powerpc64le"
3434
return "power"
35+
elseif arch(p) == "riscv64"
36+
return "riscv"
3537
else
3638
error("Unknown processor family for architecture $(arch(p))")
3739
end
@@ -662,6 +664,7 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
662664
"x86_64" => "amd64",
663665
"i686" => "386",
664666
"powerpc64le" => "ppc64le",
667+
"riscv64" => "riscv64",
665668
)
666669
return arch_mapping[arch(p)]
667670
end
@@ -1288,6 +1291,8 @@ function platform_envs(platform::AbstractPlatform, src_name::AbstractString;
12881291
mapping["GNU_LIBC_VERSION"] = "glibc 2.19"
12891292
elseif arch(platform) in ("x86_64", "i686", "powerpc64le")
12901293
mapping["GNU_LIBC_VERSION"] = "glibc 2.17"
1294+
elseif arch(platform) in ("riscv64",)
1295+
mapping["GNU_LIBC_VERSION"] = "glibc 2.35"
12911296
end
12921297
end
12931298

0 commit comments

Comments
 (0)