Re: What exactly does the compiler switch -betterC do?

2016-10-06 Thread Martin Nowak via Digitalmars-d-learn

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


Re: What exactly does the compiler switch -betterC do?

2016-10-05 Thread Jacob Carlborg via Digitalmars-d-learn

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


Re: What exactly does the compiler switch -betterC do?

2016-10-05 Thread Martin Nowak via Digitalmars-d-learn
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:

On 2016-06-19 21:53, Gary Willoughby wrote:
If compiled with -betterC, it contains these:

 T _main
 U _printf


I get significantly more symbols than that when compiling the 
following program any idea why?


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.


Re: What exactly does the compiler switch -betterC do?

2016-09-26 Thread Gary Willoughby via Digitalmars-d-learn
On Tuesday, 20 September 2016 at 13:23:35 UTC, Jacob Carlborg 
wrote:

On 2016-09-19 23:09, Gary Willoughby wrote:

$ rdmd --build-only --force -betterC -de -O -inline -release 
-w test.d

$ nm test


Indeed. 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.


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


Re: What exactly does the compiler switch -betterC do?

2016-09-20 Thread Jacob Carlborg via Digitalmars-d-learn

On 2016-09-21 02:25, Anonymouse wrote:

On Monday, 20 June 2016 at 06:35:32 UTC, Jacob Carlborg wrote:

It is intended to allow you to link an application without druntime.
[...]


What is the equavilent in gdc and ldc?


No idea, try ldc/gdc --help ;)

--
/Jacob Carlborg


Re: What exactly does the compiler switch -betterC do?

2016-09-20 Thread Anonymouse via Digitalmars-d-learn

On Monday, 20 June 2016 at 06:35:32 UTC, Jacob Carlborg wrote:

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. [...]


What is the equavilent in gdc and ldc?




Re: What exactly does the compiler switch -betterC do?

2016-09-20 Thread Jacob Carlborg via Digitalmars-d-learn

On 2016-09-19 23:09, Gary Willoughby wrote:


$ rdmd --build-only --force -betterC -de -O -inline -release -w test.d
$ nm test


Indeed. 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


Re: What exactly does the compiler switch -betterC do?

2016-09-19 Thread Gary Willoughby via Digitalmars-d-learn

On Monday, 20 June 2016 at 06:35:32 UTC, Jacob Carlborg wrote:

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:


00a8 S _D4main12__ModuleInfoZ
0068 T _D4main15__unittest_failFiZv
0018 T _D4main7__arrayZ
0040 T _D4main8__assertFiZv
00b5 s _TMP1
 U __d_arraybounds
 U __d_assert
 U __d_unittest
 T _main
 U _printf

If compiled with -betterC, it contains these:

 T _main
 U _printf


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 test



Re: What exactly does the compiler switch -betterC do?

2016-06-19 Thread Jacob Carlborg via Digitalmars-d-learn

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:


00a8 S _D4main12__ModuleInfoZ
0068 T _D4main15__unittest_failFiZv
0018 T _D4main7__arrayZ
0040 T _D4main8__assertFiZv
00b5 s _TMP1
 U __d_arraybounds
 U __d_assert
 U __d_unittest
 T _main
 U _printf

If compiled with -betterC, it contains these:

 T _main
 U _printf
--
/Jacob Carlborg


Re: What exactly does the compiler switch -betterC do?

2016-06-19 Thread docandrew via Digitalmars-d-learn

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