[commit: ghc] master: Add -f(no-)version-macro to explicitly control macros. (bc953fc)

git at git.haskell.org git at git.haskell.org
Wed Mar 30 20:46:56 UTC 2016


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/bc953fcdbc76ffbb4f06a2b74be271268f73328f/ghc

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

commit bc953fcdbc76ffbb4f06a2b74be271268f73328f
Author: Edward Z. Yang <ezyang at cs.stanford.edu>
Date:   Wed Mar 30 21:44:09 2016 +0200

    Add -f(no-)version-macro to explicitly control macros.
    
    Test Plan: validate
    
    Reviewers: thomie, austin, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: hvr
    
    Differential Revision: https://phabricator.haskell.org/D2058
    
    GHC Trac Issues: #11763


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

bc953fcdbc76ffbb4f06a2b74be271268f73328f
 compiler/main/DriverPipeline.hs                                      | 2 +-
 compiler/main/DynFlags.hs                                            | 5 ++++-
 testsuite/.gitignore                                                 | 1 +
 testsuite/tests/driver/T11763.hs                                     | 5 +++++
 .../{simplCore/should_run/T5453.stdout => driver/T11763.stdout}      | 0
 testsuite/tests/driver/all.T                                         | 1 +
 6 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index bc9c19b..586754f 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -2056,7 +2056,7 @@ doCpp dflags raw input_fn output_fn = do
     let uids = explicitPackages (pkgState dflags)
         pkgs = catMaybes (map (lookupPackage dflags) uids)
     mb_macro_include <-
-        if not (null pkgs)
+        if not (null pkgs) && gopt Opt_VersionMacros dflags
             then do macro_stub <- newTempName dflags "h"
                     writeFile macro_stub (generatePackageVersionMacros pkgs)
                     -- Include version macros for every *exposed* package.
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 9c67045..9e06445 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -486,6 +486,7 @@ data GeneralFlag
    | Opt_FlatCache
    | Opt_ExternalInterpreter
    | Opt_OptimalApplicativeDo
+   | Opt_VersionMacros
 
    -- PreInlining is on by default. The option is there just to see how
    -- bad things get if you turn it off!
@@ -3397,6 +3398,7 @@ fFlagsDeps = [
   flagSpec "unbox-strict-fields"              Opt_UnboxStrictFields,
   flagSpec "vectorisation-avoidance"          Opt_VectorisationAvoidance,
   flagSpec "vectorise"                        Opt_Vectorise,
+  flagSpec "version-macros"                   Opt_VersionMacros,
   flagSpec "worker-wrapper"                   Opt_WorkerWrapper,
   flagSpec "show-warning-groups"              Opt_ShowWarnGroups
   ]
@@ -3640,7 +3642,8 @@ defaultFlags settings
       Opt_ProfCountEntries,
       Opt_RPath,
       Opt_SharedImplib,
-      Opt_SimplPreInlining
+      Opt_SimplPreInlining,
+      Opt_VersionMacros
     ]
 
     ++ [f | (ns,f) <- optLevelFlags, 0 `elem` ns]
diff --git a/testsuite/.gitignore b/testsuite/.gitignore
index 8926e4e..655e3da 100644
--- a/testsuite/.gitignore
+++ b/testsuite/.gitignore
@@ -571,6 +571,7 @@ mk/ghcconfig*_test___spaces_ghc*.exe.mk
 /tests/driver/T8526/A.inc
 /tests/driver/T8602/t8602.sh
 /tests/driver/T9562/Main
+/tests/driver/T11763
 /tests/driver/Test.081b
 /tests/driver/Test.081b.hs
 /tests/driver/Test_081a
diff --git a/testsuite/tests/driver/T11763.hs b/testsuite/tests/driver/T11763.hs
new file mode 100644
index 0000000..3fd5df9
--- /dev/null
+++ b/testsuite/tests/driver/T11763.hs
@@ -0,0 +1,5 @@
+{-# LANGUAGE CPP #-}
+main = do
+#ifndef VERSION_containers
+    putStrLn "OK"
+#endif
diff --git a/testsuite/tests/simplCore/should_run/T5453.stdout b/testsuite/tests/driver/T11763.stdout
similarity index 100%
copy from testsuite/tests/simplCore/should_run/T5453.stdout
copy to testsuite/tests/driver/T11763.stdout
diff --git a/testsuite/tests/driver/all.T b/testsuite/tests/driver/all.T
index 23aeb99..761ad62 100644
--- a/testsuite/tests/driver/all.T
+++ b/testsuite/tests/driver/all.T
@@ -475,6 +475,7 @@ test('T11381', normal, compile_fail, [''])
 test('T11429a', normal, compile, ['-Wunrecognised-warning-flags -Wfoobar'])
 test('T11429b', normal, compile, ['-Wno-unrecognised-warning-flags -Wfoobar'])
 test('T11429c', normal, compile_fail, ['-Wunrecognised-warning-flags -Werror -Wfoobar'])
+test('T11763', normal, compile_and_run, ['-fno-version-macros'])
 
 test('T10320',
      [ ignore_output



More information about the ghc-commits mailing list