https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102765

--- Comment #14 from Iain Buclaw <ibuclaw at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #13)
> Just to note there's now a global -f[no-]semantic-interposition which might
> or might not be related.  It's switched by -Ofast, so -fno-weak-templates
> could
> eventually as well.
> 
> Confirmed at least.
Thanks Richard, and yes it could be, though it might be more for this example:
```
auto templatefn(T)()
{
    version (A)
    {
        // ...
    }
    else
    {
        // ...
    }
}
```
Where if library and user code mismatch versions, you could get size changed
warnings from the linker.


In this PR, the The example partially blocking is this:

Template variable in library
```
template rt_options()
{
    extern(C) pragma(mangle, "rt_options")
    string[] rt_options = [];
}
```
Regular "overriding" variable in user code
```
extern(C) string[] rt_options = ["gc:precise", ...];
```

If the template variable goes in a linkonce section, then user code won't link.
Upstream gets away with this by marking all symbols as weak.

Reply via email to