Last active
December 11, 2015 02:59
-
-
Save h2oota/4534856 to your computer and use it in GitHub Desktop.
Building OpenDylan on FreeBSD-amd64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Generated config | |
# | |
# | |
# This Jam file is generated by the configure script | |
# | |
BUILDDIR = ABSOLUTE_PATH_FOR_BUILD_DIRECTORY ; | |
CC ?= clang ; | |
CCFLAGS ?= -I$(BUILDDIR)/Bootstrap.1/include -w -g -O0 -fno-inline -pthread ; | |
GC_CFLAGS ?= -DGC_USE_BOEHM -DGC_THREADS -I/usr/local/include ; | |
GC_LFLAGS ?= -L/usr/local/lib -lgc-threaded ; | |
GC_USE_STATIC_BOEHM ?= false ; | |
# | |
# Configuration variables | |
# | |
CCFLAGS += -DOPEN_DYLAN_PLATFORM_UNIX -DOPEN_DYLAN_PLATFORM_FREEBSD ; | |
# | |
# Library search path | |
# | |
LINKFLAGSEXE ?= -Wl,-z,origin -Wl,-rpath,\\$ORIGIN/../lib/ -pthread ; | |
# | |
# Common build script | |
# | |
rtlibs = $(BUILDDIR)/Bootstrap.1/lib/runtime/c-amd64-freebsd/libdylan-c-runtime.a ; | |
include $(SYSTEM_ROOT)/lib/posix-build.jam ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Building OpenDylan on FreeBSD amd64 | |
=================================== | |
Install tools | |
------------- | |
devel/autoconf, devel/gmake | |
Install Boehm-GC | |
---------------- | |
+ put the patch into ports/devel/boehm-gc-threaded/files/patch-~~~__dyn_load.c | |
+ install ports | |
directory layout | |
---------------- | |
${TOP}/opendylan -- the git local repository | |
${TOP}/opendylan-2012.1 -- precompiled opendylan for FreeBSD x86 | |
${TOP}/build -- work directory | |
prepare files | |
------------- | |
1 get precompiled dylan-compiler for x86-freebsd | |
+ get http://opendylan.org/downloads/opendylan/2012.1/opendylan-2012.1-x86-freebsd.tar.bz2 | |
+ extract it. | |
2 Clone the git repository:: | |
+ git clone git://github.com/dylan-lang/opendylan.git --recursive | |
+ cd opendylan && ./autogen.sh | |
3 create build directory and put support files | |
mkdir ${TOP}/build | |
copy bootstrap1.sh into ${TOP}/build/bootstrap1.sh | |
copy bootstage1-build.jam into ${TOP}/build/bootstage1-build.jam | |
edit bootstage1-build.jam | |
BUILDDIR = ABSOLUTE_PATH_FOR_BUILD_DIRECTORY ; | |
build bootstrap1 compiler | |
------------------------- | |
1 goto ${TOP}/build | |
2 configure source | |
$ DYLANCOMPILER="dylan-compiler -build" CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ../opendylan/configure --with-gc=/usr/local | |
3 sh bootstrap1.sh | |
build everything | |
---------------- | |
1 goto ${TOP}/build | |
2 gmake 3-stage-bootstrap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- 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: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment