digitalmars.D.learn - Binary size optimization
- Imperatorn (17/17) Sep 28 2023 Today I randomly tried compiling a hello world using DMD, LDC and
- Imperatorn (2/19) Sep 28 2023 Oops, typo, I actually posted it in learn :D
Today I randomly tried compiling a hello world using DMD, LDC and gcc (yes, not gdc) I compared binary sizes and something looked off. The D ones were much larger. Sometimes 10x, with some optimizations still about 2x. But, then I tried using shared default lib and the size is even smaller than the one produced by gcc -Os! I just did two versions, one with betterC with extern(C) and one with std.stdio : printf (I didn't try dmd since I couldn't figure out easily how to share lib) [1] ldc2 -O -release -link-defaultlib-shared -betterC app.d [2] ldc2 -O -release -link-defaultlib-shared app.d Both are smaller than the gcc-version. How is this possible? What are the consequences and trade-offs? Maybe this should have been posted in Learn instead, but idk. Thanks
Sep 28 2023
On Thursday, 28 September 2023 at 08:38:42 UTC, Imperatorn wrote:Today I randomly tried compiling a hello world using DMD, LDC and gcc (yes, not gdc) I compared binary sizes and something looked off. The D ones were much larger. Sometimes 10x, with some optimizations still about 2x. But, then I tried using shared default lib and the size is even smaller than the one produced by gcc -Os! I just did two versions, one with betterC with extern(C) and one with std.stdio : printf (I didn't try dmd since I couldn't figure out easily how to share lib) [1] ldc2 -O -release -link-defaultlib-shared -betterC app.d [2] ldc2 -O -release -link-defaultlib-shared app.d Both are smaller than the gcc-version. How is this possible? What are the consequences and trade-offs? Maybe this should have been posted in Learn instead, but idk. ThanksOops, typo, I actually posted it in learn :D
Sep 28 2023