digitalmars.D.learn - Why exe size change if import entire std or just writeln?
- Marcone (13/13) Mar 23 2022 import std.stdio : writeln;
- H. S. Teoh (6/29) Mar 23 2022 Did you compile with LTO? If not, the exe may carry extra baggage,
- Salih Dincer (19/21) Mar 24 2022 You are right! Test results on linux:
import std.stdio : writeln; void main(){ writeln("Bom dia"); } Size exe file: 258 KB -------------------------------------------------------------- import std; void main(){ writeln("Bom dia"); } Size exe file: 595 KB If dependencies are resolved at compile time, why does the compiler include extra stuff?
Mar 23 2022
On Thu, Mar 24, 2022 at 01:49:30AM +0000, Marcone via Digitalmars-d-learn wrote:import std.stdio : writeln; void main(){ writeln("Bom dia"); } Size exe file: 258 KB -------------------------------------------------------------- import std; void main(){ writeln("Bom dia"); } Size exe file: 595 KB If dependencies are resolved at compile time, why does the compiler include extra stuff?Did you compile with LTO? If not, the exe may carry extra baggage, since the linker may not have tried to shed excess baggage. T -- My father told me I wasn't at all afraid of hard work. I could lie down right next to it and go to sleep. -- Walter Bright
Mar 23 2022
On Thursday, 24 March 2022 at 01:49:30 UTC, Marcone wrote:If dependencies are resolved at compile time, why does the compiler include extra stuff?You are right! Test results on linux: ```d //import std.stdio : writefln;/* version = 1; import core.stdc.stdio : printf;//*/ void main() { string hello = "hello"; version(1) { printf("%s world\n", hello.ptr);// 6464 bytes with strip } else hello.writefln!"%s World!"; // 196KB with strip } /* * ldc2 -O hello.d -release */ ```
Mar 24 2022