www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Wrong module initialization order when building with Dub on Windows?

reply Vladimir Panteleev <thecybershadow.lists gmail.com> writes:
Ran into this today, don't have time to dig in now but maybe 
someone ran into this too.

Steps to reproduce:

- git clone https://github.com/CyberShadow/ae
- cd ae/demo/inputtiming
- (download/unpack 
https://www.libsdl.org/release/SDL2-2.0.8-win32-x86.zip or 
https://www.libsdl.org/release/SDL2-2.0.8-win32-x64.zip to 
current directory)
- dub

On Windows, I get a range violation (in ae.sys.log) which 
indicates that Runtime.args has length 0, which should never 
happen.

This doesn't happen if I build as usual with rdmd, or on Linux 
(either rdmd or Dub).
Oct 01 2018
next sibling parent Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Tuesday, 2 October 2018 at 01:57:00 UTC, Vladimir Panteleev 
wrote:
 Ran into this today, don't have time to dig in now but maybe 
 someone ran into this too.

 Steps to reproduce:

 - git clone https://github.com/CyberShadow/ae
 - cd ae/demo/inputtiming
 - (download/unpack 
 https://www.libsdl.org/release/SDL2-2.0.8-win32-x86.zip or 
 https://www.libsdl.org/release/SDL2-2.0.8-win32-x64.zip to 
 current directory)
 - dub

 On Windows, I get a range violation (in ae.sys.log) which 
 indicates that Runtime.args has length 0, which should never 
 happen.

 This doesn't happen if I build as usual with rdmd, or on Linux 
 (either rdmd or Dub).
I'd take a look at what arguments are passed to DMD with rdmd vs. dub. Maybe to module order is different?
Oct 01 2018
prev sibling next sibling parent reply bauss <jj_1337 live.dk> writes:
On Tuesday, 2 October 2018 at 01:57:00 UTC, Vladimir Panteleev 
wrote:
 Ran into this today, don't have time to dig in now but maybe 
 someone ran into this too.

 Steps to reproduce:

 - git clone https://github.com/CyberShadow/ae
 - cd ae/demo/inputtiming
 - (download/unpack 
 https://www.libsdl.org/release/SDL2-2.0.8-win32-x86.zip or 
 https://www.libsdl.org/release/SDL2-2.0.8-win32-x64.zip to 
 current directory)
 - dub

 On Windows, I get a range violation (in ae.sys.log) which 
 indicates that Runtime.args has length 0, which should never 
 happen.

 This doesn't happen if I build as usual with rdmd, or on Linux 
 (either rdmd or Dub).
Honestly I would say that it should have worked regardless of the module order, because it's the runtime arguments. Basically D's runtime should set them before ANY module constructors are called and most definitely before the main function is called. So I'd say it's a bug with D's runtime and not necessary Dub. You should be able to retrieve Runtime.args no matter where and when you attempt to do so in your program, as long as arguments are passed. Of course if arguments passed are different between dub and rdmd then it's a bug, but if it's not and it's just because the modules are passed in different order, then I'd argue it's a bug with D's runtime.
Oct 01 2018
parent Jacob Carlborg <doob me.com> writes:
On 2018-10-02 08:49, bauss wrote:

 Honestly I would say that it should have worked regardless of the module 
 order, because it's the runtime arguments.
 
 Basically D's runtime should set them before ANY module constructors are 
 called and most definitely before the main function is called.
They are set before calling any module constructors. The arguments are set here [1] and the module constructors are run here [2]. [1] https://github.com/dlang/druntime/blob/e807e29472fa5973c438f97cd5d4b390ef1a4a5c/src/rt/dmain2.d#L438 [2] https://github.com/dlang/druntime/blob/e807e29472fa5973c438f97cd5d4b390ef1a4a5c/src/rt/dmain2.d#L493 -- /Jacob Carlborg
Oct 02 2018
prev sibling parent Kagamin <spam here.lot> writes:
Missing command line arguments? Sounds like this: 
https://forum.dlang.org/post/eevaqbqufmhhducuahye forum.dlang.org
Oct 02 2018