View mode: basic / threaded / horizontal-split · Log in · Help
July 06, 2012
Re: LDC -noruntime
On Friday, 6 July 2012 at 09:38:13 UTC, Jacob Carlborg wrote:
> It will not prevent the compiler for generating calls to the 
> runtime.

It should – TypeInfo references will still be generated, though.

> So if you see calls to runtime functions you need to stub them 
> out as Alex suggested or try to find a way to avoid them. Note 
> that the compiler will link with the standard library by 
> default as well. I don't know if the -noruntime flag prevents 
> that.

This is a good point – it doesn't. Use -nodefaultlib (LDC's 
-defaultlib switch works a bit differently than DMD's in that it 
appends to a list of default libs instead of replacing, this 
should imho be fixed).

David
July 06, 2012
Re: LDC -noruntime
I swear you guys read my mind sometimes...  It's creepy.

I just had this very issue, doing the exact same thing, about an hour ago.

Have you tried with -nodefaultlib -noruntime ?  Cause that's what works  
for me...

I just got *something* to compile with no runtime or std.
Whether or not it actually does anything remains to be seen.


On Fri, 06 Jul 2012 01:53:10 -0500, BLM768 <blm768@gmail.com> wrote:

> I've been trying to write an OS kernel in D, and I'm having issues with  
> the runtime. I'm trying to use LDC's -noruntime option, which is  
> _supposed_ to prevent any runtime calls from being generated, but the  
> linker keeps complaining about unresolved references to _d_assert_msg  
> and other runtime functions. It seems that LDC is ignoring the switch  
> and is generating runtime references anyway. Is there some other way to  
> force it to stop trying to pull in the runtime? I'd rather not have to  
> create/link a custom runtime at this point; I don't even have a memory  
> allocator written, so I really don't want to mess with a runtime yet.


-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/
July 07, 2012
Re: LDC -noruntime
On Friday, 6 July 2012 at 21:54:15 UTC, 1100110 wrote:
> I swear you guys read my mind sometimes...  It's creepy.
>
> I just had this very issue, doing the exact same thing, about 
> an hour ago.
>
> Have you tried with -nodefaultlib -noruntime ?  Cause that's 
> what works for me...
>
> I just got *something* to compile with no runtime or std.
> Whether or not it actually does anything remains to be seen.
>
>

No luck; it still references the runtime.
I've been stubbing out the runtime; it seems to be about done 
except for references to some functions I can't find. The symbols 
are __moddi3 and __divdi3; I assume they're C math library 
functions, as they're generated from code that uses div/mod 
operations. It also seems to be unable to properly find 
Object.toString() after I changed it to be nothrow, which I 
needed to do because I'm stubbing out the exception handling 
routines; it seems to have changed the mangling. It's a bit of a 
mess in there; I'm glad I don't always have to hack up the 
runtime :).
July 07, 2012
Re: LDC -noruntime
On Saturday, July 07, 2012 05:45:53 BLM768 wrote:
> On Friday, 6 July 2012 at 21:54:15 UTC, 1100110 wrote:
> > I swear you guys read my mind sometimes...  It's creepy.
> > 
> > I just had this very issue, doing the exact same thing, about
> > an hour ago.
> > 
> > Have you tried with -nodefaultlib -noruntime ?  Cause that's
> > what works for me...
> > 
> > I just got *something* to compile with no runtime or std.
> > Whether or not it actually does anything remains to be seen.
> 
> No luck; it still references the runtime.
> I've been stubbing out the runtime; it seems to be about done
> except for references to some functions I can't find. The symbols
> are __moddi3 and __divdi3; I assume they're C math library
> functions, as they're generated from code that uses div/mod
> operations. It also seems to be unable to properly find
> Object.toString() after I changed it to be nothrow, which I
> needed to do because I'm stubbing out the exception handling
> routines; it seems to have changed the mangling. It's a bit of a
> mess in there; I'm glad I don't always have to hack up the
> runtime :).

Yes. nothrow is part of the name mangling, because it's part of the signature. 
In the long run, toString will be @safe const pure nothrow, but it's not there 
quite yet (const correctness and Object is still being sorted out would be one 
reason; a number of key string-related functions need to become pure for 
another). But if the compiler is expecting a specific signature, then that's 
the signature that you're going to have to give it, or the linker's not going 
to find the function when it goes to look for it.

- Jonathan M Davis
July 07, 2012
Re: LDC -noruntime
Wow, I haven't had that much trouble.  But I've tried to keep everything
at my level.  It's about half xomb. =P

I salute you for your bravery.

I had planned to stay far, far away from as much of that as I could.



On Fri, 06 Jul 2012 22:45:53 -0500, BLM768 <blm768@gmail.com> wrote:

> On Friday, 6 July 2012 at 21:54:15 UTC, 1100110 wrote:
>> I swear you guys read my mind sometimes...  It's creepy.
>>
>> I just had this very issue, doing the exact same thing, about an hour  
>> ago.
>>
>> Have you tried with -nodefaultlib -noruntime ?  Cause that's what works  
>> for me...
>>
>> I just got *something* to compile with no runtime or std.
>> Whether or not it actually does anything remains to be seen.
>>
>>
>
> No luck; it still references the runtime.
> I've been stubbing out the runtime; it seems to be about done except for  
> references to some functions I can't find. The symbols are __moddi3 and  
> __divdi3; I assume they're C math library functions, as they're  
> generated from code that uses div/mod operations. It also seems to be  
> unable to properly find Object.toString() after I changed it to be  
> nothrow, which I needed to do because I'm stubbing out the exception  
> handling routines; it seems to have changed the mangling. It's a bit of  
> a mess in there; I'm glad I don't always have to hack up the runtime :).
>
>


-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/
July 07, 2012
Re: LDC -noruntime
On 07-07-2012 06:26, Jonathan M Davis wrote:
> On Saturday, July 07, 2012 05:45:53 BLM768 wrote:
>> On Friday, 6 July 2012 at 21:54:15 UTC, 1100110 wrote:
>>> I swear you guys read my mind sometimes...  It's creepy.
>>>
>>> I just had this very issue, doing the exact same thing, about
>>> an hour ago.
>>>
>>> Have you tried with -nodefaultlib -noruntime ?  Cause that's
>>> what works for me...
>>>
>>> I just got *something* to compile with no runtime or std.
>>> Whether or not it actually does anything remains to be seen.
>>
>> No luck; it still references the runtime.
>> I've been stubbing out the runtime; it seems to be about done
>> except for references to some functions I can't find. The symbols
>> are __moddi3 and __divdi3; I assume they're C math library
>> functions, as they're generated from code that uses div/mod
>> operations. It also seems to be unable to properly find
>> Object.toString() after I changed it to be nothrow, which I
>> needed to do because I'm stubbing out the exception handling
>> routines; it seems to have changed the mangling. It's a bit of a
>> mess in there; I'm glad I don't always have to hack up the
>> runtime :).
>
> Yes. nothrow is part of the name mangling, because it's part of the signature.
> In the long run, toString will be @safe const pure nothrow, but it's not there
> quite yet (const correctness and Object is still being sorted out would be one
> reason; a number of key string-related functions need to become pure for
> another). But if the compiler is expecting a specific signature, then that's
> the signature that you're going to have to give it, or the linker's not going
> to find the function when it goes to look for it.
>
> - Jonathan M Davis
>

Is overriding a @safe function with @trusted allowed/meant to be 
allowed? I hope so, otherwise this is going to be a severe limitation.

-- 
Alex Rønne Petersen
alex@lycus.org
http://lycus.org
July 07, 2012
Re: LDC -noruntime
On Saturday, 7 July 2012 at 04:27:07 UTC, Jonathan M Davis wrote:
> On Saturday, July 07, 2012 05:45:53 BLM768 wrote:
>> On Friday, 6 July 2012 at 21:54:15 UTC, 1100110 wrote:
>> > I swear you guys read my mind sometimes...  It's creepy.
>> > 
>> > I just had this very issue, doing the exact same thing, about
>> > an hour ago.
>> > 
>> > Have you tried with -nodefaultlib -noruntime ?  Cause that's
>> > what works for me...
>> > 
>> > I just got *something* to compile with no runtime or std.
>> > Whether or not it actually does anything remains to be seen.
>> 
>> No luck; it still references the runtime.
>> I've been stubbing out the runtime; it seems to be about done
>> except for references to some functions I can't find. The 
>> symbols
>> are __moddi3 and __divdi3; I assume they're C math library
>> functions, as they're generated from code that uses div/mod
>> operations. It also seems to be unable to properly find
>> Object.toString() after I changed it to be nothrow, which I
>> needed to do because I'm stubbing out the exception handling
>> routines; it seems to have changed the mangling. It's a bit of 
>> a
>> mess in there; I'm glad I don't always have to hack up the
>> runtime :).
>
> Yes. nothrow is part of the name mangling, because it's part of 
> the signature.
> In the long run, toString will be @safe const pure nothrow, but 
> it's not there
> quite yet (const correctness and Object is still being sorted 
> out would be one
> reason; a number of key string-related functions need to become 
> pure for
> another). But if the compiler is expecting a specific 
> signature, then that's
> the signature that you're going to have to give it, or the 
> linker's not going
> to find the function when it goes to look for it.
>
> - Jonathan M Davis

The problem is that if I leave the try/catch block, it's 
referring to stubbed-out functions, and if I get rid of it, LDC 
complains that toString() isn't nothrow. I guess I'd just better 
leave it in and hope that toString() never gets called. I could 
throw in an assert(false), which I'll have wired up to just cause 
a kernel panic.
July 07, 2012
Re: LDC -noruntime
On Saturday, July 07, 2012 07:27:52 Alex Rønne Petersen wrote:
> Is overriding a @safe function with @trusted allowed/meant to be
> allowed? I hope so, otherwise this is going to be a severe limitation.

Well, an overriding function in a derived class cannot be any looser than the 
one it's overriding in the base class, but @trusted is essentially the same as 
@safe from the caller's perspective, so I would expect it to work (I wouldn't 
expect @system to work though, since that _is_ looser). In fact, I'm pretty 
sure that there was a post about it not too long ago where someone was having 
issues because the function in a derived class was inferred as @safe, and they 
had to mark it as @trusted to get it to work. So, I think that you're fine on 
that count. However, even if you _couldn't_ override an @safe function with an 
@trusted one for some reason, all you would have to do is create a helper 
function which was @trusted, and you could get around the limitation quite 
easily.

- Jonathan M Davis
July 07, 2012
Re: LDC -noruntime
On 2012-07-06 21:42, David Nadlinger wrote:
> On Friday, 6 July 2012 at 09:38:13 UTC, Jacob Carlborg wrote:
>> It will not prevent the compiler for generating calls to the runtime.
>
> It should – TypeInfo references will still be generated, though.

So what happens with code like this:

auto o = new Object;

It won't generate any code for that? Then what happens with "o", 
uninitialized?

-- 
/Jacob Carlborg
Next ›   Last »
1 2
Top | Discussion index | About this forum | D home