Hadrian: always generate the libffi dynlibs manifest with globbing
authorAlp Mestanogullari <alpmestan@gmail.com>
Fri, 24 May 2019 16:19:22 +0000 (18:19 +0200)
committerMarge Bot <ben+marge-bot@smart-cactus.org>
Thu, 30 May 2019 11:28:32 +0000 (07:28 -0400)
Instead of trying to deduce which dynlibs are expected to be found (and then
copied to the RTS's build dir) in libffi's build directory, with some OS
specific logic, we now always just use `getDirectoryFilesIO` to look for
those dynlibs and record their names in the manifest. The previous logic
ended up causing problems on Windows, where we don't build dynlibs at all
for now but the manifest file's logic didn't take that into account because
it was only partially reproducing the criterions that determine whether or not
we will be building shared libraries.

This patch also re-enables the Hadrian/Windows CI job, which was failing to
build GHC precisely because of libffi shared libraries and the aforementionned
duplicated logic.

.gitlab-ci.yml
hadrian/src/Rules/Libffi.hs

index 76ce870..f9b2a42 100644 (file)
@@ -577,7 +577,7 @@ validate-x86_64-linux-fedora27:
     paths:
       - ghc.tar.xz
 
-.validate-x86_64-windows-hadrian:
+validate-x86_64-windows-hadrian:
   extends: .build-windows-hadrian
   variables:
     MSYSTEM: MINGW64
index 9a251c0..a1a5374 100644 (file)
@@ -171,19 +171,15 @@ libffiRules = do
         dynLibFiles <- do
             windows <- windowsHost
             osx     <- osxHost
-            let libffiName'' = libffiName' windows True
-            if windows
-                then
-                    let libffiDll = "lib" ++ libffiName'' ++ ".dll"
-                    in return [libffiPath -/- "inst/bin" -/- libffiDll]
-                else do
-                    let libffiLibPath = libffiPath -/- "inst/lib"
-                    dynLibsRelative <- liftIO $ getDirectoryFilesIO
-                        libffiLibPath
-                        (if osx
-                            then ["lib" ++ libffiName'' ++ ".dylib*"]
-                            else ["lib" ++ libffiName'' ++ ".so*"])
-                    return (fmap (libffiLibPath -/-) dynLibsRelative)
+            let libfilesDir = libffiPath -/-
+                    (if windows then "inst" -/- "bin" else "inst" -/- "lib")
+                libffiName'' = libffiName' windows True
+                dynlibext
+                    | windows   = "dll"
+                    | osx       = "dylib"
+                    | otherwise = "so"
+                filepat = "lib" ++ libffiName'' ++ "*." ++ dynlibext ++ "*"
+            liftIO $ getDirectoryFilesIO "." [libfilesDir -/- filepat]
 
         writeFileLines dynLibMan dynLibFiles
         putSuccess "| Successfully build libffi."