compiler-explorer/compiler-explorer

[REQUEST] Consider using gdc -fno-moduleinfo -fno-weak by default [D language]

Open

#1,961 opened on May 11, 2020

View on GitHub
 (3 comments) (0 reactions) (0 assignees)TypeScript (14,391 stars) (1,605 forks)batch import
enhancementhelp wantedlang-drequest

Description

So, both gdc and ldc do emit quite a bit of extra stuff into object code by default, like module info, type info, static module constructors, etc. It makes it a bit messy.

gdc does support -fno-moduleinfo.

I think it would be nice if you select gdc from the list of D compilers, and the options are empty, to maybe set options to -fno-moduleinfo ?

-fno-weak might also be worth too, as it will get a rid of dangling instantiations of various templates that are inlined into the code anyway by other stages, and not used by anything else.

Take a look here at a massive difference in readability of the assembler output:

https://godbolt.org/z/E3oN9q (14 vs 54 vs 211 lines of assembler)

For LDC compiler you could try --fvisibility=hidden, but in my experience it doesn't do much. The various templates instantentiations are marked weak AFAIK in ELF object (this can be changed to be once odr), but to get rid of them one would need to ask linker to remove them probably. Maybe there is some magic ldc or LLVM flag to do it directly tho.

Contributor guide