Compiling multiple source files --- each file separately, or all together?
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Sun Dec 28 21:45:59 UTC 2025
On 29/12/2025 6:01 AM, David Given wrote:
> 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?
Yes.
I dropped using the .di generator and kept to the original source files.
I did report and had bugs fixed.
However this isn't fixed, and it's a lot of work to resolve.
>> 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:
Do not ignore import paths.
If you are not compiling a module, it MUST come from -I or -extI.
It has implications that will result in a binary not linking.
With both compiler and platform specific complications.
I added -extI to specify that a module that comes from that import is
out of binary because it matters for Windows. Things do not link without
this information.
> 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?
Correct. The module is the encapsulation unit of a file.
More information about the Digitalmars-d
mailing list