Skip to content

Commit 31cdda0

Browse files
authored
Support riscv64 (#1355)
* Add riscv64 support * Support riscv64 ELF * More riscv64 support * Update BinaryBuilderBase compat * Allow newer ghr_jll
1 parent f4490e5 commit 31cdda0

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

Project.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "BinaryBuilder"
22
uuid = "12aac903-9f7c-5d81-afc2-d9565ea332ae"
33
authors = ["Elliot Saba <[email protected]>"]
4-
version = "0.6.0"
4+
version = "0.6.1"
55

66
[deps]
77
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
@@ -33,23 +33,23 @@ ghr_jll = "07c12ed4-43bc-5495-8a2a-d5838ef8d533"
3333

3434
[compat]
3535
ArgParse = "1.1"
36-
BinaryBuilderBase = "1.31"
36+
BinaryBuilderBase = "1.33"
3737
Downloads = "1"
3838
GitHub = "5.1"
3939
HTTP = "0.8, 0.9, 1"
4040
JLD2 = "0.1.6, 0.2, 0.3, 0.4, 0.5"
4141
JLLWrappers = "1.2.0"
4242
JSON = "0.21"
4343
LoggingExtras = "0.4, 1"
44-
ObjectFile = "0.4"
44+
ObjectFile = "0.4.3"
4545
OutputCollectors = "0.1"
4646
PkgLicenses = "0.2"
4747
Registrator = "1.1"
4848
RegistryTools = "2.1"
4949
SHA = "0.7, 1"
5050
Scratch = "1.0"
5151
TOML = "1"
52-
ghr_jll = "0.13, 0.14"
52+
ghr_jll = "0.13, 0.14, 0.17"
5353
julia = "1.7"
5454

5555
[extras]

src/auditor/dynamic_linkage.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ function platform_for_object(oh::ObjectHandle)
1515
ELF.EM_X86_64 => "x86_64",
1616
ELF.EM_AARCH64 => "aarch64",
1717
ELF.EM_PPC64 => "powerpc64le",
18+
ELF.EM_RISCV => "riscv64", # Could also be riscv32; should check ELF_CLASS
1819
ELF.EM_ARM => "arm",
1920
)
2021
mach = oh.header.e_machine
@@ -120,6 +121,9 @@ function is_for_platform(h::ObjectHandle, platform::AbstractPlatform)
120121
return m == ELF.EM_AARCH64
121122
elseif arch(platform) == "powerpc64le"
122123
return m == ELF.EM_PPC64
124+
elseif arch(platform) == "riscv64"
125+
# Could also be riscv32; should check ELF_CLASS
126+
return m == ELF.EM_RISCV
123127
elseif arch(platform) ("armv7l", "armv6l")
124128
return m == ELF.EM_ARM
125129
else
@@ -326,6 +330,7 @@ function patchelf_flags(p::AbstractPlatform)
326330
flags = []
327331

328332
# ppc64le and aarch64 have 64KB page sizes, don't muck up the ELF section load alignment
333+
# TODO: What is the riscv64 page size?
329334
if arch(p) in ("powerpc64le", "aarch64")
330335
append!(flags, ["--page-size", "65536"])
331336
end

src/auditor/instruction_set.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ function minimum_march(counts::Dict, p::AbstractPlatform)
121121
# TODO: Detect NEON and vfpv4 instructions
122122
elseif arch(p) == "powerpc64le"
123123
# TODO Detect POWER9/10 instructions
124+
elseif arch(p) == "riscv64"
125+
# TODO
124126
end
125127
return generic_march(p)
126128
end

src/wizard/interactive_build.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ Pick the first platform for use to run on. We prefer Linux x86_64 because
467467
that's generally the host platform, so it's usually easiest. After that we
468468
go by the following preferences:
469469
* OS (in order): Linux, Windows, OSX
470-
* Architecture: x86_64, i686, aarch64, powerpc64le, armv7l
470+
* Architecture: x86_64, i686, aarch64, powerpc64le, armv7l, riscv64
471471
* The first remaining after this selection
472472
"""
473473
function pick_preferred_platform(platforms)
@@ -480,7 +480,7 @@ function pick_preferred_platform(platforms)
480480
platforms = plats
481481
end
482482
end
483-
for a in ("x86_64", "i686", "aarch64", "powerpc64le", "armv7l")
483+
for a in ("x86_64", "i686", "aarch64", "powerpc64le", "armv7l", "riscv64")
484484
plats = filter(p->arch(p) == a, platforms)
485485
if !isempty(plats)
486486
platforms = plats

0 commit comments

Comments
 (0)