minor updates to the build system

This commit is contained in:
Blaise Tine 2024-04-30 16:27:20 -07:00
parent 19484a531a
commit aea1d2c8eb
9 changed files with 119 additions and 39 deletions

View file

@ -1,12 +1,12 @@
#!/bin/bash
# Copyright © 2019-2023
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -35,7 +35,7 @@ riscv32()
cat riscv32-gnu-toolchain.tar.bz2.parta* > riscv32-gnu-toolchain.tar.bz2
tar -xvf riscv32-gnu-toolchain.tar.bz2
cp -r riscv32-gnu-toolchain $TOOLDIR
rm -f riscv32-gnu-toolchain.tar.bz2*
rm -f riscv32-gnu-toolchain.tar.bz2*
rm -rf riscv32-gnu-toolchain
}
@ -53,7 +53,7 @@ riscv64()
cat riscv64-gnu-toolchain.tar.bz2.parta* > riscv64-gnu-toolchain.tar.bz2
tar -xvf riscv64-gnu-toolchain.tar.bz2
cp -r riscv64-gnu-toolchain $TOOLDIR
rm -f riscv64-gnu-toolchain.tar.bz2*
rm -f riscv64-gnu-toolchain.tar.bz2*
rm -rf riscv64-gnu-toolchain
}
@ -64,15 +64,15 @@ llvm()
*) parts=$(eval echo {a..b}) ;;
esac
echo $parts
rm -f llvm-vortex.tar.bz2.parta*
rm -f llvm-vortex2.tar.bz2.parta*
for x in $parts
do
wget $REPOSITORY/llvm-vortex/$OSDIR/llvm-vortex.tar.bz2.parta$x
wget $REPOSITORY/llvm-vortex/$OSDIR/llvm-vortex2.tar.bz2.parta$x
done
cat llvm-vortex.tar.bz2.parta* > llvm-vortex.tar.bz2
tar -xvf llvm-vortex.tar.bz2
cat llvm-vortex2.tar.bz2.parta* > llvm-vortex2.tar.bz2
tar -xvf llvm-vortex2.tar.bz2
cp -r llvm-vortex $TOOLDIR
rm -f llvm-vortex.tar.bz2*
rm -f llvm-vortex2.tar.bz2*
rm -rf llvm-vortex
}
@ -94,6 +94,42 @@ libc64()
rm -rf libc64
}
libcrt32()
{
wget $REPOSITORY/libcrt32/libcrt32.tar.bz2
tar -xvf libcrt32.tar.bz2
rm -f libcrt32.tar.bz2
cp -r libcrt32 $TOOLDIR
rm -rf libcrt32
}
libcrt64()
{
wget $REPOSITORY/libcrt64/libcrt64.tar.bz2
tar -xvf libcrt64.tar.bz2
rm -f libcrt64.tar.bz2
cp -r libcrt64 $TOOLDIR
rm -rf libcrt64
}
libc32()
{
wget $REPOSITORY/libc32/libc32.tar.bz2
tar -xvf libc32.tar.bz2
rm -f libc32.tar.bz2
cp -r libc32 $TOOLDIR
rm -rf libc32
}
libc64()
{
wget $REPOSITORY/libc64/libc64.tar.bz2
tar -xvf libc64.tar.bz2
rm -f libc64.tar.bz2
cp -r libc64 $TOOLDIR
rm -rf libc64
}
pocl()
{
wget $REPOSITORY/pocl/$OSDIR/pocl2.tar.bz2
@ -108,11 +144,11 @@ verilator()
wget $REPOSITORY/verilator/$OSDIR/verilator.tar.bz2
tar -xvf verilator.tar.bz2
cp -r verilator $TOOLDIR
rm -f verilator.tar.bz2
rm -f verilator.tar.bz2
rm -rf verilator
}
sv2v()
sv2v()
{
wget $REPOSITORY/sv2v/$OSDIR/sv2v.tar.bz2
tar -xvf sv2v.tar.bz2
@ -136,14 +172,14 @@ yosys()
cat yosys.tar.bz2.parta* > yosys.tar.bz2
tar -xvf yosys.tar.bz2
cp -r yosys $TOOLDIR
rm -f yosys.tar.bz2*
rm -f yosys.tar.bz2*
rm -rf yosys
}
show_usage()
{
echo "Install Pre-built Vortex Toolchain"
echo "Usage: $0 [--pocl] [--verilator] [--riscv32] [--riscv64] [--llvm] [--libc32] [--libc64] [--sv2v] [--yosys] [--all] [-h|--help]"
echo "Usage: $0 [--pocl] [--verilator] [--riscv32] [--riscv64] [--llvm] [--libcrt32] [--libcrt64] [--libc32] [--libc64] [--sv2v] [--yosys] [--all] [-h|--help]"
}
while [ "$1" != "" ]; do
@ -158,6 +194,10 @@ while [ "$1" != "" ]; do
;;
--llvm ) llvm
;;
--libcrt32 ) libcrt32
;;
--libcrt64 ) libcrt64
;;
--libc32 ) libc32
;;
--libc64 ) libc64
@ -169,6 +209,8 @@ while [ "$1" != "" ]; do
--all ) pocl
verilator
llvm
libcrt32
libcrt64
libc32
libc64
riscv32

View file

@ -1,12 +1,12 @@
#!/bin/bash
# Copyright © 2019-2023
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -19,7 +19,7 @@ set -e
TOOLDIR=${TOOLDIR:=@TOOLDIR@}
OSDIR=${OSDIR:=@OSDIR@}
riscv32()
riscv32()
{
echo "prebuilt riscv32-gnu-toolchain..."
tar -C $TOOLDIR -cvjf riscv32-gnu-toolchain.tar.bz2 riscv32-gnu-toolchain
@ -29,7 +29,7 @@ riscv32()
rm riscv32-gnu-toolchain.tar.bz2
}
riscv64()
riscv64()
{
echo "prebuilt riscv64-gnu-toolchain..."
tar -C $TOOLDIR -cvjf riscv64-gnu-toolchain.tar.bz2 riscv64-gnu-toolchain
@ -39,17 +39,33 @@ riscv64()
rm riscv64-gnu-toolchain.tar.bz2
}
llvm()
llvm()
{
echo "prebuilt llvm-vortex..."
tar -C $TOOLDIR -cvjf llvm-vortex.tar.bz2 llvm-vortex
split -b 50M llvm-vortex.tar.bz2 "llvm-vortex.tar.bz2.part"
echo "prebuilt llvm-vortex2..."
tar -C $TOOLDIR -cvjf llvm-vortex2.tar.bz2 llvm-vortex
split -b 50M llvm-vortex2.tar.bz2 "llvm-vortex2.tar.bz2.part"
mkdir -p ./llvm-vortex/$OSDIR
mv llvm-vortex.tar.bz2.part* ./llvm-vortex/$OSDIR
rm llvm-vortex.tar.bz2
mv llvm-vortex2.tar.bz2.part* ./llvm-vortex/$OSDIR
rm llvm-vortex2.tar.bz2
}
libc32()
libcrt32()
{
echo "prebuilt libcrt32..."
tar -C $TOOLDIR -cvjf libcrt32.tar.bz2 libc32
mkdir -p ./libcrt32
mv libcrt32.tar.bz2 ./libcrt32
}
libcrt64()
{
echo "prebuilt libcrt64..."
tar -C $TOOLDIR -cvjf libcrt64.tar.bz2 libc64
mkdir -p ./libcrt64
mv libcrt64.tar.bz2 ./libcrt64
}
libc32()
{
echo "prebuilt libc32..."
tar -C $TOOLDIR -cvjf libc32.tar.bz2 libc32
@ -57,7 +73,7 @@ libc32()
mv libc32.tar.bz2 ./libc32
}
libc64()
libc64()
{
echo "prebuilt libc64..."
tar -C $TOOLDIR -cvjf libc64.tar.bz2 libc64
@ -65,7 +81,7 @@ libc64()
mv libc64.tar.bz2 ./libc64
}
pocl()
pocl()
{
echo "prebuilt pocl..."
tar -C $TOOLDIR -cvjf pocl2.tar.bz2 pocl
@ -73,7 +89,7 @@ pocl()
mv pocl2.tar.bz2 ./pocl/$OSDIR
}
verilator()
verilator()
{
echo "prebuilt verilator..."
tar -C $TOOLDIR -cvjf verilator.tar.bz2 verilator
@ -81,7 +97,7 @@ verilator()
mv verilator.tar.bz2 ./verilator/$OSDIR
}
sv2v()
sv2v()
{
echo "prebuilt sv2v..."
tar -C $TOOLDIR -cvjf sv2v.tar.bz2 sv2v
@ -102,7 +118,7 @@ yosys()
show_usage()
{
echo "Setup Pre-built Vortex Toolchain"
echo "Usage: $0 [--pocl] [--verilator] [--riscv32] [--riscv64] [--llvm] [--libc32] [--libc64] [--sv2v] [-yosys] [--all] [-h|--help]"
echo "Usage: $0 [--pocl] [--verilator] [--riscv32] [--riscv64] [--llvm] [--libcrt32] [--libcrt64] [--libc32] [--libc64] [--sv2v] [-yosys] [--all] [-h|--help]"
}
while [ "$1" != "" ]; do
@ -117,6 +133,10 @@ while [ "$1" != "" ]; do
;;
--llvm ) llvm
;;
--libcrt32 ) libcrt32
;;
--libcrt64 ) libcrt64
;;
--libc32 ) libc32
;;
--libc64 ) libc64
@ -130,6 +150,8 @@ while [ "$1" != "" ]; do
riscv32
riscv64
llvm
libcrt32
libcrt64
libc32
libc64
sv2v

View file

@ -1,10 +1,10 @@
# Copyright © 2019-2023
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -20,6 +20,7 @@ TOOLDIR ?= @TOOLDIR@
LLVM_VORTEX ?= $(TOOLDIR)/llvm-vortex
LIBC_VORTEX ?= $(TOOLDIR)/libc$(XLEN)
LIBCRT_VORTEX ?= $(TOOLDIR)/libcrt$(XLEN)
RISCV_TOOLCHAIN_PATH ?= $(TOOLDIR)/riscv$(XLEN)-gnu-toolchain

View file

@ -1,3 +1,16 @@
diff --git a/src/internal/atomic.h b/src/internal/atomic.h
index 96c1552d..41b02e75 100644
--- a/src/internal/atomic.h
+++ b/src/internal/atomic.h
@@ -226,7 +226,7 @@ static inline void a_or_64(volatile uint64_t *p, uint64_t v)
#endif
#ifndef a_cas_p
-typedef char a_cas_p_undefined_but_pointer_not_32bit[-sizeof(char) == 0xffffffff ? 1 : -1];
+//typedef char a_cas_p_undefined_but_pointer_not_32bit[-sizeof(char) == 0xffffffff ? 1 : -1];
#define a_cas_p a_cas_p
static inline void *a_cas_p(volatile void *p, void *t, void *s)
{
diff --git a/src/setjmp/riscv32/longjmp.S b/src/setjmp/riscv32/longjmp.S
index f9cb3318..0980ea23 100644
--- a/src/setjmp/riscv32/longjmp.S

View file

@ -160,11 +160,13 @@ extern int vx_upload_kernel_bytes(vx_device_h hdevice, const void* content, uint
});
#endif
// mask binary region as read-only
RT_CHECK(vx_mem_access(_hbuffer, 0, bin_size, VX_MEM_READ), {
vx_mem_free(_hbuffer);
return _ret;
});
// mark global variables region as read-write
RT_CHECK(vx_mem_access(_hbuffer, bin_size, runtime_size - bin_size, VX_MEM_READ_WRITE), {
vx_mem_free(_hbuffer);
return _ret;

View file

@ -252,7 +252,7 @@ bool ACLManager::check(uint64_t addr, uint64_t size, int flags) const {
while (it != acl_map_.end() && it->first < end) {
if (it->second.end > addr) {
if ((it->second.flags & flags) != flags) {
std::cout << "Memory access violation from 0x" << std::hex << addr << " to 0x" << end << ", flags=" << (it->second.flags ^ flags) << std::endl;
std::cout << "Memory access violation from 0x" << std::hex << addr << " to 0x" << end << ", curent flags=" << it->second.flags << ", access flags=" << flags << std::endl;
return false; // Overlapping entry is missing at least one required flag bit
}
addr = it->second.end; // Move to the end of the current matching range

View file

@ -54,9 +54,9 @@ int read_kernel_file(const char* filename, uint8_t** data, size_t* size) {
*data = (uint8_t*)malloc(fsize);
*size = fread(*data, 1, fsize, fp);
fclose(fp);
return 0;
}
@ -251,7 +251,7 @@ free(allPlatforms);*/
&source,
sourceSize,
&resultCL);*/
// read kernel binary from file
// read kernel binary from file
uint8_t *kernel_bin = NULL;
size_t kernel_size;
cl_int binary_status = 0;
@ -260,7 +260,7 @@ free(allPlatforms);*/
if (0 != read_kernel_file("kernel.cl", &kernel_bin, &kernel_size))
std::abort();
oclHandles.program = clCreateProgramWithSource(
oclHandles.context, 1, (const char**)&kernel_bin, &kernel_size, &resultCL);
oclHandles.context, 1, (const char**)&kernel_bin, &kernel_size, &resultCL);
#else
if (0 != read_kernel_file("kernel.pocl", &kernel_bin, &kernel_size))
std::abort();
@ -469,7 +469,7 @@ cl_mem _clMallocRW(int size, void *h_mem_ptr) throw(string) {
cl_mem _clMalloc(int size, void *h_mem_ptr) throw(string) {
cl_mem d_mem;
d_mem = clCreateBuffer(oclHandles.context,
CL_MEM_WRITE_ONLY | CL_MEM_COPY_HOST_PTR, size,
CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, size,
h_mem_ptr, &oclHandles.cl_status);
#ifdef ERRMSG
if (oclHandles.cl_status != CL_SUCCESS)

View file

@ -22,7 +22,7 @@ LLVM_POCL ?= $(TOOLDIR)/llvm-vortex
VX_LIBS += -L$(LIBC_VORTEX)/lib -lm -lc
VX_LIBS += libclang_rt.builtins-riscv32.a
VX_LIBS += $(LIBCRT_VORTEX)/lib/baremetal/libclang_rt.builtins-riscv$(XLEN).a
#VX_LIBS += -lgcc
VX_CFLAGS += -O3 -mcmodel=medany --sysroot=$(RISCV_SYSROOT) --gcc-toolchain=$(RISCV_TOOLCHAIN_PATH) -Xclang -target-feature -Xclang +vortex

View file

@ -41,7 +41,7 @@ VX_CFLAGS += -DNDEBUG
VX_LIBS += -L$(LIBC_VORTEX)/lib -lm -lc
VX_LIBS += libclang_rt.builtins-riscv32.a
VX_LIBS += $(LIBCRT_VORTEX)/lib/baremetal/libclang_rt.builtins-riscv$(XLEN).a
#VX_LIBS += -lgcc
VX_LDFLAGS += -Wl,-Bstatic,--gc-sections,-T,$(VORTEX_KN_PATH)/scripts/link$(XLEN).ld,--defsym=STARTUP_ADDR=$(STARTUP_ADDR) $(ROOT_DIR)/kernel/libvortexrt.a $(VX_LIBS)