December 23, 2023 [Issue 24299] New: The dmd's command line option "-run" should prefer dynamic linking with the Phobos library by default | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24299 Issue ID: 24299 Summary: The dmd's command line option "-run" should prefer dynamic linking with the Phobos library by default Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: siarhei.siamashka@hotmail.com Consider the following small program: ```D import std.stdio; void main() { writeln("Hello world!"); } ``` $ which dmd /opt/dmd2-106.0/linux/bin64/dmd $ time dmd -run helloworld.d Hello world! real 0m0.414s $ time dmd -defaultlib=libphobos2.a -run helloworld.d Hello world! real 0m0.414s $ time dmd -defaultlib=libphobos2.so -L-rpath=/opt/dmd2-106.0/linux/lib64 -run helloworld.d Hello world! real 0m0.188s Linking libphobos2.a is more than twice slower than linking libphobos2.so (~414 ms vs. ~188 ms difference on my computer). While theoretically the users can use any fancy command line options, in reality many of them just don't bother. So the performance of just invoking `dmd -run helloworld.d` is bad out of the box. But the compiled binary is immediately discarded after use and there are no downsides to using dynamic linking in this scenario. So linking libphobos2.so would be a more reasonable default configuration specifically for the `-run` option. I suggest to introduce additional sections "[RunEnvironment32]" and "[RunEnvironment64]" in the "dmd.conf" file for the options specifically tailored for the "-run" option. And then binary releases of the DMD compiler could use these sections to provide fast `dmd -run` functionality out of the box. -- |
Copyright © 1999-2021 by the D Language Foundation