digitalmars.D.learn - What exactly does the compiler switch -betterC do?
- Gary Willoughby (4/4) Jun 19 2016 When compiling, what exactly does the -betterC flag do? The
- docandrew (13/17) Jun 19 2016 My understanding was that -betterC was not fully implemented yet,
- Jacob Carlborg (19/22) Jun 19 2016 It is intended to allow you to link an application without druntime. A
- Gary Willoughby (11/33) Sep 19 2016 I get significantly more symbols than that when compiling the
- Jacob Carlborg (6/8) Sep 20 2016 Indeed. I just noticed now that there's a difference between 2.070.0 and...
- Gary Willoughby (3/10) Sep 26 2016 Filed: https://issues.dlang.org/show_bug.cgi?id=16547
- Martin Nowak (5/13) Oct 05 2016 Because you're linking with druntime/phobos which drags in plenty
- Jacob Carlborg (27/30) Oct 05 2016 No. There's a difference between DMD 2.070.0 and 2.071.0:
- Martin Nowak (8/9) Oct 06 2016 On Wednesday, 5 October 2016 at 12:42:14 UTC
- Anonymouse (2/10) Sep 20 2016 What is the equavilent in gdc and ldc?
- Jacob Carlborg (4/8) Sep 20 2016 No idea, try ldc/gdc --help ;)
When compiling, what exactly does the -betterC flag do? The command help says "omit generating some runtime information and helper functions" but what does this really mean? Is there any specifics somewhere?
Jun 19 2016
On Sunday, 19 June 2016 at 19:53:46 UTC, Gary Willoughby wrote:When compiling, what exactly does the -betterC flag do? The command help says "omit generating some runtime information and helper functions" but what does this really mean? Is there any specifics somewhere?My understanding was that -betterC was not fully implemented yet, due mostly to tight compiler integration with the runtime. (old info?) I'm not super smart on the DMD source, but it looks like betterC prevents genhelpers() and genModuleInfo() from being called, with "helpers" appearing to be array checking, asserts and unit tests. A comparison of object files compiled with and without the flags shows just a small reduction in the size of the code, but grepping for bounds checking, unit tests and ModuleInfo in the -betterC generated object file shows they are missing. Hope this helps, -Jon
Jun 19 2016
On 2016-06-19 21:53, Gary Willoughby wrote:When compiling, what exactly does the -betterC flag do? The command help says "omit generating some runtime information and helper functions" but what does this really mean? Is there any specifics somewhere?It is intended to allow you to link an application without druntime. A Hello World using "extern(C) main" and printing using "printf" contains the following symbols on OS X: 00000000000000a8 S _D4main12__ModuleInfoZ 0000000000000068 T _D4main15__unittest_failFiZv 0000000000000018 T _D4main7__arrayZ 0000000000000040 T _D4main8__assertFiZv 00000000000000b5 s _TMP1 U __d_arraybounds U __d_assert U __d_unittest 0000000000000000 T _main U _printf If compiled with -betterC, it contains these: 0000000000000000 T _main U _printf -- /Jacob Carlborg
Jun 19 2016
On Monday, 20 June 2016 at 06:35:32 UTC, Jacob Carlborg wrote:On 2016-06-19 21:53, Gary Willoughby wrote:I get significantly more symbols than that when compiling the following program any idea why? import core.stdc.stdio; extern(C) void main() { printf("Hello World!\n"); } $ rdmd --build-only --force -betterC -de -O -inline -release -w test.d $ nm testWhen compiling, what exactly does the -betterC flag do? The command help says "omit generating some runtime information and helper functions" but what does this really mean? Is there any specifics somewhere?It is intended to allow you to link an application without druntime. A Hello World using "extern(C) main" and printing using "printf" contains the following symbols on OS X: 00000000000000a8 S _D4main12__ModuleInfoZ 0000000000000068 T _D4main15__unittest_failFiZv 0000000000000018 T _D4main7__arrayZ 0000000000000040 T _D4main8__assertFiZv 00000000000000b5 s _TMP1 U __d_arraybounds U __d_assert U __d_unittest 0000000000000000 T _main U _printf If compiled with -betterC, it contains these: 0000000000000000 T _main U _printf
Sep 19 2016
On 2016-09-19 23:09, Gary Willoughby wrote:$ rdmd --build-only --force -betterC -de -O -inline -release -w test.d $ nm testIndeed. I just noticed now that there's a difference between 2.070.0 and 2.071.0. I get 4 symbols with 2.070.0 and 2428 with 2.071.0. I would say it's a bug. -- /Jacob Carlborg
Sep 20 2016
On Tuesday, 20 September 2016 at 13:23:35 UTC, Jacob Carlborg wrote:On 2016-09-19 23:09, Gary Willoughby wrote:Filed: https://issues.dlang.org/show_bug.cgi?id=16547$ rdmd --build-only --force -betterC -de -O -inline -release -w test.d $ nm testIndeed. I just noticed now that there's a difference between 2.070.0 and 2.071.0. I get 4 symbols with 2.070.0 and 2428 with 2.071.0. I would say it's a bug.
Sep 26 2016
On Monday, 19 September 2016 at 21:09:39 UTC, Gary Willoughby wrote:On Monday, 20 June 2016 at 06:35:32 UTC, Jacob Carlborg wrote:Because you're linking with druntime/phobos which drags in plenty of symbols (including a GC). Also Jakob is showing the symbols of the object file, not executable.On 2016-06-19 21:53, Gary Willoughby wrote: If compiled with -betterC, it contains these: 0000000000000000 T _main U _printfI get significantly more symbols than that when compiling the following program any idea why?
Oct 05 2016
On 2016-10-05 11:39, Martin Nowak wrote:Because you're linking with druntime/phobos which drags in plenty of symbols (including a GC). Also Jakob is showing the symbols of the object file, not executable.No. There's a difference between DMD 2.070.0 and 2.071.0: $ cat main.d module main; extern (C) int printf(in char*, ...); extern (C) void main() { printf("asd\n"); } $ dvm use 2.070.0 $ dmd --version DMD64 D Compiler v2.070.0 Copyright (c) 1999-2015 by Digital Mars written by Walter Bright $ dmd -betterC main.d $ nm main | wc -l 4 $ dvm use 2.071.0 $ dmd --version DMD64 D Compiler v2.071.0 Copyright (c) 1999-2015 by Digital Mars written by Walter Bright $ dmd -betterC main.d $ nm main | wc -l 2428 Note that "main" is declared as "extern (C)", which makes all the difference. -- /Jacob Carlborg
Oct 05 2016
On Wednesday, 5 October 2016 at 12:42:14 UTC On Wednesday, 5 October 2016 at 12:42:14 UTC, Jacob Carlborg wrote:No. There's a difference between DMD 2.070.0 and 2.071.0:OK, I'll retry on OSX, the bug report said Linux though. Seems like we're dragging in all of the _Dmain stuff. IIRC _Dmain is marked as weak in some extra C file, but the problem might be unrelated to that. https://issues.dlang.org/show_bug.cgi?id=16547
Oct 06 2016
On Monday, 20 June 2016 at 06:35:32 UTC, Jacob Carlborg wrote:On 2016-06-19 21:53, Gary Willoughby wrote:What is the equavilent in gdc and ldc?When compiling, what exactly does the -betterC flag do? The command help says "omit generating some runtime information and helper functions" but what does this really mean? Is there any specifics somewhere?It is intended to allow you to link an application without druntime. [...]
Sep 20 2016
On 2016-09-21 02:25, Anonymouse wrote:On Monday, 20 June 2016 at 06:35:32 UTC, Jacob Carlborg wrote:No idea, try ldc/gdc --help ;) -- /Jacob CarlborgIt is intended to allow you to link an application without druntime. [...]What is the equavilent in gdc and ldc?
Sep 20 2016