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

Commits:

2 changed files:

Changes:

  • changelog.d/link-deterministic-order
    1
    +section: compiler
    
    2
    +synopsis: -fobject-determinism sorts the list of object files to be linked for reproducible builds
    
    3
    +issues: #27612
    
    4
    +mrs: !16457
    
    5
    +

  • compiler/GHC/Driver/Pipeline.hs
    ... ... @@ -410,8 +410,14 @@ link' hsc_env batch_attempt_linking mHscMessager hpt
    410 410
             -- know which packages are actually needed at the runtime stage.
    
    411 411
             pkg_deps <- map snd . Set.toList <$> hptCollectDependencies hpt
    
    412 412
     
    
    413
    -        -- the linkables to link
    
    414
    -        home_mods <- hptCollectHomeModInfo hpt
    
    413
    +        -- the linkables to link; under -fobject-determinism sorted, because
    
    414
    +        -- the HPT holds modules in the order in which they finished compiling,
    
    415
    +        -- which varies with -j
    
    416
    +        let det_sort
    
    417
    +              | gopt Opt_ObjectDeterminism dflags
    
    418
    +                          = sortWith (mi_module . hm_iface)
    
    419
    +              | otherwise = id
    
    420
    +        home_mods <- det_sort <$> hptCollectHomeModInfo hpt
    
    415 421
     
    
    416 422
             let home_modules = map (mi_module . hm_iface) home_mods
    
    417 423
             debugTraceMsg logger 3 (text "link: hmi ..." $$ vcat (map ppr home_modules))