Compiling multiple source files --- each file separately, or all together?

David Given dg at cowlark.com
Sun Dec 28 17:01:22 UTC 2025


On Saturday, 27 December 2025 at 23:16:58 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
[...]
> 1. The .di generator runs before semantic analysis, there are 
> no inferred attributes in its output. This can effect mangling.

This is beyond my knowledge of D, unfortunately. Is this ever a 
problem in practice?

> 2. You want the -op switch with the .di generator set to a new 
> directory. Its in dmd ~master, but ldc has it.

That's really useful, thank you.

I think the best option for me is to ignore the module lookup 
path entirely and just pass all dependent .di files into the 
compiler. That means I can put the .di files anywhere which is 
convenient for the build system, and has the additional benefit 
of decoupling the module names from the source filenames --- the 
build system no longer needs to know anything about the module 
paths at all. Using -op avoids an additional gotcha which happens 
if there are two source files with the same filename being 
compiled together:

lib1/foo.d
lib2/foo.d

Without -op, the two .di files collide, and the first one is lost.

I think I have enough to work with now; I'll report back if I get 
this working.

Incidentally, am I right that there's no way to have a single 
module built from multiple source files?


More information about the Digitalmars-d mailing list