Re: [Tinycc-devel] "error: undefined symbol main" with -pthread on linux

2017-12-23 Thread avih
Confirmed fixed. Thanks.

So quick, it must be Christmas! I wish I had more bugs to report ;)  

On Saturday, December 23, 2017 3:52 PM, Michael Matz  
wrote:
 

 Hi,

On Sat, 23 Dec 2017, avih wrote:

> I think maybe, instead of saying and doing:
> -pthread   same as -D_REENTRANT and -lpthread
> 
> It should say and do something along these lines:
> -pthread   same as -D_REENTRANT while compiling and -lpthread while linking

I decided to keep the help message as is (staying in <= 80 columns), but 
...

> However, It seems to still not behave the same as gcc. Using the same 
> test.c file as before:
> 
> tcc -pthread -c test.c # -> tcc: error: cannot specify libraries with -c
> 
> It's not unreasonable I think that tcc complains, but gcc is fine with it.

... I've fixed this behaviour.  I agree that -pthread shouldn't add the 
library with -c (or, well, at least not complain then :) ).


Ciao,
Michael.

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


Re: [Tinycc-devel] "error: undefined symbol main" with -pthread on linux

2017-12-23 Thread Michael Matz

Hi,

On Sat, 23 Dec 2017, avih wrote:


I think maybe, instead of saying and doing:
-pthread   same as -D_REENTRANT and -lpthread

It should say and do something along these lines:
-pthread   same as -D_REENTRANT while compiling and -lpthread while linking


I decided to keep the help message as is (staying in <= 80 columns), but 
...


However, It seems to still not behave the same as gcc. Using the same 
test.c file as before:


tcc -pthread -c test.c # -> tcc: error: cannot specify libraries with -c

It's not unreasonable I think that tcc complains, but gcc is fine with it.


... I've fixed this behaviour.  I agree that -pthread shouldn't add the 
library with -c (or, well, at least not complain then :) ).



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


Re: [Tinycc-devel] C99 static array indices in function args

2017-12-23 Thread Michael Matz

Hi,

On Wed, 20 Dec 2017, Michael B. Smith wrote:


It's in 6.7.5.3/7 in C99 for 'static'.

It's in 6.7.3/5 in C99 for 'const'.

Using 'static' seems to have two implied contracts:

[1] don't allow NULL parameters
[2] verify, when possible, that the passed array has AT LEAST the number 
of elements defined


Using 'const' has an implied contract:

[3] treat the array as if were a const array (e.g., "char a[const] --> 
char * const a")


Recent versions of gcc and clang do 1 and 2 (as warnings). I can't find 
anything definitive about 3.


6.7.5.3 #7 is pretty clear, the type qualifiers applied are those from 
within the [ ].  TCC doesn't support this syntax properly right now.



'restrict' is allowed by tcc, but ignored. I think that that is a bug.


Why would you think so?  restrict is a type qualifier that is allowed to 
be applied only to pointer types, parmdecls of array type transform into 
pointer types hence "int a[restrict 3]" in a parmdecl is well defined and 
meaningful.


'restrict' has several defined (not just implied) contracts. This should 
require at least a warning.


No.  Warnings are never required diagnostics (and even if, what 
specifically would you want to warn about in this case?).  The only 
require diagnostics are from constraint violations.  Most other undefined 
behaviours don't need to be diagnosed (of course, if easily doable it's 
nice to diagnose them).



Supporting 'const' properly is actually pretty easy.

Supporting 'static' - well, [1] requires that tcc generate code (to 
handle both runtime and compile-time cases), and [2] may (or may not) be 
easy to do depending on the parameter. If we assume locally defined 
arrays, like VLAs, then it is easy.


There are no changes to emitted code necessary.  The [static 3] syntax is 
an assertion of the programmer, the compiler doesn't have to check it.  On 
the contrary, the compiler is allowed (but not required) to make use of 
this assertion, and assume there are at least 3 elements.  If the 
programmer then gives fewer its his problem, it's undefined behaviour, no 
diagnostic required.  (Of course TCC, not being an optimizing compiler 
wouldn't have much opportunity to make use of these kinds of assertion, 
the same that it doesn't make use of restrict qualitications).



Ciao,
Michael.

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


Re: [Tinycc-devel] TCC version 0.9.27 is out

2017-12-23 Thread Michael Matz

Hi,

On Mon, 18 Dec 2017, Michael B. Smith wrote:

[1] Other than _Complex/_Imaginary (which C11 now identifies as 
"optional") does anyone have a clear view of what is missing to be c99 
compliant? (I've read the standard and I can build a basic test suite, 
but I just wondered if someone already had the answer.)


c99 support should be relatively complete (as far as the compiler is 
concerned, for full c99 compat you need of course a conforming C library 
as well, if you don't merely want freestanding).  Of course bugs happen, 
so if you find anything, don't hesitate to report here.  Depending on 
circumstance we might want to fix them.


[2] Can 0.9.27 compile a current Linux kernel? Can it generate a 
bootable Linux kernel?


Yes, with some smallish changes to the kernel.  Note that the kernel has a 
much larger set of requirements than c99: it needs some optimizations to 
happen (generally dead code), it needs inline asm support, and it needs 
certain attributes to be implemented and data layout rule to be followed. 
But yes, one of my testbeds is a x86-64 4.6.0 linux kernel with an about 
1000 lines patch on top.  (And another is a ancient 32bit 2.4.37 kernel 
with custom build scripts).



[3] TODO seems ancient. What is the real TODO?


There's none.  Or, if you insist, then something along the lines of "fix 
reporte bugs, keep stuff small, hack on it to have fun" :)



Ciao,
Michael.

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


Re: [Tinycc-devel] "error: undefined symbol main" with -pthread on linux

2017-12-23 Thread Michael Matz

Hi,

On Sat, 23 Dec 2017, avih wrote:


Try the same with -pthread:
tcc -pthread ./test.o -otest  # -> tcc: error: undefined symbol 'main'


Thanks for the report.  Fix in mob.


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