Commit 006a18ea authored by Clemens Fruhwirth's avatar Clemens Fruhwirth
Browse files

Build RTS as dynamic library

parent 90ef8ab2
...@@ -100,6 +100,7 @@ if test x"$TargetPlatform" != x"$HostPlatform" ; then ...@@ -100,6 +100,7 @@ if test x"$TargetPlatform" != x"$HostPlatform" ; then
fi fi
exeext='' exeext=''
soext='.so'
# #
# The following will be more difficult when we *are* cross-compiling. # The following will be more difficult when we *are* cross-compiling.
# Suitable names to slam in *_CPP are in platform.h.in. # Suitable names to slam in *_CPP are in platform.h.in.
...@@ -295,6 +296,7 @@ i[[3456]]86-*-cygwin*) ...@@ -295,6 +296,7 @@ i[[3456]]86-*-cygwin*)
HostVendor_CPP='unknown' HostVendor_CPP='unknown'
HostOS_CPP='cygwin32' HostOS_CPP='cygwin32'
exeext='.exe' exeext='.exe'
soext='.dll'
;; ;;
i[[3456]]86-*-mingw32*) i[[3456]]86-*-mingw32*)
HostPlatform=i386-unknown-mingw32 # hack again HostPlatform=i386-unknown-mingw32 # hack again
...@@ -305,6 +307,7 @@ i[[3456]]86-*-mingw32*) ...@@ -305,6 +307,7 @@ i[[3456]]86-*-mingw32*)
HostVendor_CPP='unknown' HostVendor_CPP='unknown'
HostOS_CPP='mingw32' HostOS_CPP='mingw32'
exeext='.exe' exeext='.exe'
soext='.dll'
;; ;;
i[[3456]]86-apple-darwin*) i[[3456]]86-apple-darwin*)
HostPlatform=i386-apple-darwin HostPlatform=i386-apple-darwin
...@@ -314,6 +317,7 @@ i[[3456]]86-apple-darwin*) ...@@ -314,6 +317,7 @@ i[[3456]]86-apple-darwin*)
HostArch_CPP='i386' HostArch_CPP='i386'
HostVendor_CPP='apple' HostVendor_CPP='apple'
HostOS_CPP='darwin' HostOS_CPP='darwin'
soext='.dylib'
;; ;;
i[[3456]]86-*-gnu*) i[[3456]]86-*-gnu*)
HostPlatform=i386-unknown-gnu HostPlatform=i386-unknown-gnu
...@@ -350,6 +354,7 @@ x86_64-apple-darwin*) ...@@ -350,6 +354,7 @@ x86_64-apple-darwin*)
HostArch_CPP='x86_64' HostArch_CPP='x86_64'
HostVendor_CPP='apple' HostVendor_CPP='apple'
HostOS_CPP='darwin' HostOS_CPP='darwin'
soext='.dylib'
;; ;;
m68k-*-linux*) m68k-*-linux*)
HostPlatform=m68k-unknown-linux # hack again HostPlatform=m68k-unknown-linux # hack again
...@@ -476,6 +481,7 @@ powerpc-apple-darwin*) ...@@ -476,6 +481,7 @@ powerpc-apple-darwin*)
HostArch_CPP='powerpc' HostArch_CPP='powerpc'
HostVendor_CPP='apple' HostVendor_CPP='apple'
HostOS_CPP='darwin' HostOS_CPP='darwin'
soext='.dylib'
;; ;;
powerpc-unknown-linux*) powerpc-unknown-linux*)
HostPlatform=powerpc-unknown-linux HostPlatform=powerpc-unknown-linux
...@@ -608,6 +614,7 @@ AC_SUBST(BuildVendor_CPP) ...@@ -608,6 +614,7 @@ AC_SUBST(BuildVendor_CPP)
AC_SUBST(TargetVendor_CPP) AC_SUBST(TargetVendor_CPP)
AC_SUBST(exeext) AC_SUBST(exeext)
AC_SUBST(soext)
dnl -------------------------------------------------------------- dnl --------------------------------------------------------------
dnl * Project specific configuration options dnl * Project specific configuration options
......
#ifndef __STGDLL_H__ #ifndef __STGDLL_H__
#define __STGDLL_H__ 1 #define __STGDLL_H__ 1
#if defined(HAVE_WIN32_DLL_SUPPORT) && !defined(DONT_WANT_WIN32_DLL_SUPPORT) #if defined(__PIC__) && defined(mingw32_TARGET_OS)
#define ENABLE_WIN32_DLL_SUPPORT # define DLL_IMPORT_DATA_REF(x) (_imp__##x)
#endif # define DLL_IMPORT_DATA_VARNAME(x) *_imp__##x
# if __GNUC__ && !defined(__declspec)
#ifdef ENABLE_WIN32_DLL_SUPPORT # define DLLIMPORT
# if __GNUC__ && !defined(__declspec) # else
# define DLLIMPORT # define DLLIMPORT __declspec(dllimport)
# else # define DLLIMPORT_DATA(x) _imp__##x
# define DLLIMPORT __declspec(dllimport) # endif
# define DLLIMPORT_DATA(x) _imp__##x
# endif
#else #else
# define DLLIMPORT # define DLL_IMPORT_DATA_REF(x) (&(x))
# define DLL_IMPORT_DATA_VARNAME(x) x
# define DLLIMPORT
#endif #endif
/* The view of the ghc/includes/ header files differ ever so /* The view of the ghc/includes/ header files differ ever so
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#else #else
#define DLL_IMPORT #define DLL_IMPORT
#define DLL_IMPORT_RTS DLLIMPORT #define DLL_IMPORT_RTS DLLIMPORT
# ifdef ENABLE_WIN32_DLL_SUPPORT # if defined(__PIC__) && defined(mingw32_TARGET_OS)
# define DLL_IMPORT_DATA_VAR(x) _imp__##x # define DLL_IMPORT_DATA_VAR(x) _imp__##x
# else # else
# define DLL_IMPORT_DATA_VAR(x) x # define DLL_IMPORT_DATA_VAR(x) x
......
...@@ -163,6 +163,7 @@ LeadingUnderscore=@LeadingUnderscore@ ...@@ -163,6 +163,7 @@ LeadingUnderscore=@LeadingUnderscore@
# Pin a suffix on executables? If so, what (Windows only). # Pin a suffix on executables? If so, what (Windows only).
exeext=@exeext@ exeext=@exeext@
soext=@soext@
# Windows=YES if on a Windows platform # Windows=YES if on a Windows platform
ifneq "$(findstring $(HostOS_CPP), mingw32 cygwin32)" "" ifneq "$(findstring $(HostOS_CPP), mingw32 cygwin32)" ""
...@@ -1166,6 +1167,23 @@ WAY_thr_debug_HC_OPTS=-optc-DTHREADED_RTS -optc-DDEBUG ...@@ -1166,6 +1167,23 @@ WAY_thr_debug_HC_OPTS=-optc-DTHREADED_RTS -optc-DDEBUG
WAY_thr_debug_p_NAME=threaded WAY_thr_debug_p_NAME=threaded
WAY_thr_debug_p_HC_OPTS=-optc-DTHREADED_RTS -optc-DDEBUG -prof WAY_thr_debug_p_HC_OPTS=-optc-DTHREADED_RTS -optc-DDEBUG -prof
# Way 'dyn': build dynamic shared libraries
WAY_dyn_NAME=dyn
WAY_dyn_HC_OPTS=-fPIC -dynamic
WAY_dyn_LIB_TARGET=libHSrts-gcc661.so
# Way 'thr_dyn':
WAY_thr_dyn_NAME=thr_dyn
WAY_thr_dyn_HC_OPTS=-fPIC -dynamic -optc-DTHREADED_RTS
# Way 'thr_debug_dyn':
WAY_thr_debug_dyn_NAME=thr_dyn
WAY_thr_debug_dyn_HC_OPTS=-fPIC -dynamic -optc-DTHREADED_RTS -optc-DDEBUG
# Way 'debug_dyn':
WAY_debug_dyn_NAME=thr_dyn
WAY_debug_dyn_HC_OPTS=-fPIC -dynamic -optc-DDEBUG
# #
# Add user-way configurations here: # Add user-way configurations here:
# #
......
...@@ -138,8 +138,12 @@ SRC_HC_OPTS += -fgenerics ...@@ -138,8 +138,12 @@ SRC_HC_OPTS += -fgenerics
endif endif
ifndef LIBRARY ifndef LIBRARY
ifeq "$(_way:%_dyn=YES)" "YES"
LIBRARY = libHS$(PACKAGE)$(_way:%_dyn=%)-ghc$(ProjectVersion)$(soext)
else
LIBRARY = libHS$(PACKAGE)$(_way).a LIBRARY = libHS$(PACKAGE)$(_way).a
endif endif
endif
ifeq "$(WAYS)" "" ifeq "$(WAYS)" ""
WAYS = $(GhcLibWays) WAYS = $(GhcLibWays)
...@@ -246,69 +250,6 @@ $(GHCI_LIBRARY) : $(LIBOBJS) ...@@ -246,69 +250,6 @@ $(GHCI_LIBRARY) : $(LIBOBJS)
endif # DONT_WANT_STD_GHCI_LIB_RULE endif # DONT_WANT_STD_GHCI_LIB_RULE
endif # GhcWithInterpreter endif # GhcWithInterpreter
endif # way endif # way
ifeq "$(GhcBuildDylibs)" "YES"
# Build dynamic libraries.
# Currently, this is a hack. Anyone, PLEASE clean it up.
# For now, we pretend that there are two operating systems in the world;
# Darwin, and Everything Else. Furthermore, we pretend that Everything Else
# behaves like Linux.
ifeq "$(darwin_TARGET_OS)" "1"
# Darwin: Shared libraries end in .dylib
DYLD_LIBRARY = $(patsubst %.a,%_dyn.dylib,$(LIBRARY))
# About the options used for Darwin:
# -dynamiclib
# Apple's way of saying -shared
# -undefined dynamic_lookup:
# Without these options, we'd have to specify the correct dependencies
# for each of the dylibs. Note that we could (and should) do without this
# for all libraries except the RTS; all we need to do is to pass the
# correct HSfoo_dyn.dylib files to the link command.
# This feature requires Mac OS X 10.3 or later; there is a similar feature,
# -flat_namespace -undefined suppress, which works on earlier versions,
# but it has other disadvantages.
# -single_module
# Build the dynamic library as a single "module", i.e. no dynamic binding
# nonsense when referring to symbols from within the library. The NCG
# assumes that this option is specified (on i386, at least).
# -Wl,-macosx_version_min -Wl,10.3
# Tell the linker its safe to assume that the library will run on 10.3 or
# later, so that it will not complain about the use of the option
# -undefined dynamic_lookup above.
# -install_name
# Causes the dynamic linker to ignore the DYLD_LIBRARY_PATH when loading
# this lib and instead look for it at its absolute path.
# When installing the .dylibs (see target.mk), we'll change that path to
# point to the place they are installed. Therefore, we won't have to set
# up DYLD_LIBRARY_PATH specifically for ghc.
$(DYLD_LIBRARY) : $(LIBOBJS) $(STUBOBJS)
$(CC) -dynamiclib -o $@ $(STUBOBJS) $(LIBOBJS) \
-undefined dynamic_lookup -single_module \
-Wl,-macosx_version_min -Wl,10.3 \
-install_name `pwd`/$@
else
DYLD_LIBRARY = $(patsubst %.a,%_dyn.so,$(LIBRARY))
$(DYLD_LIBRARY) : $(LIBOBJS) $(STUBOBJS)
$(CC) -shared -o $@ $(STUBOBJS) $(LIBOBJS)
endif
ifneq "$(NO_INSTALL_LIBRARY)" "YES"
INSTALL_LIBS += $(DYLD_LIBRARY)
endif
CLEAN_FILES += $(DYLD_LIBRARY)
all :: $(DYLD_LIBRARY)
endif # $(GhcBuildDylibs) == "YES"
endif # $(LIBRARY) /= "" endif # $(LIBRARY) /= ""
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
......
...@@ -265,13 +265,13 @@ ifneq "$(LIBRARY)" "" ...@@ -265,13 +265,13 @@ ifneq "$(LIBRARY)" ""
all :: $(LIBRARY) all :: $(LIBRARY)
ifneq "$(way)" "i" ifneq "$(way)" "i"
define BUILD_LIB define BUILD_STATIC_LIB
$(RM) $@ $(RM) $@
$(AR) $(AR_OPTS) $@ $(STUBOBJS) $(LIBOBJS) $(AR) $(AR_OPTS) $@ $(STUBOBJS) $(LIBOBJS)
$(RANLIB) $@ $(RANLIB) $@
endef endef
else else
define BUILD_LIB define BUILD_STATIC_LIB
$(RM) $@ $(RM) $@
al -out:$@ $(STUBOBJS) $(LIBOBJS) al -out:$@ $(STUBOBJS) $(LIBOBJS)
endef endef
...@@ -298,13 +298,13 @@ SRC_HC_OPTS += -split-objs ...@@ -298,13 +298,13 @@ SRC_HC_OPTS += -split-objs
# rename it at the end. This avoids the problem that ar may sometimes # rename it at the end. This avoids the problem that ar may sometimes
# fail, leaving a partially built archive behind. # fail, leaving a partially built archive behind.
ifeq "$(ArSupportsInput)" "" ifeq "$(ArSupportsInput)" ""
define BUILD_LIB define BUILD_STATIC_LIB
$(RM) $@ $@.tmp $(RM) $@ $@.tmp
(echo $(STUBOBJS) $(C_OBJS) $(GC_C_OBJS); $(FIND) $(patsubst %.$(way_)o,%_split,$(HS_OBJS)) -name '*.$(way_)o' -print) | xargs $(AR) $@ (echo $(STUBOBJS) $(C_OBJS) $(GC_C_OBJS); $(FIND) $(patsubst %.$(way_)o,%_split,$(HS_OBJS)) -name '*.$(way_)o' -print) | xargs $(AR) $@
$(RANLIB) $@ $(RANLIB) $@
endef endef
else else
define BUILD_LIB define BUILD_STATIC_LIB
$(RM) $@ $@.tmp $(RM) $@ $@.tmp
echo $(STUBOBJS) > $@.list echo $(STUBOBJS) > $@.list
echo $(C_OBJS) >> $@.list echo $(C_OBJS) >> $@.list
...@@ -351,70 +351,35 @@ endif # StripLibraries ...@@ -351,70 +351,35 @@ endif # StripLibraries
# Note: $(STUBOBJS) isn't depended on here, but included when building the lib. # Note: $(STUBOBJS) isn't depended on here, but included when building the lib.
# (i.e., the assumption is that $(STUBOBJS) are created as a side-effect # (i.e., the assumption is that $(STUBOBJS) are created as a side-effect
# of building $(LIBOBJS)). # of building $(LIBOBJS)).
$(LIBRARY) : $(LIBOBJS)
$(BUILD_LIB)
endif # LIBRARY = ""
ifeq "$(LIBRARY:%.so=YES)" "YES"
# ELF styled DSO
$(LIBRARY): $(LIBOBJS) $(LIB_DEPS)
$(RM) $@
$(HC) -shared -dynamic -o $@ $(STUBOBJS) $(LIBOBJS) $(LIB_LD_OPTS)
else
ifeq "$(LIBRARY:%.dylib=YES)" "YES"
$(LIBRARY): $(LIBOBJS) $(LIB_DEPS)
$(HC) -shared -dynamic -o $@ $(STUBOBJS) $(LIBOBJS) $(LIB_LD_OPTS)
else
ifeq "$(LIBRARY:%.dll=YES)" "YES"
#---------------------------------------- #----------------------------------------
# Building Win32 DLLs # Building Win32 DLLs
# #
$(LIBRARY): $(LIBOBJS) $(LIBRARY).o $(LIB_DEPS)
$(HC) -shared -dynamic -o $@ $(STUBOBJS) $(LIBOBJS) $(LIBRARY).o $(LIB_LD_OPTS)
ifeq "$(DLLized)" "YES" DLLTOOL=dlltool
SRC_CC_OPTS += -DDLLized
ifneq "$(PACKAGE)" ""
SRC_BLD_DLL_OPTS += --export-all --output-def=HS$(PACKAGE)$(_cbits)$(_way).def DllVersionInfo.$(way_)o
ifneq "$(PACKAGE) $(IS_CBITS_LIB)" "std YES"
ifneq "$(PACKAGE)" "rts"
SRC_BLD_DLL_OPTS += -lHSstd_cbits_imp -L$(GHC_LIB_DIR)/std/cbits
SRC_BLD_DLL_OPTS += -lHSrts_$(way_)imp -L$(GHC_RTS_DIR)
ifneq "$(PACKAGE)" "std"
ifeq "$(IS_CBITS_LIB)" ""
SRC_BLD_DLL_OPTS += -lHSstd_$(way_)imp -L$(GHC_LIB_DIR)/std
endif
endif
endif
endif
SRC_BLD_DLL_OPTS += -lgmp -L. -L$(GHC_RTS_DIR)/gmp
ifeq "$(IS_CBITS_LIB)" ""
SRC_BLD_DLL_OPTS += $(patsubst %,-lHS%_$(way_)imp, $(PACKAGE_DEPS))
SRC_BLD_DLL_OPTS += $(patsubst %,-L../%, $(PACKAGE_DEPS))
endif
ifneq "$(HAS_CBITS)" ""
SRC_BLD_DLL_OPTS += -lHS$(PACKAGE)_cbits_imp -Lcbits
endif
SRC_BLD_DLL_OPTS += -lwsock32 -lwinmm
endif # PACKAGE != ""
SplitObjs = NO $(LIBRARY).def: $(LIBOBJS)
$(DLLTOOL) --output-def $@ --export-all $(LIBOBJS)
ifneq "$(LIBRARY)" "" $(LIBRARY).o:
$(DLLTOOL) --output-exp $(LIBRARY).o $(LIBOBJS)
all :: DllVersionInfo.$(way_)o
ifeq "$(DLL_NAME)" "" # Generates library.dll.a; by MinGW conventions, this is the dll's import library
DLL_NAME = $(patsubst %.a,%.dll,$(subst lib,,$(LIBRARY))) $(LIBRARY).a: $(LIBOBJS) $(LIBRARY).def
endif $(DLLTOOL) --def $(LIBRARY).def --output-lib $@
ifneq "$(DLL_NAME)" ""
DLL_NAME := $(DLL_PEN)/$(DLL_NAME)
endif
all :: $(DLL_NAME)
ifeq "$(DLL_IMPLIB_NAME)" ""
DLL_IMPLIB_NAME = $(patsubst %.a,%_imp.a,$(LIBRARY))
endif
$(DLL_NAME) :: $(LIBRARY)
$(BLD_DLL) --output-lib $(DLL_IMPLIB_NAME) -o $(DLL_NAME) $(LIBRARY) $(BLD_DLL_OPTS)
endif # LIBRARY != ""
endif # DLLized
# #
# Version information is baked into a DLL by having the DLL include DllVersionInfo.o. # Version information is baked into a DLL by having the DLL include DllVersionInfo.o.
...@@ -483,6 +448,14 @@ DllVersionInfo.$(way_)rc ExeVersionInfo.$(way_)rc: ...@@ -483,6 +448,14 @@ DllVersionInfo.$(way_)rc ExeVersionInfo.$(way_)rc:
echo " VALUE \"Translation\", 0x0409, 1200" >> $@ echo " VALUE \"Translation\", 0x0409, 1200" >> $@
echo " END" >> $@ echo " END" >> $@
echo "END" >> $@ echo "END" >> $@
else
# Regular static library
$(LIBRARY): $(LIBOBJS)
$(BUILD_STATIC_LIB)
endif # %.dll
endif # %.dylib
endif # %.so
endif # LIBRARY = ""
include $(TOP)/mk/install.mk include $(TOP)/mk/install.mk
...@@ -651,7 +624,8 @@ ifeq "$(way)" "" ...@@ -651,7 +624,8 @@ ifeq "$(way)" ""
FPTOOLS_SUFFIXES := o hi hc FPTOOLS_SUFFIXES := o hi hc
WAY_TARGETS = $(foreach way,$(WAYS),$(foreach suffix, $(FPTOOLS_SUFFIXES), %.$(way)_$(suffix))) WAY_TARGETS = $(foreach way,$(WAYS),$(foreach suffix, $(FPTOOLS_SUFFIXES), %.$(way)_$(suffix)))
LIB_WAY_TARGETS = $(foreach way,$(WAYS),%_$(way).a %_$(way)) LIB_WAY_TARGETS = $(foreach way,$(filter-out %dyn,$(WAYS)), %_$(way).a)
LIB_WAY_TARGETS_DYN = $(foreach way,$(filter %dyn,$(WAYS)), %$(subst dyn,-ghc$(ProjectVersion),$(subst _dyn,dyn,$(way)))$(soext))
# $@ will be something like Foo.p_o # $@ will be something like Foo.p_o
# $(suffix $@) returns .p_o # $(suffix $@) returns .p_o
...@@ -669,6 +643,9 @@ $(WAY_TARGETS) : ...@@ -669,6 +643,9 @@ $(WAY_TARGETS) :
$(LIB_WAY_TARGETS) : $(LIB_WAY_TARGETS) :
$(MAKE) $(MFLAGS) $@ way=$(subst .,,$(suffix $(subst _,.,$(basename $@)))) $(MAKE) $(MFLAGS) $@ way=$(subst .,,$(suffix $(subst _,.,$(basename $@))))
$(LIB_WAY_TARGETS_DYN) :
$(MAKE) $(MFLAGS) $@ way=$(patsubst _dyn,dyn,$(subst .,,$(suffix $(subst _,.,$(basename $(subst -ghc$(ProjectVersion),,$@)))))_dyn)
endif # if way endif # if way
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
......
...@@ -766,7 +766,7 @@ typedef struct _RtsSymbolVal { ...@@ -766,7 +766,7 @@ typedef struct _RtsSymbolVal {
/* entirely bogus claims about types of these symbols */ /* entirely bogus claims about types of these symbols */
#define Sym(vvv) extern void vvv(void); #define Sym(vvv) extern void vvv(void);
#ifdef ENABLE_WIN32_DLL_SUPPORT #if defined(__PIC__) && defined(mingw32_TARGET_OS)
#define SymExtern(vvv) extern void _imp__ ## vvv (void); #define SymExtern(vvv) extern void _imp__ ## vvv (void);
#else #else
#define SymExtern(vvv) SymX(vvv) #define SymExtern(vvv) SymX(vvv)
...@@ -795,12 +795,8 @@ RTS_LIBGCC_SYMBOLS ...@@ -795,12 +795,8 @@ RTS_LIBGCC_SYMBOLS
#define Sym(vvv) { MAYBE_LEADING_UNDERSCORE_STR(#vvv), \ #define Sym(vvv) { MAYBE_LEADING_UNDERSCORE_STR(#vvv), \
(void*)(&(vvv)) }, (void*)(&(vvv)) },
#define SymX(vvv) Sym(vvv) #define SymX(vvv) Sym(vvv)
#ifdef ENABLE_WIN32_DLL_SUPPORT
#define SymExtern(vvv) { MAYBE_LEADING_UNDERSCORE_STR(#vvv), \ #define SymExtern(vvv) { MAYBE_LEADING_UNDERSCORE_STR(#vvv), \
(void*)(_imp__ ## vvv) }, (void*)DLL_IMPORT_DATA_REF(vvv) },
#else
#define SymExtern(vvv) Sym(vvv)
#endif
// SymX_redirect allows us to redirect references to one symbol to // SymX_redirect allows us to redirect references to one symbol to
// another symbol. See newCAF/newDynCAF for an example. // another symbol. See newCAF/newDynCAF for an example.
......
...@@ -49,10 +49,20 @@ else ...@@ -49,10 +49,20 @@ else
ALL_DIRS += posix ALL_DIRS += posix
endif endif
ifneq "$(DLLized)" "YES" ifneq "$(findstring dyn, $(way))" ""
EXCLUDED_SRCS += RtsDllMain.c DYNAMIC_RTS=YES
else else
DYNAMIC_RTS=NO
endif
ifeq "$(DYNAMIC_RTS) $(HOSTPLATFORM)" "YES i386-unknown-mingw32"
EXCLUDED_SRCS += Main.c EXCLUDED_SRCS += Main.c
# It's not included in the DLL, but we need to compile it up separately.
all :: Main.$(way_)o
INSTALL_LIBS += Main.$(way_)o
else
EXCLUDED_SRCS += RtsDllMain.c
endif endif
# This file ends up being empty unless we're building for a powerpc # This file ends up being empty unless we're building for a powerpc
...@@ -114,17 +124,29 @@ SRC_CC_OPTS += $(WARNING_OPTS) ...@@ -114,17 +124,29 @@ SRC_CC_OPTS += $(WARNING_OPTS)
SRC_CC_OPTS += $(STANDARD_OPTS) SRC_CC_OPTS += $(STANDARD_OPTS)
SRC_CC_OPTS += $(GhcRtsCcOpts) SRC_CC_OPTS += $(GhcRtsCcOpts)
SRC_HC_OPTS += $(GhcRtsHcOpts) SRC_HC_OPTS += $(GhcRtsHcOpts) -package-name rts
ifneq "$(GhcWithSMP)" "YES" ifneq "$(GhcWithSMP)" "YES"
SRC_CC_OPTS += -DNOSMP SRC_CC_OPTS += -DNOSMP
SRC_HC_OPTS += -optc-DNOSMP SRC_HC_OPTS += -optc-DNOSMP
endif endif
ifneq "$(DLLized)" "YES" ifneq "$(DYNAMIC_RTS)" "YES"
SRC_HC_OPTS += -static SRC_HC_OPTS += -static
else
LIB_LD_OPTS += -ignore-package base -ignore-package rts
ifeq "$(DYNAMIC_RTS) $(HOSTPLATFORM)" "YES i386-unknown-mingw32"
BASE_VERSION=$(strip $(shell grep version: $(TOP)/libraries/base/base.cabal | cut -f2 -d:))
BASE_NAME=HSbase-$(BASE_VERSION)-ghc$(ProjectVersion)$(soext)
BASE_DIST_LIB=$(TOP)/libraries/base/dist/build
BASE_IMPORT_LIBRARY=$(BASE_DIST_LIB)/lib$(BASE_NAME).a
LIB_DEPS=$(BASE_IMPORT_LIBRARY)
LIB_LD_OPTS += -L$(BASE_DIST_LIB) -l$(BASE_NAME)
# We extract a good bit of information out of the rts package.conf by going via ghc-pkg
LIB_LD_OPTS += $(foreach lib,$(shell $(GHC_PKG_INPLACE) field rts extra-libraries | sed -e s/extra-libraries://),"-l$(lib)")
LIB_LD_OPTS += $(foreach libdir,$(shell $(GHC_PKG_INPLACE) field rts library-dirs | sed -e s/library-dirs://),"-L$(libdir)")
endif
endif endif
# SRC_HC_OPTS += -fPIC
RtsMessages_CC_OPTS += -DProjectVersion=\"$(ProjectVersion)\" RtsMessages_CC_OPTS += -DProjectVersion=\"$(ProjectVersion)\"
RtsFlags_CC_OPTS += -DProjectVersion=\"$(ProjectVersion)\" RtsFlags_CC_OPTS += -DProjectVersion=\"$(ProjectVersion)\"
...@@ -227,31 +249,6 @@ CLEAN_FILES += $(AUTO_APPLY_CMM) ...@@ -227,31 +249,6 @@ CLEAN_FILES += $(AUTO_APPLY_CMM)
endif endif
# -----------------------------------------------------------------------------
#
# Building DLLs is only supported on mingw32 at the moment.
#
ifeq "$(DLLized)" "YES"
SRC_BLD_DLL_OPTS += -lHS_imp_stub -lgmp_imp
# It's not included in the DLL, but we need to compile it up separately.
all :: Main.dll_o
# Need an import library containing the symbols the RTS uses from the Prelude.
# So, to avoid bootstrapping trouble, we build one containing just the syms
# we need. Weirdly named to avoid clashing later on when compiling the contents
# of ghc/lib/..
#
# Note: if you do change the name of the Prelude DLL, the "--dllname <nm>.dll"
# below will need to be updated as well.
$(DLL_PEN)/HSrts$(_way).dll :: libHS_imp_stub.a
libHS_imp_stub.a :
dlltool --output-lib libHS_imp_stub.a --def HSprel.def --dllname HSstd.dll
endif
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Compile GMP only if we don't have it already # Compile GMP only if we don't have it already
# #
...@@ -336,9 +333,6 @@ sm/Compact_HC_OPTS += -optc-finline-limit=2500 ...@@ -336,9 +333,6 @@ sm/Compact_HC_OPTS += -optc-finline-limit=2500
# upd_evacee() assigments get moved before the object copy. # upd_evacee() assigments get moved before the object copy.
SRC_CC_OPTS += -fno-strict-aliasing SRC_CC_OPTS += -fno-strict-aliasing
# Cmm must be compiled via-C for now, because the NCG can't handle loops
SRC_HC_OPTS += -fvia-C
# We *want* type-checking of hand-written cmm. # We *want* type-checking of hand-written cmm.
SRC_HC_OPTS += -dcmm-lint SRC_HC_OPTS += -dcmm-lint
...@@ -362,17 +356,20 @@ endif ...@@ -362,17 +356,20 @@ endif
# #
# Just libHSrts is installed uniformly across ways # Just libHSrts is installed uniformly across ways
# #
ifeq "$(DLLized)" "YES"
INSTALL_PROGS += gmp/gmp.dll include $(TOP)/mk/target.mk
INSTALL_LIBS += gmp/libgmp_imp.a Main.dll_o
ifeq "$(DYNAMIC_RTS) $(HOSTPLATFORM)" "YES i386-unknown-mingw32"
$(BASE_IMPORT_LIBRARY): $(LIBRARY).a
$(MAKE) -C ../libraries/ make.library.base
# just for the timestamps
touch $(BASE_IMPORT_LIBRARY)
endif endif
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# #
# binary-dist