tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] float value triggers error


From: Steven G. Messervey
Subject: Re: [Tinycc-devel] float value triggers error
Date: Sun, 3 Nov 2013 12:09:32 -0800 (PST)




----- Original Message -----
From: Thomas Preud'homme <address@hidden>
To: address@hidden; Stevie G. Messervey <address@hidden>
Cc: 
Sent: Sunday, November 3, 2013 10:45 AM
Subject: Re: [Tinycc-devel] float value triggers error

>Le lundi 21 octobre 2013 07:26:07 Stevie G. Messervey a �rit :
>> Hello,
>> 
>> Here is a small example program that reproduces the error:
>> 
>> #!/usr/local/bin/tcc -run
>> #include <stdlib.h>
>> #include <stdio.h>
>> 
>> int main(int argc, char **argv) {
>>   int y = (int)(25.0 * (rand() / RAND_MAX));
>>   printf("%d\n",y);
>>   exit(EXIT_SUCCESS);
>> }
>> 
>> when attempting to execute it (or even compile it, without the #!), I get
>> these errors: tcc: error: undefined symbol '__tcc_int_fpu_control'
>> tcc: error: undefined symbol '__tcc_fpu_control'
>> 
>> I see this behavior on CentOS 5.9 and Debian 6.0.7
>> CentOS gcc: 4.4.7 20120313 (Red Hat 4.4.7-1)
>> Debian gcc: 4.4.5 (Debian 4.4.5-8)
>> Both are 32-bit
>> tcc version 0.9.25 & 0.9.26, configured only as '--with-libgcc'
>> 
>> Can anyone shed some light?

>Sorry, I couldn't reproduce this error on Debian sid. Could you try with the 
>mob branch?

>Alternatively, you could try using the same configure invocation as in the 
>Debian package? That is, ensure you have:

>Binary  directory   /usr/bin
>TinyCC directory    /usr/lib/x86_64-linux-gnu/../tcc
>Library directory   /usr/lib/x86_64-linux-gnu
>Include directory   /usr/include
>Manual directory    /usr/share/man
>Info directory      /usr/share/info
>Doc directory       /usr/share/doc/../tcc

>after running the configure script.


>> 
>> Thank you,
>>   Steve

>Best regards,

>Thomas

Okay, the results are in:
mob branch was checked out today, 03-11-13

mob-branch, configured with "--with-libgcc" only, debian squeeze 32-bit:
tcc: error: undefined symbol '__tcc_fpinit'
tcc: error: undefined symbol '__tcc_cvt_ftol'

mob-branch, "--with-libgcc", debian squeeze 64-bit:
compiles fine, outputs 0 (program itself is flawed)
interprets fine, outputs 0

0.9.26, "--prefix=/usr" only, debian squeeze 32-bit
compiles fine, outputs 0
interprets fine

Conclusions:
* The problem lies in --with-libcc on 32-bit archs.
* The test program is flawed, will always output 0.
To fix it:
  - to generate an int above zero, the intermediates must be cast to doubles 
(or floats)
    i.e. y = (int)(25.0 * ((double)rand() / (double)RAND_MAX))
  - seed the random generator

It seems like on 32-bit architectures, something is being omitted from tcc
when compiled --with-libgcc, something related to fpu intialization.

Thank you,
  Steve




reply via email to

[Prev in Thread] Current Thread [Next in Thread]