Skip to content

Haddock incompatibility with older GHC #383

Description

@ag-eitilt

I like to locally test my packages against every version the Hackage matrix would be testing, just to have the most accurate data before actually releasing, and several times have run into issues with vector by the time I get back to GHC-8.4.4 -- namely, the Haddock fails to build. Since that's not marked in the vector.cabal (and since cabal.project files don't support if()), I need to manually add a --constraint=vector<0.12.2 every time I try to test an older GHC, which I never remember to do until after flailing around for a bit. The matrix (and presumably most users) don't have this issue because everything works fine if the Haddock is never built, but I have my global Cabal config set to build the docs for everything.

The issue seems to be with the {-# UNPACK #-} pragmas on Data.Vector.Mutable.MVector, and their interaction with the postfix Haddock; there might be other similar issues, but that's the first error the build hits. It's too late at night for me to pick it apart at the moment, but vector-0.12.2.0 added (admittedly needed) explanation of each argument to the constructor in a way which the older Haddock doesn't seem to be able to parse. I'll look into this a bit further soon, but I just wanted to put this out there before I lost track of it again, and in case anyone else knows the fix off the top of their head.

Activity

  1. ag-eitilt commented on Apr 26, 2021

    @ag-eitilt
    Author

    This might be the same issue as haskell/haddock#836, in which case it seems like there might not be much of a fix beyond hiding the docs behind an #if MIN_VERSION_base(4,12,0) and providing an #else without the additional Haddock. CPP is already enabled for that module, so at least it won't be adding system complexity as well as the redundant code.

  2. lehins commented on Apr 26, 2021

    @lehins
    Contributor

    Question is: do we really need to support old buggy versions of haddock? What does it buy us?

    I think it is possible to use newer haddock version with older ghc, so if someone really needs to build documentation with ghc-8.4 and older they should be able to figure it out. Or maybe am I missing something?

  3. Bodigrim commented on Apr 26, 2021

    @Bodigrim
    Contributor

    @ag-eitilt you can put a constraint in a global cabal config. Or skip running haddock for old GHCs. Hackage Matrix does not run it, so why would you?

    I don’t think this qualifies as an issue on vector side in 2021.

  4. lehins commented on Apr 26, 2021

    @lehins
    Contributor

    I am 100% in agreement with @Bodigrim
    Closing as invalid.

  5. ag-eitilt commented on Apr 27, 2021

    @ag-eitilt
    Author

    Makes sense, though I'm not completely in support of only partially dropping support like that, given how tightly-coupled GHC and Haddock are; I will admit that there's no great way to make it more explicit, however, when we can't even directly specify what compilers are supported. By the way, I played with things a bit, and you can not, in fact, use different versions of each:

    > cd vector-0.12.2.0
    > cabal haddock --with-compiler ghc-8.4.4 --with-haddock haddock-ghc-8.10.4
    Build profile: -w ghc-8.4.4 -O1
    In order, the following will be built (use -v for more details):
     - vector-0.12.2.0 (lib) (configuration changed)
    Configuring library for vector-0.12.2.0..
    cabal: Haddock's internal GHC version must match the configured GHC version.
    The GHC version is 8.4.4 but haddock is using GHC version 8.10.4
    
    cabal: Failed to build documentation for vector-0.12.2.0.
    

    So, therefore, versions 0.12.2.0 and 0.12.3.0 only support GHC <= 8.4.4 so long as the docs aren't being built. It is still a valid line to draw, but I have to admit to being a bit disappointed that core tools in the Haskell ecosystem are considered "old buggy versions" before they're even three years old. For reference, stable Debian looks to be installing 8.4.4 even now, and the LTS release is still using 8.0.1 (I'm generating Haddock in solidarity with anyone using those older versions).

    @Bodigrim I'd love to; where would I put that constraint? Like I said originally, cabal.project doesn't work. I could add a --config-file argument, switching on the desired version, to the script I use for running older GHC, but as I understand it, that would overwrite everything else I have set in my main config file.

  6. ag-eitilt commented on Apr 27, 2021

    @ag-eitilt
    Author

    For comparison, my entire (now tested) proposed fix is six lines of code (plus, depending on how quickly the next version is set to come out, one for 0.12.3.0 as well), and deprecating the *.0 versions so cabal-install doesn't pull them in. I can't create a PR because Github doesn't allow them for tags, but I'm sure it would be easy enough to copy over the patch.

  7. Shimuuar commented on Apr 27, 2021

    @Shimuuar
    Contributor

    core tools in the Haskell ecosystem are considered "old buggy versions" before they're even three years old

    Thing is they are buggy and unsupported. Same is true for GHC by the way. Only way to get bugfixes is to upgrade. And I don't think that it's very important to maintain haddock buildable by old GHCs since it's possible

    I could add a --config-file argument, switching on the desired version, to the script I use for running older GHC, but as I understand it, that would overwrite everything else I have set in my main config file.

    AFAIU it should read from config file supplied on the command line instead of default one, not overwriting anything.

    proposed fix is six lines of code

    Problem is uses CPP in a way that different compilers may use different versions of data type definition.

  8. ag-eitilt commented on Apr 28, 2021

    @ag-eitilt
    Author

    The discussion around haskell/cabal#5232 implies that this might wind up being an issue with Cabal rather than with GHC/Haddock itself. I'll stop pushing this here quite as aggressively, though I will admit to being rather disappointed if the documentation is not considered worth a simple fix.

    core tools in the Haskell ecosystem are considered "old buggy versions" before they're even three years old

    Thing is they are buggy and unsupported. Same is true for GHC by the way. Only way to get bugfixes is to upgrade. And I don't think that it's very important to maintain haddock buildable by old GHCs since it's possible

    I'm not disputing that it's outdated, I'm just bemoaning the perception of short shelf life that has developed in the ecosystem. Though I will again point to Debian where any more conservative users (i.e. larger corporations) are still using those older versions, and that, according to its base constraints, vector nominally supports GHC all the way back to 7.4.1. My argument through all this is that, if that support range is truly the case, breaking Haddock like this effectively drops support for what's packaged with seven major versions of GHC for very little gain; I've only personally verified back to 7.10.3, but that's still at least four broken versions.

    I could add a --config-file argument, switching on the desired version, to the script I use for running older GHC, but as I understand it, that would overwrite everything else I have set in my main config file.

    AFAIU it should read from config file supplied on the command line instead of default one, not overwriting anything.

    That was a bit ambiguous on my end; I meant the same thing by "overwrite" as you do by "instead of". I consider having to duplicate every other bit of my config an unacceptable cost.

    proposed fix is six lines of code

    Problem is uses CPP in a way that different compilers may use different versions of data type definition.

    It uses CPP to add Haddock and nothing else. The definition itself is exactly the same. Any build system which doesn't add the MIN_VERSION macros will be compiled to exactly the same code, and just miss a small bit of documentation. Any compiler which can't understand CPP will fail on the #include "vector.h" line a bit farther up.

  9. ag-eitilt commented on Apr 28, 2021

    @ag-eitilt
    Author

    Well, that's an interesting find, and much better than the CPP! I'll keep records in mind for potential Haddock issues going forward in my own code. Thanks for the fix!

  10. lehins commented on Apr 28, 2021

    @lehins
    Contributor

    @ag-eitilt Yeah, I try to avoid CPP when possible and I thought today to try and see if record syntax can do the trick and it did ;) So, I'll make a vector-0.12.3.1 but I think that will be the last vector-0.12.x version, because after that the next release will be 0.13

  11. lehins commented on Apr 29, 2021

    @lehins
    Contributor

    Fixed in #384

  12. andreasabel commented on Sep 20, 2021

    @andreasabel
    Member

    @lehins: Would it be possible to release this fix soonish?

    I got hit by this by putting documentation: True in my .cabal/config and then trying to build one of my packages with an old GHC:

    tasty-silver$ cabal test -w ghc-7.8.4
    ... 
    Data/Vector/Mutable.hs:80:28: parse error on input ‘{-# UNPACK’
    Warning: Failed to build documentation for vector-0.12.3.0 (which is required
    by test:test from tasty-silver-3.3).
    
  13. konsumlamm commented on Sep 20, 2021

    @konsumlamm
    Contributor

    @andreasabel note that support for GHC 7.8 (and in general GHC < 8.0) has been dropped, so if you want to use GHC 7.8, a release with the fix won't help you.

  14. andreasabel commented on Sep 20, 2021

    @andreasabel
    Member

    @andreasabel note that support for GHC 7.8 (and in general GHC < 8.0) has been dropped, so if you want to use GHC 7.8, a release with the fix won't help you.

    Thanks for the heads up, @konsumlamm! The fix would help with GHC >= 8.0, which has the same problem:

    $ cabal test
    Resolving dependencies...
    Build profile: -w ghc-8.0.2 -O1
    In order, the following will be built (use -v for more details):
    ...
     - vector-0.12.3.0 (lib) (requires build)
    ...
    ...
    Data/Vector/Mutable.hs:80:28: error:
        parse error on input ‘{-# UNPACK’
    Warning: Failed to build documentation for vector-0.12.3.0 (which is required
    by test:test from tasty-silver-3.3).
    
  15. lehins commented on Sep 20, 2021

    @lehins
    Contributor

    @andreasabel No problem, I'll make a 0.12.3.1 later on today.

  16. lehins commented on Sep 21, 2021

    @lehins
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions