From owner-freebsd-ports@freebsd.org Tue Aug 4 21:40:38 2015 Return-Path: Delivered-To: freebsd-ports@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 728EC9B34C1 for ; Tue, 4 Aug 2015 21:40:38 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from mx2.freebsd.org (mx2.freebsd.org [8.8.178.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mx2.freebsd.org", Issuer "Gandi Standard SSL CA 2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5BE691AE1 for ; Tue, 4 Aug 2015 21:40:38 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from hammer.pct.niksun.com (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx2.freebsd.org (Postfix) with ESMTP id 0392D666AE; Tue, 4 Aug 2015 21:40:37 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Subject: Re: lang/tcc unusable To: Carlos Jacobo Puga Medina , "freebsd-ports@freebsd.org" References: <1438633579.6572.13.camel@fbsd.es> <55BFD033.8070507@FreeBSD.org> <1438634467.7343.2.camel@fbsd.es> <55BFDCA0.8040006@FreeBSD.org> <1438638022.7343.7.camel@fbsd.es> <55BFEAAA.4070008@FreeBSD.org> <1438644237.7343.13.camel@fbsd.es> <55C005D7.3050103@FreeBSD.org> <1438700587.2911.4.camel@fbsd.es> From: Jung-uk Kim Message-ID: <55C13155.3070500@FreeBSD.org> Date: Tue, 4 Aug 2015 17:40:37 -0400 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1438700587.2911.4.camel@fbsd.es> Content-Type: multipart/mixed; boundary="------------090003070306070906010801" X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Aug 2015 21:40:38 -0000 This is a multi-part message in MIME format. --------------090003070306070906010801 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On 08/04/2015 11:03, Carlos Jacobo Puga Medina wrote: > El lun, 03-08-2015 a las 20:22 -0400, Jung-uk Kim escribió: >> On 08/03/2015 19:23, Carlos Jacobo Puga Medina wrote: >>> El lun, 03-08-2015 a las 18:26 -0400, Jung-uk Kim escribió: >>>> On 08/03/2015 17:40, Carlos Jacobo Puga Medina wrote: >>>>> El lun, 03-08-2015 a las 17:26 -0400, Jung-uk Kim >>>>> escribió: >>>>>> On 08/03/2015 16:41, Carlos Jacobo Puga Medina wrote: >>>>>>> El lun, 03-08-2015 a las 16:33 -0400, Jung-uk Kim >>>>>>> escribió: >>>>>>> >>>>>>> Hi Jung-uk, > >>>>>>>> On 08/03/2015 16:26, Carlos Jacobo Puga Medina >>>>>>>> wrote: >>>>>>>>> Hi people, >>>>>>>>> >>>>>>>>> Recently I added amd64 support to TinyCC, but I >>>>>>>>> encounter the following problem trying to compile a >>>>>>>>> simple code. >>>>>>>>> >>>>>>>>> #include >>>>>>>>> >>>>>>>>> int main(){ printf("hello, world!\n); return 0; } >>>>>>>>> >>>>>>>>> % tcc -o hello hello.c In file included from >>>>>>>>> hello.c:1: /usr/include/stdio.h:63: error: ';' >>>>>>>>> expected (got "va_list") >>>>>>>>> >>>>>>>>> I guess that some change introduced in 'stdio.h' >>>>>>>>> causes this weird behaviour. Last time that TCC >>>>>>>>> worked fine was on FreeBSD 9.1 -RELEASE/i386. >>>>>>>>> >>>>>>>>> Also I reported this problem in the tinycc-devel >>>>>>>>> mailing list [1] >>>>>>>>> >>>>>>>>> Any thoughts? >>>>>>>> >>>>>>>> I haven't tried tcc but '"' is missing for the >>>>>>>> printf(). >>>>>>> >>>>>>> Yes, it was a typo here :) >>>>>> >>>>>> It seems it's a known tcc bug: >>>>>> >>>>>> http://savannah.nongnu.org/bugs/?30966 >>>>>> >>>>> >>>>> Is there something that we can do about it? >>>>> >>>>> Thanks for pointing me, jkim@ >>>> >>>> It seems there is no easy way to fix this problem without >>>> touching src tree, e.g., >>>> >>>> --- sys/x86/include/_types.h (revision 286256) +++ >>>> sys/x86/include/_types.h (working copy) @@ -152,7 +152,7 @@ >>>> */ #ifdef __GNUCLIKE_BUILTIN_VARARGS typedef >>>> __builtin_va_lis t __va_list; /* internally known to gcc */ >>>> -#elif defined(lint) +#elif defined(__TINYC__) || >>>> defined(lint) typedef char * __va_list; /* pretend */ #endif >>>> #if defined(__GNUC_VA_LIST_COMPATIBILITY) && >>>> !defined(__GNUC_VA_LIST) \ >>>> >>> >>> If you need doing some changes into the src tree. >> >> https://svnweb.freebsd.org/changeset/base/286265 >> > > That's OK! > >>> So, what do you recommend in such case? Would it be much >>> trouble add the necessary changes to run TCC again? >>> Furthermore, TinyCC developer has ignored this issue >>> completely. >> >> The only hack I see is defining __va_list as a macro from >> libtcc.c but it is ugly. >> > > Probably this should be discussed in the tinycc-devel ML. In the > meanwhile we can try your dirty hack :-) See the attached patch. Yes, it is ugly. ;-) Jung-uk Kim PS: I took the liberty of adding __LP64__ and __amd64__ while I am here. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJVwTFQAAoJEHyflib82/FGHDEH/3CxYb3Y6oNN5kvy9IdmsdoA KePyBqhUrEh/Akgn+J6u5ZKG6j7sstVszZzi4Ri7Xb+rBSztwSPc+ChxeosOwvmn Ushii3EpblG8qvWuDvoLCJP8xmkhQ6NHHM/vcvYzG5w68YxCxc1yu60M5bioiAP/ B1hbWhA+sPmovEKeTXfV2spNRUQyKqy5OxGq1v7OVf7amgfoLMZ0Su04OKAXHX4o GXfUI/jcIBiGCYzFC+7yin/JJblN1gPmgRj3LXAWg++GDvF54hwm3jvSs8qrl8Lr hi7Qbz738wzHhkYoJ1U4jFqvtJNMAK/eSP0Sq52kCrhwDDGMpe/AyNZiQgc5koI= =IcGS -----END PGP SIGNATURE----- --------------090003070306070906010801 Content-Type: text/x-patch; name="tcc.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="tcc.diff" Index: lang/tcc/files/patch-configure =================================================================== --- lang/tcc/files/patch-configure (revision 0) +++ lang/tcc/files/patch-configure (working copy) @@ -0,0 +1,30 @@ +--- configure.orig 2013-02-15 14:24:00 UTC ++++ configure +@@ -45,6 +45,7 @@ tcc_crtprefix="" + tcc_elfinterp="" + tcc_lddir= + confvars= ++define_va_list="" + + cpu=`uname -m` + +@@ -332,6 +333,9 @@ if test -z "$cross_prefix" ; then + + fi + fi ++ if ! $cc -o $CONFTEST -c $source_path/va_list.c 2>/dev/null ; then ++ define_va_list="yes" ++ fi + else + # if cross compiling, cannot launch a program, so make a static guess + case $cpu in +@@ -483,6 +487,9 @@ if test "$have_selinux" = "yes" ; then + echo "#define HAVE_SELINUX" >> $TMPH + echo "HAVE_SELINUX=yes" >> config.mak + fi ++if test "$define_va_list" = "yes" ; then ++ echo "#define DEFINE_VA_LIST" >> $TMPH ++fi + + version=`head $source_path/VERSION` + echo "VERSION=$version" >>config.mak Property changes on: lang/tcc/files/patch-configure ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: lang/tcc/files/patch-libtcc.c =================================================================== --- lang/tcc/files/patch-libtcc.c (revision 0) +++ lang/tcc/files/patch-libtcc.c (working copy) @@ -0,0 +1,28 @@ +--- libtcc.c.orig 2013-02-15 14:24:00 UTC ++++ libtcc.c +@@ -931,7 +931,11 @@ LIBTCCAPI TCCState *tcc_new(void) + tcc_define_symbol(s, "__i386", NULL); + tcc_define_symbol(s, "i386", NULL); + #elif defined(TCC_TARGET_X86_64) ++# if defined(__FreeBSD__) ++ tcc_define_symbol(s, "__amd64__", NULL); ++# endif + tcc_define_symbol(s, "__x86_64__", NULL); ++ tcc_define_symbol(s, "__LP64__", NULL); + #elif defined(TCC_TARGET_ARM) + tcc_define_symbol(s, "__ARM_ARCH_4__", NULL); + tcc_define_symbol(s, "__arm_elf__", NULL); +@@ -957,6 +961,13 @@ LIBTCCAPI TCCState *tcc_new(void) + tcc_define_symbol(s, "__linux", NULL); + # endif + # if defined(__FreeBSD__) ++# if defined(DEFINE_VA_LIST) ++# if defined(TCC_TARGET_X86_64) ++ tcc_define_symbol(s, "__va_list", "struct { long pad[3]; }"); ++# else ++ tcc_define_symbol(s, "__va_list", "char *"); ++# endif ++# endif + # define str(s) #s + tcc_define_symbol(s, "__FreeBSD__", str( __FreeBSD__)); + # undef str Property changes on: lang/tcc/files/patch-libtcc.c ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: lang/tcc/files/patch-va__list.c =================================================================== --- lang/tcc/files/patch-va__list.c (revision 0) +++ lang/tcc/files/patch-va__list.c (working copy) @@ -0,0 +1,9 @@ +--- va_list.c.orig 2015-08-04 21:20:18 UTC ++++ va_list.c +@@ -0,0 +1,6 @@ ++#ifdef __FreeBSD__ ++#undef __GNUC__ ++#undef __GNUC_MINOR__ ++#include ++void foo(__va_list); ++#endif Property changes on: lang/tcc/files/patch-va__list.c ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property --------------090003070306070906010801--