Commit 41e5229c authored by ian@well-typed.com's avatar ian@well-typed.com

Link to the right RTS whenever we build a .dll on Windows

When GHCi makes temporary DLLs, those also need to be linked against
the right RTS, or we won't be able to load them.
parent 192c7b74
......@@ -116,6 +116,22 @@ ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
@echo 'cDYNAMIC_GHC_PROGRAMS = True' >> $@
else
@echo 'cDYNAMIC_GHC_PROGRAMS = False' >> $@
endif
# Note that GhcThreaded just reflects the Makefile variable setting.
# In particular, the stage1 compiler is never actually compiled with
# -threaded, but it will nevertheless have cGhcThreaded = True.
# The "+RTS --info" output will show what RTS GHC is really using.
@echo 'cGhcThreaded :: Bool' >> $@
ifeq "$(GhcThreaded)" "YES"
@echo 'cGhcThreaded = True' >> $@
else
@echo 'cGhcThreaded = False' >> $@
endif
@echo 'cGhcDebugged :: Bool' >> $@
ifeq "$(GhcDebugged)" "YES"
@echo 'cGhcDebugged = True' >> $@
else
@echo 'cGhcDebugged = False' >> $@
endif
@echo done.
......
......@@ -50,7 +50,7 @@ module DynFlags (
printOutputForUser, printInfoForUser,
Way(..), mkBuildTag, wayRTSOnly, updateWays,
Way(..), mkBuildTag, wayRTSOnly, addWay', updateWays,
wayGeneralFlags, wayUnsetGeneralFlags,
-- ** Safe Haskell
......
......@@ -1051,10 +1051,22 @@ linesPlatform xs =
#endif
linkDynLib :: DynFlags -> [String] -> [PackageId] -> IO ()
linkDynLib dflags o_files dep_packages
linkDynLib dflags0 o_files dep_packages
= do
let verbFlags = getVerbFlags dflags
let o_file = outputFile dflags
let -- This is a rather ugly hack to fix dynamically linked
-- GHC on Windows. If GHC is linked with -threaded, then
-- it links against libHSrts_thr. But if base is linked
-- against libHSrts, then both end up getting loaded,
-- and things go wrong. We therefore link the libraries
-- with the same RTS flags that we link GHC with.
dflags1 = if cGhcThreaded then addWay' WayThreaded dflags0
else dflags0
dflags2 = if cGhcDebugged then addWay' WayDebug dflags1
else dflags1
dflags = updateWays dflags2
verbFlags = getVerbFlags dflags
o_file = outputFile dflags
pkgs <- getPreloadPackagesAnd dflags dep_packages
......
......@@ -140,18 +140,6 @@ $1_$2_$3_GHC_LD_OPTS += \
else ifeq "$$(TargetOS_CPP)" "darwin"
$1_$2_$3_GHC_LD_OPTS += -optl-Wl,-headerpad_max_install_names
endif
# This is a rather ugly hack to fix dynamically linked GHC on Windows.
# If GHC is linked with -threaded, then it links against libHSrts_thr.
# But if base is linked against libHSrts, then both end up getting
# loaded, and things go wrong. We therefore link the libraries with the
# same RTS flags that we link GHC with.
ifeq "$$(GhcThreaded)" "YES"
$1_$2_$3_GHC_LD_OPTS += -threaded
endif
ifeq "$$(GhcDebugged)" "YES"
$1_$2_$3_GHC_LD_OPTS += -debug
endif
endif
endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment