diff options
author | Ian Lynagh <ian@well-typed.com> | 2013-05-12 20:31:45 +0100 |
---|---|---|
committer | Ian Lynagh <ian@well-typed.com> | 2013-05-12 20:31:45 +0100 |
commit | 0aae29808d76ce45b88017102056f3391cec57a3 (patch) | |
tree | a00f38a8c5a86fa477aae34d970d81124fa7e54f /rules | |
parent | a2be710f4bb005c2e339799da4b63d376adfaf6b (diff) | |
parent | b35a6ce0e34255d200ddcf341ffc645fd237ea32 (diff) | |
download | haskell-0aae29808d76ce45b88017102056f3391cec57a3.tar.gz |
Merge win:/cygdrive/c/ghc/git/dt
Diffstat (limited to 'rules')
-rw-r--r-- | rules/build-prog.mk | 21 | ||||
-rw-r--r-- | rules/distdir-way-opts.mk | 12 |
2 files changed, 32 insertions, 1 deletions
diff --git a/rules/build-prog.mk b/rules/build-prog.mk index 464ed73567..9d1e5890be 100644 --- a/rules/build-prog.mk +++ b/rules/build-prog.mk @@ -204,8 +204,27 @@ $1/$2/build/tmp/$$($1_$2_PROG) $1/$2/build/tmp/$$($1_$2_PROG).dll : \ $$(error Bad build stage)))),\ $$$$($$(dep)_dist-$(if $(filter 0,$3),boot,install)_PROGRAM_DEP_LIB))) +$1_$2_PROG_NEEDS_C_WRAPPER = NO ifeq "$$(Windows_Host) $$($1_$2_PROGRAM_WAY)" "YES dyn" -$1/$2/build/tmp/$$($1_$2_PROG) : $1/$2/build/tmp/$$($1_$2_PROG).c $1/$2/build/tmp/$$($1_$2_PROG).dll | $$$$(dir $$$$@)/. +ifneq "$$($1_$2_HS_SRCS)" "" +$1_$2_PROG_NEEDS_C_WRAPPER = YES +endif +endif + +ifeq "$$($1_$2_PROG_NEEDS_C_WRAPPER)" "YES" + +$1/$2/build/tmp/$$($1_$2_PROG)-inplace-wrapper.c: driver/utils/dynwrapper.c | $$$$(dir $$$$@)/. + $$(call removeFiles,$$@) + echo '#include <Windows.h>' >> $$@ + echo 'LPTSTR path_dirs[] = {' >> $$@ + $$(foreach d,$$($1_$2_DEP_LIB_REL_DIRS),$$(call make-command,echo ' TEXT("$$d")$$(comma)' >> $$@)) + echo ' TEXT("$1/$2/build/tmp/"),' >> $$@ + echo ' NULL};' >> $$@ + echo 'LPTSTR progDll = TEXT("../../$1/$2/build/tmp/$$($1_$2_PROG).dll");' >> $$@ + echo 'LPTSTR rtsDll = TEXT("$$($$(WINDOWS_DYN_PROG_RTS))");' >> $$@ + cat driver/utils/dynwrapper.c >> $$@ + +$1/$2/build/tmp/$$($1_$2_PROG) : $1/$2/build/tmp/$$($1_$2_PROG)-inplace-wrapper.c $1/$2/build/tmp/$$($1_$2_PROG).dll | $$$$(dir $$$$@)/. $$(call cmd,$1_$2_HC) -no-hs-main -optc-g -optc-O0 $$< -o $$@ $1/$2/build/tmp/$$($1_$2_PROG).dll : $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) | $$$$(dir $$$$@)/. diff --git a/rules/distdir-way-opts.mk b/rules/distdir-way-opts.mk index acf68823e4..f288d3919e 100644 --- a/rules/distdir-way-opts.mk +++ b/rules/distdir-way-opts.mk @@ -132,6 +132,18 @@ $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 |