Skip to content
Snippets Groups Projects
Commit 9be1749d authored by David Eichmann's avatar David Eichmann :lifter: Committed by Marge Bot
Browse files

Hadrian: Add Mising Libffi Dependencies #16653

Libffi is ultimately built from a single archive file (e.g.
libffi-tarballs/libffi-3.99999+git20171002+77e130c.tar.gz).
The file can be seen as the shallow dependency for the whole
libffi build. Hence, in all libffi rules, the archive is
`need`ed and the build directory is `trackAllow`ed.
parent 70c24471
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,7 @@ askLibffilDynLibs stage = askOracle (LibffiDynLibs stage) ...@@ -24,6 +24,7 @@ askLibffilDynLibs stage = askOracle (LibffiDynLibs stage)
-- | The path to the dynamic library manifest file. The file contains all file -- | The path to the dynamic library manifest file. The file contains all file
-- paths to libffi dynamic library file paths. -- paths to libffi dynamic library file paths.
-- The path is calculated but not `need`ed.
dynLibManifest' :: Monad m => m FilePath -> Stage -> m FilePath dynLibManifest' :: Monad m => m FilePath -> Stage -> m FilePath
dynLibManifest' getRoot stage = do dynLibManifest' getRoot stage = do
root <- getRoot root <- getRoot
...@@ -103,6 +104,24 @@ configureEnvironment stage = do ...@@ -103,6 +104,24 @@ configureEnvironment stage = do
, return . AddEnv "CFLAGS" $ unwords cFlags ++ " -w" , return . AddEnv "CFLAGS" $ unwords cFlags ++ " -w"
, return . AddEnv "LDFLAGS" $ unwords ldFlags ++ " -w" ] , return . AddEnv "LDFLAGS" $ unwords ldFlags ++ " -w" ]
-- Need the libffi archive and `trackAllow` all files in the build directory.
-- As all libffi build files are derived from this archive, we can safely
-- `trackAllow` the libffi build dir. I.e the archive file can be seen as a
-- shallow dependency of the libffi build. This is much simpler than working out
-- the dependencies of each rule (within the build dir).
-- This means changing the archive file forces a clean build of libffi. This
-- seems like a performance issue, but is justified as building libffi is fast
-- and the archive file is rarely changed.
needLibfffiArchive :: FilePath -> Action FilePath
needLibfffiArchive buildPath = do
top <- topDirectory
tarball <- unifyPath
. fromSingleton "Exactly one LibFFI tarball is expected"
<$> getDirectoryFiles top ["libffi-tarballs/libffi*.tar.gz"]
need [top -/- tarball]
trackAllow [buildPath -/- "//*"]
return tarball
libffiRules :: Rules () libffiRules :: Rules ()
libffiRules = do libffiRules = do
_ <- addOracleCache $ \ (LibffiDynLibs stage) _ <- addOracleCache $ \ (LibffiDynLibs stage)
...@@ -119,6 +138,7 @@ libffiRules = do ...@@ -119,6 +138,7 @@ libffiRules = do
, dynLibMan , dynLibMan
] ]
priority 2 $ topLevelTargets &%> \_ -> do priority 2 $ topLevelTargets &%> \_ -> do
_ <- needLibfffiArchive libffiPath
context <- libffiContext stage context <- libffiContext stage
-- Note this build needs the Makefile, triggering the rules bellow. -- Note this build needs the Makefile, triggering the rules bellow.
...@@ -149,11 +169,7 @@ libffiRules = do ...@@ -149,11 +169,7 @@ libffiRules = do
-- Extract libffi tar file -- Extract libffi tar file
context <- libffiContext stage context <- libffiContext stage
removeDirectory libffiPath removeDirectory libffiPath
top <- topDirectory tarball <- needLibfffiArchive libffiPath
tarball <- unifyPath . fromSingleton "Exactly one LibFFI tarball is expected"
<$> getDirectoryFiles top ["libffi-tarballs/libffi*.tar.gz"]
need [top -/- tarball]
-- Go from 'libffi-3.99999+git20171002+77e130c.tar.gz' to 'libffi-3.99999' -- Go from 'libffi-3.99999+git20171002+77e130c.tar.gz' to 'libffi-3.99999'
let libname = takeWhile (/= '+') $ takeFileName tarball let libname = takeWhile (/= '+') $ takeFileName tarball
...@@ -166,12 +182,14 @@ libffiRules = do ...@@ -166,12 +182,14 @@ libffiRules = do
-- And finally: -- And finally:
removeFiles (path) [libname <//> "*"] removeFiles (path) [libname <//> "*"]
top <- topDirectory
fixFile mkIn (fixLibffiMakefile top) fixFile mkIn (fixLibffiMakefile top)
files <- liftIO $ getDirectoryFilesIO "." [libffiPath <//> "*"] files <- liftIO $ getDirectoryFilesIO "." [libffiPath <//> "*"]
produces files produces files
fmap (libffiPath -/-) ["Makefile", "config.guess", "config.sub"] &%> \[mk, _, _] -> do fmap (libffiPath -/-) ["Makefile", "config.guess", "config.sub"] &%> \[mk, _, _] -> do
_ <- needLibfffiArchive libffiPath
context <- libffiContext stage context <- libffiContext stage
-- This need rule extracts the libffi tar file to libffiPath. -- This need rule extracts the libffi tar file to libffiPath.
......
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