www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Setting the stack size

reply Franciszek Czekala <home valentimex.com> writes:
How do you set the stack size for D programs?
Dec 01 2010
next sibling parent Jesse Phillips <jessekphillips+D gmail.com> writes:
Franciszek Czekala Wrote:

 How do you set the stack size for D programs?
http://bytes.com/topic/c/answers/221976-enlarge-stack-size-gcc "No. The stack size is not set in the ELF binary. It's a settable user resource limit; see RLIMIT_STACK in setrlimit(2)." Sorry don't know what Windows does.
Dec 01 2010
prev sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
Franciszek Czekala:

 How do you set the stack size for D programs?
On Windows with DMD this is how to set the max stack size to about 1.5 GB of the "test.d" module: dmd -L/STACK:1500000000 test.d (I'd like D to have a standard syntax (maybe a pragma(...)) to tell the other parts of the compilation chain how much stack to use). Bye, bearophile
Dec 01 2010
next sibling parent reply Andrew Wiley <debio264 gmail.com> writes:
On Wed, Dec 1, 2010 at 2:36 PM, bearophile <bearophileHUGS lycos.com> wrote:

 Franciszek Czekala:

 How do you set the stack size for D programs?
On Windows with DMD this is how to set the max stack size to about 1.5 GB of the "test.d" module: dmd -L/STACK:1500000000 test.d (I'd like D to have a standard syntax (maybe a pragma(...)) to tell the other parts of the compilation chain how much stack to use).
If the stack size is only set by the executable on Windows, I don't see how that would be useful.
Dec 01 2010
parent reply Mike Parker <aldacron gmail.com> writes:
On 12/2/2010 6:12 AM, Andrew Wiley wrote:
 On Wed, Dec 1, 2010 at 2:36 PM, bearophile <bearophileHUGS lycos.com
 <mailto:bearophileHUGS lycos.com>> wrote:

     Franciszek Czekala:

      > How do you set the stack size for D programs?

     On Windows with DMD this is how to set the max stack size to about
     1.5 GB of the "test.d" module:
     dmd -L/STACK:1500000000 test.d

     (I'd like D to have a standard syntax (maybe a pragma(...)) to tell
     the other parts of the compilation chain how much stack to use).


 If the stack size is only set by the executable on Windows, I don't see
 how that would be useful.
It's not set by DMD, but by the linker. You need to pass the appropriate flag to the linker on each platform via the -L command line option. bearophile's example is for OPTLINK. On platforms where DMD is backed by the gcc toolchain, you should be able to use dmd -L--stack 1500000000 test.d
Dec 01 2010
parent reply Andrew Wiley <debio264 gmail.com> writes:
On Wed, Dec 1, 2010 at 7:14 PM, Mike Parker <aldacron gmail.com> wrote:

 On 12/2/2010 6:12 AM, Andrew Wiley wrote:

 On Wed, Dec 1, 2010 at 2:36 PM, bearophile <bearophileHUGS lycos.com
 <mailto:bearophileHUGS lycos.com>> wrote:

    Franciszek Czekala:

     > How do you set the stack size for D programs?

    On Windows with DMD this is how to set the max stack size to about
    1.5 GB of the "test.d" module:
    dmd -L/STACK:1500000000 test.d

    (I'd like D to have a standard syntax (maybe a pragma(...)) to tell
    the other parts of the compilation chain how much stack to use).


 If the stack size is only set by the executable on Windows, I don't see
 how that would be useful.
It's not set by DMD, but by the linker. You need to pass the appropriate flag to the linker on each platform via the -L command line option. bearophile's example is for OPTLINK. On platforms where DMD is backed by the gcc toolchain, you should be able to use dmd -L--stack 1500000000 test.d
$ ld --stack ld: unrecognized option '--stack' ld: use the --help option for usage information The linker doesn't set the stack size on Linux/Unix (seems like OSX is an exception). You set the stack size in the environment with 'ulimit -s'
Dec 01 2010
parent Mike Parker <aldacron gmail.com> writes:
On 12/2/2010 10:33 AM, Andrew Wiley wrote:
 On Wed, Dec 1, 2010 at 7:14 PM, Mike Parker <aldacron gmail.com
 <mailto:aldacron gmail.com>> wrote:

     On 12/2/2010 6:12 AM, Andrew Wiley wrote:



         On Wed, Dec 1, 2010 at 2:36 PM, bearophile
         <bearophileHUGS lycos.com <mailto:bearophileHUGS lycos.com>
         <mailto:bearophileHUGS lycos.com
         <mailto:bearophileHUGS lycos.com>>> wrote:

             Franciszek Czekala:

          > How do you set the stack size for D programs?

             On Windows with DMD this is how to set the max stack size to
         about
             1.5 GB of the "test.d" module:
             dmd -L/STACK:1500000000 test.d

             (I'd like D to have a standard syntax (maybe a pragma(...))
         to tell
             the other parts of the compilation chain how much stack to use).


         If the stack size is only set by the executable on Windows, I
         don't see
         how that would be useful.


     It's not set by DMD, but by the linker. You need to pass the
     appropriate flag to the linker on each platform via the -L command
     line option. bearophile's example is for OPTLINK. On platforms where
     DMD is backed by the gcc toolchain, you should be able to use

     dmd -L--stack 1500000000 test.d


 $ ld --stack
 ld: unrecognized option '--stack'
 ld: use the --help option for usage information

 The linker doesn't set the stack size on Linux/Unix (seems like OSX is
 an exception). You set the stack size in the environment with 'ulimit -s'
I got that from the ld man page [1]. But on checking again, I see this: [This option is specific to the i386 PE targeted port of the linker] Sorry about that. [1] http://linux.die.net/man/1/ld
Dec 02 2010
prev sibling next sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
 On Windows with DMD this is how to set the max stack size to about 1.5 GB of
the "test.d" module:
 dmd -L/STACK:1500000000 test.d
D is good for allowing to add the last values to the results table for n up to 25: http://en.wikipedia.org/wiki/Man_or_boy_test The reference to D was later removed by someone, of course. They have even removed D examples from the template metaprogramming page, etc. The page about CTFE resists still: http://en.wikipedia.org/wiki/Compile_time_function_execution Wikipedia looks like a fair place based on rules and laws, but in truth a lot of its contents are determined by politics. If there are enough people interested in keeping a page/topic alive, then it survives. So you are able to find many page about single Pokemon characters (some of them are cute, but they cultural importance is not huge), but no pages (because they have deleted it) about some useful software. Bye, bearophile
Dec 01 2010
next sibling parent reply Justin C Calvarese <jccalvarese gmail.com> writes:
== Quote from bearophile (bearophileHUGS lycos.com)'s article
 http://en.wikipedia.org/wiki/Man_or_boy_test
 The reference to D was later removed by someone, of course.
 They have even removed D examples from the template metaprogramming page, etc.
The page about CTFE
 resists still:
 http://en.wikipedia.org/wiki/Compile_time_function_execution
 Wikipedia looks like a fair place based on rules and laws, but in truth a lot
of its contents are
 determined by politics. If there are enough people interested in keeping a
page/topic alive, then it
 survives. So you are able to find many page about single Pokemon characters
(some of them are cute,
 but they cultural importance is not huge), but no pages (because they have
deleted it) about some
useful
 software.

 Bye,
 bearophile
If Wikipedia is hostile to D, maybe the content should be offered to other venues. I'm sure that there are many websites that could benefit from some interesting articles about programming concepts that could include D code examples, such as: * http://knol.google.com/ * http://www.mywikibiz.com/ * http://rosettacode.org/ (I know that there are many other websites that could be mentioned. I just wanted to list a few websites to illustrate my idea.) jcc7
Dec 01 2010
parent reply spir <denis.spir gmail.com> writes:
On Thu, 2 Dec 2010 05:13:27 +0000 (UTC)
Justin C Calvarese <jccalvarese gmail.com> wrote:

 If Wikipedia is hostile to D
What is this supposed to mean? Who is Mr Wikipedia not liking D? (I'm not j= oking -- I would like to know things about wikipedia I do not know yet.) Denis -- -- -- -- -- -- -- vit esse estrany =E2=98=A3 spir.wikidot.com
Dec 02 2010
parent so <so so.do> writes:
 If Wikipedia is hostile to D
What is this supposed to mean? Who is Mr Wikipedia not liking D? (I'm not joking -- I would like to know things about wikipedia I do not know yet.)
What is this Mr gamedev not liking D? Not hard to check. -- Using Opera's revolutionary email client: http://www.opera.com/mail/
Dec 02 2010
prev sibling next sibling parent so <so so.do> writes:
 The reference to D was later removed by someone, of course.
 They have even removed D examples from the template metaprogramming  
 page, etc. The page about CTFE resists still:
Even CTFE example is hostile. If i search line/sphere ... first thing i see in wikipedia is a almost perfect computer generated image, not the hand made one. Good to know about this, thank you! -- Using Opera's revolutionary email client: http://www.opera.com/mail/
Dec 02 2010
prev sibling next sibling parent reply retard <re tard.com.invalid> writes:
Wed, 01 Dec 2010 20:52:47 -0500, bearophile wrote:

 On Windows with DMD this is how to set the max stack size to about 1.5
 GB of the "test.d" module: dmd -L/STACK:1500000000 test.d
D is good for allowing to add the last values to the results table for n up to 25: http://en.wikipedia.org/wiki/Man_or_boy_test The reference to D was later removed by someone, of course.
Nothing D specific really, they argued that the article should remain clean since the test was designed for *Algol*, not D. It's not a language competition, people only want to know what the 'Man or boy test' is. By your logic, all those programming articles should include 500+ implementations of the algorithm in various languages to avoid any kind of discrimination. It's a general purpose encyclopedia, not a language competition, understand that? Write your competition code to sites like rosettacode. The implementations are here: http://en.wikipedia.org/wiki/Wikipedia_talk:Articles_for_creation/ Submissions/Man_or_boy_test_implementations They haven't yet decided whether they're worth a new article.
 They have even removed D
 examples from the template metaprogramming page, etc.
etc. ? What else? The generic programming constructs of D have already been discussed here: http://en.wikipedia.org/wiki/Generic_programming#Templates_in_D Repeating the same shit provides little additional value IMHO. I think the whole template metaprogramming article is redundant and all the metaprogramming articles should have a better organization. The particular D code that was removed was: http://en.wikipedia.org/w/index.php? title=Template_metaprogramming&diff=64616972&oldid=64616688 The discussion page mentions it doesn't add any value and I can't disagree. The article should really go through review. It also discusses static polymorphism which isn't only related to templates. CRTP is also possible already has a new page: http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern
 The page about CTFE resists still:
 http://en.wikipedia.org/wiki/Compile_time_function_execution
Resists? You weren't able to fill it with D propaganda? It already lists the DigitalMars pages as only references. And provides 2/3 examples in D. What else should it do?
 Wikipedia
 looks like a fair place based on rules and laws, but in truth a lot of
 its contents are determined by politics.
You aren't helping that with that FUD.
 If there are enough people
 interested in keeping a page/topic alive, then it survives.
Notability guidelines.
 So you are
 able to find many page about single Pokemon characters (some of them are
 cute, but they cultural importance is not huge), but no pages (because
 they have deleted it) about some useful software.
But pikamen are notable!
 
 Bye,
 bearophile
Dec 02 2010
parent reply so <so so.do> writes:
 http://en.wikipedia.org/w/index.php?
 title=Template_metaprogramming&diff=64616972&oldid=64616688

 The discussion page mentions it doesn't add any value and I can't
 disagree.
They might be clueless to say that, but you?
 Resists? You weren't able to fill it with D propaganda? It already lists
 the DigitalMars pages as only references. And provides 2/3 examples in D.
 What else should it do?
What propaganda are you talking about? If they are not some populist pricks first thing you would see on that page would be D. -- Using Opera's revolutionary email client: http://www.opera.com/mail/
Dec 02 2010
next sibling parent reply retard <re tard.com.invalid> writes:
Thu, 02 Dec 2010 11:10:33 +0200, so wrote:

 http://en.wikipedia.org/w/index.php?
 title=Template_metaprogramming&diff=64616972&oldid=64616688

 The discussion page mentions it doesn't add any value and I can't
 disagree.
They might be clueless to say that, but you?
I agree static-if, alias parameters, and the other extensions are worth mentioning, but syntactical changes more or less aren't. I'd introduce the templates using code written in C++ and then list the differences between C++ and D. After all, C++ and C++ TMP are widely known. Even I have few books of them in my bookshelf and ps/pdf papers discussing C++ TMP. There aren't any books or peer reviewed articles about D's metaprogramming, right? Prioritizing D over C++ doesn't make sense, the citations should emphasize notable relevant sources.
 
 Resists? You weren't able to fill it with D propaganda? It already
 lists the DigitalMars pages as only references. And provides 2/3
 examples in D. What else should it do?
What propaganda are you talking about? If they are not some populist pricks first thing you would see on that page would be D.
It clearly seems that both C++ and D communities think they invented the term CTFE. In C++ the functions are "meta-functions" (templates) [1], in D "ordinary" functions. But the same shit comes with a different name in other languages. It's essentially the same concept of metaprogramming. [1] http://www.amazon.com/Template-Metaprogramming-Concepts-Techniques- Beyond/dp/0321227255
Dec 02 2010
parent reply so <so so.do> writes:
 I'd introduce the templates using code written in C++ and then list the
 differences between C++ and D. After all, C++ and C++ TMP are widely
 known. Even I have few books of them in my bookshelf and ps/pdf papers
 discussing C++ TMP. There aren't any books or peer reviewed articles
 about D's metaprogramming, right? Prioritizing D over C++ doesn't make
 sense, the citations should emphasize notable relevant sources.
Someone in some third world country proved Goldbach's conjecture. Proof is there and accepted by everyone that understand what/how he does it. What are you going to do as the all mighty objective wikipedia? Are you going to wait till that guy get matured enough and write a book about the meaning of life, before you label him as a human being? Or maybe you want to talk about his proof after a thousand of failed attempts?
 It clearly seems that both C++ and D communities think they invented the
 term CTFE. In C++ the functions are "meta-functions" (templates) [1], in  
 D
 "ordinary" functions. But the same shit comes with a different name in
 other languages. It's essentially the same concept of metaprogramming.

 [1] http://www.amazon.com/Template-Metaprogramming-Concepts-Techniques-
 Beyond/dp/0321227255
CTFE in essance meta-programming i agree, but comparing to others like comparing a tree to a forest. And no one here claimed D is the inventor of meta-programming. -- Using Opera's revolutionary email client: http://www.opera.com/mail/
Dec 02 2010
parent reply retard <re tard.com.invalid> writes:
Thu, 02 Dec 2010 12:07:19 +0200, so wrote:

 I'd introduce the templates using code written in C++ and then list the
 differences between C++ and D. After all, C++ and C++ TMP are widely
 known. Even I have few books of them in my bookshelf and ps/pdf papers
 discussing C++ TMP. There aren't any books or peer reviewed articles
 about D's metaprogramming, right? Prioritizing D over C++ doesn't make
 sense, the citations should emphasize notable relevant sources.
Someone in some third world country proved Goldbach's conjecture. Proof is there and accepted by everyone that understand what/how he does it. What are you going to do as the all mighty objective wikipedia?
Agreed, I don't like some of the Wikipedia's policies or editors, but this isn't the case now. D came a bit late to the party - many books were already written. The D's documentation doesn't discuss metaprogramming in general very extensively. Even when you just want to cite _something_, the C++ literature isn't that bad. The same information implemented in D is scattered around the net in newsgroup articles, dr dobbs journal, Bartosz's blog, TDPL, and so on. You don't have a single authoritative, peer reviewed source about D metaprogramming. There's more to it than langugage syntax and semantics.
 
 It clearly seems that both C++ and D communities think they invented
 the term CTFE. In C++ the functions are "meta-functions" (templates)
 [1], in D
 "ordinary" functions. But the same shit comes with a different name in
 other languages. It's essentially the same concept of metaprogramming.

 [1] http://www.amazon.com/Template-Metaprogramming-Concepts-Techniques-
 Beyond/dp/0321227255
CTFE in essance meta-programming i agree, but comparing to others like comparing a tree to a forest.
Like I said, the articles would need a review. The particular page is already full of unrelated text.
 And no one here claimed D is the inventor of meta-programming.
Bearophile argued that the Wikipedia in general dismisses D harsly due to political reasons. I don't find this true. And like I said, it's not a competition. It's not a magazine where you can post your ads, it's an encyclopedia. More text about D isn't better. I find this D language advocacy in Wikipedia disgusting - clearly, you should document notable features of D, but the main objective cannot be as much visibility as possible. Some of the related programming articles try to be generic, language agnostic. There's a language independent introduction and examples in various languages. And when there's an examples section, there should be a balance between the languages, e.g. one or two examples per language, not 1 example in other languages and 100 in D, because D has so much more features. I hate this kind of desperate pushing. What the heck we are, a religious cult? He (or someone else) previously complained that the language shootout guy doesn't include D in the test so he must he D because of some <XXX> reason. I think that if a language has real technical merits, this kind of worrying about the public image is silly. If you worry about D's notability, write more articles about D and more code in D.
Dec 02 2010
next sibling parent so <so so.do> writes:
 There's a language independentintroduction and examples in various  
 languages
 http://en.wikipedia.org/wiki/Man_or_boy_test
You are right.
 More text about D isn't better
 I find this D language advocacy in Wikipedia disgusting
I absolutely agree on these two points, but it is not what i meant. What i meant is that if your solution is the best, you deserve the best credit. This is a matter of objectivity.
 I think that if a language has real technical merits, this kind
 of worrying about the public image is silly. If you worry about D's
 notability, write more articles about D and more code in D.
Public image has a huge importance on one thing, If you are a newbie, it is the first thing you'll face. On the other hand as the homepage says D is not a "first language", which invalidates this importance. This discussion is funny. so retard so retard ... -- Using Opera's revolutionary email client: http://www.opera.com/mail/
Dec 02 2010
prev sibling parent reply Don <nospam nospam.com> writes:
retard wrote:
 Thu, 02 Dec 2010 12:07:19 +0200, so wrote:
 I find this D language advocacy in Wikipedia disgusting - clearly, you 
 should document notable features of D, but the main objective cannot be 
 as much visibility as possible.
 I think that if a language has real technical merits, this kind 
 of worrying about the public image is silly. If you worry about D's 
 notability, write more articles about D and more code in D.
Well said. Actually, I don't think broad publicity for D is desirable at this point. Right now, we desperately want library and toolchain developers. But the arrival of hordes of app developers who expect a polished product, would be a disaster for D.
Dec 02 2010
parent Bruno Medeiros <brunodomedeiros+spam com.gmail> writes:
On 02/12/2010 14:53, Don wrote:
 retard wrote:
 Thu, 02 Dec 2010 12:07:19 +0200, so wrote:
 I find this D language advocacy in Wikipedia disgusting - clearly, you
 should document notable features of D, but the main objective cannot
 be as much visibility as possible.
 I think that if a language has real technical merits, this kind of
 worrying about the public image is silly. If you worry about D's
 notability, write more articles about D and more code in D.
Well said. Actually, I don't think broad publicity for D is desirable at this point. Right now, we desperately want library and toolchain developers. But the arrival of hordes of app developers who expect a polished product, would be a disaster for D.
Well said as well. In fact, I think this is a particular thing we could be doing more to mitigate criticism of D: to make it more clear that at this stage D is still not mature enough in terms of implementation (perhaps in terms of design as well). For example, a lot of the criticism I saw in the Gentoo forums post (and elsewhere I don't remember where) was because of exactly that: the people were expecting D to be quite mature, at least the compiler. -- Bruno Medeiros - Software Engineer
Dec 14 2010
prev sibling parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 12/2/10 3:10 AM, so wrote:
 http://en.wikipedia.org/w/index.php?
 title=Template_metaprogramming&diff=64616972&oldid=64616688

 The discussion page mentions it doesn't add any value and I can't
 disagree.
They might be clueless to say that, but you?
I don't think there's any conspiracy against D on Wikipedia, but the edit mentioned above is actually damaging to people who want to understand metaprogramming. Static if has been a huge boon for D, and it has been recognized by C++ luminaries that it would be^H^Hhave been a huge boon for C++0x as well. Discussing the stilted C++ implementation exclusively detracts considerably from understanding the true issues at hand. Andrei
Dec 03 2010
prev sibling parent spir <denis.spir gmail.com> writes:
On Wed, 01 Dec 2010 20:52:47 -0500
bearophile <bearophileHUGS lycos.com> wrote:

 D is good for allowing to add the last values to the results table for n =
up to 25:
 http://en.wikipedia.org/wiki/Man_or_boy_test
 The reference to D was later removed by someone, of course.
 They have even removed D examples from the template metaprogramming page,=
etc. The page about CTFE resists still:
 http://en.wikipedia.org/wiki/Compile_time_function_execution
 Wikipedia looks like a fair place based on rules and laws, but in truth a=
lot of its contents are determined by politics.=20 Could you expand on this? (I mean especially in the case of D)? Denis -- -- -- -- -- -- -- vit esse estrany =E2=98=A3 spir.wikidot.com
Dec 02 2010
prev sibling parent Franciszek Czekala <home valentimex.com> writes:
Thank you for the information (I should have mentioned that I am
interested in Windows). I suspected it should be done via linker
and found the /STACK option in optlink info but I thought that one
had to invoke the linker separately. Now I know how to do it in
one pass. However, I asked the question in the forum because it
did not seem to work. After some more experimenting with recursive
functions I came to the following conclusion:

1) The minimum stack size is 4*64KB=262144 bytes. Setting a
smaller value via -L/STACK has no effect.
2) The stack size is increased in 64KB chunks. If you specify a
number of bytes which is not a multiple of 64KB you will get the
size of the stack being the smallest multiple of 64KB bigger than
the number you specify. Thus if you have a stack overflow in your
program and increase the stack size by 10000 bytes for example,
you may see no effect.
Dec 03 2010