www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Can someone please explain -allinst?

reply "Gary Willoughby" <dev nomad.so> writes:
Can someone explain the -allinst compiler flag for me please? 
I've absolutely no idea what this flag does or when to use it.
Nov 21 2013
next sibling parent "Rob T" <alanb ucora.com> writes:
On Thursday, 21 November 2013 at 21:20:59 UTC, Gary Willoughby 
wrote:
 Can someone explain the -allinst compiler flag for me please? 
 I've absolutely no idea what this flag does or when to use it.
I'm definitely not the best person to explain it, and I also would like to know more on this subject. If my understanding is correct, allinst apparently means generate "all instances". From what I got from some postings on this issue is that DMD now tries to optimize away template bloat by not generating template instances that are not used. I've had linker errors with auto ref parameters, and had to do some hacking to make them go away - basically I got rid of the "auto ref", but why these errors happened, and why I had to remove the auto is not certain, so whatever was done really needs to be much better explained. Later I read in a posting that had I compiled with -allinst, then the linker errors would have gone away, but that was after I changed my code, so I don't know what effect it would have had. --rt
Nov 21 2013
prev sibling parent reply "Jesse Phillips" <Jesse.K.Phillips+D gmail.com> writes:
On Thursday, 21 November 2013 at 21:20:59 UTC, Gary Willoughby 
wrote:
 Can someone explain the -allinst compiler flag for me please? 
 I've absolutely no idea what this flag does or when to use it.
I don't think I have have an understanding of it, but here is what I think I had read. If I'm right, please say so. If not again, say so and ignore me. -allinst causes the compiler to preform the same behavior as prior to 2.064. What was that behavior? When building the program all the called templates would get instantiated (those in the library used and the other program files). What changed (again my interpretation of a quick read) was that the library will include the instances of the template used in the library. When generating the program the code for the templates where expected to exist in the library so that it doesn't have to instantiate them again. I suspect this leads to expecting instances which haven't actually been used to exist in the library, so you use the flag -allinst to force the compiler to build all the instances being used.
Nov 21 2013
parent Dmitry Olshansky <dmitry.olsh gmail.com> writes:
22-Nov-2013 03:25, Jesse Phillips пишет:
 On Thursday, 21 November 2013 at 21:20:59 UTC, Gary Willoughby wrote:
 Can someone explain the -allinst compiler flag for me please? I've
 absolutely no idea what this flag does or when to use it.
I don't think I have have an understanding of it, but here is what I think I had read. If I'm right, please say so. If not again, say so and ignore me. -allinst causes the compiler to preform the same behavior as prior to 2.064. What was that behavior? When building the program all the called templates would get instantiated (those in the library used and the other program files). What changed (again my interpretation of a quick read) was that the library will include the instances of the template used in the library. When generating the program the code for the templates where expected to exist in the library so that it doesn't have to instantiate them again. I suspect this leads to expecting instances which haven't actually been used to exist in the library, so you use the flag -allinst to force the compiler to build all the instances being used.
Something like that, plus compiler now tries not to generate instances that are only used in C-T checks (static ifs etc.). Something in this logic is currently broken or implementation is lacking, hence the workaround switch. -- Dmitry Olshansky
Nov 22 2013