[commit: ghc] master: Hadrian: include 'findPtr' via find-ptr cabal flag (924026e)

git at git.haskell.org git at git.haskell.org
Tue Dec 4 07:16:01 UTC 2018


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

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

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

commit 924026e0405396a3f559f163e829b88f30cca49e
Author: Alec Theriault <alec.theriault at gmail.com>
Date:   Tue Dec 4 00:21:48 2018 +0000

    Hadrian: include 'findPtr' via find-ptr cabal flag
    
    Summary:
    This is the latest in the 'findPtr' saga. See
    
      * 900c47f88784b91517c00be3e1087322e62f698e
      * 561748cb507505bd5b7bd76bdc57796d896b62a2
    
    for the previous attempts. The problem with re-using the 'debug'
    cabal flag for the purpose of forcing inclusion of 'findPtr' occurs
    when 'debug' is one of the RTS ways, but RTS is not being compiled
    with '-DDEBUG':
    
      * the 'debug' flag gets passed to cabal, signalling to build
        'rts' with the debug flavour, but also forcing inclusion of
        the 'findPtr'/'_findPtr' symbol
    
      * since '-DDEBUG' isn't enabled, that symbol doesn't show up in
        the libraries, so executable that depend on 'rts' (everything)
        will end up always requiring 'findPtr'/'_findPtr' but 'rts' won'y
        provide it!
    
    The fix is simple: create a a new 'find-ptr' cabal-flag whose only
    purpose is forcing '-Wl,-u,findPtr'/'-Wl,-u,_findPtr'. Then, enable that
    flag when the RTS is being compiled with '-DDEBUG'
    
    Test Plan: ./hadrian/build.sh -c # on mac
    
    Reviewers: alpmestan, snowleopard, bgamari, erikd, simonmar, Phyx
    
    Reviewed By: alpmestan, snowleopard, Phyx
    
    Subscribers: Phyx, rwbarton, carter
    
    GHC Trac Issues: #15956
    
    Differential Revision: https://phabricator.haskell.org/D5404


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

924026e0405396a3f559f163e829b88f30cca49e
 hadrian/src/Rules/Test.hs        | 4 ++--
 hadrian/src/Settings/Packages.hs | 1 +
 rts/rts.cabal.in                 | 9 +++++----
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/hadrian/src/Rules/Test.hs b/hadrian/src/Rules/Test.hs
index 9a314dc..b72c1b9 100644
--- a/hadrian/src/Rules/Test.hs
+++ b/hadrian/src/Rules/Test.hs
@@ -26,13 +26,13 @@ testRules :: Rules ()
 testRules = do
     root <- buildRootRules
 
-    -- | Using program shipped with testsuite to generate ghcconfig file.
+    -- Using program shipped with testsuite to generate ghcconfig file.
     root -/- ghcConfigProgPath ~> do
         ghc <- builderPath $ Ghc CompileHs Stage0
         createDirectory $ takeDirectory (root -/- ghcConfigProgPath)
         cmd ghc [ghcConfigHsPath, "-o" , root -/- ghcConfigProgPath]
 
-    -- | TODO : Use input test compiler and not just stage2 compiler.
+    -- TODO : Use input test compiler and not just stage2 compiler.
     root -/- ghcConfigPath ~> do
         ghcPath <- needFile Stage1 ghc
         need [root -/- ghcConfigProgPath]
diff --git a/hadrian/src/Settings/Packages.hs b/hadrian/src/Settings/Packages.hs
index 51a980c..8963c76 100644
--- a/hadrian/src/Settings/Packages.hs
+++ b/hadrian/src/Settings/Packages.hs
@@ -286,6 +286,7 @@ rtsPackageArgs = package rts ? do
           , any (wayUnit Debug) rtsWays ? arg "debug"
           , any (wayUnit Logging) rtsWays ? arg "logging"
           , any (wayUnit Dynamic) rtsWays ? arg "dynamic"
+          , Debug `wayUnit` way           ? arg "find-ptr"
           ]
         , builder (Cc FindCDependencies) ? cArgs
         , builder (Ghc CompileCWithGhc) ? map ("-optc" ++) <$> cArgs
diff --git a/rts/rts.cabal.in b/rts/rts.cabal.in
index e9cc7d1..a3f74be 100644
--- a/rts/rts.cabal.in
+++ b/rts/rts.cabal.in
@@ -28,6 +28,8 @@ flag leading-underscore
   default: @CabalLeadingUnderscore@
 flag smp
   default: True
+flag find-ptr
+  default: False
 -- Some cabal flags used to control the flavours we want to produce
 -- for libHSrts in hadrian. By default, we just produce vanilla and
 -- threaded. The flags "compose": if you enable debug and profiling,
@@ -268,9 +270,8 @@ library
          "-Wl,-u,_hs_atomicwrite8"
          "-Wl,-u,_hs_atomicwrite16"
          "-Wl,-u,_hs_atomicwrite32"
-         "-Wl,-u,_findPtr"
 
-      if flag(debug)
+      if flag(find-ptr)
         -- This symbol is useful in gdb, but not referred to anywhere,
         -- so we need to force it to be included in the binary.
         ld-options: "-Wl,-u,_findPtr"
@@ -346,10 +347,10 @@ library
          "-Wl,-u,hs_atomicwrite16"
          "-Wl,-u,hs_atomicwrite32"
 
-      if flag(debug)
+      if flag(find-ptr)
         -- This symbol is useful in gdb, but not referred to anywhere,
         -- so we need to force it to be included in the binary.
-        ld-options: "-Wl,-u,_findPtr"
+        ld-options: "-Wl,-u,findPtr"
 
     if os(osx)
       ld-options: "-Wl,-search_paths_first"



More information about the ghc-commits mailing list