Enable shared libs on OpenBSD
authorMatthias Kilian <kili@outback.escape.de>
Sat, 18 Sep 2010 20:50:40 +0000 (20:50 +0000)
committerMatthias Kilian <kili@outback.escape.de>
Sat, 18 Sep 2010 20:50:40 +0000 (20:50 +0000)
compiler/HsVersions.h
compiler/main/DriverPipeline.hs
compiler/main/StaticFlags.hs
compiler/nativeGen/Platform.hs
libffi/ghc.mk
mk/config.mk.in

index ad17189..4d8e521 100644 (file)
@@ -17,7 +17,7 @@ you will screw up the layout where they are used in case expressions!
 #include "ghc_boot_platform.h"
 
 /* This macro indicates that the target OS supports ELF-like shared libraries */
 #include "ghc_boot_platform.h"
 
 /* This macro indicates that the target OS supports ELF-like shared libraries */
-#if linux_TARGET_OS || freebsd_TARGET_OS
+#if linux_TARGET_OS || freebsd_TARGET_OS || openbsd_TARGET_OS
 #define elf_OBJ_FORMAT 1
 #endif
 
 #define elf_OBJ_FORMAT 1
 #endif
 
index 08d568f..464aa28 100644 (file)
@@ -1538,7 +1538,7 @@ linkBinary dflags o_files dep_packages = do
 
     let
         thread_opts | WayThreaded `elem` ways = [
 
     let
         thread_opts | WayThreaded `elem` ways = [
-#if !defined(mingw32_TARGET_OS) && !defined(freebsd_TARGET_OS) && !defined(haiku_TARGET_OS)
+#if !defined(mingw32_TARGET_OS) && !defined(freebsd_TARGET_OS) && !defined(openbsd_TARGET_OS) && !defined(haiku_TARGET_OS)
                         "-lpthread"
 #endif
 #if defined(osf3_TARGET_OS)
                         "-lpthread"
 #endif
 #if defined(osf3_TARGET_OS)
index a8e3551..52a8694 100644 (file)
@@ -413,6 +413,9 @@ way_details =
        -- the problems are our fault or theirs, but it seems that using the
        -- alternative 1:1 threading library libthr works around it:
          "-optl-lthr"
        -- the problems are our fault or theirs, but it seems that using the
        -- alternative 1:1 threading library libthr works around it:
          "-optl-lthr"
+#elif defined(openbsd_TARGET_OS)
+         "-optc-pthread"
+       , "-optl-pthread"
 #elif defined(solaris2_TARGET_OS)
           "-optl-lrt"
 #endif
 #elif defined(solaris2_TARGET_OS)
           "-optl-lrt"
 #endif
@@ -428,6 +431,10 @@ way_details =
        --      with -fPIC. Labels not in the current package are assumed to be in a DLL 
        --      different from the current one.
        , "-fPIC"
        --      with -fPIC. Labels not in the current package are assumed to be in a DLL 
        --      different from the current one.
        , "-fPIC"
+#elif defined(openbsd_TARGET_OS)
+       -- Without this, linking the shared libHSffi fails because
+       -- it uses pthread mutexes.
+       , "-optl-pthread"
 #endif
        ],
 
 #endif
        ],
 
index afbf0b2..6c6b124 100644 (file)
@@ -49,6 +49,7 @@ data OS
        | OSSolaris
        | OSMinGW32
        | OSFreeBSD
        | OSSolaris
        | OSMinGW32
        | OSFreeBSD
+       | OSOpenBSD
        deriving (Show, Eq)
 
 
        deriving (Show, Eq)
 
 
@@ -56,6 +57,7 @@ data OS
 osElfTarget :: OS -> Bool
 osElfTarget OSLinux   = True
 osElfTarget OSFreeBSD = True
 osElfTarget :: OS -> Bool
 osElfTarget OSLinux   = True
 osElfTarget OSFreeBSD = True
+osElfTarget OSOpenBSD = True
 osElfTarget _         = False
 
 -- | This is the target platform as far as the #ifdefs are concerned.
 osElfTarget _         = False
 
 -- | This is the target platform as far as the #ifdefs are concerned.
@@ -96,6 +98,8 @@ defaultTargetOS       = OSSolaris
 defaultTargetOS        = OSMinGW32
 #elif freebsd_TARGET_OS
 defaultTargetOS        = OSFreeBSD
 defaultTargetOS        = OSMinGW32
 #elif freebsd_TARGET_OS
 defaultTargetOS        = OSFreeBSD
+#elif openbsd_TARGET_OS
+defaultTargetOS        = OSOpenBSD
 #else
 defaultTargetOS        = OSUnknown
 #endif
 #else
 defaultTargetOS        = OSUnknown
 #endif
index 8001fb2..eaffa3f 100644 (file)
@@ -75,6 +75,8 @@ libffi_DYNAMIC_PROG =
 ifeq "$(darwin_TARGET_OS)" "1"
 libffi_DYNAMIC_LIBS = libffi/dist-install/build/libffi$(soext) \
                       libffi/dist-install/build/libffi.5$(soext)
 ifeq "$(darwin_TARGET_OS)" "1"
 libffi_DYNAMIC_LIBS = libffi/dist-install/build/libffi$(soext) \
                       libffi/dist-install/build/libffi.5$(soext)
+else ifeq "$(openbsd_TARGET_OS)" "1"
+libffi_DYNAMIC_LIBS = libffi/dist-install/build/libffi.so.5.10
 else
 libffi_DYNAMIC_LIBS = libffi/dist-install/build/libffi.so \
                       libffi/dist-install/build/libffi.so.5
 else
 libffi_DYNAMIC_LIBS = libffi/dist-install/build/libffi.so \
                       libffi/dist-install/build/libffi.so.5
index c3c421a..3882c26 100644 (file)
@@ -104,7 +104,12 @@ GhcDynamic=NO
 GhcProfiled=NO
 
 # Do we support shared libs?
 GhcProfiled=NO
 
 # Do we support shared libs?
-PlatformSupportsSharedLibs = $(if $(filter $(TARGETPLATFORM),i386-unknown-linux x86_64-unknown-linux i386-unknown-freebsd x86_64-unknown-freebsd i386-unknown-mingw32 i386-apple-darwin powerpc-apple-darwin),YES,NO)
+PlatformSupportsSharedLibs = $(if $(filter $(TARGETPLATFORM),\
+       i386-unknown-linux x86_64-unknown-linux \
+       i386-unknown-freebsd x86_64-unknown-freebsd \
+       i386-unknown-openbsd x86_64-unknown-openbsd \
+       i386-unknown-mingw32 \
+       i386-apple-darwin powerpc-apple-darwin),YES,NO)
 
 # Build a compiler that will build *unregisterised* libraries and
 # binaries by default.  Unregisterised code is supposed to compile and
 
 # Build a compiler that will build *unregisterised* libraries and
 # binaries by default.  Unregisterised code is supposed to compile and