summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordoug <douglas.wilson@gmail.com>2017-05-04 14:16:17 -0400
committerBen Gamari <ben@smart-cactus.org>2017-05-04 18:20:44 -0400
commitdb10b79994f7728cbaaa906c6f6eda0b6783df29 (patch)
tree16c260e5f30d7773fd5d05df1facedfb4293171c
parenta660844c0859b7a2e76c15f2fb4abec209afea90 (diff)
downloadhaskell-db10b79994f7728cbaaa906c6f6eda0b6783df29.tar.gz
Pass -ffrontend-opt arguments to frontend plugin in the correct order
Previously they were passed in the reverse order that they're specified on the command line. Add a haddock to frontendPluginOpts in DynFlags.hs. Modify test frontend01 to cover the case of multiple -ffrontend-opt. Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie GHC Trac Issues: #13632 Differential Revision: https://phabricator.haskell.org/D3520
-rw-r--r--compiler/main/DynFlags.hs2
-rw-r--r--ghc/Main.hs3
-rw-r--r--testsuite/tests/plugins/Makefile2
-rw-r--r--testsuite/tests/plugins/frontend01.stdout2
4 files changed, 6 insertions, 3 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 383a71a7e5..5771fd6b57 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -796,6 +796,8 @@ data DynFlags = DynFlags {
pluginModNames :: [ModuleName],
pluginModNameOpts :: [(ModuleName,String)],
frontendPluginOpts :: [String],
+ -- ^ the @-ffrontend-opt@ flags given on the command line, in *reverse*
+ -- order that they're specified on the command line.
-- GHC API hooks
hooks :: Hooks,
diff --git a/ghc/Main.hs b/ghc/Main.hs
index 6ece4302db..0a4e17aa7d 100644
--- a/ghc/Main.hs
+++ b/ghc/Main.hs
@@ -837,7 +837,8 @@ doFrontend modname _ = pluginError [modname]
doFrontend modname srcs = do
hsc_env <- getSession
frontend_plugin <- liftIO $ loadFrontendPlugin hsc_env modname
- frontend frontend_plugin (frontendPluginOpts (hsc_dflags hsc_env)) srcs
+ frontend frontend_plugin
+ (reverse $ frontendPluginOpts (hsc_dflags hsc_env)) srcs
#endif
-- -----------------------------------------------------------------------------
diff --git a/testsuite/tests/plugins/Makefile b/testsuite/tests/plugins/Makefile
index 46fdc7df2f..efe17efeb8 100644
--- a/testsuite/tests/plugins/Makefile
+++ b/testsuite/tests/plugins/Makefile
@@ -34,7 +34,7 @@ T10294a:
frontend01:
$(RM) FrontendPlugin.hi FrontendPlugin.o frontend01 frontend01.hi frontend.o
"$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) -Wall -package ghc -c FrontendPlugin.hs
- "$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) --frontend FrontendPlugin -ffrontend-opt foobar frontend01
+ "$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) --frontend FrontendPlugin -ffrontend-opt foo -ffrontend-opt bar frontend01
./frontend01
# -hide-all-plugin-packages + -package (this should not work!)
diff --git a/testsuite/tests/plugins/frontend01.stdout b/testsuite/tests/plugins/frontend01.stdout
index 84950bcbc9..234c91c10b 100644
--- a/testsuite/tests/plugins/frontend01.stdout
+++ b/testsuite/tests/plugins/frontend01.stdout
@@ -1,4 +1,4 @@
-["foobar"]
+["foo","bar"]
[1 of 1] Compiling Main ( frontend01.hs, frontend01.o )
Linking frontend01 ...
hello world