[Issue 23850] Differentiate between a module that is in binary vs outside of binary when including -I
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Apr 22 19:42:41 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=23850
kinke <kinke at gmx.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kinke at gmx.net
--- Comment #1 from kinke <kinke at gmx.net> ---
Templates highly complicate matters. Little contrived example: an application
with `app.d`, depending on a shared lib with `sharedlib.d`, which further
depends on a `staticlib.d` static library:
app.d:
```
void foo() {
import sharedlib;
sharedFoo!();
}
```
sharedlib.d:
```
void sharedFoo()() {
import staticlib;
staticFoo!();
}
```
staticlib.d:
```
void staticFoo()() {
bar();
}
private void bar() {}
```
The staticlib.lib library contains `bar()` only. If sharedlib doesn't
instantiate `staticFoo!()` itself, sharedlib.dll contains no `staticFoo`
symbol, and the staticlib.obj object file isn't linked into the DLL either
(provides no required symbols). So it's the actual app which contains both
`sharedFoo` and `staticFoo` symbols, but still depends on the non-templated
`bar` function. So the app needs to be linked against staticlib.lib too, a
transitive dependency from the shared lib.
Things become interesting if `staticFoo` is instantiated and codegen'd in
sharedlib.dll. Then a per-module flag doesn't suffice anymore - staticlib.d's
`staticFoo()` part is linked from the shared library, but `bar()` from the
static lib.
--
More information about the Digitalmars-d-bugs
mailing list