Skip to content
Snippets Groups Projects
Commit df6229ce authored by Cheng Shao's avatar Cheng Shao :beach:
Browse files

driver: fix getGccSearchDirectory for wasm target

This commit fixes getGccSearchDirectory logic for wasm target, ensures
the correct search directory containing libc.so etc can be found by
GHC. getGccSearchDirectory is also exported so it can be used
elsewhere to obtain the wasi-sdk libdir and pass to the dyld script.

(cherry picked from commit b562e3a6)
parent 7e740586
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,7 @@ module GHC.Linker.Loader ...@@ -33,6 +33,7 @@ module GHC.Linker.Loader
, modifyLoaderState , modifyLoaderState
, initLinkDepsOpts , initLinkDepsOpts
, partitionLinkable , partitionLinkable
, getGccSearchDirectory
) )
where where
...@@ -1491,12 +1492,11 @@ searchForLibUsingGcc logger dflags so dirs = do ...@@ -1491,12 +1492,11 @@ searchForLibUsingGcc logger dflags so dirs = do
-- libraries and components. See Note [Fork/Exec Windows]. -- libraries and components. See Note [Fork/Exec Windows].
getGCCPaths :: Logger -> DynFlags -> OS -> IO [FilePath] getGCCPaths :: Logger -> DynFlags -> OS -> IO [FilePath]
getGCCPaths logger dflags os getGCCPaths logger dflags os
= case os of | os == OSMinGW32 || platformArch (targetPlatform dflags) == ArchWasm32 =
OSMinGW32 ->
do gcc_dirs <- getGccSearchDirectory logger dflags "libraries" do gcc_dirs <- getGccSearchDirectory logger dflags "libraries"
sys_dirs <- getSystemDirectories sys_dirs <- getSystemDirectories
return $ nub $ gcc_dirs ++ sys_dirs return $ nub $ gcc_dirs ++ sys_dirs
_ -> return [] | otherwise = return []
-- | Cache for the GCC search directories as this can't easily change -- | Cache for the GCC search directories as this can't easily change
-- during an invocation of GHC. (Maybe with some env. variable but we'll) -- during an invocation of GHC. (Maybe with some env. variable but we'll)
...@@ -1529,7 +1529,7 @@ getGccSearchDirectory logger dflags key = do ...@@ -1529,7 +1529,7 @@ getGccSearchDirectory logger dflags key = do
modifyIORef' gccSearchDirCache ((key, dirs):) modifyIORef' gccSearchDirCache ((key, dirs):)
return val return val
where split :: FilePath -> [FilePath] where split :: FilePath -> [FilePath]
split r = case break (==';') r of split r = case break (`elem` [';', ':']) r of
(s, [] ) -> [s] (s, [] ) -> [s]
(s, (_:xs)) -> s : split xs (s, (_:xs)) -> s : split xs
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment