www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - Tiny executables

reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
Hi, I'm trying to integrate LDC into SlimD
(https://github.com/CyberShadow/SlimD).

1. I couldn't find an equivalent to DMD's -betterC, to avoid 
generating ModuleInfos. I thought that -fdata-sections and 
-ffunction-sections would make it unnecessary, however LDC still 
generates a .ctors section, which linkers don't discard.

2. How does one do incremental compilation and LTO with LDC? 
Clang has -emit-llvm, but ldc2.exe doesn't have such an option.

3. Do I understand correctly that LDC uses COFF object files, 
however uses gcc/ld for linking? Meaning that MinGW uses COFF 
files on Windows as well?
Sep 18 2014
parent reply David Nadlinger via digitalmars-d-ldc <digitalmars-d-ldc puremagic.com> writes:
On 19 Sep 2014, at 6:45, Vladimir Panteleev via digitalmars-d-ldc wrote:
 1. I couldn't find an equivalent to DMD's -betterC, to avoid 
 generating ModuleInfos. I thought that -fdata-sections and 
 -ffunction-sections would make it unnecessary, however LDC still 
 generates a .ctors section, which linkers don't discard.
We are currently lacking something like that, unfortunately. It definitely would be worth adding something along the lines of -betterC (with a more descriptive name, that is). There is pragma(LDC_no_moduleinfo) [1], though, which might still get you a long ways.
 2. How does one do incremental compilation and LTO with LDC? Clang has 
 -emit-llvm, but ldc2.exe doesn't have such an option.
-output-ll/-output-bc. You currently need to do the LTO part by hand, though (using opt and then llc to generate code).
 3. Do I understand correctly that LDC uses COFF object files, however 
 uses gcc/ld for linking? Meaning that MinGW uses COFF files on Windows 
 as well?
OTOH, yes, MinGW also emits object files as COFF. If you are only interested in Win64 you could also try to use the MSVC-based toolchain. There are still some issues with it, but if you only need low-level stuff anyway and thus do not care about bugs in e.g. exception handling, it might work out just fine. Stripping unused sections actually works with link.exe, in contrast to MinGW's COFF linker. David [1] http://wiki.dlang.org/LDC-specific_language_changes#LDC_no_moduleinfo
Sep 19 2014
parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Friday, 19 September 2014 at 08:07:51 UTC, David Nadlinger via 
digitalmars-d-ldc wrote:
 There is pragma(LDC_no_moduleinfo) [1], though, which might 
 still get you a long ways.
It did, thanks.
 3. Do I understand correctly that LDC uses COFF object files, 
 however uses gcc/ld for linking? Meaning that MinGW uses COFF 
 files on Windows as well?
OTOH, yes, MinGW also emits object files as COFF. If you are only interested in Win64 you could also try to use the MSVC-based toolchain.
The MS linker seemed to work OK for my very simple cases.
 Stripping unused sections actually works with link.exe, in 
 contrast to MinGW's COFF linker.
For some reason the MS linker left the .ctors section as-is in the resulting EXE, but pragma(LDC_no_moduleinfo) took care of that.
Sep 20 2014