[commit: ghc] ghc-8.0: Turn `__GLASGOW_HASKELL_LLVM__` into an integer again (3b13a04)

git at git.haskell.org git at git.haskell.org
Sun Oct 2 18:54:04 UTC 2016


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

On branch  : ghc-8.0
Link       : http://ghc.haskell.org/trac/ghc/changeset/3b13a0426f59b47fb27646c694caf1df55a684e3/ghc

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

commit 3b13a0426f59b47fb27646c694caf1df55a684e3
Author: Nicolas Trangez <ikke at nicolast.be>
Date:   Sat Oct 1 17:58:11 2016 -0400

    Turn `__GLASGOW_HASKELL_LLVM__` into an integer again
    
    In GHC < 8.0.1, the value of `__GLASGOW_HASKELL_LLVM__`, exposed
    through the preprocessor when compiled with `-fllvm`, was an integer
    value, encoded according to some rules specified in the user guide.
    
    Due to an oversight, in GHC 8.0.1 the value of this define became a
    tuple, exposed as e.g. `(3, 7)`. This was an unintended regression.
    
    This patch turns the value of the `__GLASGOW_HASKELL_LLVM__` definition
    into a single integer again, but changes the formatting of said number
    slightly. Before, any LLVM version where the major or minor component >=
    10 would cause ambiguous values for `__GLASGOW_HASKELL_LLVM__`. With
    this patch, the value is in line with `__GLASGOW_HASKELL__`, adding a
    padding `0` in-between major and minor component if applicable (we
    assume no minors >= 100 will ever exist).
    
    The documentation in the user guide is updated accordingly, and a
    reference is made in the 8.0.2 release notes.
    
    Test Plan: validate
    
    Reviewers: bgamari, erikd
    
    Reviewed By: bgamari
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D2552
    
    GHC Trac Issues: #12628
    
    (cherry picked from commit b0d53a839da0149e0142da036b6ebf5a01b3216f)


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

3b13a0426f59b47fb27646c694caf1df55a684e3
 compiler/main/DriverPipeline.hs  | 6 +++++-
 docs/users_guide/8.0.2-notes.rst | 6 ++++++
 docs/users_guide/phases.rst      | 4 +++-
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 2f59678..d16afc5 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -2100,8 +2100,12 @@ getBackendDefs :: DynFlags -> IO [String]
 getBackendDefs dflags | hscTarget dflags == HscLlvm = do
     llvmVer <- figureLlvmVersion dflags
     return $ case llvmVer of
-               Just n -> [ "-D__GLASGOW_HASKELL_LLVM__="++show n ]
+               Just n -> [ "-D__GLASGOW_HASKELL_LLVM__=" ++ format n ]
                _      -> []
+  where
+    format (major, minor)
+      | minor >= 100 = error "getBackendDefs: Unsupported minor version"
+      | otherwise = show $ (100 * major + minor :: Int) -- Contract is Int
 
 getBackendDefs _ =
     return []
diff --git a/docs/users_guide/8.0.2-notes.rst b/docs/users_guide/8.0.2-notes.rst
index 508387e..668474a 100644
--- a/docs/users_guide/8.0.2-notes.rst
+++ b/docs/users_guide/8.0.2-notes.rst
@@ -34,6 +34,12 @@ Compiler
    defaulting to decimal, hexadecimal if the address starts with `0x`, and
    octal if the address starts with `0`.
 
+-  Due to an oversight in GHC 8.0.1, the value of the preprocessor macro
+   ``__GLASGOW_HASKELL_LLVM__``, which exposes the LLVM version used by GHC, was
+   no longer an integer. This value is now turned into an integer again, but the
+   formatting is changed to be in line with ``__GLASGOW_HASKELL__``
+   (:ghc-ticket:`12628`).
+
 Runtime system
 ~~~~~~~~~~~~~~
 
diff --git a/docs/users_guide/phases.rst b/docs/users_guide/phases.rst
index 0c3b59f..01c2e1f 100644
--- a/docs/users_guide/phases.rst
+++ b/docs/users_guide/phases.rst
@@ -291,7 +291,9 @@ defined by your local GHC installation, the following trick is useful:
 
     Only defined when ``-fllvm`` is specified. When GHC is using version
     ``x.y.z`` of LLVM, the value of ``__GLASGOW_HASKELL_LLVM__`` is the
-    integer ⟨xy⟩.
+    integer ⟨xyy⟩ (if ⟨y⟩ is a single digit, then a leading zero
+    is added, so for example when using version 3.7 of LLVM,
+    ``__GLASGOW_HASKELL_LLVM__==307``).
 
 ``__PARALLEL_HASKELL__``
     .. index::



More information about the ghc-commits mailing list