www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - How to reduce executable filesize

reply Andre Pany <andre s-e-a-p.de> writes:
Hi,
If I remember correctly on linux (ubuntu) you can compile an 
executable which uses and DRuntime as shared objects.

How is the ldc2 command for this?
I assume I can find the shared objects for phobos and DRuntime in 
the ldc2 linux x86_64 release archive?

Is there also an additional argument to strip any non used 
symbols?

Kind regards
Andre
Jul 12 2019
next sibling parent reply Andre Pany <andre s-e-a-p.de> writes:
On Friday, 12 July 2019 at 16:37:05 UTC, Andre Pany wrote:
 Hi,
 If I remember correctly on linux (ubuntu) you can compile an 
 executable which uses and DRuntime as shared objects.

 How is the ldc2 command for this?
 I assume I can find the shared objects for phobos and DRuntime 
 in the ldc2 linux x86_64 release archive?

 Is there also an additional argument to strip any non used 
 symbols?

 Kind regards
 Andre
Should read ...which uses Phobos and DRuntime as shared...
Jul 12 2019
parent reply Andre Pany <andre s-e-a-p.de> writes:
On Friday, 12 July 2019 at 16:42:06 UTC, Andre Pany wrote:
 On Friday, 12 July 2019 at 16:37:05 UTC, Andre Pany wrote:
 Hi,
 If I remember correctly on linux (ubuntu) you can compile an 
 executable which uses and DRuntime as shared objects.

 How is the ldc2 command for this?
 I assume I can find the shared objects for phobos and DRuntime 
 in the ldc2 linux x86_64 release archive?

 Is there also an additional argument to strip any non used 
 symbols?

 Kind regards
 Andre
Should read ...which uses Phobos and DRuntime as shared...
I found it: ldc2 app.d -defaultlib=druntime-ldc-shared,phobos2-ldc-shared -debuglib=druntime-ldc-debug-shared,phobos2-ldc-debug-shared Kind regards Andre
Jul 12 2019
parent reply kinke <noone nowhere.com> writes:
On Friday, 12 July 2019 at 22:22:01 UTC, Andre Pany wrote:
 I found it:

 ldc2 app.d -defaultlib=druntime-ldc-shared,phobos2-ldc-shared 
 -debuglib=druntime-ldc-debug-shared,phobos2-ldc-debug-shared
`-link-defaultlib-shared` implies that and takes care of rpath as well.
Jul 16 2019
parent reply Andre Pany <andre s-e-a-p.de> writes:
On Tuesday, 16 July 2019 at 10:30:50 UTC, kinke wrote:
 On Friday, 12 July 2019 at 22:22:01 UTC, Andre Pany wrote:
 I found it:

 ldc2 app.d -defaultlib=druntime-ldc-shared,phobos2-ldc-shared 
 -debuglib=druntime-ldc-debug-shared,phobos2-ldc-debug-shared
`-link-defaultlib-shared` implies that and takes care of rpath as well.
Thanks a lot. Is it also easily possible to compile an application with DRuntime statically linked and completely without Phobos? Kind regards André
Jul 19 2019
parent reply kinke <noone nowhere.com> writes:
On Friday, 19 July 2019 at 11:28:26 UTC, Andre Pany wrote:
 Is it also easily possible to compile an
 application with DRuntime statically linked and completely
 without Phobos?
Sure, that's `-defaultlib=druntime-ldc`.
Jul 21 2019
parent Andre Pany <andre s-e-a-p.de> writes:
On Sunday, 21 July 2019 at 21:59:06 UTC, kinke wrote:
 On Friday, 19 July 2019 at 11:28:26 UTC, Andre Pany wrote:
 Is it also easily possible to compile an
 application with DRuntime statically linked and completely
 without Phobos?
Sure, that's `-defaultlib=druntime-ldc`.
Thanks again:) Kind regards Andre
Jul 21 2019
prev sibling parent CaitlinSmith <CaitlinSmith dooinfo.com> writes:
On Friday, 12 July 2019 at 16:37:05 UTC, Andre Pany wrote:
 Hi,
 If I remember correctly on linux (ubuntu) you can compile an 
 executable which uses and DRuntime as shared objects.

 How is the ldc2 command for this?
 I assume I can find the shared objects for phobos and DRuntime 
 in the ldc2 linux x86_64 release archive?

 Is there also an additional argument to strip any non used 
 symbols?

 Kind regards
 Andre
If you want to make more compression, then do it with UPX. The complete order of make extremelly compression are: strip.exe. UPX. ... Using upx should be sufficient to reduce (compress) size of executable file. Download and extract upx. Select the files you want to compress. Click Start compression Exact steps are here: https://docsbay.net/upx-how-to-reduce-executable-files-size
Jul 29 2019