Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC

Commits:

3 changed files:

Changes:

  • changelog.d/rts_symlinks.md
    1
    +section: packaging
    
    2
    +issues: #27162
    
    3
    +mrs: !15913
    
    4
    +synopsis:
    
    5
    +  GHC binary distributions no longer ship with unversioned symlinks of the RTS libraries (.so/.dylib)
    
    6
    +description:
    
    7
    +  Whith dynamic linking, an RTS with explicit version number is already linked by default e.g.
    
    8
    +  `libHSrts-1.0.3-ghc9.14.1.so`. GHC's binary distributions previously included symlinks without
    
    9
    +  an explicit RTS versions number e.g. `libHSrts-ghc9.14.1.so -> libHSrts-1.0.3-ghc9.14.1.so`.
    
    10
    +  As they are not used, such unversioned symlinks are no longer included in binary distributions.
    
    11
    +  Custom tooling that makes use of the removed symlinks, should now use the versioned file name instead.

  • hadrian/src/Rules/Register.hs
    ... ... @@ -12,7 +12,6 @@ import Hadrian.BuildPath
    12 12
     import Hadrian.Expression
    
    13 13
     import Hadrian.Haskell.Cabal
    
    14 14
     import Packages
    
    15
    -import Rules.Rts
    
    16 15
     import Settings
    
    17 16
     import Target
    
    18 17
     import Utilities
    
    ... ... @@ -88,14 +87,9 @@ parseToBuildSubdirectory root = do
    88 87
     -- * Registering
    
    89 88
     
    
    90 89
     registerPackages :: [Context] -> Action ()
    
    91
    -registerPackages ctxs = do
    
    90
    +registerPackages ctxs =
    
    92 91
         need =<< mapM pkgRegisteredLibraryFile ctxs
    
    93 92
     
    
    94
    -    -- Dynamic RTS library files need symlinks (Rules.Rts.rtsRules).
    
    95
    -    forM_ ctxs $ \ ctx -> when (package ctx == rts) $ do
    
    96
    -        ways <- interpretInContext ctx (getLibraryWays <> getRtsWays)
    
    97
    -        needRtsSymLinks (stage ctx) ways
    
    98
    -
    
    99 93
     -- | Register a package and initialise the corresponding package database if
    
    100 94
     -- need be. Note that we only register packages in 'Stage0' and 'Stage1'.
    
    101 95
     registerPackageRules :: [(Resource, Int)] -> Stage -> Inplace -> Rules ()
    

  • hadrian/src/Rules/Rts.hs
    1
    -{-# LANGUAGE MultiWayIf #-}
    
    1
    +module Rules.Rts (rtsRules) where
    
    2 2
     
    
    3
    -module Rules.Rts (rtsRules, needRtsSymLinks) where
    
    4
    -
    
    5
    -import qualified Data.Set as Set
    
    6
    -
    
    7
    -import Packages (rts)
    
    8 3
     import Hadrian.Utilities
    
    9 4
     import Settings.Builders.Common
    
    10 5
     
    
    ... ... @@ -12,18 +7,7 @@ import Settings.Builders.Common
    12 7
     -- library files (see Rules.Library.libraryRules).
    
    13 8
     rtsRules :: Rules ()
    
    14 9
     rtsRules = priority 3 $ do
    
    15
    -    -- Dynamic RTS library files need symlinks without the dummy version number.
    
    16
    -    -- This is for backwards compatibility (the old make build system omitted the
    
    17
    -    -- dummy version number).
    
    18 10
         root <- buildRootRules
    
    19
    -    [ root -/- "**/libHSrts_*-ghc*.so",
    
    20
    -      root -/- "**/libHSrts_*-ghc*.dylib",
    
    21
    -      root -/- "**/libHSrts-ghc*.so",
    
    22
    -      root -/- "**/libHSrts-ghc*.dylib"]
    
    23
    -      |%> \ rtsLibFilePath' -> createFileLink
    
    24
    -            (addRtsDummyVersion $ takeFileName rtsLibFilePath')
    
    25
    -            rtsLibFilePath'
    
    26
    -
    
    27 11
         -- Solve the recursive dependency between the rts and ghc-internal
    
    28 12
         -- on Windows by creating an import lib for the ghc-internal dll,
    
    29 13
         -- to be linked into the rts dll.
    
    ... ... @@ -37,35 +21,3 @@ buildGhcInternalImportLib target = do
    37 21
             output = target -- the .dll.a import lib
    
    38 22
         need [input]
    
    39 23
         runBuilder Dlltool ["-d", input, "-l", output] [input] [output]
    40
    -
    
    41
    --- Need symlinks generated by rtsRules.
    
    42
    -needRtsSymLinks :: Stage -> Set.Set Way -> Action ()
    
    43
    -needRtsSymLinks stage rtsWays
    
    44
    -    = forM_ (Set.filter (wayUnit Dynamic) rtsWays) $ \ way -> do
    
    45
    -        let ctx = Context stage rts way Final
    
    46
    -        distDir     <- distDynDir ctx
    
    47
    -        rtsLibFile  <- takeFileName <$> pkgLibraryFile ctx
    
    48
    -        need [removeRtsDummyVersion (distDir </> rtsLibFile)]
    
    49
    -
    
    50
    -prefix, versionlessPrefix :: String
    
    51
    -versionlessPrefix = "libHSrts"
    
    52
    -prefix = versionlessPrefix ++ "-1.0.3"
    
    53
    -
    
    54
    --- removeRtsDummyVersion "a/libHSrts-1.0-ghc1.2.3.4.so"
    
    55
    ---                    == "a/libHSrts-ghc1.2.3.4.so"
    
    56
    -removeRtsDummyVersion :: FilePath -> FilePath
    
    57
    -removeRtsDummyVersion = replaceLibFilePrefix prefix versionlessPrefix
    
    58
    -
    
    59
    --- addRtsDummyVersion "a/libHSrts-ghc1.2.3.4.so"
    
    60
    ---                 == "a/libHSrts-1.0-ghc1.2.3.4.so"
    
    61
    -addRtsDummyVersion :: FilePath -> FilePath
    
    62
    -addRtsDummyVersion = replaceLibFilePrefix versionlessPrefix prefix
    
    63
    -
    
    64
    -replaceLibFilePrefix :: String -> String -> FilePath -> FilePath
    
    65
    -replaceLibFilePrefix oldPrefix newPrefix oldFilePath = let
    
    66
    -    oldFileName = takeFileName oldFilePath
    
    67
    -    newFileName = maybe
    
    68
    -        (error $ "Expected RTS library file to start with " ++ oldPrefix)
    
    69
    -        (newPrefix ++)
    
    70
    -        (stripPrefix oldPrefix oldFileName)
    
    71
    -    in replaceFileName oldFilePath newFileName