Skip to content
Open
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
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ DEF-arm64-FreeBSD = $(DEF-arm64) -DTARGETOS_FreeBSD
DEF-arm64-NetBSD = $(DEF-arm64) -DTARGETOS_NetBSD
DEF-arm64-OpenBSD = $(DEF-arm64) -DTARGETOS_OpenBSD
DEF-riscv64 = -DTCC_TARGET_RISCV64
DEF-riscv32 = -DTCC_TARGET_RISCV32
DEF-c67 = -DTCC_TARGET_C67 -w # disable warnigs
DEF-x86_64-FreeBSD = $(DEF-x86_64) -DTARGETOS_FreeBSD
DEF-x86_64-NetBSD = $(DEF-x86_64) -DTARGETOS_NetBSD
Expand All @@ -131,7 +132,7 @@ all: $(PROGS) $(TCCLIBS) $(TCCDOCS)

# cross compiler targets to build
TCC_X = i386 x86_64 i386-win32 x86_64-win32 x86_64-osx arm arm64 arm-wince c67
TCC_X += riscv64 arm64-osx
TCC_X += riscv64 riscv32 arm64-osx
# TCC_X += arm-fpa arm-fpa-ld arm-vfp arm-eabi

# cross libtcc1.a targets to build
Expand Down Expand Up @@ -189,6 +190,7 @@ TRIPLET-x86_64 ?= x86_64-linux-gnu
TRIPLET-arm ?= arm-linux-gnueabi
TRIPLET-arm64 ?= aarch64-linux-gnu
TRIPLET-riscv64 ?= riscv64-linux-gnu
TRIPLET-riscv32 ?= riscv32-linux-gnu
MARCH-i386 ?= i386-linux-gnu
MARCH-$T ?= $(TRIPLET-$T)
TR = $(if $(TRIPLET-$T),$T,ignored)
Expand Down Expand Up @@ -216,6 +218,7 @@ arm64_FILES = $(CORE_FILES) arm64-gen.c arm64-link.c arm64-asm.c
arm64-osx_FILES = $(arm64_FILES) tccmacho.c
c67_FILES = $(CORE_FILES) c67-gen.c c67-link.c tcccoff.c
riscv64_FILES = $(CORE_FILES) riscv64-gen.c riscv64-link.c riscv64-asm.c
riscv32_FILES = $(CORE_FILES) riscv32-gen.c riscv32-link.c riscv32-asm.c

TCCDEFS_H$(subst yes,,$(CONFIG_predefs)) = tccdefs_.h

Expand Down
9 changes: 7 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ case "$cpu" in
riscv64)
cpu="riscv64"
;;
riscv32)
cpu="riscv32"
;;
*)
echo "Unsupported CPU"
exit 1
Expand Down Expand Up @@ -636,7 +639,7 @@ cat >$TMPH <<EOF
#define GCC_MINOR $gcc_minor

#if !(TCC_TARGET_I386 || TCC_TARGET_X86_64 || TCC_TARGET_ARM\
|| TCC_TARGET_ARM64 || TCC_TARGET_RISCV64 || TCC_TARGET_C67)
|| TCC_TARGET_ARM64 || TCC_TARGET_RISCV64 || TCC_TARGET_RISCV32 || TCC_TARGET_C67)
EOF

predefs=1
Expand All @@ -653,6 +656,7 @@ for v in $cpu $confvars ; do
CONFIG_x86_64=yes) print_num TCC_TARGET_X86_64 1 ;;
CONFIG_arm64=yes) print_num TCC_TARGET_ARM64 1 ;;
CONFIG_riscv64=yes) print_num TCC_TARGET_RISCV64 1 ;;
CONFIG_riscv32=yes) print_num TCC_TARGET_RISCV32 1 ;;
CONFIG_arm=yes) print_num TCC_TARGET_ARM 1
print_num CONFIG_TCC_CPUVER "$cpuver" ;;
CONFIG_arm_eabihf=yes) print_num TCC_ARM_EABI 1
Expand Down Expand Up @@ -687,7 +691,8 @@ for v in $cpu $confvars ; do
esac
;;
# other
CONFIG_libgcc=yes) print_num CONFIG_USE_LIBGCC 1 ;;
CONFIG_libgcc=yes) print_num CONFIG_USE_LIBGCC 1
print_str TCC_LIBGCC "libgcc_s.so.1" ;;
CONFIG_selinux=yes) print_num CONFIG_SELINUX 1 ;;
CONFIG_pie=yes) print_num CONFIG_TCC_PIE 1 ;;
CONFIG_pic=yes) print_num CONFIG_TCC_PIC 1 ;;
Expand Down
2 changes: 2 additions & 0 deletions conftest.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ int _CRT_glob = 0;
# define TRIPLET_ARCH "aarch64"
#elif defined(__riscv) && defined(__LP64__)
# define TRIPLET_ARCH "riscv64"
#elif defined(__riscv) && !defined(__LP64__)
# define TRIPLET_ARCH "riscv32"
#else
# define TRIPLET_ARCH "unknown"
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/tccdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@
} __builtin_va_list;

#endif
#elif defined __riscv
#elif defined __riscv || defined TCC_TARGET_RISCV32
typedef char *__builtin_va_list;
#define __va_reg_size (__riscv_xlen >> 3)
#define _tcc_align(addr,type) (((unsigned long)addr + __alignof__(type) - 1) \
Expand Down
2 changes: 2 additions & 0 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ I386_O = libtcc1.o $(COMMON_O)
X86_64_O = libtcc1.o $(COMMON_O)
ARM_O = libtcc1.o armeabi.o armflush.o $(COMMON_O)
ARM64_O = lib-arm64.o $(COMMON_O)
RISCV32_O = libtcc1.o stdatomic.o builtin.o alloca.o
RISCV64_O = lib-arm64.o $(COMMON_O)
COMMON_O = stdatomic.o atomic.o builtin.o alloca.o alloca-bt.o
WIN_O = crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o
Expand Down Expand Up @@ -72,6 +73,7 @@ OBJ-arm-vfp = $(OBJ-arm)
OBJ-arm-eabi = $(OBJ-arm)
OBJ-arm-eabihf = $(OBJ-arm)
OBJ-arm-wince = $(ARM_O) $(WIN_O)
OBJ-riscv32 = $(RISCV32_O) $(LIN_O)
OBJ-riscv64 = $(RISCV64_O) $(LIN_O)

OBJ-extra = $(filter $(EXTRA_O),$(OBJ-$T))
Expand Down
9 changes: 9 additions & 0 deletions libtcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
#include "riscv64-gen.c"
#include "riscv64-link.c"
#include "riscv64-asm.c"
#elif defined(TCC_TARGET_RISCV32)
#include "riscv32-gen.c"
#include "riscv32-link.c"
#include "riscv32-asm.c"
#else
#error unknown target
#endif
Expand Down Expand Up @@ -1731,6 +1735,9 @@ static const FlagDef options_m[] = {
{ offsetof(TCCState, ms_bitfields), 0, "ms-bitfields" },
#ifdef TCC_TARGET_X86_64
{ offsetof(TCCState, nosse), FD_INVERT, "sse" },
#endif
#ifdef TCC_TARGET_RISCV32
{ offsetof(TCCState, fpu), 0, "fpu" },
#endif
{ 0, 0, NULL }
};
Expand Down Expand Up @@ -1783,6 +1790,8 @@ static const char dumpmachine_str[] =
"aarch64"
#elif defined TCC_TARGET_RISCV64
"riscv64"
#elif defined TCC_TARGET_RISCV32
"riscv32"
#endif
"-"
#ifdef TCC_TARGET_PE
Expand Down
Loading