Skip to content

Commit dbfe8af

Browse files
authored
0_RootFS: Support riscv64 (#8468)
* 0_RootFS: Support riscv64 * 0_RootFS: Support riscv64 * RootFS.md: Add riscv64 description
1 parent b196211 commit dbfe8af

File tree

4 files changed

+41
-13
lines changed

4 files changed

+41
-13
lines changed

0_RootFS/PlatformSupport/build_tarballs.jl

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# ```
66
# using BinaryBuilder
77
# using BinaryBuilder: aatriplet
8-
# for platform in supported_platforms()
8+
# for platform in supported_platforms(; experimental=true)
99
# # Append version numbers for BSD systems
1010
# if Sys.isapple(platform)
1111
# suffix = arch(platform) == "aarch64" ? "20" : "14"
@@ -90,6 +90,9 @@ target_to_linux_arch()
9090
powerpc*)
9191
echo "powerpc"
9292
;;
93+
riscv64*)
94+
echo "riscv"
95+
;;
9396
i686*)
9497
echo "x86"
9598
;;
@@ -180,7 +183,8 @@ ln -s "${prefix}" "${sysroot}/usr/local"
180183

181184
# Build the artifacts
182185
ndARGS, deploy_target = find_deploy_arg(ARGS)
183-
build_info = build_tarballs(ndARGS, "$(name)-$(triplet(compiler_target))", version, sources, script, [host_platform], Product[], []; skip_audit=true)
186+
build_info = build_tarballs(ndARGS, "$(name)-$(triplet(compiler_target))", version, sources, script, [host_platform], Product[], [];
187+
skip_audit=true, validate_name=false)
184188
if deploy_target !== nothing
185189
upload_and_insert_shards(deploy_target, name, version, build_info; target=compiler_target)
186190
end

0_RootFS/gcc_common.jl

+16-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# `--deploy` flag to the `build_tarballs.jl` script. You can either build &
2222
# deploy the compilers one by one or run something like
2323
#
24-
# for p in i686-linux-gnu x86_64-linux-gnu aarch64-linux-gnu armv7l-linux-gnueabihf powerpc64le-linux-gnu i686-linux-musl x86_64-linux-musl aarch64-linux-musl armv7l-linux-musleabihf x86_64-apple-darwin14 x86_64-unknown-freebsd13.2 aarch64-unknown-freebsd13.2 i686-w64-mingw32 x86_64-w64-mingw32; do julia build_tarballs.jl --debug --verbose --deploy "${p}"; done
24+
# for p in i686-linux-gnu x86_64-linux-gnu aarch64-linux-gnu armv7l-linux-gnueabihf powerpc64le-linux-gnu riscv64-linux-gnu i686-linux-musl x86_64-linux-musl aarch64-linux-musl armv7l-linux-musleabihf x86_64-apple-darwin14 x86_64-unknown-freebsd13.2 aarch64-unknown-freebsd13.2 i686-w64-mingw32 x86_64-w64-mingw32; do julia build_tarballs.jl --debug --verbose --deploy "${p}"; done
2525

2626
include("./common.jl")
2727
include("./gcc_sources.jl")
@@ -70,6 +70,10 @@ function gcc_script(compiler_target::Platform)
7070
ppc64*)
7171
LIB64=lib64
7272
;;
73+
risc64*)
74+
# TODO: Is this correct?
75+
LIB64=lib64
76+
;;
7377
*)
7478
LIB64=lib
7579
;;
@@ -295,6 +299,7 @@ function gcc_script(compiler_target::Platform)
295299
if [[ ${COMPILER_TARGET} == *-gnu* ]]; then
296300
# patch glibc
297301
cd ${WORKSPACE}/srcdir/glibc-*
302+
298303
# patch glibc to keep around libgcc_s_resume on arm
299304
# ref: https://sourceware.org/ml/libc-alpha/2014-05/msg00573.html
300305
atomic_patch -p1 $WORKSPACE/srcdir/patches/glibc_arm_gcc_fix.patch || true
@@ -336,13 +341,13 @@ function gcc_script(compiler_target::Platform)
336341
337342
# Patches for building glibc 2.17 on ppc64le
338343
for p in ${WORKSPACE}/srcdir/patches/glibc-ppc64le-*.patch; do
339-
atomic_patch -p1 ${p} || true;
344+
atomic_patch -p1 ${p} || true
340345
done
341346
342347
# Patch bad `movq` argument in glibc 2.17, adapted from:
343348
# https://github.com/bminor/glibc/commit/b1ec623ed50bb8c7b9b6333fa350c3866dbde87f
344349
# X-ref: https://github.com/crosstool-ng/crosstool-ng/issues/1825#issuecomment-1437918391
345-
atomic_patch -p1 $WORKSPACE/srcdir/patches/glibc_movq_fix.patch
350+
atomic_patch -p1 $WORKSPACE/srcdir/patches/glibc_movq_fix.patch || true
346351
347352
# Various configure overrides
348353
GLIBC_CONFIGURE_OVERRIDES=( libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes )
@@ -352,6 +357,12 @@ function gcc_script(compiler_target::Platform)
352357
GLIBC_CONFIGURE_OVERRIDES+=( libc_cv_ssp=no libc_cv_ssp_strong=no )
353358
fi
354359
360+
if [[ ${COMPILER_TARGET} == riscv64-* ]]; then
361+
# Explicitly disable C++
362+
# (Disable for all architectures?)
363+
GLIBC_CONFIGURE_OVERRIDES+=( CXX=false )
364+
fi
365+
355366
# Configure glibc
356367
mkdir ${WORKSPACE}/srcdir/glibc_build
357368
cd ${WORKSPACE}/srcdir/glibc_build
@@ -478,7 +489,7 @@ function gcc_script(compiler_target::Platform)
478489
479490
# Back to GCC-land, install libgcc
480491
cd ${WORKSPACE}/srcdir/gcc_stage1
481-
make all-target-libgcc -j ${nproc}
492+
make all-target-libgcc -j${nproc}
482493
make install-target-libgcc
483494
484495
# Finish off libc
@@ -578,7 +589,7 @@ function gcc_script(compiler_target::Platform)
578589
${GCC_CONF_ARGS}
579590
580591
## Build, build, build!
581-
make -j ${nproc}
592+
make -j${nproc}
582593
make install
583594
584595
# Remove misleading libtool archives

0_RootFS/gcc_sources.jl

+17-5
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ function gcc_sources(gcc_version::VersionNumber, compiler_target::Platform; kwar
163163
"634a084377ee2e2932c66459b0396edf76da2e9f"),
164164
]
165165
else
166-
# Different versions of GCC should be pared with different versions of Binutils
166+
# Different versions of GCC should be paired with different versions of Binutils
167167
binutils_gcc_version_mapping = Dict(
168168
v"4.8.5" => v"2.24",
169169
v"5.2.0" => v"2.25.1",
@@ -241,14 +241,26 @@ function gcc_sources(gcc_version::VersionNumber, compiler_target::Platform; kwar
241241
ArchiveSource("https://mirrors.kernel.org/gnu/glibc/glibc-2.17.tar.xz",
242242
"6914e337401e0e0ade23694e1b2c52a5f09e4eda3270c67e7c3ba93a89b5b23e"),
243243
]
244+
elseif arch(compiler_target) in ["riscv64"]
245+
libc_sources = [
246+
ArchiveSource("https://mirrors.kernel.org/gnu/glibc/glibc-2.35.tar.xz",
247+
"5123732f6b67ccd319305efd399971d58592122bcc2a6518a1bd2510dd0cf52e"),
248+
]
244249
else
245250
error("Unknown arch for glibc for compiler target $(compiler_target)")
246251
end
247252
elseif Sys.islinux(compiler_target) && libc(compiler_target) == "musl"
248-
libc_sources = [
249-
ArchiveSource("https://www.musl-libc.org/releases/musl-1.1.19.tar.gz",
250-
"db59a8578226b98373f5b27e61f0dd29ad2456f4aa9cec587ba8c24508e4c1d9"),
251-
]
253+
if arch(compiler_target) in ["riscv64"]
254+
libc_sources = [
255+
ArchiveSource("https://www.musl-libc.org/releases/musl-1.2.0.tar.gz",
256+
"c6de7b191139142d3f9a7b5b702c9cae1b5ee6e7f57e582da9328629408fd4e8"),
257+
]
258+
else
259+
libc_sources = [
260+
ArchiveSource("https://www.musl-libc.org/releases/musl-1.1.19.tar.gz",
261+
"db59a8578226b98373f5b27e61f0dd29ad2456f4aa9cec587ba8c24508e4c1d9"),
262+
]
263+
end
252264
elseif Sys.isapple(compiler_target)
253265
if arch(compiler_target) == "aarch64"
254266
libc_sources = [

RootFS.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ The Care and Feeding of a Root Filesystem
33

44
This document details some of the journey we have embarked upon to create a Linux environment that supports cross-compilation for a very wide range of architectures and platforms. At the moment of writing, we support the following platforms (expressed in compiler triplet format):
55

6-
* glibc Linux: `i686-linux-gnu`, `x86_64-linux-gnu`, `aarch64-linux-gnu`, `armv7l-linux-gnueabihf`, `powerpc64le-linux-gnu`, `armv6l-linux-gnueabihf`
6+
* glibc Linux: `i686-linux-gnu`, `x86_64-linux-gnu`, `aarch64-linux-gnu`, `armv7l-linux-gnueabihf`, `armv6l-linux-gnueabihf`, `powerpc64le-linux-gnu`, `riscv64-linux-gnu`
77
* musl Linux: `i686-linux-musl`, `x86_64-linux-musl`, `aarch64-linux-musl`, `armv7l-linux-musleabihf`, `armv6l-linux-musleabihf`
88
* MacOS: `x86_64-apple-darwin`, `aarch64-apple-darwin`
99
* FreeBSD: `x86_64-unknown-freebsd13.2`, `aarch64-unknown-freebsd13.2`
@@ -40,6 +40,7 @@ The version of `glibc` we can compile against varies by system; we attempt to us
4040
| aarch64 | v2.19 |
4141
| armv7l | v2.19 |
4242
| powerpc64le | v2.17 |
43+
| riscv64 | v2.35 |
4344

4445

4546
Compiler Shards

0 commit comments

Comments
 (0)