Re: [Tinycc-devel] Regression building GMP with tcc, bisected

2020-07-06 Thread Michael Matz

Hello,

On Mon, 6 Jul 2020, Herman ten Brugge wrote:


In the old code you can also make it fail:
tst.s:
-
    .data
    .globl  foo
    .long   0
foo
    .byte   0
-

If you compile it in the old compiler with:
tcc -include tst.s -c tst.s
you get no error. This is because of the same latent bug in next_nomacro1.


I think the bug is rather to prepare preprocessing directives and the 
inline stack when no preprocessing is to be done.  See 40671f76 in mob.



Ciao,
Michael.___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] Regression building GMP with tcc, bisected

2020-07-06 Thread grischka

Herman ten Brugge via Tinycc-devel wrote:

In the old code you can also make it fail:
tst.s:
-
.data
.globl  foo
.long   0
foo
.byte   0
-

If you compile it in the old compiler with:
tcc -include tst.s -c tst.s
you get no error. This is because of the same latent bug in next_nomacro1.
The better change is below. I do not know how to solve this in another way.
Perhaps you have a better solution?


Well, Herman, "latent" I guess is the word describing best the
situation.

From what people wrote so far one would think there is something
wrong with the assembler that it would not see a missing ':' colon.

Howeber what you obviously found out but did not tell with any
single word is that tcc does not see it because it doesn't even
start to process the file.

Now if you could find a solution that at least *tries* to explain
something, for the other people, I mean. ?

-- grischka



Herman



___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] Regression building GMP with tcc, bisected

2020-07-06 Thread Herman ten Brugge via Tinycc-devel

In the old code you can also make it fail:
tst.s:
-
    .data
    .globl  foo
    .long   0
foo
    .byte   0
-

If you compile it in the old compiler with:
tcc -include tst.s -c tst.s
you get no error. This is because of the same latent bug in next_nomacro1.
The better change is below. I do not know how to solve this in another way.
Perhaps you have a better solution?

    Herman

diff --git a/tccpp.c b/tccpp.c
index e5283c6..bf98e54 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -2643,7 +2643,7 @@ static inline void next_nomacro1(void)
 tok_flags |= TOK_FLAG_EOF;
 tok = TOK_LINEFEED;
 goto keep_tok_flags;
-    } else if (!(parse_flags & PARSE_FLAG_PREPROCESS)) {
+    } else if (file->fd != -2 && !(parse_flags & 
PARSE_FLAG_PREPROCESS)) {

 tok = TOK_EOF;
 } else if (s1->ifdef_stack_ptr != file->ifdef_stack_ptr) {
 tcc_error("missing #endif");
@@ -3754,6 +3754,7 @@ ST_FUNC void preprocess_start(TCCState *s1, int 
is_asm)

 //printf("%s\n", (char*)cstr.data);
 *s1->include_stack_ptr++ = file;
 tcc_open_bf(s1, "", cstr.size);
+    file->fd = -2;
 memcpy(file->buffer, cstr.data, cstr.size);
 cstr_free(&cstr);


On 2020-07-06 14:14, Michael Matz wrote:

Hello Herman,

On Mon, 6 Jul 2020, Herman ten Brugge via Tinycc-devel wrote:


Patch below should fix the problem on mob.
I can commit it if it works for you.


Please find a different way, without strcmp in next_nomacro1.  In 
principle it shouldn't matter how the file is named, and if the 
cmdline buffer setup somehow makes a difference to normal files than 
that should be changed, so that next_nomacro1 behaves as normal.



Ciao,
Michael.



    Herman


diff --git a/tccpp.c b/tccpp.c
index 94f8b02..ae8579b 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -2643,7 +2643,8 @@ static inline void next_nomacro1(void)
 tok_flags |= TOK_FLAG_EOF;
 tok = TOK_LINEFEED;
 goto keep_tok_flags;
-    } else if (!(parse_flags & PARSE_FLAG_PREPROCESS)) {
+    } else if (strcmp(file->filename, "") &&
+   !(parse_flags & PARSE_FLAG_PREPROCESS)) {
 tok = TOK_EOF;
 } else if (s1->ifdef_stack_ptr != file->ifdef_stack_ptr) {
 tcc_error("missing #endif");



On 2020-07-06 03:22, John Scott wrote:
 tcc 0.9.27 works, but current mob fails during GMP's configure 
step. For

 GMP I
 use --disable-assembly and --disable-static, and it fails on
 checking how to define a 32-bit word... configure: error: cannot 
determine

 how
 to define a 32-bit word

 I don't know for certain that this is tcc's fault; it could be a 
normal

 change
 that broke the configure script's heuristics. You can fetch GMP from
 https://gmplib.org/download/gmp/gmp-6.2.0.tar.lz

 Here's the culprit:
 72729d8e360489416146d6d4fd6bc57c9c72c29b is the first bad commit
 commit 72729d8e360489416146d6d4fd6bc57c9c72c29b
 Author: grischka 
 Date:   Wed Dec 11 00:37:18 2019 +0100

 allow libtcc states to be used concurrently

 This allows creation of TCCStates and operation with API
 calls independently from each other, even from threads.

 Frontend (option parsing/libtcc.c) and backend (linker/tccelf.c)
 now depend only on the TCCState (s1) argument.

 Compilation per se (tccpp.c, tccgen.c) is still using
 globals for convenience.  There is only one entry point
 to this section which is tcc_compile() which is protected
 by a semaphore.

 There are some hacks involved to avoid too many changes,
 as well as some changes in order to avoid too many hacks ;)

 The test libtcc_test_mt.c shows the feature.  Except this
 new file the patch adds 87 lines overall.



___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel




___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] Some Stats

2020-07-06 Thread Christian Jullien
Hi, it now fails at least on RPi:
=== Boostrapping with gcc
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  gcc (8.3)
Target OS   Linux
CPU arm
Triplet arm-linux-gnueabihf
Config  strip arm_eabihf arm_vfp arm_vfp
Creating config.mak and config.h
gcc -o tcc.o -c tcc.c -DCONFIG_TRIPLET="\"arm-linux-gnueabihf\"" 
-DTCC_CPU_VERSI ON=7 
-DTCC_TARGET_ARM -DTCC_ARM_EABI -DTCC_ARM_HARDFLOAT -DTCC_ARM_VFP   -DO 
NE_SOURCE=0 -Wall -O2 
-Wdeclaration-after-statement -fno-strict-aliasing -Wno-po  
   inter-sign -Wno-sign-compare -Wno-unused-result 
-Wno-format-truncation -I.
gcc -o libtcc.o -c libtcc.c -DCONFIG_TRIPLET="\"arm-linux-gnueabihf\"" 
-DTCC_CPU _VERSION=7 
-DTCC_TARGET_ARM -DTCC_ARM_EABI -DTCC_ARM_HARDFLOAT -DTCC_ARM_VFP   
 -DONE_SOURCE=0 -Wall -O2 
-Wdeclaration-after-statement -fno-strict-aliasing -
 Wno-pointer-sign -Wno-sign-compare -Wno-unused-result 
-Wno-format-truncation -I. 
gcc -o tccpp.o -c tccpp.c -DCONFIG_TRIPLET="\"arm-linux-gnueabihf\"" 
-DTCC_CPU_V ERSION=7 
-DTCC_TARGET_ARM -DTCC_ARM_EABI -DTCC_ARM_HARDFLOAT -DTCC_ARM_VFP   
 -DONE_SOURCE=0 -Wall -O2 
-Wdeclaration-after-statement -fno-strict-aliasing -Wn  
   o-pointer-sign -Wno-sign-compare -Wno-unused-result 
-Wno-format-truncation -I.
gcc -o tccgen.o -c tccgen.c -DCONFIG_TRIPLET="\"arm-linux-gnueabihf\"" 
-DTCC_CPU _VERSION=7 
-DTCC_TARGET_ARM -DTCC_ARM_EABI -DTCC_ARM_HARDFLOAT -DTCC_ARM_VFP   
 -DONE_SOURCE=0 -Wall -O2 
-Wdeclaration-after-statement -fno-strict-aliasing -
 Wno-pointer-sign -Wno-sign-compare -Wno-unused-result 
-Wno-format-truncation -I. 
tccgen.c: In function ‘gbound_args’:
tccgen.c:1922:18: error: ‘TOK_alloca’ undeclared (first use in this function); 
d id you mean ‘tok_alloc’?
 if (v == TOK_alloca)
  ^~
  tok_alloc


-Original Message-
From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org] On 
Behalf Of grischka
Sent: Monday, July 06, 2020 14:09
To: tinycc-devel@nongnu.org
Subject: [Tinycc-devel] Some Stats

 From the last commits:

 __builtin_/__bound_: A 'stay tiny' approach to the matter
 16 files changed, 641 insertions(+), 719 deletions(-)

 rework leading underscores
 23 files changed, 160 insertions(+), 178 deletions(-)

 some cleanups related to recent commits
 16 files changed, 124 insertions(+), 155 deletions(-)

 libtcc: accept tcc_define_symbol(s1, "sym=value", NULL)
 3 files changed, 19 insertions(+), 44 deletions(-)

that is -152 lines total ;)

-- grischka


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] Regression building GMP with tcc, bisected

2020-07-06 Thread Michael Matz

Hello Herman,

On Mon, 6 Jul 2020, Herman ten Brugge via Tinycc-devel wrote:


Patch below should fix the problem on mob.
I can commit it if it works for you.


Please find a different way, without strcmp in next_nomacro1.  In 
principle it shouldn't matter how the file is named, and if the cmdline 
buffer setup somehow makes a difference to normal files than that should 
be changed, so that next_nomacro1 behaves as normal.



Ciao,
Michael.



    Herman


diff --git a/tccpp.c b/tccpp.c
index 94f8b02..ae8579b 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -2643,7 +2643,8 @@ static inline void next_nomacro1(void)
 tok_flags |= TOK_FLAG_EOF;
 tok = TOK_LINEFEED;
 goto keep_tok_flags;
-    } else if (!(parse_flags & PARSE_FLAG_PREPROCESS)) {
+    } else if (strcmp(file->filename, "") &&
+   !(parse_flags & PARSE_FLAG_PREPROCESS)) {
 tok = TOK_EOF;
 } else if (s1->ifdef_stack_ptr != file->ifdef_stack_ptr) {
 tcc_error("missing #endif");



On 2020-07-06 03:22, John Scott wrote:

 tcc 0.9.27 works, but current mob fails during GMP's configure step. For
 GMP I
 use --disable-assembly and --disable-static, and it fails on
 checking how to define a 32-bit word... configure: error: cannot determine
 how
 to define a 32-bit word

 I don't know for certain that this is tcc's fault; it could be a normal
 change
 that broke the configure script's heuristics. You can fetch GMP from
 https://gmplib.org/download/gmp/gmp-6.2.0.tar.lz

 Here's the culprit:
 72729d8e360489416146d6d4fd6bc57c9c72c29b is the first bad commit
 commit 72729d8e360489416146d6d4fd6bc57c9c72c29b
 Author: grischka 
 Date:   Wed Dec 11 00:37:18 2019 +0100

 allow libtcc states to be used concurrently

 This allows creation of TCCStates and operation with API
 calls independently from each other, even from threads.

 Frontend (option parsing/libtcc.c) and backend (linker/tccelf.c)
 now depend only on the TCCState (s1) argument.

 Compilation per se (tccpp.c, tccgen.c) is still using
 globals for convenience.  There is only one entry point
 to this section which is tcc_compile() which is protected
 by a semaphore.

 There are some hacks involved to avoid too many changes,
 as well as some changes in order to avoid too many hacks ;)

 The test libtcc_test_mt.c shows the feature.  Except this
 new file the patch adds 87 lines overall.



___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] Regression building GMP with tcc, bisected

2020-07-06 Thread Herman ten Brugge via Tinycc-devel

Patch below should fix the problem on mob.
I can commit it if it works for you.

    Herman


diff --git a/tccpp.c b/tccpp.c
index 94f8b02..ae8579b 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -2643,7 +2643,8 @@ static inline void next_nomacro1(void)
 tok_flags |= TOK_FLAG_EOF;
 tok = TOK_LINEFEED;
 goto keep_tok_flags;
-    } else if (!(parse_flags & PARSE_FLAG_PREPROCESS)) {
+    } else if (strcmp(file->filename, "") &&
+   !(parse_flags & PARSE_FLAG_PREPROCESS)) {
 tok = TOK_EOF;
 } else if (s1->ifdef_stack_ptr != file->ifdef_stack_ptr) {
 tcc_error("missing #endif");



On 2020-07-06 03:22, John Scott wrote:

tcc 0.9.27 works, but current mob fails during GMP's configure step. For GMP I
use --disable-assembly and --disable-static, and it fails on
checking how to define a 32-bit word... configure: error: cannot determine how
to define a 32-bit word

I don't know for certain that this is tcc's fault; it could be a normal change
that broke the configure script's heuristics. You can fetch GMP from
https://gmplib.org/download/gmp/gmp-6.2.0.tar.lz

Here's the culprit:
72729d8e360489416146d6d4fd6bc57c9c72c29b is the first bad commit
commit 72729d8e360489416146d6d4fd6bc57c9c72c29b
Author: grischka 
Date:   Wed Dec 11 00:37:18 2019 +0100

allow libtcc states to be used concurrently

This allows creation of TCCStates and operation with API
calls independently from each other, even from threads.

Frontend (option parsing/libtcc.c) and backend (linker/tccelf.c)
now depend only on the TCCState (s1) argument.

Compilation per se (tccpp.c, tccgen.c) is still using
globals for convenience.  There is only one entry point
to this section which is tcc_compile() which is protected
by a semaphore.

There are some hacks involved to avoid too many changes,
as well as some changes in order to avoid too many hacks ;)

The test libtcc_test_mt.c shows the feature.  Except this
new file the patch adds 87 lines overall.



___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


[Tinycc-devel] Some Stats

2020-07-06 Thread grischka

From the last commits:

__builtin_/__bound_: A 'stay tiny' approach to the matter
16 files changed, 641 insertions(+), 719 deletions(-)

rework leading underscores
23 files changed, 160 insertions(+), 178 deletions(-)

some cleanups related to recent commits
16 files changed, 124 insertions(+), 155 deletions(-)

libtcc: accept tcc_define_symbol(s1, "sym=value", NULL)
3 files changed, 19 insertions(+), 44 deletions(-)

that is -152 lines total ;)

-- grischka


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] Regression building GMP with tcc, bisected

2020-07-06 Thread Vincent Lefevre
On 2020-07-05 21:22:27 -0400, John Scott wrote:
> tcc 0.9.27 works, but current mob fails during GMP's configure step. For GMP 
> I 
> use --disable-assembly and --disable-static, and it fails on
> checking how to define a 32-bit word... configure: error: cannot determine 
> how 
> to define a 32-bit word

The issue is that in the GMP test with the new tcc,
$gmp_cv_asm_label_suffix is empty instead of being ":", so that
the generated conftest.s is wrong and fails to assemble.

for gmp_tmp_op in .long .word data4; do
  cat >conftest.s &1
configure:25724: $? = 1
conftest.s:2: error: unknown opcode 'somelabel'
configure: failed program was:
.text
somelabel
conftest.s:2: error: unknown opcode 'somelabel'
trying :
configure:25721: tcc -c   conftest.s >conftest.out 2>&1
configure:25724: $? = 0
configure:25744: result: :

With the new one:

configure:25708: checking for assembler label suffix
trying 
configure:25721: tcc -c   conftest.s >conftest.out 2>&1
configure:25724: $? = 0
configure:25744: result: 

So, the issue is that the program

.text
somelabel

should fail while it doesn't (indeed, it does with gcc and old tcc,
but doesn't with the mod branch).

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] How to programming winsock on tcc

2020-07-06 Thread Christian Jullien
For your convenience, I’ve just added the missing include file 
“win32/include/winapi/ws2tcpip.h” in mob.

Now, MS sample compiles ROOTB from mob

 

C:>tcc -c server.c

C:>tcc -o server.exe server.o -lws2_32

C:>server.exe

^C

 

From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org] On 
Behalf Of Christian Jullien
Sent: Sunday, July 05, 2020 20:55
To: tinycc-devel@nongnu.org
Subject: Re: [Tinycc-devel] How to programming winsock on tcc

 

You may need to grab more include files from 
https://download.savannah.gnu.org/releases/tinycc/winapi-full-for-0.9.27.zip

 

C.

 

From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org] On 
Behalf Of blue sky
Sent: Sunday, July 05, 2020 18:29
To: tinycc-devel@nongnu.org
Subject: [Tinycc-devel] How to programming winsock on tcc

 

Dear Tinycc, 

My name's Ongta, 

 

Tinycc is very good but I cannot write a program that uses winsock as 
https://docs.microsoft.com/en-us/windows/win32/winsock/complete-server-code

Could you help me config to do that.

Many thanks,

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


[Tinycc-devel] some riscv problem

2020-07-06 Thread Herman ten Brugge via Tinycc-devel
While testing the gcc testsuite on all targets I found some problems on 
the riscv target.


- The riscv64-link.c contains a static last_hi. This does not work with 
threads. So sometimes:

  tcc_error("unsupported hi/lo pcrel reloc scheme");
  is called.

- The code:

typedef struct { void *p; } Ptr;
extern Ptr get_stuff (void);
int main(void) { Ptr p = get_stuff (); }

 does core dump with 'tcc -c'.
 Seems there is a problem with gfunc_sret.

- The code:

struct x { int a, b, c; };
extern struct x a ();
extern void b (struct x);
void foo () { a (); b (a ()); }

  does core dump with 'tcc -c -b'.

I do not understand the riscv code well enough to fix this.

Regards,

    Herman




___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel