Skip to content
3 changes: 2 additions & 1 deletion pkg/dav1d/gen.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local arch = config.target.platform:match('[^-]*')
cflags{
'-Wall', '-Wno-maybe-uninitialized',
'-D _XOPEN_SOURCE=700',
Expand All @@ -6,7 +7,7 @@ cflags{
'-I $srcdir/tools',
'-I $outdir',
'-I $outdir/include/dav1d',
'-I $dir',
arch == 'riscv64' and '-I $dir/riscv' or '-I $dir',
}
nasmflags{
'-i $srcdir/src/',
Expand Down
17 changes: 17 additions & 0 deletions pkg/dav1d/riscv/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#define ARCH_AARCH64 0
#define ARCH_ARM 0
#define ARCH_PPC64LE 0
#define ARCH_X86 0
#define ARCH_X86_32 0
#define ARCH_X86_64 0
#define CONFIG_16BPC 1
#define CONFIG_8BPC 1
#define CONFIG_LOG 1
#define ENDIANNESS_BIG 0
#define HAVE_ASM 1
Comment thread
michaelforney marked this conversation as resolved.
Outdated
#define HAVE_AVX512ICL 1
#define HAVE_CLOCK_GETTIME 1
#define HAVE_DLSYM 1
#define HAVE_POSIX_MEMALIGN 1
#define HAVE_UNISTD_H 1
#define STACK_ALIGNMENT 32
3 changes: 2 additions & 1 deletion pkg/libffi/gen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ build('sed', '$outdir/include/ffi.h', '$srcdir/include/ffi.h.in', {
})

pkg.hdrs = {
copy('$outdir/include', '$srcdir/src/'..({x86_64='x86', aarch64='aarch64'})[arch], {'ffitarget.h'}),
copy('$outdir/include', '$srcdir/src/'..({x86_64='x86', aarch64='aarch64', riscv64='riscv'})[arch], {'ffitarget.h'}),
'$outdir/include/ffi.h',
install=true,
}
Expand All @@ -31,6 +31,7 @@ lib('libffi.a', [[
prep_cif.c types.c raw_api.c java_raw_api.c closures.c
@aarch64 aarch64/(ffi.c sysv.S)
@x86_64 x86/(ffi64.c unix64.S ffiw64.c win64.S)
@riscv64 riscv/(ffi.c sysv.S)
)
]])
file('lib/libffi.a', '644', '$outdir/libffi.a')
Expand Down
1 change: 1 addition & 0 deletions pkg/linux-headers/gen.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local arch = ({
aarch64='arm64',
x86_64='x86',
riscv64='riscv',
})[config.target.platform:match('[^-]*')]
sub('tools.ninja', function()
toolchain(config.host)
Expand Down
25 changes: 25 additions & 0 deletions pkg/linux-headers/riscv.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
return {
-- <cd src/arch/riscv/include/uapi && find * -name '*.h' -exec printf "\t'%s',\n" {} + | LC_COLLATE=C sort
'asm/auxvec.h',
'asm/bitsperlong.h',
'asm/bpf_perf_event.h',
'asm/byteorder.h',
'asm/elf.h',
'asm/hwcap.h',
'asm/hwprobe.h',
'asm/kvm.h',
'asm/perf_regs.h',
'asm/ptrace.h',
'asm/setup.h',
'asm/sigcontext.h',
'asm/ucontext.h',
'asm/unistd.h',
'asm/vendor/mips.h',
'asm/vendor/sifive.h',
'asm/vendor/thead.h',
unistd = {},
Comment thread
michaelforney marked this conversation as resolved.
Outdated
generic={
-- <awk '$1 == "generic-y" {printf "\\t\\t'\'%s\'',\\n", $3}' src/arch/riscv/include/uapi/asm/Kbuild
'kvm_para.h',
Comment thread
michaelforney marked this conversation as resolved.
Outdated
},
}
17 changes: 16 additions & 1 deletion pkg/musl/gen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,22 @@ for _, lib in ipairs{'libm.a', 'librt.a', 'libpthread.a', 'libcrypt.a', 'libutil
end

local startfiles = {'$outdir/libc.a'}
for _, src in ipairs{'crt1.c', 'rcrt1.c', 'Scrt1.c', arch..'/crti.s', arch..'/crtn.s'} do

local crts = (arch == 'riscv64') and {
'crt1.c',
'rcrt1.c',
'Scrt1.c',
'crti.c',
'crtn.c',
} or {
'crt1.c',
'rcrt1.c',
'Scrt1.c',
arch..'/crti.s',
arch..'/crtn.s',
}

for _, src in ipairs(crts) do
Comment thread
michaelforney marked this conversation as resolved.
Outdated
local obj = src:gsub('.-(%w*)%.[cs]$', '%1.o')
local out = '$outdir/'..obj
build('cc', out, {'$srcdir/crt/'..src, '|', '$gendir/deps'}, {cflags='$cflags $cflags_nossp'})
Expand Down
39 changes: 39 additions & 0 deletions pkg/musl/riscv64.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
return {
srcs={
-- <cd src && printf "\t\t'%s',\n" src/*/riscv64/*.[csS]
'src/fenv/riscv64/fenv-sf.c',
'src/fenv/riscv64/fenv.S',
'src/ldso/riscv64/dlsym.s',
'src/ldso/riscv64/tlsdesc.s',
'src/math/riscv64/copysign.c',
'src/math/riscv64/copysignf.c',
'src/math/riscv64/fabs.c',
'src/math/riscv64/fabsf.c',
'src/math/riscv64/fma.c',
'src/math/riscv64/fmaf.c',
'src/math/riscv64/fmax.c',
'src/math/riscv64/fmaxf.c',
'src/math/riscv64/fmin.c',
'src/math/riscv64/fminf.c',
'src/math/riscv64/sqrt.c',
'src/math/riscv64/sqrtf.c',
'src/process/riscv64/vfork.s',
'src/setjmp/riscv64/longjmp.S',
'src/setjmp/riscv64/setjmp.S',
'src/signal/riscv64/restore.s',
'src/signal/riscv64/sigsetjmp.s',
'src/thread/riscv64/__set_thread_area.s',
'src/thread/riscv64/__unmapself.s',
'src/thread/riscv64/clone.s',
'src/thread/riscv64/syscall_cp.s',
},
bits={
-- <cd src/arch/riscv/bits && printf "\t\t'%s',\n" *.h
Comment thread
michaelforney marked this conversation as resolved.
Outdated
'fenv.h',
'float.h',
'setjmp.h',
'signal.h',
'user.h',
},
}