www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Does dmd's -i "include imported modules in the compilation" switch

reply =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
-i is a useful feature:

   https://dlang.org/dmd-linux.html

Does dmd compile auto-included files separately? Does it generate 
temporary object files? If so, where does it write the files? Would -i 
cause race conditions on the file system?

Thank you,
Ali
Nov 03 2020
parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Tue, Nov 03, 2020 at 10:42:55AM -0800, Ali Çehreli via Digitalmars-d-learn
wrote:
 -i is a useful feature:
 
   https://dlang.org/dmd-linux.html
 
 Does dmd compile auto-included files separately? Does it generate
 temporary object files? If so, where does it write the files? Would -i
 cause race conditions on the file system?
[...] I believe -i behaves as though you manually typed the names of the source files on the command line. So it would do what the compiler would usually do in the latter case. AFAIK, that means it loads everything into memory and produces only a single object file for the final executable. Separate compilation only happens if you invoke the compiler separately for each source file or group of source files. T -- We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the Internet, we know this is not true. -- Robert Wilensk
Nov 03 2020
parent Jacob Carlborg <doob me.com> writes:
On 2020-11-03 20:02, H. S. Teoh wrote:

 I believe -i behaves as though you manually typed the names of the
 source files on the command line.  So it would do what the compiler
 would usually do in the latter case.
Yes, this is correct.
 AFAIK, that means it loads everything into memory and produces only a
 single object file for the final executable. Separate compilation only
 happens if you invoke the compiler separately for each source file or
 group of source files.
If the `-c` flag is passed, the compiler will produce one object file for each source file. If the `-c` flag is **not** passed, it will produce one executable and one single object file. -- /Jacob Carlborg
Nov 04 2020