Re: porting to amd64-freebsd

[email protected]
Newsgroups gmane.comp.lang.dylan.gwydion.devel
Message-ID <op.wqsnsdhd2wakfp@lenovo-b0c22c0d>
Hello,

On Sat, 12 Jan 2013 17:43:29 +0900, Bruce Mitchener  
<[email protected]> wrote:

> Hello!
>
>
> On Sat, Jan 12, 2013 at 2:15 PM, <[email protected]> wrote:
>
>> hi hackers,
>>
>> I'm porting OpenDylan to FreeBSD-amd64. I've found the problem about
>> boehm-gc, and I've fixed it.
>> then I currently succeeded build the Bootstrap.1/bin/dylan-**
>> compiler(elf64).
>> next step, I'm trying to build the dylan-compiler using
>> Bootstrap.1/bin/dylan-**compiler.
>> But, I've got a SIGSEGV in compiling dfmc-reader.
>>
>
> Probably the most important thing right now is to understand what you've
> done and how you're trying to do the build.

> What was the problem with Boehm GC?
ports/devel/boehm-gc-threading(Boehm GC 7.1) does not scan static roots in  
the shared object.
I've fixed it.(patch attached)
without this patch. stage1 compiler aborts in initialization phase.

> Are you starting with a working 32 bit build of OpenDylan on FreeBSD or  
> are
> you trying to use the last / very old amd64-freebsd build?
I have been startd with latest FreeBSD-x86(32bit) dylan-compiler.

I explain the procedure what I have done.

1 I have get opendylan-2012.1-x86-freebsd.tar.bz2 and latest git source.
2 layout of working directory is
   ${TOP}/opendylan-2012.1-x86-freebsd
   ${TOP}/opendylay      (git clone and do autogen.sh)
   ${TOP}/build
3 create sources/jamfiles/amd64-freebsd-build.jam
include $(SYSTEM_ROOT)/lib/config.jam ;
RTOBJS_llvm ?= ;
CCFLAGS  += -DOPEN_DYLAN_PLATFORM_UNIX -DOPEN_DYLAN_PLATFORM_FREEBSD ;
LINKFLAGSEXE ?= -Wl,-z,origin -Wl,-rpath,\\$ORIGIN/../lib/ ;
include $(SYSTEM_ROOT)/lib/posix-build.jam ;
rtclibs += -lpthread -lrt ;
4 modyfy Makefiles to refer amd64-freebsd-build.jam.
5 at ${TOP}/build  configure the source
    DYLANCOMPILER="dylan-compiler -build" CPPFLAGS=-I/usr/local/include  
LDFLAGS=-L/usr/local/lib ../opendylan/configure --with-gc=/usr/local
6 build stage1 compiler using  
opendylan-2012.1-x86-freebsd/bin/dylan-compiler
    DYLANCOMPILER="env  
LD_LIBRARY_PATH=\$(abs_builddir)/opendylan-2012.1/lib  
\$(abs_builddir)/../opendylan-2012.1/bin/dylan-compiler -build  
-build-script \$(abs_builddir)/bootstage1-build.jam"
    gmake bootstrap-stage-1 DYLANCOMPILER="$DYLANCOMPILER"
    I have get 64bit Bootstrap.1/bin/dylan-compiler
    bootstage1-build.jam is attached
7 gmake 3-stage-bootstrap
    this skip building  the stage1 compiler. the SIGSEGV is occured in this  
step.

> The error below sounds, I think, like an error from using 32 bit DOOD on  
> a
> 64 bit platform. That's just a vague memory though.
I think this is an  an important hint. I will check DOOD's data struct and  
procedure which you suggested me.

--
HIROSHI OOTA

_______________________________________________
hackers mailing list
[email protected]
https://lists.opendylan.org/mailman/listinfo/hackers
gc-7.1__dyn_load.c (application/octet-stream, 1.4 KB)
--- dyn_load.c-	2013-01-07 11:47:37.692122307 +0900
+++ dyn_load.c	2013-01-11 17:58:07.623141180 +0900
@@ -88,6 +88,9 @@ static int (*GC_has_static_roots)(const 
 #   include <stddef.h>
 #   include <elf.h>
 #   include <link.h>
+#if defined(FREEBSD)
+#   include <dlfcn.h>
+#endif
 #endif
 
 /* Newer versions of GNU/Linux define this macro.  We
@@ -497,6 +500,7 @@ extern ElfW(Dyn) _DYNAMIC[];
 
 static struct link_map *
 GC_FirstDLOpenedLinkMap()
+#if !defined(FREEBSD)
 {
     ElfW(Dyn) *dp;
     static struct link_map *cachedResult = 0;
@@ -517,7 +521,21 @@ GC_FirstDLOpenedLinkMap()
     }
     return cachedResult;
 }
-
+#else
+{
+    static struct link_map *cachedResult = 0;
+    if (cachedResult == 0) {
+	void *p;
+#undef dlopen
+	if ((p = dlopen(NULL, RTLD_NOW | RTLD_NOLOAD)) != NULL) {
+#define dlopen done!call!me
+	    dlinfo(p, RTLD_DI_LINKMAP, &cachedResult);
+	    dlclose(p);
+	}
+    }
+    return cachedResult;
+}
+#endif
 
 void GC_register_dynamic_libraries()
 {
@@ -541,7 +559,13 @@ void GC_register_dynamic_libraries()
         
 	e = (ElfW(Ehdr) *) lm->l_addr;
         p = ((ElfW(Phdr) *)(((char *)(e)) + e->e_phoff));
+#if defined(FREEBSD)
+	if (lm == GC_FirstDLOpenedLinkMap())
+	  offset = 0;
+	else
+#endif
         offset = ((unsigned long)(lm->l_addr));
+
         for( i = 0; i < (int)(e->e_phnum); ((i++),(p++)) ) {
           switch( p->p_type ) {
             case PT_LOAD:
bootstage1-build.jam (application/octet-stream, 702 B) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.