On Sunday, 15 July 2018 at 20:29:29 UTC, tcb wrote:
I've been trying to compile a trivial program (extern C int main() {return 0;}) without linking parts of the C runtime with no success.

I compile with dmd -debuglib= -defaultlib= -v -L=/INFORMATION -betterC but optlink shows a lot of things from snn.lib being pulled in and the resultant executable is about 12kb. I also replaced object.d with an empty module.

If I pass /nodefaultlib to the linker I get warning 23: no stack and __acrtused_con is undefined so the linker fails with no start address.

Is it possible to completely remove the C runtime on windows, and if so how? Sorry for the sloppily formatted post.

I recently created an issue that included an example that allows you to compile a Hello World program on linux x64 without the c standard library, druntime or phobos.

https://issues.dlang.org/show_bug.cgi?id=19078

You can modify it to run on windows as well. I'm not sure if the _start assembly implementation would be the same on windows. Try it out and let me know how it works.

Reply via email to