SapphireDensetsu / ypsilon

Automatically exported from code.google.com/p/ypsilon
Other
0 stars 0 forks source link

ypsilon must be explicitly linked against libdl on Debian GNU/kFreeBSD #103

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
ypsilon currently fails to build from source when using a FreeBSD kernel
and a GNU userland on Debian GNU/kFreeBSD.

g++ -m32 -pthread -o ypsilon file.o main.o vm0.o object_heap_compact.o
subr_flonum.o vm1.o object_set.o subr_hash.o vm2.o object_slab.o
subr_list.o interpreter.o serialize.o vm3.o port.o subr_others.o arith.o
printer.o subr_port.o subr_r5rs_arith.o equiv.o reader.o ffi.o subr_base.o
bag.o subr_unicode.o hash.o subr_base_arith.o ucs4.o ioerror.o
subr_bitwise.o utf8.o subr_bvector.o violation.o object_factory.o
subr_ffi.o object_heap.o subr_fixnum.o bit.o list.o fasl.o socket.o
subr_socket.o ffi_stub_freebsd.o
file.o: In function `load_shared_object(scm_string_rec_t*)':
file.cpp:(.text+0x6a): undefined reference to `dlopen'
file.o: In function `last_shared_object_error()':
file.cpp:(.text+0x1): undefined reference to `dlerror'
file.o: In function `lookup_shared_object(void*, void*)':
file.cpp:(.text+0x2e): undefined reference to `dlsym'
file.cpp:(.text+0x3f): undefined reference to `dlsym'
file.cpp:(.text+0x50): undefined reference to `dlsym'
collect2: ld returned 1 exit status
make: *** [ypsilon] Error 1

This is solved by explicitly linking ypsilon against libdl:

diff --git a/Makefile b/Makefile
index 5dc7ab1..abfb259 100644
--- a/Makefile
+++ b/Makefile
@@ -68,13 +68,13 @@ ifneq (, $(findstring FreeBSD, $(UNAME)))
   ifeq ($(DATAMODEL), ILP32)  
     CPPFLAGS += -DDEFAULT_HEAP_LIMIT=32
     CXXFLAGS += -m32
-    LDFLAGS = -m32
+    LDFLAGS = -m32 -ldl
     ASFLAGS = --32
     SRCS += ffi_stub_freebsd.s
   else
     CPPFLAGS += -DDEFAULT_HEAP_LIMIT=64
     CXXFLAGS += -m64
-    LDFLAGS = -m64
+    LDFLAGS = -m64 -ldl
     ASFLAGS = --64
     SRCS += ffi_stub_freebsd64.s
   endif

Please note that I do NOT have access to a pure FreeBSD system to test this
patch on. There is a tiny probability that this might not work on normal
FreeBSD, but it is at least definitely needed on Debian GNU/kFreeBSD.

Regards,
Daniel

Original issue reported on code.google.com by dmoer...@gmail.com on 2 Jun 2009 at 4:23

GoogleCodeExporter commented 8 years ago
Sorry, inelegant patch, this is better:

Index: Makefile
===================================================================
--- Makefile    (revision 484)
+++ Makefile    (working copy)
@@ -136,7 +136,7 @@
     ASFLAGS = --64
     SRCS += ffi_stub_freebsd64.s
   endif
-  LDLIBS = -pthread
+  LDLIBS = -pthread -ldl
 endif

 ifneq (,$(findstring OpenBSD, $(UNAME)))

Original comment by dmoer...@gmail.com on 2 Jun 2009 at 4:32

GoogleCodeExporter commented 8 years ago
Thank you for your message. :-)
I have updated Makefile and trunk directory updated to revision 486.
Please try. Thank you!
-- fujita

Original comment by y.fujita...@gmail.com on 2 Jun 2009 at 1:43

GoogleCodeExporter commented 8 years ago
Just to clear this up, on FreeBSD the missing `dlsym' is actually a part of 
libc.

Original comment by vmage...@gmail.com on 2 Jun 2009 at 2:20

GoogleCodeExporter commented 8 years ago
In addition, libdl is also part of libc on Linux, so there wasn't a reason for 
-ldl
to be absent from FreeBSD but present in Linux.

Original comment by dmoer...@gmail.com on 3 Jun 2009 at 2:22

GoogleCodeExporter commented 8 years ago
What I meant was `dlopen' and `dlsym' are part of -lc,
there is actually no separate -ldl on FreeBSD.
In short, revision 486 does the right thing for everyone.

Original comment by vmage...@gmail.com on 3 Jun 2009 at 9:02