summaryrefslogtreecommitdiff
path: root/compiler/main/DriverPipeline.hs
diff options
context:
space:
mode:
authorNicolas Trangez <ikke@nicolast.be>2016-10-01 17:58:11 -0400
committerBen Gamari <ben@smart-cactus.org>2016-10-01 20:01:29 -0400
commitb0d53a839da0149e0142da036b6ebf5a01b3216f (patch)
tree40d092148d1e366f3042210c21ca15a5c306847a /compiler/main/DriverPipeline.hs
parent0014fa56e9f2fe936da85627c92a288037c8c19b (diff)
downloadhaskell-b0d53a839da0149e0142da036b6ebf5a01b3216f.tar.gz
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
Diffstat (limited to 'compiler/main/DriverPipeline.hs')
-rw-r--r--compiler/main/DriverPipeline.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 5d648e60f9..6e61d20dc8 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -2099,8 +2099,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 []