From a8906394ca94ecb21ff4a124ed7029c996a47bc3 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sat, 21 Dec 2024 18:44:55 -0500 Subject: [PATCH 1/5] Add riscv64 support --- Project.toml | 2 +- src/auditor/dynamic_linkage.jl | 4 ++++ src/auditor/instruction_set.jl | 2 ++ src/wizard/interactive_build.jl | 4 ++-- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 1b247ac21..0ee874dbd 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "BinaryBuilder" uuid = "12aac903-9f7c-5d81-afc2-d9565ea332ae" authors = ["Elliot Saba "] -version = "0.6.0" +version = "0.6.1" [deps] ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63" diff --git a/src/auditor/dynamic_linkage.jl b/src/auditor/dynamic_linkage.jl index b1fa3aa69..cd6a40abd 100644 --- a/src/auditor/dynamic_linkage.jl +++ b/src/auditor/dynamic_linkage.jl @@ -15,6 +15,7 @@ function platform_for_object(oh::ObjectHandle) ELF.EM_X86_64 => "x86_64", ELF.EM_AARCH64 => "aarch64", ELF.EM_PPC64 => "powerpc64le", + ELF.EM_RISCV => "riscv64", # Could also be riscv32 ELF.EM_ARM => "arm", ) mach = oh.header.e_machine @@ -120,6 +121,8 @@ function is_for_platform(h::ObjectHandle, platform::AbstractPlatform) return m == ELF.EM_AARCH64 elseif arch(platform) == "powerpc64le" return m == ELF.EM_PPC64 + elseif arch(platform) == "riscv64" + return m == ELF.EM_RISCV elseif arch(platform) ∈ ("armv7l", "armv6l") return m == ELF.EM_ARM else @@ -326,6 +329,7 @@ function patchelf_flags(p::AbstractPlatform) flags = [] # ppc64le and aarch64 have 64KB page sizes, don't muck up the ELF section load alignment + # TODO: What is the riscv64 page size? if arch(p) in ("powerpc64le", "aarch64") append!(flags, ["--page-size", "65536"]) end diff --git a/src/auditor/instruction_set.jl b/src/auditor/instruction_set.jl index 07beb52c4..550c04fa7 100644 --- a/src/auditor/instruction_set.jl +++ b/src/auditor/instruction_set.jl @@ -121,6 +121,8 @@ function minimum_march(counts::Dict, p::AbstractPlatform) # TODO: Detect NEON and vfpv4 instructions elseif arch(p) == "powerpc64le" # TODO Detect POWER9/10 instructions + elseif arch(p) == "riscv64" + # TODO end return generic_march(p) end diff --git a/src/wizard/interactive_build.jl b/src/wizard/interactive_build.jl index e55cfa0fa..b939dc275 100644 --- a/src/wizard/interactive_build.jl +++ b/src/wizard/interactive_build.jl @@ -467,7 +467,7 @@ Pick the first platform for use to run on. We prefer Linux x86_64 because that's generally the host platform, so it's usually easiest. After that we go by the following preferences: * OS (in order): Linux, Windows, OSX -* Architecture: x86_64, i686, aarch64, powerpc64le, armv7l +* Architecture: x86_64, i686, aarch64, powerpc64le, armv7l, riscv64 * The first remaining after this selection """ function pick_preferred_platform(platforms) @@ -480,7 +480,7 @@ function pick_preferred_platform(platforms) platforms = plats end end - for a in ("x86_64", "i686", "aarch64", "powerpc64le", "armv7l") + for a in ("x86_64", "i686", "aarch64", "powerpc64le", "armv7l", "riscv64") plats = filter(p->arch(p) == a, platforms) if !isempty(plats) platforms = plats From 01ddd691538cd3ca375b120237f3c8a2521200cf Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sat, 21 Dec 2024 19:59:29 -0500 Subject: [PATCH 2/5] Support riscv64 ELF --- Project.toml | 2 +- src/auditor/dynamic_linkage.jl | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 0ee874dbd..879ba2fb2 100644 --- a/Project.toml +++ b/Project.toml @@ -41,7 +41,7 @@ JLD2 = "0.1.6, 0.2, 0.3, 0.4, 0.5" JLLWrappers = "1.2.0" JSON = "0.21" LoggingExtras = "0.4, 1" -ObjectFile = "0.4" +ObjectFile = "0.4.3" OutputCollectors = "0.1" PkgLicenses = "0.2" Registrator = "1.1" diff --git a/src/auditor/dynamic_linkage.jl b/src/auditor/dynamic_linkage.jl index cd6a40abd..1c91072a7 100644 --- a/src/auditor/dynamic_linkage.jl +++ b/src/auditor/dynamic_linkage.jl @@ -15,7 +15,7 @@ function platform_for_object(oh::ObjectHandle) ELF.EM_X86_64 => "x86_64", ELF.EM_AARCH64 => "aarch64", ELF.EM_PPC64 => "powerpc64le", - ELF.EM_RISCV => "riscv64", # Could also be riscv32 + ELF.EM_RISCV => "riscv64", # Could also be riscv32; should check ELF_CLASS ELF.EM_ARM => "arm", ) mach = oh.header.e_machine @@ -122,6 +122,7 @@ function is_for_platform(h::ObjectHandle, platform::AbstractPlatform) elseif arch(platform) == "powerpc64le" return m == ELF.EM_PPC64 elseif arch(platform) == "riscv64" + # Could also be riscv32; should check ELF_CLASS return m == ELF.EM_RISCV elseif arch(platform) ∈ ("armv7l", "armv6l") return m == ELF.EM_ARM From 97be57fba11bf7534eb430b9f353cbe36c7e9c9a Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sat, 21 Dec 2024 20:03:26 -0500 Subject: [PATCH 3/5] More riscv64 support --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 879ba2fb2..a1b348c94 100644 --- a/Project.toml +++ b/Project.toml @@ -33,7 +33,7 @@ ghr_jll = "07c12ed4-43bc-5495-8a2a-d5838ef8d533" [compat] ArgParse = "1.1" -BinaryBuilderBase = "1.31" +BinaryBuilderBase = "1.34" Downloads = "1" GitHub = "5.1" HTTP = "0.8, 0.9, 1" From 6f785b25d051deacc9ef776678b6e9f9fceb1e85 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sun, 22 Dec 2024 10:38:20 -0500 Subject: [PATCH 4/5] Update BinaryBuilderBase compat --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index a1b348c94..56bc0a7d3 100644 --- a/Project.toml +++ b/Project.toml @@ -33,7 +33,7 @@ ghr_jll = "07c12ed4-43bc-5495-8a2a-d5838ef8d533" [compat] ArgParse = "1.1" -BinaryBuilderBase = "1.34" +BinaryBuilderBase = "1.33" Downloads = "1" GitHub = "5.1" HTTP = "0.8, 0.9, 1" From a96b7fb47f6c8ad4dacbbb1f0da20d018320ef5e Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Mon, 23 Dec 2024 14:39:46 -0500 Subject: [PATCH 5/5] Allow newer ghr_jll --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 56bc0a7d3..3dcc58db7 100644 --- a/Project.toml +++ b/Project.toml @@ -49,7 +49,7 @@ RegistryTools = "2.1" SHA = "0.7, 1" Scratch = "1.0" TOML = "1" -ghr_jll = "0.13, 0.14" +ghr_jll = "0.13, 0.14, 0.17" julia = "1.7" [extras]