From b71e5d1e2cda821e44c8c68843be03be2fb7cb9f Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Sun, 5 Nov 2023 13:28:43 +0100 Subject: [PATCH] build: Add support for TCC in RISC-V. For RISC-V TCC needs a modified libc because it doesn't support Extended Assembly. This change enables that kind of behavior, letting us select the TCC library when it is present. * build-aux/bootstrap.sh.in: Add a block to build-source-lib for TCC. * build-aux/configure-lib.sh: Guard TCC to remove repeated definitions from its libc. * build-aux/install.sh.in: Make it install TCC's library, too --- build-aux/bootstrap.sh.in | 11 +++++++++++ build-aux/configure-lib.sh | 8 ++++++++ build-aux/install.sh.in | 3 +++ 3 files changed, 22 insertions(+) diff --git a/build-aux/bootstrap.sh.in b/build-aux/bootstrap.sh.in index 53524b3a..8502cb6a 100644 --- a/build-aux/bootstrap.sh.in +++ b/build-aux/bootstrap.sh.in @@ -142,3 +142,14 @@ cp bin/mes-mescc bin/mes fi @SHELL@ ${srcdest}build-aux/build-source-lib.sh ) +( + mkdir -p tcc-lib + cp config.sh tcc-lib + cd tcc-lib + compiler=tcc + if test -z "$srcdest"; then + srcdest=../ + srcdir=../ + fi + ${SHELL} ${srcdest}build-aux/build-source-lib.sh +) diff --git a/build-aux/configure-lib.sh b/build-aux/configure-lib.sh index 22d0fe89..2740a044 100644 --- a/build-aux/configure-lib.sh +++ b/build-aux/configure-lib.sh @@ -108,8 +108,16 @@ lib/mes/ntoab.c lib/mes/oputc.c lib/mes/ultoa.c lib/mes/utoa.c +" + +# /include/mes/lib-cc.h already defines __raise.c as a macro for __TCC__ +# if we include it in the target source lib it explodes when reading the +# function definition +if test $compiler != tcc; then + libmes_SOURCES="$libmes_SOURCES lib/stub/__raise.c " +fi if test $mes_libc = mes; then libmes_SOURCES="$libmes_SOURCES diff --git a/build-aux/install.sh.in b/build-aux/install.sh.in index f3a69229..f2e14ccf 100644 --- a/build-aux/install.sh.in +++ b/build-aux/install.sh.in @@ -114,6 +114,9 @@ fi if test -d mescc-lib/$mes_cpu-mes; then tar -cf- -C mescc-lib $mes_cpu-mes | tar -${v}xf- -C $DESTDIR$libdir fi +if test -d tcc-lib/$mes_cpu-mes; then + tar -cf- -C tcc-lib/$mes_cpu-mes . | tar -${v}xf- -C $DESTDIR$libdir +fi mkdir -p ${DESTDIR}${guile_site_dir} mkdir -p ${DESTDIR}${guile_site_ccache_dir}