Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dummy program without Phobos deps still links in Phobos modules (lld-specific) #4258

Open
kinke opened this issue Nov 12, 2022 · 2 comments
Open

Comments

@kinke
Copy link
Member

kinke commented Nov 12, 2022

Ubuntu 22, LDC v1.30.0, lld v14:

void main() {
    import core.stdc.stdio;
    foreach (m; ModuleInfo)
        printf("%.*s\n", cast(int) m.name.length, m.name.ptr);
}

Built without any explicit flags, this results in an almost 1.2 MB program, with 156 linked D modules (./hello | wc -l), incl. Phobos modules.

When building/linking with -defaultlib=druntime-ldc, the size is almost halved, and 80 druntime modules are linked.

With DMD v2.100.1, the size is almost 900 KB, while only including 37 modules (druntime only). [Some extra intra-dependencies in LDC's druntime are to be expected.] And DMD merges druntime and Phobos to a single library.

I guess this might be caused by the linker pulling in template instantiation symbols (instantiated and also available in druntime) from Phobos object files (Phobos library listed before druntime in linker cmdline, as Phobos depends on druntime). And just as I'm filing this issue, I've retried with bfd and gold, and yep, the same 80 modules (and ~620 KB size) without explicit -defaultlib=druntime-ldc, so it's lld-specific.

@kinke
Copy link
Member Author

kinke commented Nov 12, 2022

Apparently even much worse on Mac: #4256

@D-a-n-i-l-o
Copy link

See my answer at #4256

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants