any patch for LDC compiler on freebsd 8/amd64?

7 views
Skip to first unread message

strin...@gmail.com

unread,
Mar 6, 2009, 4:32:45 AM3/6/09
to LDC - the LLVM D compiler
I'am trying to build llvmdc on freebsd8/amd64. make ldc works well
with following patch.but I can't make runtime. rt_stackBottom() in ldc/
runtime/internal/memory.d(91) can't compile.

diff -r cc6489f32519 dmd/mtype.c
--- a/dmd/mtype.c Thu Mar 05 21:32:18 2009 +0100
+++ b/dmd/mtype.c Fri Mar 06 17:22:32 2009 +0800
@@ -41,6 +41,9 @@
static double zero = 0;
#elif __MINGW32__
static double zero = 0;
+#elif __FreeBSD__
+#include <math.h>
+static double zero = 0;
#elif __GNUC__
#if !(defined (__SVR4) && defined (__sun))
#include <bits/nan.h>

Christian Kamm

unread,
Mar 7, 2009, 3:20:00 PM3/7/09
to ldc...@googlegroups.com
On Friday 06 March 2009 10:32 strin...@gmail.com wrote:
> I'am trying to build llvmdc on freebsd8/amd64. make ldc works well
> with following patch.but I can't make runtime. rt_stackBottom() in ldc/
> runtime/internal/memory.d(91) can't compile.

No, while there's basic support for FreeBSD, it's not yet usable. As you've
noticed, the runtime, in particular memory.d, still need quite a bit of work.
If you're interested in getting this to work, I recommend you take a look at
GDC's memory.d - as far as I remember it has some FreeBSD code.

signature.asc

strin...@gmail.com

unread,
Mar 9, 2009, 5:22:42 AM3/9/09
to LDC - the LLVM D compiler


On Mar 8, 4:20 am, Christian Kamm <k...@incasoftware.de> wrote:
Yes,I noticed as far as i found the error.The functions seems
simple.but how to add a dependence in cmake's configure files?And void
initStaticDataPtrs() in runtime/internal/memory.d(322) also need work
(Maybe it can works like tango/gdc's initStaticDataPtrs).

----------------------------------------------------------------------------------------------------------
--- a/runtime/internal/memory.d Mon Mar 09 03:44:11 2009 +0100
+++ b/runtime/internal/memory.d Mon Mar 09 17:14:03 2009 +0800
@@ -135,6 +135,15 @@
return cast(void*) 0x8048000;
}
}
+ else version( freebsd )
+ {
+ void* stack_origin;
+
+ if( _d_gc_freebsd_stack(&stack_origin) )
+ return stack_origin;
+ else // No way to signal an error
+ return null;
+ }
else
{
static assert( false, "Operating system not supported." );


------freebsd_gc.c------------------
#include <unistd.h>
#include <sys/types.h>
#include <sys/sysctl.h>

int _d_gcc_gc_freebsd_stack(void ** out_origin)
{
int nm[2] = {CTL_KERN, KERN_USRSTACK};
size_t len = sizeof(void *);
int r = sysctl(nm, 2, out_origin, &len, NULL, 0);

return ! r;
}

Christian Kamm

unread,
Mar 10, 2009, 3:13:23 AM3/10/09
to ldc...@googlegroups.com
> Yes,I noticed as far as i found the error.The functions seems
> simple.but how to add a dependence in cmake's configure files?And void
> initStaticDataPtrs() in runtime/internal/memory.d(322) also need work
> (Maybe it can works like tango/gdc's initStaticDataPtrs).

Thanks for the patch! Yes, initStaticDataPtrs is the other function in
memory.d that will need adjustments for FreeBSD. If you want shared library
support, the /proc/self/maps parsing code may need to be updated too.

To avoid introducing another C file dependency to the runtime, I'd like to
rewrite freebsd_gc.c in D. I will be busy for the few next days, but if you do
it and send in the updated patch, I'll apply it as it comes in.

signature.asc
Reply all
Reply to author
Forward
0 new messages