Discussion:
[Tinycc-devel] Set the stack size of an executable
Thomas Mertes
2011-07-11 07:06:36 UTC
Permalink
Hello.

Is there a tcc option to set the stack size of an executable?

I compiled my project (http://seed7.sourceforge.net) with
tcc version 0.9.25 under Windows and Linux. Most things
work, but some programs crash, because the stack is too
small (I am quite sure it is a stack size problem. You can
save the time to tell me about endless recursions, etc. ).
Compilers/linkers usually have a possibility to set the stack
size. For Windows + MinGW gcc I use the option:

-Wl,--stack,4194304

Other compilers have similar options. A solution which
uses gcc as linker would not be helpful, since I want to
provide a makefile for people who just have tcc installed.


Greetings Thomas Mertes
--
Seed7 Homepage: http://seed7.sourceforge.net
Seed7 - The extensible programming language: User defined statements
and operators, abstract data types, templates without special
syntax, OO with interfaces and multiple dispatch, statically typed,
interpreted or compiled, portable, runs under linux/unix/windows.
--
NEU: FreePhone - kostenlos mobil telefonieren!
Jetzt informieren: http://www.gmx.net/de/go/freephone
grischka
2011-07-11 16:54:49 UTC
Permalink
Post by Thomas Mertes
Hello.
Is there a tcc option to set the stack size of an executable?
Now yes: http://repo.or.cz/w/tinycc.git/commitdiff/45184e01

Under linux I think you'd need to use setrlimit().

Btw, your Seed7 compiler, does it work with tcc as backend?
(Just curious)

--- grischka
Post by Thomas Mertes
I compiled my project (http://seed7.sourceforge.net) with
tcc version 0.9.25 under Windows and Linux. Most things
work, but some programs crash, because the stack is too
small (I am quite sure it is a stack size problem. You can
save the time to tell me about endless recursions, etc. ).
Compilers/linkers usually have a possibility to set the stack
-Wl,--stack,4194304
Other compilers have similar options. A solution which
uses gcc as linker would not be helpful, since I want to
provide a makefile for people who just have tcc installed.
Greetings Thomas Mertes
Thomas Mertes
2011-07-13 12:08:02 UTC
Permalink
Post by grischka
Post by Thomas Mertes
Hello.
Is there a tcc option to set the stack size of an executable?
Now yes: http://repo.or.cz/w/tinycc.git/commitdiff/45184e01
Great.
When will a precompiled Windows tcc with this feature be available?
BTW: Is it intended to differ slightly from the option MinGW uses
for this purpose?
Post by grischka
Under linux I think you'd need to use setrlimit().
Under Linux the default stack size was always sufficient.
When I compile and link under Linux I get errors like:
tcc: undefined symbol 'memmove'
As "quick" fix I wrote the functions strlen, strchr, strcmp,
strncmp, strstr, memcmp, memcpy, memmove and memset. Hopefully this
error is already fixed. Which version contains the fix? I use the
tcc package from Ubuntu, so it will probably take some time until
the package is updated.
Post by grischka
Btw, your Seed7 compiler, does it work with tcc as backend?
(Just curious)
Under Linux: Yes
The Seed7 test suite succeeds with tcc (and my string functions).

Under Windows I could not find prototypes, of fseek and ftell with
64 bit offset, in the header files. Competing compilers do not agree
in names for this functions and the 64 bit offset type:
MinGW uses: fseeko64, ftello64 and off64_t
MSVC and Borland use: _fseeki64, _ftelli64 and __int64

Under Linux + GCC the preprocessor macro
_FILE_OFFSET_BITS 64
needs to be defined before any system include.
Then fseeko, ftello and off_t work with 64 bit offsets.

Any of the three solutions would help me.

BTW: The Windows port of Seed7 with tcc made it necessary to write
my own (clean room) implementation of CommandLineToArgvW (the
original is part of IIRC shell32.dll and seems to be available for
other windows compilers, but not for tcc).

Things like 64 bit file offset and Unicode support are very
important for Seed7. Seed7 programmers should not be bothered with
such low level details.


Greetings Thomas Mertes
--
Seed7 Homepage: http://seed7.sourceforge.net
Seed7 - The extensible programming language: User defined statements
and operators, abstract data types, templates without special
syntax, OO with interfaces and multiple dispatch, statically typed,
interpreted or compiled, portable, runs under linux/unix/windows.
--
NEU: FreePhone - kostenlos mobil telefonieren!
Jetzt informieren: http://www.gmx.net/de/go/freephone
Thomas Preud'homme
2011-07-13 12:41:28 UTC
Permalink
Le mercredi 13 juillet 2011 14:08:02, Thomas Mertes a écrit :
[SNIP]
Post by Thomas Mertes
Post by grischka
Under linux I think you'd need to use setrlimit().
Under Linux the default stack size was always sufficient.
tcc: undefined symbol 'memmove'
As "quick" fix I wrote the functions strlen, strchr, strcmp,
strncmp, strstr, memcmp, memcpy, memmove and memset. Hopefully this
error is already fixed. Which version contains the fix? I use the
tcc package from Ubuntu, so it will probably take some time until
the package is updated.
This has been fixed in the development branch (also known as the mob branch).
As for Ubuntu, [0] indicates that tcc 0.9.25-6 is shipped. This version should
contain the fix, as the fix was included from 0.9.25-4.

[0] https://launchpad.net/ubuntu/+source/tcc

Which version of the package do you use (what gives you dpkg -l tcc)?
[SNIP]
Post by Thomas Mertes
Greetings Thomas Mertes
Thanks for your interest in tinycc.

Best regards,

Thomas Preud'homme
grischka
2011-07-13 23:21:25 UTC
Permalink
Post by Thomas Mertes
Great.
When will a precompiled Windows tcc with this feature be available?
Next release, planned in 1..2 months.
Post by Thomas Mertes
BTW: Is it intended to differ slightly from the option MinGW uses
for this purpose?
What? No. I was testing
-Wl,--stack=nnn
and
-Wl,--stack,nnn
with both tcc and gcc.
Post by Thomas Mertes
Under Windows I could not find prototypes, of fseek and ftell with
64 bit offset, in the header files. Competing compilers do not agree
MinGW uses: fseeko64, ftello64 and off64_t
MSVC and Borland use: _fseeki64, _ftelli64 and __int64
We have newer stdio.h from mingw with lots of such variants, but
anyway TCC relies on what is in msvcrt.dll.

msvcrt.dll (Vista/32 and Win7/64) has:
_fseeki64
fseek
ftell

SetFilePointer() and _get_osfhandle(fp->_file) may be useful for
coding up an ftell64 replacement.

--- grischka

Loading...