Commit 1ad14f38 authored by Niklas Hambuechen's avatar Niklas Hambuechen

Makefile.am: Don't use -dynamic-too for .hpc_o files

It turns out that GHC 7.8's -dynamic-too is forbidden not only for
profiling builds object files, but also for those using HPC coverage.

This commit accordingly renames HFLAGS_NOPROF to HFLAGS_DYNAMIC
(since it now is not conditional on profiling any more),
and makes sure that it is not used for profiling or HPC.

This way we achieve that, for profiling+coverage builds
  - .dyn_o files are available for use in TH in the following 3 cases
  - .o files are for the normal binaries
  - .hpc_o files are for coverage-enabled test binaries
  - .prof_o files are for profiling binaries

We make .hpc_o files depend on the .o files because the creation of
the .o files will also create the .so files needed for TH.
This was already in place for .prof_o files.

This requires that HFLAGS now also contains `-itest/hs` since
the rule for .o files is now also responsible for building .o/.so files
in test/hs.
Signed-off-by: default avatarNiklas Hambuechen <niklash@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent 7f7c9c2c
...@@ -772,18 +772,15 @@ DEP_SUFFIXES += -dep-suffix $(HPROF_SUFFIX)_ -dep-suffix $(HTEST_SUFFIX)_ \ ...@@ -772,18 +772,15 @@ DEP_SUFFIXES += -dep-suffix $(HPROF_SUFFIX)_ -dep-suffix $(HTEST_SUFFIX)_ \
-dep-suffix "" -dep-suffix ""
endif endif
# Flags that are only for GHC invocations which are not doing profiling # GHC > 7.6 needs -dynamic-too when using Template Haskell since its
# 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. # ghci is switched to loading dynamic libraries by default.
# But this flag must only be used in non-profiling GHC invocations, # It must only be used in non-profiling GHC invocations.
# so we put it in HFLAGS_NOPROF. # We also don't use it in compilations that use HTEST_SUFFIX (which are
# compiled with -fhpc) because HPC coverage doesn't interact well with
# GHCI shared lib loading (https://ghc.haskell.org/trac/ghc/ticket/9762).
HFLAGS_DYNAMIC =
if !GHC_LE_76 if !GHC_LE_76
HFLAGS_NOPROF += -dynamic-too HFLAGS_DYNAMIC += -dynamic-too
endif endif
if HPROFILE if HPROFILE
...@@ -800,9 +797,6 @@ endif ...@@ -800,9 +797,6 @@ endif
HTEST_FLAGS = $(HFLAGS) -fhpc -itest/hs \ HTEST_FLAGS = $(HFLAGS) -fhpc -itest/hs \
-osuf $(HTEST_SUFFIX)_o \ -osuf $(HTEST_SUFFIX)_o \
-hisuf $(HTEST_SUFFIX)_hi -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.) # extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
HEXTRA = HEXTRA =
...@@ -1265,7 +1259,7 @@ HS_MAKEFILE_GHC_SRCS += $(HS_TEST_PROGS:%=%.hs) ...@@ -1265,7 +1259,7 @@ HS_MAKEFILE_GHC_SRCS += $(HS_TEST_PROGS:%=%.hs)
endif endif
Makefile.ghc: $(HS_MAKEFILE_GHC_SRCS) Makefile \ Makefile.ghc: $(HS_MAKEFILE_GHC_SRCS) Makefile \
| $(built_base_sources) $(HS_BUILT_SRCS) | $(built_base_sources) $(HS_BUILT_SRCS)
$(GHC) -M -dep-makefile $@ $(DEP_SUFFIXES) $(HFLAGS) $(HFLAGS_NOPROF) \ $(GHC) -M -dep-makefile $@ $(DEP_SUFFIXES) $(HFLAGS) $(HFLAGS_DYNAMIC) \
-itest/hs \ -itest/hs \
$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA_COMBINED) $(HS_MAKEFILE_GHC_SRCS) $(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA_COMBINED) $(HS_MAKEFILE_GHC_SRCS)
# Since ghc -M does not generate dependency line for object files, dependencies # Since ghc -M does not generate dependency line for object files, dependencies
...@@ -1282,9 +1276,19 @@ Makefile.ghc: $(HS_MAKEFILE_GHC_SRCS) Makefile \ ...@@ -1282,9 +1276,19 @@ Makefile.ghc: $(HS_MAKEFILE_GHC_SRCS) Makefile \
@include_makefile_ghc@ @include_makefile_ghc@
# Like the %.o rule, but allows access to the test/hs directory.
# This uses HFLAGS instead of HTEST_FLAGS because it's only for generating
# object files (.o for GHC <= 7.6, .o/.so for newer GHCs) that are loaded
# in GHCI when evaluating TH. The actual test-with-coverage .hpc_o files
# are created in the `%.$(HTEST_SUFFIX)_o` rule.
test/hs/%.o:
@echo '[GHC|test]: $@ <- test/hs/$^'
@$(GHC) -c $(HFLAGS) -itest/hs $(HFLAGS_DYNAMIC) \
$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA_COMBINED) $(@:%.o=%.hs)
%.o: %.o:
@echo '[GHC]: $@ <- $^' @echo '[GHC]: $@ <- $^'
@$(GHC) -c $(HFLAGS) $(HFLAGS_NOPROF) \ @$(GHC) -c $(HFLAGS) $(HFLAGS_DYNAMIC) \
$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA_COMBINED) $(@:%.o=%.hs) $(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA_COMBINED) $(@:%.o=%.hs)
# For TH+profiling we need to compile twice: Once without profiling, # For TH+profiling we need to compile twice: Once without profiling,
...@@ -1299,7 +1303,11 @@ if HPROFILE ...@@ -1299,7 +1303,11 @@ if HPROFILE
$(@:%.$(HPROF_SUFFIX)_o=%.hs) $(@:%.$(HPROF_SUFFIX)_o=%.hs)
endif endif
%.$(HTEST_SUFFIX)_o: # We depend on the non-test .o file here because we need the corresponding .so
# file for GHC > 7.6 ghci dynamic loading for TH, and creating the .o file
# will create the .so file since we use -dynamic-too (using the `test/hs/%.o`
# rule).
%.$(HTEST_SUFFIX)_o: %.o
@echo '[GHC|test]: $@ <- $^' @echo '[GHC|test]: $@ <- $^'
@$(GHC) -c $(HTEST_FLAGS) \ @$(GHC) -c $(HTEST_FLAGS) \
$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA_COMBINED) $(@:%.$(HTEST_SUFFIX)_o=%.hs) $(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA_COMBINED) $(@:%.$(HTEST_SUFFIX)_o=%.hs)
...@@ -1316,7 +1324,7 @@ $(HS_SRC_PROGS): %: %.$(HPROF_SUFFIX)_o | stamp-directories ...@@ -1316,7 +1324,7 @@ $(HS_SRC_PROGS): %: %.$(HPROF_SUFFIX)_o | stamp-directories
else else
$(HS_SRC_PROGS): %: %.o | stamp-directories $(HS_SRC_PROGS): %: %.o | stamp-directories
@echo '[GHC-link]: $@' @echo '[GHC-link]: $@'
$(GHC) $(HFLAGS) $(HFLAGS_NOPROF) \ $(GHC) $(HFLAGS) $(HFLAGS_DYNAMIC) \
$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA_COMBINED) --make $(@:%=%.hs) $(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA_COMBINED) --make $(@:%=%.hs)
endif endif
@rm -f $(notdir $@).tix @rm -f $(notdir $@).tix
......
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