Commit bc953fcd authored by Edward Z. Yang's avatar Edward Z. Yang Committed by Ben Gamari

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
parent e9c2555a
......@@ -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.
......
......@@ -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]
......
......@@ -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
......
{-# LANGUAGE CPP #-}
main = do
#ifndef VERSION_containers
putStrLn "OK"
#endif
......@@ -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
......
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