What exactly the --allinst compiler flag does.

user1234 user1234 at 12.de
Sat Sep 28 17:09:42 UTC 2024


On Saturday, 28 September 2024 at 12:20:43 UTC, realhet wrote:
> Hi,
>
> I have some statements in my mind about --allinst, but I'm not 
> sure they are correct or not.
>
> 1. Normally the compiler analyzes the full code with all the 
> modules, and it only compiles code for template things that are 
> used in the given code.
>
> 2. It is not needed for compiling the code with a single 
> compiler instance, but is required for projects that are 
> compiled in parallel by using multiple compiler instances.
>
> Please someone tell me that these statements are valid or I 
> know this wrong.  (These are just my speculations, feelings, I 
> didn't find documentation on this.)

Speaking of speculation... "-allinst" disable an internal system 
of speculation that is: "this instance is already emitted so dont 
do it again".

Over the years it has appeared that the speculation does not 
always work as it should.

The classic symptom of that is when people encounter linker 
errors related to missing symbols. "-allinst" is the number one 
workaround. When activated, it's likely that things get emitted 
more than once, but at least, speculation bugs are gone.

You may ask "but then there should be other linker errors about 
double definition ?". No, those syms has to be emitted as "weak" 
symbols, so the linker ignore duplicated definitions.


More information about the Digitalmars-d-learn mailing list