[commit: ghc] ghc-8.2: Pass -ffrontend-opt arguments to frontend plugin in the correct order (771e8d6)

git at git.haskell.org git at git.haskell.org
Fri May 5 02:54:48 UTC 2017


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

On branch  : ghc-8.2
Link       : http://ghc.haskell.org/trac/ghc/changeset/771e8d6838238fe87b2282696bff77fd4c474f71/ghc

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

commit 771e8d6838238fe87b2282696bff77fd4c474f71
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
    
    (cherry picked from commit db10b79994f7728cbaaa906c6f6eda0b6783df29)


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

771e8d6838238fe87b2282696bff77fd4c474f71
 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 2773b87..10bf671 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -794,6 +794,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 29012f6..cc6d08e 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