[commit: ghc] ghc-7.8: Bug #9439: Ensure that stage 0 compiler isn't affected (1f7dc1b)

git at git.haskell.org git at git.haskell.org
Mon Oct 27 15:59:09 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-7.8
Link       : http://ghc.haskell.org/trac/ghc/changeset/1f7dc1bbd0f4f55cf0c7b15d7e4d2480cf2db9d1/ghc

>---------------------------------------------------------------

commit 1f7dc1bbd0f4f55cf0c7b15d7e4d2480cf2db9d1
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Mon Aug 18 21:44:25 2014 -0500

    Bug #9439: Ensure that stage 0 compiler isn't affected
    
    Summary:
    Bug #9439 will cause miscompilation of GHC's LLVM backend. Here we
    ensure that an affected compiler isn't used to bootstrap.
    
    Test Plan: Attempt to bootstrap GHC with an affected stage 0 compiler.
    
    Reviewers: rwbarton, austin
    
    Reviewed By: austin
    
    Subscribers: simonmar, relrod, ezyang, carter
    
    Differential Revision: https://phabricator.haskell.org/D159
    
    (cherry picked from commit bbd031134a571c1020945b2548e3fc4795b5047a)


>---------------------------------------------------------------

1f7dc1bbd0f4f55cf0c7b15d7e4d2480cf2db9d1
 Makefile         |  7 +++++++
 configure.ac     | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 mk/project.mk.in |  3 +++
 3 files changed, 60 insertions(+)

diff --git a/Makefile b/Makefile
index 6872cb3..4145d97 100644
--- a/Makefile
+++ b/Makefile
@@ -44,6 +44,13 @@ endif
 
 include mk/custom-settings.mk
 
+# Verify that stage 0 LLVM backend isn't affected by Bug #9439 if needed
+ifeq "$(GHC_LLVM_AFFECTED_BY_9439)" "1"
+ifneq "$(findstring -fllvm,$(GhcHcOpts) $(GhcStage1HcOpts))" ""
+$(error Stage 0 compiler is affected by Bug #9439. Refusing to bootstrap with -fllvm)
+endif
+endif
+
 # No need to update makefiles for these targets:
 REALGOALS=$(filter-out binary-dist binary-dist-prep bootstrapping-files framework-pkg clean clean_% distclean maintainer-clean show echo help test fulltest,$(MAKECMDGOALS))
 
diff --git a/configure.ac b/configure.ac
index 8f53bdf..f455e3d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -184,6 +184,56 @@ AC_SUBST([WithGhc])
 dnl ** Without optimization some INLINE trickery fails for GHCi
 SRC_CC_OPTS="-O"
 
+dnl ** Bug 9439: Some GHC 7.8 releases had broken LLVM code generator.
+dnl Unfortunately we don't know whether the user is going to request a
+dnl build with the LLVM backend as this is only given in build.mk.
+dnl
+dnl Instead, we try to do as much work as possible here, checking
+dnl whether -fllvm is the stage 0 compiler's default. If so we
+dnl fail. If not, we check whether -fllvm is affected explicitly and
+dnl if so set a flag. The build system will later check this flag
+dnl after the desired build flags are known.
+AC_MSG_CHECKING(whether bootstrap compiler is affected by bug 9439)
+echo "main = putStrLn \"%function\"" > conftestghc.hs
+
+# Check whether LLVM backend is default for this platform
+${WithGhc} conftestghc.hs 2>&1 >/dev/null
+res=`./conftestghc`
+if test "x$res" == "x%object"
+then
+    AC_MSG_RESULT(yes)
+    echo "Buggy bootstrap compiler"
+    echo ""
+    echo "The stage 0 compiler $WithGhc is affected by GHC Bug \#9439"
+    echo "and therefore will miscompile the LLVM backend if -fllvm is"
+    echo "used."
+    echo
+    echo "Please use another bootstrap compiler"
+    exit 1
+fi
+
+# -fllvm is not the default, but set a flag so the Makefile can check
+# -for it in the build flags later on
+${WithGhc} -fforce-recomp -fllvm conftestghc.hs 2>&1 >/dev/null
+if test $? == 0
+then
+    res=`./conftestghc`
+    if test "x$res" == "x%object"
+    then
+        AC_MSG_RESULT(yes)
+        GHC_LLVM_AFFECTED_BY_9439=1
+    elif test "x$res" == "x%function"
+    then
+        AC_MSG_RESULT(no)
+        GHC_LLVM_AFFECTED_BY_9439=0
+    else
+        AC_MSG_WARN(unexpected output $res)
+    fi
+else
+    AC_MSG_RESULT(failed to compile, assuming no)
+fi
+AC_SUBST([GHC_LLVM_AFFECTED_BY_9439])
+
 dnl--------------------------------------------------------------------
 dnl * Choose host(/target/build) platform
 dnl--------------------------------------------------------------------
diff --git a/mk/project.mk.in b/mk/project.mk.in
index 28692d4..69ed885 100644
--- a/mk/project.mk.in
+++ b/mk/project.mk.in
@@ -157,3 +157,6 @@ SOLARIS_BROKEN_SHLD=@SOLARIS_BROKEN_SHLD@
 # Do we have a C compiler using an LLVM back end?
 CC_LLVM_BACKEND  = @CC_LLVM_BACKEND@
 CC_CLANG_BACKEND = @CC_CLANG_BACKEND@
+
+# Is the stage0 compiler affected by Bug #9439?
+GHC_LLVM_AFFECTED_BY_9439 = @GHC_LLVM_AFFECTED_BY_9439@



More information about the ghc-commits mailing list