To make the test code work some more things needed to change (see attachment).
There are test failures. I still have to figure out why these happen.

    Herman

On 2020-08-08 15:55, Herman ten Brugge wrote:
Can you try tcc patch below.
I also had to add some libraries to radare2. See patch below.

    Herman


diff --git a/tccgen.c b/tccgen.c
index cd236fd..d0448ce 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -2093,7 +2093,7 @@ static int adjust_bf(SValue *sv, int bit_pos, int bit_size)
         return 0;
     t = sv->type.ref->auxtype;
     if (t != -1 && t != VT_STRUCT) {
-        sv->type.t = (sv->type.t & ~VT_BTYPE) | t;
+        sv->type.t = (sv->type.t & ~(VT_BTYPE | VT_LONG)) | t;
         sv->r |= VT_LVAL;
     }
     return t;

diff --git a/libr/bin/Makefile b/libr/bin/Makefile
index 4a30278e7..d88a333cf 100644
--- a/libr/bin/Makefile
+++ b/libr/bin/Makefile
@@ -2,7 +2,7 @@ include ../config.mk
 include ../../global.mk

 NAME=r_bin
-R2DEPS=r_util r_io r_socket r_magic r_hash r_syscall
+R2DEPS=r_util r_io r_socket r_magic r_hash r_syscall r_cons

 .PHONY: pre

diff --git a/libr/egg/Makefile b/libr/egg/Makefile
index e38169c07..67d288ebf 100644
--- a/libr/egg/Makefile
+++ b/libr/egg/Makefile
@@ -1,7 +1,7 @@
 include ../config.mk

 NAME=r_egg
-R2DEPS=r_asm r_syscall r_util r_parse r_reg
+R2DEPS=r_asm r_syscall r_util r_parse r_reg r_lang
 R2DEPS+=r_flag r_cons

 OBJS=egg.o egg_lang.o
diff --git a/libr/fs/Makefile b/libr/fs/Makefile
index d57e5a207..92dc0dcbb 100644
--- a/libr/fs/Makefile
+++ b/libr/fs/Makefile
@@ -1,5 +1,5 @@
 NAME=r_fs
-R2DEPS=r_util r_io
+R2DEPS=r_util r_io r_cons r_socket
 CFLAGS+=-DR2_PLUGIN_INCORE -Iarch/include -Iarch

 SHLR=../../shlr/



On 2020-08-08 11:35, XVilka Haos of System wrote:
Dear tcc developers,
we are trying to build radare2 with a recent tcc from git and get this error:

tcc: x86_64-gen.c:452: load: Assertion `((ft & VT_BTYPE) == VT_INT) ||
((ft & VT_BTYPE) == VT_LLONG) || ((ft & VT_BTYPE) == VT_PTR) || ((ft &
VT_BTYPE) == VT_FUNC)' failed.

See the corresponding  PR in our repository
https://github.com/radareorg/radare2/pull/17295

See full log here
https://github.com/radareorg/radare2/runs/961265893?check_suite_focus=true#step:6:1225

Please take a look.

Kind regards,
XVilka.



diff --git a/libr/bin/Makefile b/libr/bin/Makefile
index 4a30278e7..d88a333cf 100644
--- a/libr/bin/Makefile
+++ b/libr/bin/Makefile
@@ -2,7 +2,7 @@ include ../config.mk
 include ../../global.mk
 
 NAME=r_bin
-R2DEPS=r_util r_io r_socket r_magic r_hash r_syscall
+R2DEPS=r_util r_io r_socket r_magic r_hash r_syscall r_cons
 
 .PHONY: pre
 
diff --git a/libr/bin/p/bin_dex.c b/libr/bin/p/bin_dex.c
index 187ab60f6..e73df1b75 100644
--- a/libr/bin/p/bin_dex.c
+++ b/libr/bin/p/bin_dex.c
@@ -120,7 +120,7 @@ static int countOnes(ut32 val) {
                return 0;
        }
        /* visual studio doesnt supports __buitin_clz */
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__TINYC__)
        int count = 0;
        val = val - ((val >> 1) & 0x55555555);
        val = (val & 0x33333333) + ((val >> 2) & 0x33333333);
diff --git a/libr/debug/p/native/linux/linux_coredump.c 
b/libr/debug/p/native/linux/linux_coredump.c
index 90aa387bd..dd7ba5e70 100644
--- a/libr/debug/p/native/linux/linux_coredump.c
+++ b/libr/debug/p/native/linux/linux_coredump.c
@@ -1334,7 +1334,7 @@ fail:
        return NULL;
 }
 
-#if __i386__ || __x86_64
+#if __i386__ || __x86_64__
 static int get_xsave_size(RDebug *dbg, int pid) {
 #ifdef PTRACE_GETREGSET
        struct iovec local;
diff --git a/libr/egg/Makefile b/libr/egg/Makefile
index e38169c07..67d288ebf 100644
--- a/libr/egg/Makefile
+++ b/libr/egg/Makefile
@@ -1,7 +1,7 @@
 include ../config.mk
 
 NAME=r_egg
-R2DEPS=r_asm r_syscall r_util r_parse r_reg
+R2DEPS=r_asm r_syscall r_util r_parse r_reg r_lang
 R2DEPS+=r_flag r_cons
 
 OBJS=egg.o egg_lang.o
diff --git a/libr/fs/Makefile b/libr/fs/Makefile
index d57e5a207..92dc0dcbb 100644
--- a/libr/fs/Makefile
+++ b/libr/fs/Makefile
@@ -1,5 +1,5 @@
 NAME=r_fs
-R2DEPS=r_util r_io
+R2DEPS=r_util r_io r_cons r_socket
 CFLAGS+=-DR2_PLUGIN_INCORE -Iarch/include -Iarch
 
 SHLR=../../shlr/
diff --git a/shlr/heap/include/r_jemalloc/internal/util.h 
b/shlr/heap/include/r_jemalloc/internal/util.h
index b0d767240..a62600842 100644
--- a/shlr/heap/include/r_jemalloc/internal/util.h
+++ b/shlr/heap/include/r_jemalloc/internal/util.h
@@ -287,7 +287,7 @@ lg_floor(size_t x)
        assert(ret < UINT_MAX);
        return ((unsigned)ret);
 }
-#elif (defined(JEMALLOC_HAVE_BUILTIN_CLZ))
+#elif (defined(JEMALLOC_HAVE_BUILTIN_CLZ)) && !defined(__TINYC__)
 JEMALLOC_INLINE unsigned
 lg_floor(size_t x)
 {
diff --git a/shlr/lz4/lz4.c b/shlr/lz4/lz4.c
index 3fe133718..006f910d9 100644
--- a/shlr/lz4/lz4.c
+++ b/shlr/lz4/lz4.c
@@ -291,7 +291,7 @@ static unsigned LZ4_NbCommonBytes (register reg_t val) {
                        unsigned long r = 0;
                        _BitScanReverse64( &r, val );
                        return (unsigned)(r>>3);
-#       elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && 
!defined(LZ4_FORCE_SW_BITCOUNT)
+#       elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && 
!defined(LZ4_FORCE_SW_BITCOUNT) && !defined(__TINYC__)
                        return (__builtin_clzll((ut64)val) >> 3);
 #       else
                        static const ut32 by32 = sizeof(val)*4;  /* 32 on 64 
bits (goal), 16 on 32 bits.
@@ -304,11 +304,11 @@ static unsigned LZ4_NbCommonBytes (register reg_t val) {
                        return r;
 #       endif
                } else /* 32 bits */ {
-#       if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
+#       if (defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT))
                        unsigned long r = 0;
                        _BitScanReverse( &r, (unsigned long)val );
                        return (unsigned)(r>>3);
-#       elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && 
!defined(LZ4_FORCE_SW_BITCOUNT)
+#       elif (defined(__clang__) || (defined(__GNUC__) && (__GNUC__>=3))) && 
!defined(LZ4_FORCE_SW_BITCOUNT) && !defined(__TINYC__)
                        return (__builtin_clz((ut32)val) >> 3);
 #       else
                        unsigned r;
diff --git a/shlr/tree-sitter/lib/src/atomic.h 
b/shlr/tree-sitter/lib/src/atomic.h
index 7bd0e850a..8472724d7 100644
--- a/shlr/tree-sitter/lib/src/atomic.h
+++ b/shlr/tree-sitter/lib/src/atomic.h
@@ -3,7 +3,23 @@
 
 #include <stdint.h>
 
-#ifdef _WIN32
+#ifdef __TINYC__
+
+static inline size_t atomic_load(const volatile size_t *p) {
+  return *p;
+}
+
+static inline uint32_t atomic_inc(volatile uint32_t *p) {
+  *p += 1;
+  return *p;
+}
+
+static inline uint32_t atomic_dec(volatile uint32_t *p) {
+  *p -= 1;
+  return p;
+}
+
+#elif defined( _WIN32)
 
 #include <windows.h>
 
diff --git a/shlr/tree-sitter/lib/src/bits.h b/shlr/tree-sitter/lib/src/bits.h
index ce7a71556..ab544f89d 100644
--- a/shlr/tree-sitter/lib/src/bits.h
+++ b/shlr/tree-sitter/lib/src/bits.h
@@ -7,7 +7,18 @@ static inline uint32_t bitmask_for_index(uint16_t id) {
   return (1u << (31 - id));
 }
 
-#if defined _WIN32 && !defined __GNUC__
+#ifdef __TINYC__
+
+static inline uint32_t count_leading_zeros(uint32_t x) {
+  int count = 0;
+  if (x == 0) return 32;
+  x = x - ((x >> 1) & 0x55555555);
+  x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
+  count = (((x + (x >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
+  return count;
+}
+
+#elif defined _WIN32 && !defined __GNUC__
 
 #include <intrin.h>
 
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to