[commit: ghc] wip/T15971, wip/T16150, wip/alp/hadrian-docs-crosslinking, wip/misc-testsuite: Check that libs found by GCC aren't folders (6b5ec08)

git at git.haskell.org git at git.haskell.org
Wed Jan 9 21:36:07 UTC 2019


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

On branches: wip/T15971,wip/T16150,wip/alp/hadrian-docs-crosslinking,wip/misc-testsuite
Link       : http://ghc.haskell.org/trac/ghc/changeset/6b5ec08a4a64525bae87a8c2202688ffc6f86aa8/ghc

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

commit 6b5ec08a4a64525bae87a8c2202688ffc6f86aa8
Author: Alec Theriault <alec.theriault at gmail.com>
Date:   Mon Jan 7 12:59:36 2019 -0800

    Check that libs found by GCC aren't folders
    
    Summary:
    We use 'gcc -B<base-location> --print-file-name mylib.a' as a way of
    checking if 'gcc' can discover 'mylib.a' at the given location. However,
    this can break down if there is a folder caller 'mylib.a' that 'gcc' can
    discover. We can guard against this by explicitly checking that the path
    returned by 'gcc' is a file.
    
    This may seem like a far-fetched scenario, but since
    3d17f1f10fc00540ac052f2fd03182906aa47e35, we look for libraries without
    any prefix or suffix (ie. 'extra-libraries: softfloat', we look for just
    'softfloat' as well as 'softloat.a', 'softfloat.dll.a', etc.) which means
    that there might actusally be a folder of that name in one of the base
    locations.
    
    Reviewers: Phyx, bgamari, hvr, angerman
    
    Reviewed By: Phyx, angerman
    
    Subscribers: angerman, rwbarton, carter
    
    GHC Trac Issues: #16063
    
    Differential Revision: https://phabricator.haskell.org/D5462


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

6b5ec08a4a64525bae87a8c2202688ffc6f86aa8
 compiler/ghci/Linker.hs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/compiler/ghci/Linker.hs b/compiler/ghci/Linker.hs
index 3f4264c..dad13b7 100644
--- a/compiler/ghci/Linker.hs
+++ b/compiler/ghci/Linker.hs
@@ -1556,7 +1556,8 @@ searchForLibUsingGcc dflags so dirs = do
                 l:_ -> l
    if (file == so)
       then return Nothing
-      else return (Just file)
+      else do b <- doesFileExist file -- file could be a folder (see #16063)
+              return (if b then Just file else Nothing)
 
 -- | Retrieve the list of search directory GCC and the System use to find
 --   libraries and components. See Note [Fork/Exec Windows].



More information about the ghc-commits mailing list