Use --export-dynamic to ensure ghci works on newer openbsds
authorDon Stewart <dons@cse.unsw.edu.au>
Thu, 21 Sep 2006 01:01:55 +0000 (01:01 +0000)
committerDon Stewart <dons@cse.unsw.edu.au>
Thu, 21 Sep 2006 01:01:55 +0000 (01:01 +0000)
Changes to the RTLD_DEFAULT semantics broke the trick we used to ensure
libc symbols were available to the ghci linker, in OpenBSD 4.0. We can
fix this by linking the ghc binary itself with --export-dynamic on this
system, removing the need for any magic Linker.c games.

GHCi now works on OpenBSD 4.0

Contributed by Eric Mertens <emertens at gmail.com>

compiler/Makefile.ghcbin
rts/Linker.c

index 6d4cbc8..41f0858 100644 (file)
@@ -18,6 +18,9 @@ SRC_HC_OPTS += \
   -cpp -fglasgow-exts -fno-generics -Rghc-timing \
   -I. -IcodeGen -InativeGen -Iparser
 SRC_HC_OPTS += $(GhcHcOpts) $(GhcStage$(stage)HcOpts)
+ifeq "$(TargetOS_CPP)" "openbsd"
+SRC_HC_OPTS += -optl-Xlinker -optl-E
+endif
 
 ifeq "$(GhcWithInterpreter)" "YES"
 SRC_HC_OPTS += -DGHCI -DBREAKPOINT
index 933f4dd..93fca03 100644 (file)
@@ -941,11 +941,6 @@ static int linker_init_done = 0 ;
 static void *dl_prog_handle;
 #endif
 
-/* dlopen(NULL,..) doesn't work so we grab libc explicitly */
-#if defined(openbsd_HOST_OS)
-static void *dl_libc_handle;
-#endif
-
 void
 initLinker( void )
 {
@@ -975,9 +970,6 @@ initLinker( void )
     dl_prog_handle = RTLD_DEFAULT;
 #   else
     dl_prog_handle = dlopen(NULL, RTLD_LAZY);
-#   if defined(openbsd_HOST_OS)
-    dl_libc_handle = dlopen("libc.so", RTLD_LAZY);
-#   endif
 #   endif /* RTLD_DEFAULT */
 #   endif
 }
@@ -1128,10 +1120,7 @@ lookupSymbol( char *lbl )
 
     if (val == NULL) {
 #       if defined(OBJFORMAT_ELF)
-#      if defined(openbsd_HOST_OS)
-       val = dlsym(dl_prog_handle, lbl);
-       return (val != NULL) ? val : dlsym(dl_libc_handle,lbl);
-#      elif defined(x86_64_HOST_ARCH)
+#      if defined(x86_64_HOST_ARCH)
        val = dlsym(dl_prog_handle, lbl);
        if (val >= (void *)0x80000000) {
            void *new_val;
@@ -1141,7 +1130,7 @@ lookupSymbol( char *lbl )
        } else {
            return val;
        }
-#      else /* not openbsd */
+#      else
        return dlsym(dl_prog_handle, lbl);
 #      endif
 #       elif defined(OBJFORMAT_MACHO)