Can you test attached patch.
There might be more places that use __APPLE__ that should be done differently.
You can commit if it works because I cannot test it.

    Herman

On 2020-09-19 06:48, Christian Jullien wrote:

Hi I generally test tcc Linux x64 on Fedora 32, giving a try on an up to date Debian v10.5, while it works with gcc, using clang, I get:

jullien@debian64:~/tinycc$ uname -a

Linux debian64 4.19.0-10-amd64 #1 SMP Debian 4.19.132-1 (2020-07-24) x86_64 GNU/Linux

jullien@debian64:~/tinycc$ clang -v

clang version 7.0.1-8 (tags/RELEASE_701/final)

Target: x86_64-pc-linux-gnu

jullien@debian64:~/tinycc$ ./configure --cc=clang

Binary directory    /usr/local/bin

TinyCC directory    /usr/local/lib/tcc

Library directory   /usr/local/lib

Include directory   /usr/local/include

Manual directory    /usr/local/share/man

Info directory      /usr/local/share/info

Doc directory       /usr/local/share/doc

Source path         /home/jullien/tinycc

C compiler          clang (7.0)

Target OS           Linux

CPU                 x86_64

Triplet x86_64-linux-gnu

Creating config.mak and config.h

config.h is unchanged

jullien@debian64:~/tinycc$ make && make test

...

running tcc.c in threads to run fib

3 2 1 13 8 610 34 2584 144 55 5 21 233 1597 377 987 89 6765 10946 4181

(1497 ms)

compiling tcc.c 10 times

(610 ms)

tcctest.c:3232:10: error: invalid operand for instruction

        __asm__("xchgb %b0,%h0\n\t"     /* swap lower bytes     */

                ^

<inline asm>:1:13: note: instantiated into assembly here

        xchgb %dil,%di

                   ^~~

tcctest.c:3233:17: error: invalid operand for instruction

                "rorl $16,%0\n\t"       /* swap words           */

                              ^

<inline asm>:3:13: note: instantiated into assembly here

        xchgb %dil,%di

                   ^~~

2 errors generated.

make[2]: *** [Makefile:121: test.ref] Error 1

make[1]: *** [Makefile:95: all] Error 2

make[1]: Leaving directory '/home/jullien/tinycc/tests'

make: *** [Makefile:393: test] Error 2


diff --git a/tests/tcctest.c b/tests/tcctest.c
index f72b651..fcb6b02 100644
--- a/tests/tcctest.c
+++ b/tests/tcctest.c
@@ -3225,9 +3225,17 @@ static __inline__ void sigdelset1(unsigned int *set, int 
_sig)
        asm("btrl %1,%0" : "=m"(*set) : "Ir"(_sig - 1) : "cc", "flags");
 }
 
-#ifndef __APPLE__
+#ifdef __clang__
 /* clang's inline asm is uncapable of 'xchgb %b0,%h0' */
 static __inline__ __const__ unsigned int swab32(unsigned int x)
+{
+        return ((x >> 24) & 0xff) |
+               ((x >> 8) & 0xff00) |
+               ((x << 8) & 0xff0000) |
+               ((x << 24) & 0xff000000);
+}
+#else
+static __inline__ __const__ unsigned int swab32(unsigned int x)
 {
        __asm__("xchgb %b0,%h0\n\t"     /* swap lower bytes     */
                "rorl $16,%0\n\t"       /* swap words           */
@@ -3647,9 +3655,7 @@ void asm_test(void)
     __asm__("btsl %1,%0" : "=m"(set) : "Ir"(20) : "cc");
     printf("set=0x%x\n", set);
     val = 0x01020304;
-#ifndef __APPLE__
     printf("swab32(0x%08x) = 0x%0x\n", val, swab32(val));
-#endif
 #ifndef _WIN32
 #ifndef __APPLE__
     override_func1();
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to