[Tinycc-devel] bug #50847: #line vs. #include "foo.h"

2017-04-25 Thread Larry Doolittle
tinycc community -

I found and submitted tinycc bug #50847: #line directive corrupts #include 
search path
https://savannah.nongnu.org/bugs/index.php?50847

Three comments:

1.  The submission wraps the test case in a tidy (485 byte) tarball.
For lazyweb members who don't want to unpack that, there's really not
much to it.  The bug is triggered by bad.c:
 #line 10 "mythical.c"
 #include "simple.h"
 int foo(bar *b)
 { return b->x == b->y; }
where simple.h provides a typedef for bar, and the bug shows up
when bad.c is in a different directory from where you run the compile.
The command line in demo.sh is "tcc -c dir/bad.c".

2.  The c99 standard is mute on where C compilers are supposed to find
their include files, but the gcc documentation is clear:
https://gcc.gnu.org/onlinedocs/gcc-3.0.2/cpp_2.html
GCC looks for headers requested with #include "file" first in the directory 
containing the current file, then in the same places it would have looked for a 
header requested with angle brackets. For example, if `/usr/include/sys/stat.h' 
contains #include "types.h", GCC looks for `types.h' first in 
`/usr/include/sys', then in its usual search path.
`#line' (see section 6. Line Control) does not change GCC's idea of the 
directory containing the current file.
This is also the behavior of clang.

3.  I put together a brain-dead patch to tinycc mob HEAD,
that touches three lines total and seems to do the job.
It is arguably somewhat wasteful of scratch memory.
Here it is, sorry if the mail pipeline mangles it:

diff --git a/libtcc.c b/libtcc.c
index 99bf783..302ce39 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -581,6 +581,7 @@ ST_FUNC void tcc_open_bf(TCCState *s1, const char 
*filename, int initlen)
 bf->buf_end = bf->buffer + initlen;
 bf->buf_end[0] = CH_EOB; /* put eob symbol */
 pstrcpy(bf->filename, sizeof(bf->filename), filename);
+pstrcpy(bf->filename2, sizeof(bf->filename2), filename);
 #ifdef _WIN32
 normalize_slashes(bf->filename);
 #endif
diff --git a/tcc.h b/tcc.h
index 5b9d4a3..92b9060 100644
--- a/tcc.h
+++ b/tcc.h
@@ -546,6 +546,7 @@ typedef struct BufferedFile {
 int *ifdef_stack_ptr; /* ifdef_stack value at the start of the file */
 int include_next_index; /* next search path */
 char filename[1024];/* filename */
+char filename2[1024];/* filename not modified by # line directive */
 unsigned char unget[4];
 unsigned char buffer[1]; /* extra size for CH_EOB char */
 } BufferedFile;
diff --git a/tccpp.c b/tccpp.c
index 7e5cdcf..4495752 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -1791,7 +1791,8 @@ ST_FUNC void preprocess(int is_bof)
 /* search in file's dir if "header.h" */
 if (c != '\"')
 continue;
-path = file->filename;
+/* https://savannah.nongnu.org/bugs/index.php?50847 */
+path = file->filename2;
 pstrncpy(buf1, path, tcc_basename(path) - path);
 
 } else {


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


Re: [Tinycc-devel] configure file permission

2017-04-25 Thread grischka

Larry Doolittle wrote:

Friends -

commit 7acf9aa8 from earlier today took away the x (execute) permission
bits on configure.  


Sorry, it was by accident.  Don't know why or when but sometimes my
git and/or msys or something does that.

-- gr

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


[Tinycc-devel] configure file permission

2017-04-25 Thread Larry Doolittle
Friends -

commit 7acf9aa8 from earlier today took away the x (execute) permission
bits on configure.  That means the instructions in README
   ./configure
   make
   make test
   make install
don't work any more.  Just FYI, maybe you want to put those bits back,
or update the README to say "sh configure".

   - Larry

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


Re: [Tinycc-devel] bug #50847: #line vs. #include "foo.h"

2017-04-25 Thread Larry Doolittle
grischka -

On Tue, Apr 25, 2017 at 09:20:53PM +0200, grischka wrote:
> Larry Doolittle wrote:
> >3.  I put together a brain-dead patch to tinycc mob HEAD,
> >that touches three lines total and seems to do the job.
> >It is arguably somewhat wasteful of scratch memory.
> Push to mob if you want it in the release.
> (After all, if it works, and, what else could we do.  I think I had
> a quite similar patch somewhere, some (long) time ago.)

OK, I seem to have followed the directions at http://repo.or.cz/tinycc.git
successfully.  I imagine a test case should be added to the source tree,
but I haven't looked into that.

  - Larry

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


Re: [Tinycc-devel] bug #50847: #line vs. #include "foo.h"

2017-04-25 Thread grischka

Larry Doolittle wrote:

3.  I put together a brain-dead patch to tinycc mob HEAD,
that touches three lines total and seems to do the job.
It is arguably somewhat wasteful of scratch memory.
Here it is, sorry if the mail pipeline mangles it:


Push to mob if you want it in the release.

(After all, if it works, and, what else could we do.  I think I had
a quite similar patch somewhere, some (long) time ago.)

-- gr


diff --git a/libtcc.c b/libtcc.c
index 99bf783..302ce39 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -581,6 +581,7 @@ ST_FUNC void tcc_open_bf(TCCState *s1, const char 
*filename, int initlen)
 bf->buf_end = bf->buffer + initlen;
 bf->buf_end[0] = CH_EOB; /* put eob symbol */
 pstrcpy(bf->filename, sizeof(bf->filename), filename);
+pstrcpy(bf->filename2, sizeof(bf->filename2), filename);
 #ifdef _WIN32
 normalize_slashes(bf->filename);
 #endif
diff --git a/tcc.h b/tcc.h
index 5b9d4a3..92b9060 100644
--- a/tcc.h
+++ b/tcc.h
@@ -546,6 +546,7 @@ typedef struct BufferedFile {
 int *ifdef_stack_ptr; /* ifdef_stack value at the start of the file */
 int include_next_index; /* next search path */
 char filename[1024];/* filename */
+char filename2[1024];/* filename not modified by # line directive */
 unsigned char unget[4];
 unsigned char buffer[1]; /* extra size for CH_EOB char */
 } BufferedFile;
diff --git a/tccpp.c b/tccpp.c
index 7e5cdcf..4495752 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -1791,7 +1791,8 @@ ST_FUNC void preprocess(int is_bof)
 /* search in file's dir if "header.h" */
 if (c != '\"')
 continue;
-path = file->filename;
+/* https://savannah.nongnu.org/bugs/index.php?50847 */
+path = file->filename2;
 pstrncpy(buf1, path, tcc_basename(path) - path);
 
 } else {


___
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] TinyCC in macOS

2017-04-25 Thread Andrei E. Warkentin
Thank you. I followed the directions on the http://repo.or.cz/tinycc.git
website. The three patches have been pushed.

A

On Sat, Apr 15, 2017 at 8:42 PM, Michael Matz  wrote:

> Hello,
>
> On Thu, 13 Apr 2017, Andrei E. Warkentin wrote:
>
> How does the merge process work for tinycc? Anything you want from my end?
>>
>
> I used imprecise language.  When I said "merge" I meant "push to mob". See
> http://repo.or.cz/tinycc.git, in particular the section "mob" of the
> repository readme.  (Please rebase your work to current mob before pushing;
> I'm not sure if non-fast-forwards are even accepted, but just in case to
> not uglify history too much).
>
>
>
> Ciao,
> Michael.
>
> ___
> Tinycc-devel mailing list
> Tinycc-devel@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>



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


Re: [Tinycc-devel] Add support of musl-libc to tinycc

2017-04-25 Thread Austin English
On Mon, Apr 24, 2017 at 10:12 AM, avih  wrote:
> Because you asked so nice, here's a less than 5 minutes guide to get enough
> musl for tcc on Alpine linux, and without any permanent storage:
>
> - Download the "VANILLA" iso (80M) from https://alpinelinux.org/downloads/
> - Boot as live cd in a [V]M with network. No HDD required, 512M ram is
> enough*
>
> - Login as root (no password)
> - "echo \n\n\n | setup-interfaces" (or do manual setup)
> - "ifup eth0"
> - "echo 1 | setup-apkrepos" (or run it directly and choose manually)
> - "apk add build-base git" to get some build deps (but not for the docs)
>
> That's enough to clone the tinycc repo, build it and run the tests, but
> that's
> without the doc tools.
>
> [*] 256M is probably enough if you don't install git, and you might need
> more
> if you add more tools like openssh or vim, or xfce4 etc ;)
>
> Of course, if instead of using it as live cd you to install it someplace
> then 256M should be enough for quite a lot.

While that's helpful if someone wants to reproduce, it doesn't
describe the problem at all.

-- 
-Austin
GPG: 14FB D7EA A041 937B

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