haskell / text

Haskell library for space- and time-efficient operations over Unicode text.
http://hackage.haskell.org/package/text
BSD 2-Clause "Simplified" License
407 stars 158 forks source link

haddock crashes with SIGILL when building under DragonFly BSD #538

Open tuxillo opened 1 year ago

tuxillo commented 1 year ago

While building ghc-9.4.6 under DragonFly BSD we got a strange haddock crash:

/----------------------------------------------------------\
| Successfully built program 'ghc-bin' (Stage1).           |
| Executable: _build/stage1/bin/ghc                        |
| Program synopsis: The Glorious Glasgow Haskell Compiler. |
\----------------------------------------------------------/
| Create directory _build/bindist/ghc-9.4.5-x86_64-portbld-dragonfly
| Create directory _build/bindist/ghc-9.4.5-x86_64-portbld-dragonfly/bin
| Create directory _build/bindist/ghc-9.4.5-x86_64-portbld-dragonfly/lib
| Copy file: _build/stage1/bin/ghc => _build/bindist/ghc-9.4.5-x86_64-portbld-dragonfly/bin/ghc-9.4.5
| Copy file: _build/stage1/bin/ghc-pkg => _build/bindist/ghc-9.4.5-x86_64-portbld-dragonfly/bin/ghc-pkg-9.4.5
| Copy file: _build/stage1/bin/hp2ps => _build/bindist/ghc-9.4.5-x86_64-portbld-dragonfly/bin/hp2ps-ghc-9.4.5
| Copy file: _build/stage1/bin/hsc2hs => _build/bindist/ghc-9.4.5-x86_64-portbld-dragonfly/bin/hsc2hs-ghc-9.4.5
| Copy file: _build/stage1/lib/bin/unlit => _build/bindist/ghc-9.4.5-x86_64-portbld-dragonfly/bin/unlit-ghc-9.4.5
| Copy file: _build/stage1/bin/haddock => _build/bindist/ghc-9.4.5-x86_64-portbld-dragonfly/bin/haddock-ghc-9.4.5
| Copy file: _build/stage1/bin/hpc => _build/bindist/ghc-9.4.5-x86_64-portbld-dragonfly/bin/hpc-ghc-9.4.5
| Copy file: _build/stage1/lib/bin/ghc-iserv-dyn => _build/bindist/ghc-9.4.5-x86_64-portbld-dragonfly/bin/ghc-iserv-dyn-ghc-9.4.5
| Copy file: _build/stage1/bin/runghc => _build/bindist/ghc-9.4.5-x86_64-portbld-dragonfly/bin/runghc-9.4.5
| Copy file: _build/stage1/lib/bin/ghc-iserv => _build/bindist/ghc-9.4.5-x86_64-portbld-dragonfly/bin/ghc-iserv-ghc-9.4.5
| Copy file: _build/stage1/lib/bin/ghc-iserv-prof => _build/bindist/ghc-9.4.5-x86_64-portbld-dragonfly/bin/ghc-iserv-prof-ghc-9.4.5
| Copy file: _build/stage1/lib/bin/ghc-iserv-dyn => _build/bindist/ghc-9.4.5-x86_64-portbld-dragonfly/bin/ghc-iserv-dyn-ghc-9.4.5
| Copy directory: _build/stage1/lib => _build/bindist/ghc-9.4.5-x86_64-portbld-dragonfly
| Copy directory: _build/stage1/lib/x86_64-dragonfly-ghc-9.4.5/rts-1.0.2/include => _build/bindist/ghc-9.4.5-x86_64-portbld-dragonfly
# ghc-pkg (for binary-dist-dir)
| Remove file _build/bindist/ghc-9.4.5-x86_64-portbld-dragonfly/lib/settings
| Run Sphinx ManMode: docs/users_guide => /tmp/extra-dir-6060607777810
| Run Sphinx LatexMode: utils/haddock/doc => /tmp/extra-dir-6060607777808
| Run Sphinx HtmlMode: utils/haddock/doc => _build/doc/html/Haddock
| Create directory _build/stage1/haddock-timing-files
| Run Haddock BuildPackage: libraries/ghc-prim/GHC/CString.hs (and 12 more) => _build/doc/html/libraries/ghc-prim-0.9.0/ghc-prim.haddock
| Run Sphinx LatexMode: docs/users_guide => /tmp/extra-dir-6060607777809
| Run Sphinx HtmlMode: docs/users_guide => _build/doc/html/users_guide
Command line: _build/stage1/bin/haddock --verbosity=0 -B_build/stage1/lib --lib=_build/stage1/lib --odir=_build/doc/html/libraries/ghc-prim-0.9.0 --dump-interface=_build/doc/html/libraries/ghc-prim-0.9.0/ghc-prim.haddock --html --hyperlinked-source --hoogle --quickjump '--title=ghc-prim-0.9.0: GHC primitives' --prologue=_build/doc/html/libraries/ghc-prim-0.9.0/haddock-prologue.txt --optghc=-D__HADDOCK_VERSION__=2270 --optghc=-hisuf --optghc=dyn_hi --optghc=-osuf --optghc=dyn_o --optghc=-hcsuf --optghc=dyn_hc --optghc=-fPIC --optghc=-dynamic --optghc=-hide-all-packages --optghc=-no-user-package-db '--optghc=-package-env -' '--optghc=-this-unit-id ghc-prim-0.9.0' '--optghc=-package-id rts-1.0.2' --optghc=-i --optghc=-i/construction/lang/ghc/ghc-9.4.5/_build/stage1/libraries/ghc-prim/build --optghc=-i/construction/lang/ghc/ghc-9.4.5/_build/stage1/libraries/ghc-prim/build/autogen --optghc=-i/construction/lang/ghc/ghc-9.4.5/libraries/ghc-prim --optghc=-Irts/include --optghc=-I_build/stage1/libraries/ghc-prim/build --optghc=-I/usr/local/include --optghc=-I/construction/lang/ghc/ghc-9.4.5/_build/stage1/lib/x86_64-dragonfly-ghc-9.4.5/rts-1.0.2/include --optghc=-optP-include --optghc=-optP_build/stage1/libraries/ghc-prim/build/autogen/cabal_macros.h --optghc=-outputdir --optghc=_build/stage1/libraries/ghc-prim/build --optghc=-this-unit-id --optghc=ghc-prim --optghc=-XHaskell2010 --optghc=-no-global-package-db --optghc=-package-db=/construction/lang/ghc/ghc-9.4.5/_build/stage1/lib/package.conf.d --optghc=-ghcversion-file=rts/include/ghcversion.h --optghc=-ghcversion-file=rts/include/ghcversion.h --optghc=-Wno-deprecated-flags --optghc=-Wno-trustworthy-safe libraries/ghc-prim/GHC/CString.hs libraries/ghc-prim/GHC/Classes.hs libraries/ghc-prim/GHC/Debug.hs libraries/ghc-prim/GHC/Magic.hs libraries/ghc-prim/GHC/Magic/Dict.hs libraries/ghc-prim/GHC/Prim/Exception.hs libraries/ghc-prim/GHC/Prim/Ext.hs libraries/ghc-prim/GHC/Prim/Panic.hs libraries/ghc-prim/GHC/Prim/PtrEq.hs _build/stage1/libraries/ghc-prim/build/GHC/PrimopWrappers.hs libraries/ghc-prim/GHC/Tuple.hs libraries/ghc-prim/GHC/Types.hs _build/stage1/libraries/ghc-prim/build/GHC/Prim.hs +RTS -t_build/stage1/haddock-timing-files/ghc-prim.t --machine-readable -RTS
===> Command failed with error code: -4
Command failed
Build failed.

After some investigation, it seems the issue is that DragonFly BSD does not support AVX512. So changing the ifdef here:

https://github.com/haskell/text/blob/master/cbits/measure_off.c#L214

To avoid going through the avx512 path solved the issue and the build finished ok.

I am not sure whether other OSes will be affected by this issue but it seems the declaration of COMPILER_SUPPORTS_AVX512 alone might not be enough?

Bodigrim commented 1 year ago

As witnessed by CI, other BSD systems (FreeBSD, OpenBSD, NetBSD) do not seem to have this issue. Do you know what makes DragonFly BSD peculiar in this aspect? Is it possible to add a CI job?

tuxillo commented 1 year ago

We just don't support AVX512. It's still to be implemented.

Bodigrim commented 1 year ago

PR is welcome, ideally accompanied by a CI job for DragonFly BSD, otherwise it can easily regress back in future.

tuxillo commented 1 year ago

Sure, I'll send one when I have some time. Can you point me to the other BSD CI jobs?

Bodigrim commented 1 year ago

https://github.com/haskell/text/blob/master/.cirrus.yml

tuxillo commented 1 year ago

Thanks. Looks like I'd have to send a PR to pg-vm-images first.

chreekat commented 1 year ago

I am not sure whether other OSes will be affected by this issue but it seems the declaration of COMPILER_SUPPORTS_AVX512 alone might not be enough?

Would it be better to say the definition of COMPILER_SUPPORTS_AVX512 needs to be extended to account for Dragonfly? It's already mixing checks of compiler version and operating system version, anyway, which makes the variable's name look misleading to me.