clean up build steps & instructions

This commit is contained in:
sheaf 2022-12-04 15:52:29 +01:00
parent c80fdac30a
commit bcd38ed791
8 changed files with 113 additions and 152 deletions

View file

@ -32,7 +32,7 @@ common common
build-depends:
base
>= 4.16 && < 4.20
>= 4.16 && < 4.18
, acts
^>= 0.3.1.0
, containers
@ -42,9 +42,9 @@ common common
, generic-lens
>= 2.2 && < 2.3
, groups
^>= 0.5.3
^>= 0.5.3
, groups-generic
^>= 0.2
^>= 0.3
, primitive
^>= 0.7.1.0
, transformers
@ -76,17 +76,17 @@ common extras
, hashable
>= 1.3.0.0 && < 1.5
, lens
>= 4.19.2 && < 5.2
>= 4.19.2 && < 5.3
, mtl
^>= 2.2.2
>= 2.2.2 && < 2.4
, scientific
^>= 0.3.6.2
>= 0.3.6.2 && < 0.3.8
, stm
^>= 2.5.0.0
, text
>= 1.2.3.1 && < 2.1
, unordered-containers
>= 0.2.11 && < 0.2.16
>= 0.2.11 && < 0.2.20
, waargonaut
^>= 0.8.0.2
@ -107,12 +107,10 @@ common gtk
^>= 2.0.24
, gi-gtk
>= 4.0.3 && < 4.1
--, gi-gtksource
-- >= 3.0.23 && < 3.1
, haskell-gi
>= 0.25 && < 0.26
>= 0.26 && < 0.27
, haskell-gi-base
>= 0.25 && < 0.26
>= 0.26 && < 0.27
library splines
@ -150,7 +148,7 @@ library splines
, prim-instances
^>= 0.2
, vector
>= 0.12.1.2 && < 0.13
>= 0.12.1.2 && < 0.14
library metabrushes

View file

@ -1,40 +1,34 @@
packages: .
constraints:
acts -finitary
acts -finitary
allow-newer:
waargonaut:*,
*:haskell-gi-base, *:haskell-gi,
*:base, *:template-haskell, *:text,
ghc-typelits-natnormalise:ghc-bignum,
integer-logarithms:ghc-bignum,
hashable:ghc-bignum,
lens:hashable, aeson:hashable
digit:lens,
hoist-error:base,
natural:lens,
prim-instances:base,
records-sop:ghc-prim,
waargonaut:lens, waargonaut:records-sop, waargonaut:text, waargonaut:witherable
-- various fixes for 'hmatrix'
-- Fix a severe bug in Waargonaut (no corresponding Hackage release???)
source-repository-package
type: git
location: https://github.com/haskell-numerics/hmatrix
tag: e9268cd5ea31322220c0847f2fdce968789693b4
subdir: packages/base
location: https://github.com/haskell-waargonaut/waargonaut
tag: 5f838582a8c5aae1a198ecd4958729e53a6b03cf
-- GHC compat fixes for records-sop
-----------------------------
-- GHC 9.2 support patches --
-----------------------------
-- eigen
source-repository-package
type: git
location: https://github.com/chessai/eigen
tag: 8fff32a43df743c8c83428a86dd566a0936a4fba
-- records-sop
source-repository-package
type: git
location: https://github.com/kosmikus/records-sop
tag: abab99b4b870fce55e81dd03d4e41fb50502ca4e
package hmatrix
ghc-options: "-w"
flags: +openblas
source-repository-package
type: git
location: https://github.com/well-typed/large-records
subdir: large-generics
large-anon
tag: acb837a9a4c22cea1abf552b47f9d3bf5af2fbdf
package *
ghc-options: "-finfo-table-map" "-fdistinct-constructor-tables"

View file

@ -2,34 +2,28 @@
# Installation notes
On Windows, we need to install an up-to-date MinGW/MSYS2 toolchain,
together with the packages required by the `haskell-gi` libraries (for `GTK`),
the `hmatrix` library, as well as `flint` and `msolve`.
together with the packages required by the `haskell-gi` libraries (for `GTK`).
With an `MSYS2` installation, the following environment variables will need to be set (with `MSYS2` installed at `C:\msys64`):
With an `MSYS2` installation at `C:\Haskell\ghcup\msys64`, the following environment variables will need to be set :
`PATH`: `C:\msys64\mingw64\bin;C:\msys64\usr\bin`
`PKG_CONFIG_PATH`: `C:\msys64\mingw64\lib\pkgconfig`
`XDG_DATA_DIRS`: `C:\msys64\mingw64\share;C:\msys64\usr\share`
`PATH`: `C:\Haskell\ghcup\msys64\mingw64\bin;C:\Haskell\ghcup\msys64\usr\bin`
`PKG_CONFIG_PATH`: `C:\Haskell\ghcup\msys64\mingw64\lib\pkgconfig`
`XDG_DATA_DIRS`: `C:\Haskell\ghcup\msys64\mingw64\share;C:\Haskell\ghcup\msys64\usr\share`
Then we install some necessary packages using the following command:
Then we need `pkg-config` and the suite of `GTK` libraries.
After updating the package database if necessary with `pacman -Sy msys2-keyring`, we can do:
```bash
pacman -S -q --noconfirm mingw64/mingw-w64-x86_64-pkg-config mingw64/mingw-w64-x86_64-gobject-introspection mingw64/mingw-w64-x86_64-openblas
pacman -S -q --noconfirm mingw64/mingw-w64-x86_64-pkg-config mingw64/mingw-w64-x86_64-gobject-introspection mingw64/mingw-w64-x86_64-atk mingw64/mingw-w64-x86_64-gtksourceview5
```
Next, `flint`, which `msolve` depends on.
NB: at the time of writing, the relevant gtksource version is 5; this might need to be
updated if you run into issues, as the API of the auto-generated Haskell gi libraries might be
different dependent on the version numbers of the gi foreign libraries.
Build `flint` by downloading it and running the configure script. On Windows (MINGW64):
```bash
./configure ABI=64 --build=${MINGW_CHOST} --prefix=${MINGW_PREFIX} --enable-static --disable-shared --with-gmp=${MINGW_PREFIX} --with-mpfr=${MINGW_PREFIX}
make && make install
```
`flint` needs `gmp`, `mpfr`, but these should already be present.
For `msolve`, the default installation directions (`./autogen.sh`, `./configure`, `make && make install`) seem to work (without having to set any additional options), as of `msolve` version `0.1.3`.
Note that GHC 9.2 and below are affected by some bugs on Windows, e.g. [#21109](https://gitlab.haskell.org/ghc/ghc/-/issues/21109)
and [#21111](https://gitlab.haskell.org/ghc/ghc/-/issues/21111). So you should use GHC 9.4 (or above),
and make sure that you are using `cabal-install > 3.8` (due to [#21990](https://gitlab.haskell.org/ghc/ghc/-/issues/21990)).
## Possible errors
@ -53,6 +47,7 @@ to install it.
### gobject could not be found
An error such as
```bash
The pkg-config package 'gobject' is required but it could not be found.
```
@ -68,6 +63,64 @@ pkg-config --list-all
If packages such as `cairo`, `gtk` etc do not appear, this means `PKG_CONFIG_PATH` is not set correctly.
Search for `*.pc` files in your `MSYS2` installation, and ensure their paths are included in `PKG_CONFIG_PATH`.
You might also have multiple different `pkg-config` executables in your `PATH`;
if so, ensure that `cabal` is using the correct one, e.g. by modifying the `extra-prog-path`
field in your `cabal.config` file; see e.g. [ghcup issue #371](https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/371).
### Missing (or bad) C libraries
An error of the form:
```bash
Missing dependencies on foreign libraries:
* Missing (or bad) C libraries: gobject-2.0
```
indicates that `cabal` is not able to find an external C dependency. If the
C dependency is indeed installed, then perhaps `cabal` is calling the wrong
`pkg-config` executable. This could be due to an incorrect `extra-prog-path`
in your `cabal.config` file; see e.g. [ghcup issue #371](https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/371).
To fix this, you need to ensure the `pkg-config` executable is correct, e.g.
by re-ordering the paths in the `extra-prog-path` stanza so that the path
containing the correct `pkg-config` appears first.
### Failed to load shared library
An error of the form
```bash
Failed to load shared library 'libcairo-gobject-2.dll' referenced by the typelib: 'libcairo-gobject-2.dll': The specified procedure could not be found.
gi-cairo> Could not resolve symbol "cairo_gobject_context_get_type" in namespace "cairo"
```
indicates an issue finding exported functions in the `DLL`s that we depend upon.
I'm not yet sure how to fix this issue; see [haskell-gi issue #391](https://github.com/haskell-gi/haskell-gi/issues/391).
### Error compiling C standard libraries
An error of the form
```bash
C:\Haskell\ghcup\ghc\9.4.3\lib\..\mingw\include\c++\v1\cmath:642:26: error:
error: no template named 'numeric_limits'
```
signals that GHC is getting confused about which Unix toolchain to use. This
might be due to having
```cabal
extra-include-dirs: C:\Haskell\ghcup\msys64\mingw64\include
```
in your global `cabal.config` file, or in your `cabal.project.local` file.
You should **not** specify `extra-include-dirs` on a per-package
basis in your `cabal.project.local` file either: these should be handled by `pkg-config`.
Remove any `extra-include-dirs` and `extra-lib-dirs`, both in your global `cabal.config`
and in local `cabal.project`/`cabal.project.local` files to proceed.
### ...is a relative path which makes no sense
Any error of the form:
@ -85,7 +138,7 @@ pacman -S -q --noconfirm mingw64/mingw-w64-x86_64-pkg-config
```
This should fix the issue. Another solution is to pass the `--force` flag to `ghc-pkg` for the problematic packages.
At the time of writing, the only dependency which presents this problem is `graphite2`, which is a dependency of `cairo`.
One dependency which used to present this problem was `graphite2`, which is a dependency of `cairo`.
This causes a problem with the `gi-cairo-render` library, so in the `cabal.project` file we can specify:
```
@ -105,74 +158,5 @@ Libs: -L${libdir} -lgraphite2
Cflags: -I${includedir}
```
See [this patch](https://github.com/msys2/MINGW-packages/pull/6966). The package `fontconfig` also presented this issue; this was resolved in [this patch](https://github.com/msys2/MINGW-packages/issues/872).
### Missing C library `openblas`
The error message
```
Missing dependencies on foreign libraries:
* Missing (or bad) C library: openblas
```
indicates that `cabal` could not find a C library that `hmatrix` depends on.
Make sure that `openblas` is installed:
```
pacman -S -q --noconfirm mingw64/mingw-w64-x86_64-openblas
```
then ensure that `cabal` can find it, for instance:
```
package hmatrix
extra-lib-dirs: "C:/msys64/mingw64/bin"
extra-include-dirs: "C:/msys64/mingw64/include"
```
enables `cabal` to find `C:/msys64/mingw64/bin/libopenblas.dll`.
### The code execution cannot proceed because libgfortran_64-3.dll was not found
An error such as
```
The code execution cannot proceed because libgfortran_64-3.dll was not found
```
or
```
The code execution cannot proceed because libgcc_s_seh_64-1.dll was not found
```
indicates that a dependency of `BLAS` could not be loaded. These should have been installed as dependencies of `openblas` (see previous error), but otherwise you can try:
```
pacman -S -q --noconfirm mingw64/mingw-w64-x86_64-gcc-fortran mingw64/mingw-w64-x86_64-gcc
```
### addDLL: library not loaded
The error message
```
addDLL: libopenblas or dependencies not loaded. (Win32 error 126)
```
means that `GHC` was not able to find the `BLAS` library, or a dependency thereof.
Follow the previous two steps to ensure both the library and its dependencies can be found.
### Unknown symbol dgesvd_
An error of the form
```
ghc.exe: | MetaBrush\dist-newstyle\build\x86_64-windows\ghc-8.8.4\hmatrix-0.20.0.0\build\libHShmatrix-0.20.0.0-inplace.a: unknown symbol `dgesvd_'
```
indicates that `GHC` was not able to load symbols for the `hmatrix` dependency. This should be solved in the same way as the previous error.
See [this patch](https://github.com/msys2/MINGW-packages/pull/6966).
The package `fontconfig` also presented this issue; this was resolved in [this patch](https://github.com/msys2/MINGW-packages/issues/872).

View file

@ -9,6 +9,7 @@
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilyDependencies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module MetaBrush.DSL.Interpolation

View file

@ -9,6 +9,7 @@
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
module MetaBrush.Document.Draw
( DrawAnchor(..), anchorsAreComplementary

View file

@ -216,7 +216,7 @@ myIntersect (MkR r2) =
MkR d -> MkR (HashMap.intersection d r2)
proveRecordDicts :: forall c r x. Record (Dict c) r -> (AllFields c r => x) -> x
proveRecordDicts = withDict
proveRecordDicts = withDict @(AllFields c r)
describeRecord :: forall kvs. AllFields Typeable kvs => [ ( Text, TypeRep ) ]
describeRecord = collapse $ cmapWithKey @Typeable describeField (recordDicts @Typeable @kvs)

View file

@ -78,20 +78,3 @@ data Segment p =
deriving Applicative
via Generically1 Segment
deriving anyclass ( NFData, NFData1 )
-- TODO: move the following to the groups or groups-generic package.
ginvert :: forall g. ( Generic g, Group ( Rep g () ) ) => g -> g
ginvert = to . invert @( Rep g () ) . from
gpow :: forall n g. ( Integral n, Generic g, Group ( Rep g () ) ) => g -> n -> g
gpow x n = to ( pow @( Rep g () ) ( from x ) n )
instance
( Generic g
, Monoid ( Generically g )
, Group ( Rep g () )
)
=> Group ( Generically g ) where
invert (Generically x) = Generically (ginvert x)
pow (Generically x) n = Generically (gpow x n)