Add -dnostdlib to simplify the use of DLang without stdlib#10180
Conversation
|
Thanks for your pull request and interest in making D better, @ErnyTech! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#10180" |
|
How does it compare to |
|
-betterC links the libc and import object.d, while -dnostdlib was born to be used without any stdlib (druntime, phobos and libc) |
|
I don't understand. Just don't call your main function |
|
Already have a PR for this: #9831 It turns out we don't need an new option, using |
If you examine the other PRs (#10181, #10182, #10183, #10184), you will see that there is more to it than just linking the default platform libraries. This PR will introduce a compiler switch that will also disable implicitly importing
That's only true for the startup code ( I've given this PR some thought, but the approach proposed here is not my preference. I'm interested in making D more pay-as-you-go, but the spirit of the pay-as-you-go mantra is that everything is turned OFF by default and you only turn ON what you need. The approach taken with this PR is to turn things OFF. That's not a deal-breaker, but it's a warning flag that something's not right. I have an alternate proposal which I believe will be more generally useful for all, more in the spirit of "pay-as-you-go", and will reduce much hard-coded complexity in the compiler. I propose utilizing Those who are using D for bare-metal, new platforms, or other pioneering use cases that don't wish to utilize the compiler's defaults can simply invoke the compiler with I believe that will be more scalable, will reduce complexitiy in the compiler, and will be more generally useful for all. |
|
@JinShil I already started work on your proposal but we are waiting on @WalterBright to respond #9936 (comment) [WIP] [NeedsAcceptOrRejectFromWalter] Move standard library config to dmd.conf [WIP] [NeedsAcceptOrRejectFromWalter] Remove hardcoded phobos info from the compiler |
This PR was created to provide an easier alternative to accept than #7825 and #9814
This PR has been divided into 5 parts to make it easier to analyze each change and not to accept all the changes
With this initial PR you begin to define the new flag: "-dnostdlib" which will allow developers to use the DLang compiler without any dependency on various runtime (both DRuntime and Libc) without having to use boring methods like generating object files and linking them manually (this is done for example here https://github.com/JinShil/utiliD/blob/91b9048cac92e8341816cd2bc78fdc066f5ad5cc/test/HelloWorld/run.d#L17)
With this PR, unlike previous attempts, no code/script currently in use will be broken, just a new flag will be added for users interested in using DLang without any standard library.
The "-dnostdlib" flag should do the following:
dmd/src/dmd/compiler.d
Line 74 in 22113af
dmd/src/dmd/link.d
Line 672 in 22113af
dmd/src/dmd/dmodule.d
Line 1134 in 22113af
After this PR it will be possible to compile with DMD a source code like this just adding -dnostdlib (so with a way like C compilers):