Re: [Tinycc-devel] Bug: malloc + function returning double + comparison between doubles

2012-06-10 Thread Michael Matz

Hi,

On Sat, 9 Jun 2012, g...@sdf.org wrote:


   d = malloc (s);


If this returns a pointer with upper 32 bits set (which depends on malloc 
size, fragmentation and moon phase) ...



   d[0] = 10.0;
   i = d[0]  f ();


... those are lost in the caller-save/restore code for the address of d[0] 
generated because of the call to f.  This is because the reload was done 
in VT_INT mode, not VT_PTR as it should have been.


I fixed it on the mob branch with a hopefully more reliable testcase using 
alloca (which on x86-64 will always return a pointer with high 32 bit set 
because the stack will be set up that way).


Thomas: as you were last fiddling with arm, you might want to check if the 
test works on it.  The other alloca testcase is #ifdef'ed on i386 and 
x86_64, but that only makes sense if alloca really isn't supported on arm, 
which I can't believe.  If that really is the case callsave_test() needs 
to be conditional too.



Ciao,
Michael.

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


Re: [Tinycc-devel] Bug: malloc + function returning double + comparison between doubles

2012-06-10 Thread Daniel Glöckner
On Sun, Jun 10, 2012 at 09:15:52AM +0200, Michael Matz wrote:
 Thomas: as you were last fiddling with arm, you might want to check
 if the test works on it.  The other alloca testcase is #ifdef'ed on
 i386 and x86_64, but that only makes sense if alloca really isn't
 supported on arm, which I can't believe.  If that really is the case
 callsave_test() needs to be conditional too.

Some time ago I posted an alloca version for ARM:
http://lists.nongnu.org/archive/html/tinycc-devel/2011-02/msg00046.html
but we don't build a libtcc1 for ARM and libgcc/libc don't provide
alloca as it is a GCC builtin.

  Daniel

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


Re: [Tinycc-devel] Bug: malloc + function returning double + comparison between doubles

2012-06-10 Thread Michael Matz

Hi,

On Sun, 10 Jun 2012, Daniel Glöckner wrote:


On Sun, Jun 10, 2012 at 09:15:52AM +0200, Michael Matz wrote:

Thomas: as you were last fiddling with arm, you might want to check
if the test works on it.  The other alloca testcase is #ifdef'ed on
i386 and x86_64, but that only makes sense if alloca really isn't
supported on arm, which I can't believe.  If that really is the case
callsave_test() needs to be conditional too.


Some time ago I posted an alloca version for ARM:
http://lists.nongnu.org/archive/html/tinycc-devel/2011-02/msg00046.html


Ah, I see.  Well, alloca is highly desirable to have IMHO, so ...


but we don't build a libtcc1 for ARM


... I think we should do so then.  As it seems the various arithmetic 
routines of libtcc1.c aren't needed on arm it would only contain alloca. 
I'd vote for the assembler implementation (don't know if it would have to 
differ between the eabi and oldabi variants).



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


Re: [Tinycc-devel] Bug: malloc + function returning double + comparison between doubles

2012-06-10 Thread Thomas Preud'homme
Le dimanche 10 juin 2012 20:01:11, Michael Matz a écrit :
 Hi,
 
 On Sun, 10 Jun 2012, Daniel Glöckner wrote:
  On Sun, Jun 10, 2012 at 09:15:52AM +0200, Michael Matz wrote:
  Thomas: as you were last fiddling with arm, you might want to check
  if the test works on it.  The other alloca testcase is #ifdef'ed on
  i386 and x86_64, but that only makes sense if alloca really isn't
  supported on arm, which I can't believe.  If that really is the case
  callsave_test() needs to be conditional too.
  
  Some time ago I posted an alloca version for ARM:
  http://lists.nongnu.org/archive/html/tinycc-devel/2011-02/msg00046.html
 
 Ah, I see.  Well, alloca is highly desirable to have IMHO, so ...
 
  but we don't build a libtcc1 for ARM
 
 ... I think we should do so then.  As it seems the various arithmetic
 routines of libtcc1.c aren't needed on arm it would only contain alloca.
 I'd vote for the assembler implementation (don't know if it would have to
 differ between the eabi and oldabi variants).

It doesn't use VFP so it will work for both ABI. It also work for the new 
eabihf which I introduced as there is no float parameter.

 
 
 Ciao,
 Michael.

Best regards,

Thomas Preud'homme


signature.asc
Description: This is a digitally signed message part.
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] Bug: malloc + function returning double + comparison between doubles

2012-06-10 Thread Daniel Glöckner
On Sun, Jun 10, 2012 at 08:03:24PM +0200, Thomas Preud'homme wrote:
 Le dimanche 10 juin 2012 20:01:11, Michael Matz a écrit :
   but we don't build a libtcc1 for ARM
  
  ... I think we should do so then.  As it seems the various arithmetic
  routines of libtcc1.c aren't needed on arm it would only contain alloca.
  I'd vote for the assembler implementation (don't know if it would have to
  differ between the eabi and oldabi variants).
 
 It doesn't use VFP so it will work for both ABI. It also work for the new 
 eabihf which I introduced as there is no float parameter.

Compiler generated calls have been chosen to allow the use of
libgcc_s.so.1 on ARM EABI and OABI. It is needed for divisions,
64-bit shifts, and some floating point conversion. One day we
might also support devices without floating point hardware/emulator,
where we could use the EABI soft float functions already contained
in libgcc. I also added a configure option --with-libgcc to make
TinyCC automatically link to libgcc_s.so.1 instead of libtcc1.a.

If we now start to supply a libtcc1.a that does not include the
functions from libgcc_s.so.1, we need to link to two libraries.

  Daniel

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


Re: [Tinycc-devel] Bug: malloc + function returning double + comparison between doubles

2012-06-10 Thread Michael Matz

Hi,

On Sun, 10 Jun 2012, Daniel Glöckner wrote:

Compiler generated calls have been chosen to allow the use of 
libgcc_s.so.1 on ARM EABI and OABI. It is needed for divisions, 64-bit 
shifts, and some floating point conversion. One day we might also 
support devices without floating point hardware/emulator, where we could 
use the EABI soft float functions already contained in libgcc. I also 
added a configure option --with-libgcc to make TinyCC automatically link 
to libgcc_s.so.1 instead of libtcc1.a.


If we now start to supply a libtcc1.a that does not include the 
functions from libgcc_s.so.1, we need to link to two libraries.


But that's no problem, is it?  Alternatively alloca could be expanded 
inline at a (small) code size cost, but I think a libtcc1.a makes sense 
even when using libgcc_s (the former being the tinycc internals libs, the 
latter being a conveniently supported 3rd party lib).



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


Re: [Tinycc-devel] TinyCC on older (x68) Mac does not compile

2012-06-10 Thread Milutin Jovanović
OK, I just commited a small change in which I disabled some stack
optimizations when calling gcc. This solved it on my machine. Can you try
it on your machine.

Miki.


On 10 June 2012 20:22, Milutin Jovanović jovanovic.milu...@gmail.comwrote:


 Hi,

 As far as I can see, the problem is not OS X related, but rather it is
 related to using gcc-4.2, or another version of the gcc compiler. If you
 use latest llvm version, it should work. If I use gcc-4.2 I get the same
 problem as you. It might help if you can send your printout of commands:

 $ gcc --version
 i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build
 5658) (LLVM build 2336.1.00)
 Copyright (C) 2007 Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 In any case I will see if I can figure out what is going on.

 Miki.



 On 10 June 2012 00:51, Pedro A ARANDA paag...@hotmail.com wrote:

  Hi,

 I'm trying to compile tinycc on an older Intel Mac. It is detected as x86
 by configure. During the build,
 when tcc is used to create libtcc.a, it crashes with a segmentation fault:

 gcc -o tcc tcc.o libtcc.a -lm -ldl -Wall -g -O2 -fno-strict-aliasing
 -Wno-pointer-sign -Wno-sign-compare -D_FORTIFY_SOURCE=0
 -mpreferred-stack-boundary=2 -march=i386 -falign-functions=0 -m32
 gcc -o tiny_libmaker win32/tools/tiny_libmaker.c -Wall -g -O2
 -fno-strict-aliasing -Wno-pointer-sign -Wno-sign-compare
 -D_FORTIFY_SOURCE=0 -mpreferred-stack-boundary=2 -march=i386
 -falign-functions=0 -m32
 mkdir -p i386
 ../tcc -B.. -m32 -D_ANSI_SOURCE -c libtcc1.c -o i386/libtcc1.o
 -DTCC_TARGET_I386
 make[1]: *** [i386/libtcc1.o] Segmentation fault
 make: *** [libtcc1.a] Error 2

 The uname -a command yields

 Darwin Pedro-A-Arandas-mac.local 10.5.0 Darwin Kernel Version 10.5.0: Fri
 Nov  5 23:20:39 PDT 2010; root:xnu-1504.9.17~1/RELEASE_I386 i386

 Cheers,/PA



 ___
 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] x86 optimization flags

2012-06-10 Thread Milutin Jovanović
Hi all,

I am not sure if you noticed an email today about a seg fault on osx. I
have traced the problem to some optimization flags. The makefile section is:

ifeq ($(ARCH),i386)
CFLAGS+=-mpreferred-stack-boundary=2
ifeq ($(GCC_MAJOR),2)
CFLAGS+=-m386 -malign-functions=0
else
CFLAGS+=-march=i386 -falign-functions=0
endif
endif

For some reason when using -mpreferred-stack-boundary=2 causes this problem.

Any way, my questions really is this, do we need this whole section at all?
The stack-boundary is already not optimized on 64 bit builds. Is tcc being
used in environments where this will make a difference? I think this
actually slows down the code, but...

Aligning functions? Pretty much the same question. This cannot save more
then a few bytes.

-march=i386, -m386? I think that -m32, which is applied later in the
makefile, already does when we really need. Are we trying to produce tcc
that can run on really old machines?

For now I have disabled this block for osx builds. Can we remove
completely? Your thoughts?

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