[commit: ghc] master: Pass -ffrontend-opt arguments to frontend plugin in the correct order (db10b79)

git at git.haskell.org git at git.haskell.org
Thu May 4 22:22:52 UTC 2017


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

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

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

commit db10b79994f7728cbaaa906c6f6eda0b6783df29
Author: doug <douglas.wilson at gmail.com>
Date:   Thu May 4 14:16:17 2017 -0400

    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


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

db10b79994f7728cbaaa906c6f6eda0b6783df29
 compiler/main/DynFlags.hs                 | 2 ++
 ghc/Main.hs                               | 3 ++-
 testsuite/tests/plugins/Makefile          | 2 +-
 testsuite/tests/plugins/frontend01.stdout | 2 +-
 4 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 383a71a..5771fd6 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 6ece430..0a4e17a 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 46fdc7d..efe17ef 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 84950bc..234c91c 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



More information about the ghc-commits mailing list