Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ jobs:
- milkv-duos
- milkv-jupiter
- milkv-jupiter-clang
# - milkv-jupiter-zig
- qemu-riscv64
- qemu-riscv64-clang
- qemu-riscv64-zig
steps:
- name: Install dependencies
run: |
toolchain_pkgs=""
target=${{ matrix.target }}
if [[ ${target} == *"clang" ]]; then
if [[ ${target} == *"zig" ]]; then
toolchain_pkgs="zig clang lld llvm"
elif [[ ${target} == *"clang" ]]; then
toolchain_pkgs="clang lld llvm"
else
toolchain_pkgs="binutils-riscv-none-elf gcc-riscv-none-elf"
Expand Down Expand Up @@ -52,7 +56,9 @@ jobs:
mkdir build
cd build
target=${{ matrix.target }}
if [[ ${target} == *"clang" ]]; then
if [[ ${target} == *"zig" ]]; then
../configure --target ${target::-4} --zig
elif [[ ${target} == *"clang" ]]; then
../configure --target ${target::-6} --clang
else
../configure --target ${target}
Expand Down
19 changes: 16 additions & 3 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ known_arches=(riscv64)
# shellcheck disable=SC2034 # Only accessed indirectly.
tool_prefixes_riscv64=(riscv64-none-elf- riscv-none-elf- riscv64-unknown-elf-)

args=$(getopt -n ./configure -o 'h' -l 'arch:,help,no-default-cflags,clang,prefix:,target:' -- "$@")
args=$(getopt -n ./configure -o 'h' -l 'arch:,help,no-default-cflags,clang,zig,prefix:,target:' -- "$@")
eval set -- "$args"
unset args

Expand All @@ -41,6 +41,7 @@ default_cflags=1
default_ldflags=1
help=0
clang=0
zig=0
prefix=/
while true; do
case "$1" in
Expand Down Expand Up @@ -68,6 +69,10 @@ while true; do
clang=1
shift
;;
--zig)
zig=1
shift
;;
--no-default-cflags)
default_cflags=0
shift
Expand Down Expand Up @@ -169,7 +174,15 @@ find_tool_with_prefix() {
find_tool "$tool_name" "${tools[@]}"
}

if [[ "$clang" = 1 ]]; then
if [[ "$zig" = 1 ]]; then
CC="zig cc"
if [[ "$default_cflags" = 1 ]]; then
CFLAGS="--no-warnings $CFLAGS"
fi
if [[ "$default_ldflags" = 1 ]]; then
LDFLAGS="-fuse-ld=lld $LDFLAGS"
fi
elif [[ "$clang" = 1 ]]; then
find_tool_with_prefix CC clang
if [[ "$default_cflags" = 1 ]]; then
CFLAGS="-target riscv64-none-elf -Wno-error=\#warnings $CFLAGS"
Expand Down Expand Up @@ -200,7 +213,7 @@ prefix = $(printf %q "$prefix")
srcdir = $(printf %q "$repo")
target = $(printf %q "$target")

CC = $(printf %q "$CC")
CC = $(printf "$CC")
GDB = $(printf %q "$GDB")
OBJDUMP = $(printf %q "$OBJDUMP")
PYTHON3 = $(printf %q "$PYTHON3")
Expand Down
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
pkgs.pkgsCross.riscv64-embedded.buildPackages.llvmPackages.lld
pkgs.python3
pkgs.watchexec
pkgs.zig
];

dontUnpack = true;
Expand Down
6 changes: 5 additions & 1 deletion src/targets/riscv64/qemu-riscv64.mak
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

kernel-cflags += -march=rv64imafdcbv_zicsr_zicntr_zihpm_ziccif_ziccrse_ziccamoa_zicclsm_zic64b_za64rs_zihintpause_zba_zbb_zbs_zicbom_zicbop_zicboz_zfhmin_zkt_zvfhmin_zvbb_zvkt_zihintntl_zicond_zimop_zcmop_zcb_zfa_zawrs_svpbmt_svinval_svnapot_sstc_sscofpmf_zifencei
ifeq ($(findstring zig,$(CC)),zig)
kernel-cflags += -target riscv64-freestanding-none
else
kernel-cflags += -march=rv64imafdcbv_zicsr_zicntr_zihpm_ziccif_ziccrse_ziccamoa_zicclsm_zic64b_za64rs_zihintpause_zba_zbb_zbs_zicbom_zicbop_zicboz_zfhmin_zkt_zvfhmin_zvbb_zvkt_zihintntl_zicond_zimop_zcmop_zcb_zfa_zawrs_svpbmt_svinval_svnapot_sstc_sscofpmf_zifencei
endif
target-qemuflags = --machine virt --cpu rva23s64 --smp 2 -m 1G --netdev user,id=net0 -device rtl8139,netdev=net0,bus=pcie.0
Loading