Commit 083776b9 authored by Niklas Hambuechen's avatar Niklas Hambuechen

Fix compiler invocation for GHC >= 7.8

GHC 7.8 switched to dynamic linking being used for ghci, which requires
that .so file are being built for modules that are loaded for TH.

For this reason, GHC >= 7.8 has a -dynamic-too flag, which we now use.

However, -dynamic-too must not be enabled for profiling builds,
which is why this commit introduces a HFLAGS_NOPROF variable
(currently only containing -dynamic-too) that must be passed to
all GHC invocations that are not creating profiling output.
Signed-off-by: default avatarNiklas Hambuechen <niklash@google.com>
Reviewed-by: default avatarHrvoje Ribicic <riba@google.com>
parent b78a2c30
......@@ -772,6 +772,20 @@ DEP_SUFFIXES += -dep-suffix $(HPROF_SUFFIX)_ -dep-suffix $(HTEST_SUFFIX)_ \
-dep-suffix ""
endif
# Flags that are only for GHC invocations which are not doing profiling
# compiles.
# It must be used in all places where HFLAGS is used but not HPROFFLAGS,
# independent of whether HPROFILE is on or off.
HFLAGS_NOPROF =
# GHC >= 7.8 needs -dynamic-too when using Template Haskell since its
# ghci is switched to loading dynamic libraries by default.
# But this flag must only be used in non-profiling GHC invocations,
# so we put it in HFLAGS_NOPROF.
if !GHC_LE_76
HFLAGS_NOPROF += -dynamic-too
endif
if HPROFILE
HPROFFLAGS = -prof -fprof-auto-top -osuf $(HPROF_SUFFIX)_o \
-hisuf $(HPROF_SUFFIX)_hi -rtsopts
......@@ -786,6 +800,9 @@ endif
HTEST_FLAGS = $(HFLAGS) -fhpc -itest/hs \
-osuf .$(HTEST_SUFFIX)_o \
-hisuf .$(HTEST_SUFFIX)_hi
if !HPROFILE
HTEST_FLAGS += $(HFLAGS_NOPROF)
endif
# extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
HEXTRA =
......@@ -1246,7 +1263,8 @@ HS_MAKEFILE_GHC_SRCS += $(HS_TEST_PROGS:%=%.hs)
endif
Makefile.ghc: $(HS_MAKEFILE_GHC_SRCS) Makefile \
| $(built_base_sources) $(HS_BUILT_SRCS)
$(GHC) -M -dep-makefile $@ $(DEP_SUFFIXES) $(HFLAGS) -itest/hs \
$(GHC) -M -dep-makefile $@ $(DEP_SUFFIXES) $(HFLAGS) $(HFLAGS_NOPROF) \
-itest/hs \
$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA_COMBINED) $(HS_MAKEFILE_GHC_SRCS)
# Since ghc -M does not generate dependency line for object files, dependencies
# from a target executable seed object (e.g. src/hluxid.o) to objects which
......@@ -1264,7 +1282,7 @@ Makefile.ghc: $(HS_MAKEFILE_GHC_SRCS) Makefile \
%.o:
@echo '[GHC]: $@ <- $^'
@$(GHC) -c $(HFLAGS) \
@$(GHC) -c $(HFLAGS) $(HFLAGS_NOPROF) \
$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA_COMBINED) $(@:%.o=%.hs)
# For TH+profiling we need to compile twice: Once without profiling,
......@@ -1290,13 +1308,15 @@ endif
if HPROFILE
$(HS_SRC_PROGS): %: %.$(HPROF_SUFFIX)_o | stamp-directories
@echo '[GHC-link]: $@'
$(GHC) $(HFLAGS) $(HPROFFLAGS) \
$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA_COMBINED) --make $(@:%=%.hs)
else
$(HS_SRC_PROGS): %: %.o | stamp-directories
endif
@echo '[GHC-link]: $@'
$(GHC) $(HFLAGS) \
$(HPROFFLAGS) \
$(GHC) $(HFLAGS) $(HFLAGS_NOPROF) \
$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA_COMBINED) --make $(@:%=%.hs)
endif
@rm -f $(notdir $@).tix
@touch "$@"
......
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