RISC-V target support

This commit is contained in:
Andrey Turkin 2024-06-17 10:03:00 +03:00
parent 9a3cebcfde
commit d7ecf2e747
12 changed files with 437 additions and 394 deletions

View File

@ -9,3 +9,7 @@ rustflags = []
[target.x86_64-unknown-redox]
linker = "x86_64-unknown-redox-gcc"
rustflags = []
[target.riscv64gc-unknown-redox]
linker = "riscv64-unknown-redox-gcc"
rustflags = []

784
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -20,12 +20,17 @@ name = "cookbook"
path = "src/lib.rs"
[dependencies]
blake3 = "1.5"
blake3 = "=1.5.3" # 1.5.4 is incompatible with blake3 0.3 dependency from pkgar
pbr = "1.0.2"
pkgar = "0.1.7"
pkgar-keys = "0.1.0"
redoxer = "0.2"
serde = { version = "=1.0.197", features = ["derive"] }
termion = "1.5.5"
termion = "4"
toml = "0.8"
walkdir = "2.3.1"
[patch.crates-io]
redox_installer = { git = "https://gitlab.redox-os.org/redox-os/installer.git" }
ring = { git = "https://gitlab.redox-os.org/redox-os/ring.git", branch = "redox-unix-0.13.5" }

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
export PKG_CONFIG_SYSROOT_DIR="${COOKBOOK_SYSROOT}"
export PKG_CONFIG_LIBDIR="${PKG_CONFIG_SYSROOT_DIR}/lib/pkgconfig"
export PKG_CONFIG_PATH="${PKG_CONFIG_SYSROOT_DIR}/share/pkgconfig"
exec pkg-config --static "$@"

View File

@ -8,6 +8,9 @@ then
fi
ARCH="${TARGET%%-*}"
HOST="$TARGET"
if [ x"${HOST}" == x"riscv64gc-unknown-redox" ] ; then
HOST="riscv64-unknown-redox"
fi
# Automatic variables
ROOT="$(cd `dirname "$0"` && pwd)"

@ -1 +1 @@
Subproject commit 87e2dc87076f37a47b914adb8aa1e7ad54e85942
Subproject commit 2b799744292054a1b04e5c2616ee1106119cfa2e

View File

@ -25,7 +25,7 @@ then
fi
# Build UEFI bootloader for supported architectures
if [ "${ARCH}" == "aarch64" -o "${ARCH}" == "x86_64" ]
if [ "${ARCH}" == "aarch64" -o "${ARCH}" == "x86_64" -o "${ARCH}" == "riscv64gc" ]
then
bootloader "${ARCH}-unknown-uefi" bootloader.efi bootloader.efi
bootloader "${ARCH}-unknown-uefi" bootloader-live.efi bootloader-live.efi

View File

@ -4,7 +4,7 @@ git = "https://gitlab.redox-os.org/redox-os/bootstrap.git"
[build]
template = "custom"
script = """
ARCH="$(echo "${TARGET}" | cut -d - -f1)"
ARCH="$(echo "${GNU_TARGET}" | cut -d - -f1)"
cargo \
-Zbuild-std=core,alloc,compiler_builtins \
-Zbuild-std-features=compiler-builtins-mem rustc \
@ -15,7 +15,7 @@ cargo \
-- \
--emit link="${COOKBOOK_BUILD}/${TARGET}/release/libbootstrap.a"
mkdir -v "${COOKBOOK_STAGE}/boot"
"${TARGET}-ld" \
"${GNU_TARGET}-ld" \
-o "${COOKBOOK_STAGE}/boot/bootstrap" \
--gc-sections \
-T "${COOKBOOK_SOURCE}/src/${ARCH}.ld" \

View File

@ -2,6 +2,6 @@
git = "https://gitlab.redox-os.org/redox-os/escalated.git"
# Escalated is not backwards compatible wrt relibc versions, so we pin it here
# so it's updated together with the other main submodules.
rev = "846e0774"
rev = "6c9d3e44"
[build]
template = "cargo"

View File

@ -5,7 +5,7 @@ git = "https://gitlab.redox-os.org/redox-os/kernel.git"
template = "custom"
script = """
export RUST_TARGET_PATH="${COOKBOOK_SOURCE}/targets"
ARCH="$(echo "${TARGET}" | cut -d - -f1)"
ARCH="$(echo "${GNU_TARGET}" | cut -d - -f1)"
cargo rustc \
--bin kernel \
--manifest-path "${COOKBOOK_SOURCE}/Cargo.toml" \
@ -16,11 +16,11 @@ cargo rustc \
-C link-arg=-T -Clink-arg="${COOKBOOK_SOURCE}/linkers/${ARCH}.ld" \
-C link-arg=-z -Clink-arg=max-page-size=0x1000 \
--emit link="${PWD}/kernel.all"
"${TARGET}-objcopy" \
"${GNU_TARGET}-objcopy" \
--only-keep-debug \
kernel.all \
kernel.sym
"${TARGET}-objcopy" \
"${GNU_TARGET}-objcopy" \
--strip-debug \
kernel.all \
kernel

View File

@ -9,7 +9,7 @@ script = """
(cd ${COOKBOOK_SOURCE} && ./autogen.sh)
export CFLAGS="-static"
COOKBOOK_CONFIGURE_FLAGS=(
--host="${TARGET}"
--host="${GNU_TARGET}"
--prefix=""
--disable-lzmadec
--disable-lzmainfo

View File

@ -597,7 +597,7 @@ function cookbook_cargo_packages {
# configure template
COOKBOOK_CONFIGURE="${COOKBOOK_SOURCE}/configure"
COOKBOOK_CONFIGURE_FLAGS=(
--host="${TARGET}"
--host="${GNU_TARGET}"
--prefix=""
--disable-shared
--enable-static
@ -615,12 +615,12 @@ function cookbook_configure {
# Strip binaries
if [ -d "${COOKBOOK_STAGE}/bin" ] && [ -z "${COOKBOOK_NOSTRIP}" ]
then
find "${COOKBOOK_STAGE}/bin" -type f -exec "${TARGET}-strip" -v {} ';'
find "${COOKBOOK_STAGE}/bin" -type f -exec "${GNU_TARGET}-strip" -v {} ';'
fi
if [ -d "${COOKBOOK_STAGE}/usr/bin" ] && [ -z "${COOKBOOK_NOSTRIP}" ]
then
find "${COOKBOOK_STAGE}/usr/bin" -type f -exec "${TARGET}-strip" -v {} ';'
find "${COOKBOOK_STAGE}/usr/bin" -type f -exec "${GNU_TARGET}-strip" -v {} ';'
fi
# Remove libtool files