Re: [Tinycc-devel] va_* broken on x86-64: any volonteer? (fwd)
Hi, [resent because my work email is not subscribed here :-/] On Thu, 9 Jan 2014, Thomas Preud'homme wrote: That's because GCC doesn't have any problem. The problem is in TinyCC. I was compiling mksh with TinyCC (I called it tcc in my initial mail) and it gave me linker error about undefined __va_arg if I remember correctly. Are you sure it's not a bug in mksh, and in which version anyway? The stdarg testcases from the testsuite all work just fine. I can also build mksh-R48b with tcc just fine: % uname -a % cd /matz/git/tinycc; git log --online HEAD^.. 767410b Various Makefile fixes for cross-compilation % ./configure; make; make test ... all works ... % cd /tmp/ % tar xvf mksh-R48b.tgz % mkdir mksh/build; cd mksh/build % CC=/matz/git/tinycc/tcc -B/matz/git/tinycc/ /bin/sh ../Build.sh ... Run the regression test suite: ./test.sh Please also read the sample file dot.mkshrc and the fine manual. % ./mksh ./test.sh ... Total failed: 0 Total passed: 466 So, if you want anything fixed we'd first need to know what is broken, e.g. a testcase ;) Ciao, Michael. ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Re: [Tinycc-devel] va_* broken on x86-64: any volonteer?
Le jeudi 9 janvier 2014, 14:14:52 Michael Matz a écrit : Hi, On Thu, 9 Jan 2014, Thomas Preud'homme wrote: That's because GCC doesn't have any problem. The problem is in TinyCC. I was compiling mksh with TinyCC (I called it tcc in my initial mail) and it gave me linker error about undefined __va_arg if I remember correctly. Are you sure it's not a bug in mksh, and in which version anyway? The stdarg testcases from the testsuite all work just fine. I can also build mksh-R48b with tcc just fine: % uname -a % cd /matz/git/tinycc; git log --online HEAD^.. 767410b Various Makefile fixes for cross-compilation % ./configure; make; make test ... all works ... % cd /tmp/ % tar xvf mksh-R48b.tgz % mkdir mksh/build; cd mksh/build % CC=/matz/git/tinycc/tcc -B/matz/git/tinycc/ /bin/sh ../Build.sh ... Oh I see. I compiled with --with-libgcc and gcc doesn't provide __va_* like libtcc1 does. So I guess either libgcc should not be proposed for x86-64 systems or libtcc1 should always be linked in as well as to fill in the blank. Or maybe now that arm can uses libtcc1 this option could be just removed. If there is some value in keeping it, it could also be nice that tcc can work directly with libgcc (and thus have va_* macros builtin, see stdarg.h from gcc and gcc's source code). Dear users, does any of you see value in the --with-libgcc switch of configure? Best regards, Thomas ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Re: [Tinycc-devel] va_* broken on x86-64: any volonteer?
Hi, [bah, resent again because of suse.de not being the subscribed address here :-/ ] On Thu, 9 Jan 2014, Thomas Preud'homme wrote: Oh I see. I compiled with --with-libgcc and gcc doesn't provide __va_* like libtcc1 does. So I guess either libgcc should not be proposed for x86-64 systems or libtcc1 should always be linked in as well as to fill in the blank. Yeah. tcc meanwhile also emits references to other symbols that aren't in libgcc. E.g. __floatundixf. Or maybe now that arm can uses libtcc1 this option could be just removed. If there is some value in keeping it, it could also be nice that tcc can work directly with libgcc (and thus have va_* macros builtin, see stdarg.h from gcc and gcc's source code). You can't without providing the implementation currently residing in libtcc directly as inline variant in the code generator (as libgcc doesn't contain any implementation of that stuff). As the x86_64 variant of stdargs is a bit convoluted (as in, more that three/four instructions) that doesn't seem like the best solution. So, ... Dear users, does any of you see value in the --with-libgcc switch of configure? ... if the possibility of using libgcc should be retained, then yes, libtcc needs to be linked in additionally. Which seems to make sense as that lib indeed is supposed to provide the runtime parts that the compiler (here tcc) specifically wants to rely on. Ciao, Michael. ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Re: [Tinycc-devel] va_* broken on x86-64: any volonteer?
On Fri, Jan 10, 2014 at 1:13 AM, Michael Matz matz@frakked.de wrote: Hi, [bah, resent again because of suse.de not being the subscribed address here :-/ ] On Thu, 9 Jan 2014, Thomas Preud'homme wrote: Oh I see. I compiled with --with-libgcc and gcc doesn't provide __va_* like libtcc1 does. So I guess either libgcc should not be proposed for x86-64 systems or libtcc1 should always be linked in as well as to fill in the blank. Yeah. tcc meanwhile also emits references to other symbols that aren't in libgcc. E.g. __floatundixf. Or maybe now that arm can uses libtcc1 this option could be just removed. If there is some value in keeping it, it could also be nice that tcc can work directly with libgcc (and thus have va_* macros builtin, see stdarg.h from gcc and gcc's source code). You can't without providing the implementation currently residing in libtcc directly as inline variant in the code generator (as libgcc doesn't contain any implementation of that stuff). As the x86_64 variant of stdargs is a bit convoluted (as in, more that three/four instructions) that doesn't seem like the best solution. So, ... Yeah, I have looked at how GCC handles stdarg for x86-64, but I chose the current way because I didn't want to make TCC unnecessary bigger. Hard-coding va_* would be appropriate for GCC, but might be inappropriate for TinyCC :) BTW, I have just noticed http://repo.or.cz/w/tinycc.git/commitdiff/55ea6d3fc175b0e01e2e946ca9b319c1fbe8aa67?hp=3f1d971eeebe315795079c3adbe4022d6d19. I knew my first implementation did not follow the x86-64 ABI but I was too lazy to implement it correctly. It should have been working for basic types and printf was OK, and everything should have been working if you build everything with TCC, so I stopped fixing this. A big kudos to James! Dear users, does any of you see value in the --with-libgcc switch of configure? ... if the possibility of using libgcc should be retained, then yes, libtcc needs to be linked in additionally. Which seems to make sense as that lib indeed is supposed to provide the runtime parts that the compiler (here tcc) specifically wants to rely on. Ciao, Michael. ___ 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] va_* broken on x86-64: any volonteer?
Le jeudi 9 janvier 2014, 17:13:41 Michael Matz a écrit : Yeah. tcc meanwhile also emits references to other symbols that aren't in libgcc. E.g. __floatundixf. Indeed. Or maybe now that arm can uses libtcc1 this option could be just removed. If there is some value in keeping it, it could also be nice that tcc can work directly with libgcc (and thus have va_* macros builtin, see stdarg.h from gcc and gcc's source code). You can't without providing the implementation currently residing in libtcc directly as inline variant in the code generator (as libgcc doesn't contain any implementation of that stuff). As the x86_64 variant of stdargs is a bit convoluted (as in, more that three/four instructions) that doesn't seem like the best solution. So, ... That's what gcc does but indeed, tcc tries to be smaller and faster than gcc so indeed. Dear users, does any of you see value in the --with-libgcc switch of configure? ... if the possibility of using libgcc should be retained, then yes, libtcc needs to be linked in additionally. Which seems to make sense as that lib indeed is supposed to provide the runtime parts that the compiler (here tcc) specifically wants to rely on. Right, I'm tempted to remove the libgcc switch but I need to look again at the commit that introduced it for the reasons. Best regards, Thomas ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Re: [Tinycc-devel] va_* broken on x86-64: any volonteer?
Hi, I'm happy to look into this, but I cannot reproduce the issue so far. I have built GCC git head and did $ make CC=/usr/local/stow/gcc-git/bin/gcc clean $ make CC=/usr/local/stow/gcc-git/bin/gcc $ make CC=/usr/local/stow/gcc-git/bin/gcc test and it finished successfully. Could you tell me your OS, the version of GCC, the version of binutils, and the actual error message? Thanks! On Wed, Jan 8, 2014 at 4:22 PM, Thomas Preud'homme robo...@celest.frwrote: Greetings, During a recent test on x86-64 machine I noticed that support for variadic function is broken on x86-64 port of tcc. Basically, __va_* no longer exists and so the linker complains. Looking at gcc, va_* macros are replaced by internal symbols __builtin_va_* which gcc process to find the position of argument on stack according to x86-64 calling convention. I quickly glanced at gcc's source and what I could see is that the calling convention is more complicated than on i386 (i386 uses the generic implementation while x86-64 has a dedicated function). Since you worked in the past on x86-64_gen.c I guess you must be more familiar than me with this calling convention. Would any of you feel like taking a stab at it? Best regards, Thomas ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Re: [Tinycc-devel] va_* broken on x86-64: any volonteer?
Le jeudi 9 janvier 2014, 00:20:12 shinichiro hamaji a écrit : Hi, I'm happy to look into this, but I cannot reproduce the issue so far. I have built GCC git head and did $ make CC=/usr/local/stow/gcc-git/bin/gcc clean $ make CC=/usr/local/stow/gcc-git/bin/gcc $ make CC=/usr/local/stow/gcc-git/bin/gcc test and it finished successfully. Could you tell me your OS, the version of GCC, the version of binutils, and the actual error message? That's because GCC doesn't have any problem. The problem is in TinyCC. I was compiling mksh with TinyCC (I called it tcc in my initial mail) and it gave me linker error about undefined __va_arg if I remember correctly. I thought you could help fixing it as you contributed the initial code for x86-64 target on TinyCC. Thanks! Thanks for your reply. Best regards, Thomas ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
[Tinycc-devel] va_* broken on x86-64: any volonteer?
Greetings, During a recent test on x86-64 machine I noticed that support for variadic function is broken on x86-64 port of tcc. Basically, __va_* no longer exists and so the linker complains. Looking at gcc, va_* macros are replaced by internal symbols __builtin_va_* which gcc process to find the position of argument on stack according to x86-64 calling convention. I quickly glanced at gcc's source and what I could see is that the calling convention is more complicated than on i386 (i386 uses the generic implementation while x86-64 has a dedicated function). Since you worked in the past on x86-64_gen.c I guess you must be more familiar than me with this calling convention. Would any of you feel like taking a stab at it? Best regards, Thomas ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel