[Tinycc-devel] tcc port to cygwin
Atttached is a first cut port of the TinyCC build to the cygwin platform. The mains problems seem to be from managing the different include files. I hand added some defines to libtcc1.c for __INTPTR_TYPE__ and a few others to get that to build. However, it is now failing to build bcheck.c with: > ../tcc -B.. -c bcheck.c -o x86_64/bcheck.o -I.. -Wall -g -O0 -Wdeclaration-after-statement -Wno-deprecated-declarations -Wno-strict-aliasing -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result -Wno-uninitialized -fno-strict-aliasing -fPIC -DTCC_TARGET_X86_64 > In file included from bcheck.c:20: > In file included from /usr/include/stdlib.h:18: > /usr/include/sys/reent.h:196: error: ')' expected (got "*") > Makefile:116: recipe for target 'x86_64/bcheck.o' failed > make[1]: *** [x86_64/bcheck.o] Error 1 Looking at the origin of the error message in the skip() routine in tccpp.c, I could not find any place that skip() was called with an argument of ')'. Is there some other place that message could be coming from. Seems like it might be a possible problem in the preprocessing --Chris From f1ee3de3a4c24157c9927cb3706f4e902ae88710 Mon Sep 17 00:00:00 2001 From: Chris Marshall Date: Fri, 20 May 2016 08:02:03 -0400 Subject: [PATCH] Basic port to cygwin of mob tcc The remaining issues appear to be ones relating to include file problems. Specifically, the local include/stddef.h and others seem to be inconsistent with those from the native gcc (as in /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/include/stddef.h or others. --- conftest.c| 2 ++ lib/libtcc1.c | 5 + libtcc.c | 3 +++ tccrun.c | 8 4 files changed, 18 insertions(+) diff --git a/conftest.c b/conftest.c index fa07a1b..8fe2e01 100644 --- a/conftest.c +++ b/conftest.c @@ -18,6 +18,8 @@ # define TRIPLET_OS "linux" #elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__) # define TRIPLET_OS "kfreebsd" +#elif defined (__CYGWIN__) +# define TRIPLET_OS "cygwin" #elif !defined (__GNU__) # define TRIPLET_OS "unknown" #endif diff --git a/lib/libtcc1.c b/lib/libtcc1.c index a5fee7b..05ec15b 100644 --- a/lib/libtcc1.c +++ b/lib/libtcc1.c @@ -28,6 +28,11 @@ the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#define __INTPTR_TYPE__ long int +#define __INTPTR_MAX__ 9223372036854775807L +#define __INT32_TYPE__ int +#define __INT32_MAX__ 2147483647 + #include #define W_TYPE_SIZE 32 diff --git a/libtcc.c b/libtcc.c index b0fcdf9..44caf21 100644 --- a/libtcc.c +++ b/libtcc.c @@ -1131,6 +1131,9 @@ LIBTCCAPI TCCState *tcc_new(void) tcc_define_symbol(s, "__linux__", NULL); tcc_define_symbol(s, "__linux", NULL); # endif +# if defined(__CYGWIN__) +tcc_define_symbol(s, "__CYGWIN__", NULL); +# endif # if defined(__FreeBSD__) tcc_define_symbol(s, "__FreeBSD__", "__FreeBSD__"); # endif diff --git a/tccrun.c b/tccrun.c index 9ee70e4..af539e3 100644 --- a/tccrun.c +++ b/tccrun.c @@ -496,6 +496,8 @@ static int rt_get_caller_pc(addr_t *paddr, ucontext_t *uc, int level) *paddr = uc->uc_mcontext->__ss.__eip; #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) *paddr = uc->uc_mcontext.mc_eip; +#elif defined(__CYGWIN__) +*paddr = uc->uc_mcontext.eip; #elif defined(__dietlibc__) *paddr = uc->uc_mcontext.eip; #elif defined(__NetBSD__) @@ -509,6 +511,8 @@ static int rt_get_caller_pc(addr_t *paddr, ucontext_t *uc, int level) fp = uc->uc_mcontext->__ss.__ebp; #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) fp = uc->uc_mcontext.mc_ebp; +#elif defined(__CYGWIN__) +fp = uc->uc_mcontext.ebp; #elif defined(__dietlibc__) fp = uc->uc_mcontext.ebp; #elif defined(__NetBSD__) @@ -544,6 +548,8 @@ static int rt_get_caller_pc(addr_t *paddr, ucontext_t *uc, int level) *paddr = uc->uc_mcontext.mc_rip; #elif defined(__NetBSD__) *paddr = uc->uc_mcontext.__gregs[_REG_RIP]; +#elif defined(__CYGWIN__) +*paddr = uc->uc_mcontext.rip; #else *paddr = uc->uc_mcontext.gregs[REG_RIP]; #endif @@ -555,6 +561,8 @@ static int rt_get_caller_pc(addr_t *paddr, ucontext_t *uc, int level) fp = uc->uc_mcontext.mc_rbp; #elif defined(__NetBSD__) fp = uc->uc_mcontext.__gregs[_REG_RBP]; +#elif defined(__CYGWIN__) +fp = uc->uc_mcontext.rbp; #else fp = uc->uc_mcontext.gregs[REG_RBP]; #endif -- 2.5.3 ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Re: [Tinycc-devel] tcc port to cygwin
Hello Chris, According to ack, "skip(')')" shows up all over the place in tccgen.c. What does line 196 of your sys/reent.h look like? Also, if I started from a pristine Windows installation with a core Cygwin installation, which Cygwin packages would I need to install to get to where you are? David On Fri, May 20, 2016 at 8:24 AM, Chris Marshall wrote: > Atttached is a first cut port of the TinyCC build to the cygwin platform. > > The mains problems seem to be from managing the different include files. > I hand added some defines to libtcc1.c for __INTPTR_TYPE__ and a few > others to get that to build. > > However, it is now failing to build bcheck.c with: > > > ../tcc -B.. -c bcheck.c -o x86_64/bcheck.o -I.. -Wall -g -O0 > -Wdeclaration-after-statement -Wno-deprecated-declarations > -Wno-strict-aliasing -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result > -Wno-uninitialized -fno-strict-aliasing -fPIC -DTCC_TARGET_X86_64 > > In file included from bcheck.c:20: > > In file included from /usr/include/stdlib.h:18: > > /usr/include/sys/reent.h:196: error: ')' expected (got "*") > > Makefile:116: recipe for target 'x86_64/bcheck.o' failed > > make[1]: *** [x86_64/bcheck.o] Error 1 > > Looking at the origin of the error message in the skip() routine > in tccpp.c, I could not find any place that skip() was called with > an argument of ')'. Is there some other place that message > could be coming from. Seems like it might be a possible > problem in the preprocessing > > --Chris > > > > ___ > Tinycc-devel mailing list > Tinycc-devel@nongnu.org > https://lists.nongnu.org/mailman/listinfo/tinycc-devel > > -- "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." -- Brian Kernighan ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Re: [Tinycc-devel] tcc port to cygwin
Hi David- Ack! I was only looking at the tccpp.c since the problem was with the includes. I think if you select the Devel all you'll get alot of things which should be enough. Off the top of my head, the specifics would be gmake/make, gcc, and maybe git + your choice of editor. Sorry I can't be more specific but the cygwin setup.exe is not really easy to determine what is needed. In the past, when I've had problems, I search for the problem file or whatever using this page: https://cygwin.com/cgi-bin2/package-grep.cgi Then you install and iterate until things work. Unfortunately, I would help you with this but the cygwin setup program is too smart for me to make it think I'm doing a clean install. If you determine the needed packages, that would be great to know---personally and for any potential Alien::TCC stuff on cygwin. --Chris On Fri, May 20, 2016 at 9:17 AM, David Mertens wrote: > Hello Chris, > > According to ack, "skip(')')" shows up all over the place in tccgen.c. > What does line 196 of your sys/reent.h look like? > > Also, if I started from a pristine Windows installation with a core Cygwin > installation, which Cygwin packages would I need to install to get to where > you are? > > David > > On Fri, May 20, 2016 at 8:24 AM, Chris Marshall > wrote: > >> Atttached is a first cut port of the TinyCC build to the cygwin platform. >> >> The mains problems seem to be from managing the different include files. >> I hand added some defines to libtcc1.c for __INTPTR_TYPE__ and a few >> others to get that to build. >> >> However, it is now failing to build bcheck.c with: >> >> > ../tcc -B.. -c bcheck.c -o x86_64/bcheck.o -I.. -Wall -g -O0 >> -Wdeclaration-after-statement -Wno-deprecated-declarations >> -Wno-strict-aliasing -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result >> -Wno-uninitialized -fno-strict-aliasing -fPIC -DTCC_TARGET_X86_64 >> > In file included from bcheck.c:20: >> > In file included from /usr/include/stdlib.h:18: >> > /usr/include/sys/reent.h:196: error: ')' expected (got "*") >> > Makefile:116: recipe for target 'x86_64/bcheck.o' failed >> > make[1]: *** [x86_64/bcheck.o] Error 1 >> >> Looking at the origin of the error message in the skip() routine >> in tccpp.c, I could not find any place that skip() was called with >> an argument of ')'. Is there some other place that message >> could be coming from. Seems like it might be a possible >> problem in the preprocessing >> >> --Chris >> >> >> >> ___ >> Tinycc-devel mailing list >> Tinycc-devel@nongnu.org >> https://lists.nongnu.org/mailman/listinfo/tinycc-devel >> >> > > > -- > "Debugging is twice as hard as writing the code in the first place. > Therefore, if you write the code as cleverly as possible, you are, > by definition, not smart enough to debug it." -- Brian Kernighan > > ___ > 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] tcc port to cygwin
Gives me the clue that the problem may be in the parsing rather the pp stuff. The output when PARSE_DEBUG is set definitely shows the problem area. Maybe someone more knowledgeable can figure this out. Unfortunately, I've used up my available tcc debug time for the week. I did manage to port COS to build on cygwin and am starting on some of the PDL Next Gen stuff there. The connection with tcc is that I would like to use it to JIT so that the COS/C stuff can be updated at runtime for dynamic operation---such as applying a computational role to a pdl operation. Cheers, Chris On Fri, May 20, 2016 at 11:02 AM, Chris Marshall wrote: > Hi David- > > Ack! I was only looking at the tccpp.c since the problem was with the > includes. > > I think if you select the Devel all you'll get alot of things which should > be enough. > Off the top of my head, the specifics would be gmake/make, gcc, and maybe > git + your choice of editor. > Sorry I can't be more specific but the cygwin setup.exe is not really easy > to determine what is needed. > In the past, when I've had problems, I search for the problem file or > whatever using this page: > > https://cygwin.com/cgi-bin2/package-grep.cgi > > Then you install and iterate until things work. Unfortunately, I would > help you with this but > the cygwin setup program is too smart for me to make it think I'm doing a > clean install. > If you determine the needed packages, that would be great to > know---personally and for > any potential Alien::TCC stuff on cygwin. > > --Chris > > > On Fri, May 20, 2016 at 9:17 AM, David Mertens > wrote: > >> Hello Chris, >> >> According to ack, "skip(')')" shows up all over the place in tccgen.c. >> What does line 196 of your sys/reent.h look like? >> >> Also, if I started from a pristine Windows installation with a core >> Cygwin installation, which Cygwin packages would I need to install to get >> to where you are? >> >> David >> >> On Fri, May 20, 2016 at 8:24 AM, Chris Marshall >> wrote: >> >>> Atttached is a first cut port of the TinyCC build to the cygwin platform. >>> >>> The mains problems seem to be from managing the different include files. >>> I hand added some defines to libtcc1.c for __INTPTR_TYPE__ and a few >>> others to get that to build. >>> >>> However, it is now failing to build bcheck.c with: >>> >>> > ../tcc -B.. -c bcheck.c -o x86_64/bcheck.o -I.. -Wall -g -O0 >>> -Wdeclaration-after-statement -Wno-deprecated-declarations >>> -Wno-strict-aliasing -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result >>> -Wno-uninitialized -fno-strict-aliasing -fPIC -DTCC_TARGET_X86_64 >>> > In file included from bcheck.c:20: >>> > In file included from /usr/include/stdlib.h:18: >>> > /usr/include/sys/reent.h:196: error: ')' expected (got "*") >>> > Makefile:116: recipe for target 'x86_64/bcheck.o' failed >>> > make[1]: *** [x86_64/bcheck.o] Error 1 >>> >>> Looking at the origin of the error message in the skip() routine >>> in tccpp.c, I could not find any place that skip() was called with >>> an argument of ')'. Is there some other place that message >>> could be coming from. Seems like it might be a possible >>> problem in the preprocessing >>> >>> --Chris >>> >>> >>> >>> ___ >>> Tinycc-devel mailing list >>> Tinycc-devel@nongnu.org >>> https://lists.nongnu.org/mailman/listinfo/tinycc-devel >>> >>> >> >> >> -- >> "Debugging is twice as hard as writing the code in the first place. >> Therefore, if you write the code as cleverly as possible, you are, >> by definition, not smart enough to debug it." -- Brian Kernighan >> >> ___ >> 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] tcc compilation on MSYS2
@seyko While I appreciate the confidence in me when you take code/patches which I wrote and commit them to mob yourself (and also the credit which you gave in your commits from today - in the past you did so without giving credit IIRC), I'd also appreciate some heads up and possibly some discussion. For instance, your commit bab4519 which is based on an issue which I detected and fixed (not perfectly, but still) at my drafts branch to allow the tests to run at a custom build dir, you changed the code to use 'realpath', but realpath is not available on all systems. You can use this code instead, which I wrote and I think would be enough for this case, here: https://github.com/avih/tinycc/blob/drafts/win32/build-tcc-reproducible.sh#L11 Also, if you take someone else's commit and push it yourself, you can keep the author the same (assuming you didn't make meaningful changes) using git format-patch and git am (or cherry-pick etc), such that the original author doesn't appear only at the commit message, but actually stays the author of the commit. On Saturday, May 14, 2016 5:33 PM, avih wrote: You can try my branch: https://github.com/avih/tinycc/commits/drafts (note, I force-push and keep it rebased on top of mob). It includes several build consolidation for windows such that it needs less windows-specific checks etc, but also adds some other improvements (like getopt working out of the box, and few more, including make it self-hosting using the latest official tcc-for-windows-release - 0.26). It shouldn't hard to identify the commits which only touch the build system. I haven't touched tcc for some months, and at the time I was able to use my drafts branch to build tcc and cross out of tree with all tests passing and the output executables working as expected, either on windows or linux, either in msys2-32/64 env using the native (gcc) compiler or msys1 env (using tcc0.26-32 for windows as the compiler and tiny_libmaker.exe as AR). I've updated it today (pushed to the drafts branch already) and added one commit which reverts a win32 specific stuff at the tests/Makefile (my earlier consolidations made it unneeded), and it now _seems_ to work again as expected (was able to build using msys2 (gcc) or msys[1] (tcc.exe) and all the tests pass). But I didn't test it extensively. If you wish to test the version which got some more testing by me, you can try the branch "snapshot-drafts-2015-12-17" Hope it helps. PS.I wanted to push some/all of the commits on my "drafts" branch to mob after some cleanups, but never really got to end up doing it. If there's enough interest and my current drafts branc ends up usable for many, I'll reconsider putting the effort. On Saturday, May 14, 2016 4:57 PM, Chris Marshall wrote: As someone whose primary development environment is cygwin/win7, I would love for tcc to build and run under cygwin. --Chris On 5/14/2016 03:24, Sergey Korshunoff wrote: > MSYS2 is current environment for Qt and other software development on > Windows. It is a mingw+cygwin with a package manager (pacman), ported > from ARCH Linux. MSYS2 allow to build > mingw32/mingw64/cygwin32/cygwin64 programs in unix-like environment. > Currenly tcc can not be build on this environment (mix of unix and > windows). I think a system name (uname output) is needed to > select/reject some code in sources of the tcc. > > ___ > 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 ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel