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, "<command line>", 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, "<command line>") &&
+ !(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 <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