Skip to content
  • Andreas Klebinger's avatar
    ghc-the-library: Retain cafs in both static in dynamic builds. · 08ba8720
    Andreas Klebinger authored and Marge Bot's avatar Marge Bot committed
    We use keepCAFsForGHCi.c to force -fkeep-cafs behaviour by using a
    __attribute__((constructor)) function.
    
    This broke for static builds where the linker discarded the object file
    since it was not reverenced from any exported code. We fix this by
    asserting that the flag is enabled using a function in the same module
    as the constructor. Which causes the object file to be retained by the
    linker, which in turn causes the constructor the be run in static builds.
    
    This changes nothing for dynamic builds using the ghc library. But causes
    static to also retain CAFs (as we expect them to).
    
    Fixes #22417.
    
    -------------------------
    Metric Decrease:
        T21839r
    -------------------------
    08ba8720