Re: #16368: Boot GHC's libffi installation path leaks into stage1 build

"GHC" <[email protected]>
Newsgroups gmane.comp.lang.haskell.glasgow.bugs
Message-ID <[email protected]>
#16368: Boot GHC's libffi installation path leaks into stage1 build
-------------------------------------+-------------------------------------
        Reporter:  sgraf             |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  ⊥
       Component:  Build System      |              Version:  8.6.3
  (Hadrian)                          |
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by sgraf):

 * cc: bgamari (added)


Comment:

 The `libffi` bit seems to be pulled in from `rts`, which itself isn't
 mentioned as include dir:

 {{{
 {sourcePackageId = PackageIdentifier {pkgName = PackageName "rts",
 pkgVersion = mkVersion [1,0]}, sourceLibName = LMainLibName,
 installedComponentId_ = ComponentId "", installedUnitId = UnitId "rts",
 instantiatedWith = [], compatPackageKey = "rts", license = Left (License
 (ELicense (ELicenseId BSD_3_Clause) Nothing)), copyright = "", maintainer
 = "[email protected]", author = "", stability = "",
 homepage = "", pkgUrl = "", synopsis = "", description = "", category =
 "", abiHash = AbiHash "", indefinite = False, exposed = True,
 exposedModules = [], hiddenModules = [], trusted = False, importDirs = [],
 libraryDirs = ["/nix/store/7874h075nf8yikvr47642xqrwqwyv99s-
 ghc-8.6.3/lib/ghc-8.6.3/rts","/nix/store/karxq4hlfmfj0c3yk4wv5mfaz06p70k8-libffi-3.2.1/lib"],
 libraryDynDirs = [], dataDir = "", hsLibraries = ["HSrts"], extraLibraries
 = ["m","rt","dl","ffi","pthread"], extraGHCiLibraries = [], includeDirs =
 ["/nix/store/7874h075nf8yikvr47642xqrwqwyv99s-
 ghc-8.6.3/lib/ghc-8.6.3/include","/nix/store/karxq4hlfmfj0c3yk4wv5mfaz06p70k8-libffi-3.2.1/include"],
 includes = ["Stg.h"], depends = [], abiDepends = [], ccOptions = [],
 cxxOptions = [], ldOptions = [], frameworkDirs = [], frameworks = [],
 haddockInterfaces = [], haddockHTMLs = [], pkgRoot = Just "/nix/store
 /23ndnrb11m3k7zh4p84vjmdgand0p45b-ghc-8.6.3-with-packages/lib/ghc-8.6.3",
 libVisibility = LibraryVisibilityPrivate}
 }}}

 I could probably fix this by the following patch:

 {{{#!diff
 diff --git a/utils/ghc-cabal/Main.hs b/utils/ghc-cabal/Main.hs
 index 8b776499fd..f4a2313194 100644
 --- a/utils/ghc-cabal/Main.hs
 +++ b/utils/ghc-cabal/Main.hs
 @@ -338,14 +338,22 @@ generate directory distdir config_args
                [(_,[rts])] ->
                   PackageIndex.insert rts{
                       Installed.ldOptions = [],
 -                     Installed.libraryDirs = filter (not . ("gcc-lib"
 `isSuffixOf`)) (Installed.libraryDirs rts)} index
 -                        -- GHC <= 6.12 had $topdir/gcc-lib in their
 -                        -- library-dirs for the rts package, which causes
 -                        -- problems when we try to use the in-tree mingw,
 -                        -- due to accidentally picking up the
 incompatible
 -                        -- libraries there.  So we filter out gcc-lib
 from
 -                        -- the RTS's library-dirs here.
 +                     Installed.libraryDirs = filter_dirs
 (Installed.libraryDirs rts),
 +                     Installed.includeDirs = filter_dirs
 (Installed.includeDirs rts)
 +                  } index
                _ -> error "No (or multiple) ghc rts package is
 registered!!"
 +          filter_dirs = filter (\dir -> not (or [is_gcc_lib dir,
 is_libffi dir]))
 +          -- GHC <= 6.12 had $topdir/gcc-lib in their
 +          -- library-dirs for the rts package, which causes
 +          -- problems when we try to use the in-tree mingw,
 +          -- due to accidentally picking up the incompatible
 +          -- libraries there.  So we filter out gcc-lib from
 +          -- the RTS's library-dirs here.
 +          is_gcc_lib = ("gcc-lib" `isSuffixOf`)
 +          -- In Trac #16368, we noticed that libffi paths
 +          -- from the boot GHC shadow the local libffi tarballs
 +          -- in a similar manner.
 +          is_libffi = ("libffi" `isInfixOf`)

            dep_ids  = map snd (externalPackageDeps lbi)
            deps     = map display dep_ids
 }}}

 Are there any other packages in the above list that look from to you?
 bgamari, perhaps?

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/16368#comment:1>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.