March 03, 2014
On Monday, 3 March 2014 at 15:44:30 UTC, Jeroen Bollen wrote:
> On Monday, 3 March 2014 at 15:36:02 UTC, Daniel Murphy wrote:
>>
>> "Jeroen Bollen"  wrote in message news:unvhloslmpxvxhawypoq@forum.dlang.org...
>>
>>> How to stop DMD from linking against any libraries? A simple program like this already links to quite a few libraries:
>>
>> The easiest way is to link yourself.  You can run dmd with -v to get the link command and start from there.
>
> Cheers

Please be aware of
https://d.puremagic.com/issues/show_bug.cgi?id=12268 though
March 03, 2014
On Monday, 3 March 2014 at 16:21:25 UTC, Dicebot wrote:
> On Monday, 3 March 2014 at 15:44:30 UTC, Jeroen Bollen wrote:
>> On Monday, 3 March 2014 at 15:36:02 UTC, Daniel Murphy wrote:
>>>
>>> "Jeroen Bollen"  wrote in message news:unvhloslmpxvxhawypoq@forum.dlang.org...
>>>
>>>> How to stop DMD from linking against any libraries? A simple program like this already links to quite a few libraries:
>>>
>>> The easiest way is to link yourself.  You can run dmd with -v to get the link command and start from there.
>>
>> Cheers
>
> Please be aware of
> https://d.puremagic.com/issues/show_bug.cgi?id=12268 though

Is any sort of static linkage really necessary though?
March 03, 2014
On Monday, 3 March 2014 at 17:21:50 UTC, Jeroen Bollen wrote:
> On Monday, 3 March 2014 at 16:21:25 UTC, Dicebot wrote:
>>
>> Please be aware of
>> https://d.puremagic.com/issues/show_bug.cgi?id=12268 though
>
> Is any sort of static linkage really necessary though?

Seems like it is, without specifying the libraries I get an error:

app.o: In function `main':
app.d:(.text.main+0x13): undefined reference to `_d_run_main'
app.o:(.text.d_dso_init[.data.d_dso_rec]+0x32): undefined reference to `_d_dso_registry'
collect2: error: ld returned 1 exit status
March 03, 2014
Just realized that's probably the missing runtime. Why does it need a runtime though? It's just returning.
March 04, 2014
On Monday, 3 March 2014 at 19:03:20 UTC, Jeroen Bollen wrote:
> Just realized that's probably the missing runtime. Why does it need a runtime though? It's just returning.

There's some hidden references to the runtime outputted, especially when you write a D main, which adds references to d_run_main and other such stuff.

If you make it an extern(C) main instead of a regular D main, it gets rid of some of that, but it will still complain about the d_dso_registry thing (at least on Linux).

You can add a dummy "extern(C) void _d_dso_registry() {}" to it to hack past that too, but you probably shouldn't - going without the runtime is a fair amount of work for little practical benefit, though it can be pretty educational.

The definition of this function in druntime is src/rt/sections_linux.d

From that file:

/* For each shared library and executable, the compiler generates code that
 * sets up CompilerDSOData and calls _d_dso_registry().
 * A pointer to that code is inserted into both the .ctors and .dtors
 * segment so it gets called by the loader on startup and shutdown.
 */
extern(C) void _d_dso_registry(CompilerDSOData* data)

March 04, 2014
On Tuesday, 4 March 2014 at 01:22:15 UTC, Adam D. Ruppe wrote:
> On Monday, 3 March 2014 at 19:03:20 UTC, Jeroen Bollen wrote:
>> Just realized that's probably the missing runtime. Why does it need a runtime though? It's just returning.
>
> There's some hidden references to the runtime outputted, especially when you write a D main, which adds references to d_run_main and other such stuff.
>
> If you make it an extern(C) main instead of a regular D main, it gets rid of some of that, but it will still complain about the d_dso_registry thing (at least on Linux).
>
> You can add a dummy "extern(C) void _d_dso_registry() {}" to it to hack past that too, but you probably shouldn't - going without the runtime is a fair amount of work for little practical benefit, though it can be pretty educational.
>
> The definition of this function in druntime is src/rt/sections_linux.d
>
> From that file:
>
> /* For each shared library and executable, the compiler generates code that
>  * sets up CompilerDSOData and calls _d_dso_registry().
>  * A pointer to that code is inserted into both the .ctors and .dtors
>  * segment so it gets called by the loader on startup and shutdown.
>  */
> extern(C) void _d_dso_registry(CompilerDSOData* data)

What does the runtime actually do?
1 2
Next ›   Last »