Commit Graph

62 Commits

Author SHA1 Message Date
Hamish Mackenzie
e5ab3910e7
Check ghc-pkg works before we trust its results (#1069) 2021-03-18 19:54:46 +13:00
Hamish Mackenzie
4d700cf155
Fixing emcc usage in haskell.nix ghcjs (#1064)
* Use emscripten branch of GHCJS for 8.6

* Adds release-linux-only.nix (for hydra with no mac builders)

* Sets HOME to a temp dir once per derivation to help performance of emcc

* Updates materialization

* Uses symlinks to reduce ghc derivation size for wrapped ghcjs

* Removes compiler-nix-name test
    This test checked that the default compiler was overridden by the
    compiler-nix-name arg.  There is no default any more.

The GHCJS branches used include fixes for:

* hs$ret_1 typo (should be hs$ret1)

* A bignum issue
2021-03-12 12:21:07 +13:00
Hamish Mackenzie
5c25ce919f
Add getComponent to project and package (#1060)
* Delays cabal configure errors until after evaluation when possible.

* Avoids rerunning long `cabal configure` if we already know it will fail.

* Provides a way to get a component from a package or project using a `cabal` like reference.

Code using the `tool` functions will automatically use `getComponent`.

For `(hackage-package {...}).components.library` is also ok.

```
# Consider changing hackage-package use:
(pkgs.haskell-nix.hackage-package {...}).components.exes.something
(pkgs.haskell-nix.hackage-package {...}).getComponent "exe:something"

# For any cabal project:
project.hsPkgs.somepackage.components.exes.something
project.getComponent "somepackage:exe:something"
# or do it in two steps
(project.getPackage "somepackage").getComponent "exe:something"
```

The reason for the new function is that we cannot provide the attribute interface without knowing that packages are in the project first.

Here is how the `cabal configure` error output is handled:

* The `plan-nix` derivation builds even if `cabal configure` fails.

* When it fails, it copies `failed-cabal-configure.nix` to the `$out/default.nix` along with a copy of the `cabal configure` output.

* When `failed-cabal-configure.nix` is imported and used in any way it writes the `cabal configure` output with `__trace` so it will always be visible.

* Instead of a `plan` the imported nix contains a `configurationError` pointing the `cabal configure` output.

* The intermediate functions `configurationError` and bubble it up to where it is needed.

* `getPackage` returns a mostly empty proxy for a real package when there is a `configurationError`

* The `getComponent` function always returns a derivation, but the version in the proxy writes the `cabal configure` output to stdout and calls `exit 1` (so that it will never build).
2021-03-04 20:10:58 +13:00
Hamish Mackenzie
0d781c04c4
Switch from cabal 3.2 to 3.4 (#1058) 2021-03-01 15:42:23 +13:00
Hamish Mackenzie
42b10678ff
Add support for setting ghcOptions on all packages (#1046)
`ghcOptions` has been moved from package and is now a list of strings.
    old: packages.x.package.ghcOptions = "someGHCoption";
    new: packages.x.ghcOptions = ["someGHCoption"];
To specify ghcOptions for all packages:
    ghcOptions = ["someGHCoption"];
For a single component:
    packages.x.compoents.library.ghcOptions = ["someGHCoption"];
2021-02-19 00:38:36 +13:00
Hamish Mackenzie
413adb037f
Update core interface files GHC to 8.10.4 (#1039) 2021-02-16 23:15:55 +13:00
Hamish Mackenzie
422c4afec3
Update unboxed tuple patch (#1037)
Also Includes aarch64 fix in ghc 8.10.4

See https://github.com/input-output-hk/haskell.nix/issues/1027
2021-02-12 23:06:08 +13:00
Hamish Mackenzie
89f50a96dd
Use pkgs.lib instead of stdenv.lib (#1031)
Fixes:

Warning: `stdenv.lib` is deprecated and will be removed in the next release. Please use `pkgs.lib` instead. For more information see https://github.com/NixOS/nixpkgs/issues/108938
2021-02-11 01:07:16 +13:00
Hamish Mackenzie
cd91692380
GHC 8.10.4 (#1033)
* Adds GHC 8.10.4 support

* Drops GHC 8.8.3, 8.10.2 and 8.10.3 from CI

* Adds warning to encourage people to use less buggy ghc
2021-02-09 14:30:32 +13:00
Hamish Mackenzie
40a26afa33
Patch for ghc 8.10.3 to make musl builds possible on aarch64 (#1029)
See https://github.com/input-output-hk/haskell.nix/issues/1027#issuecomment-772087166
2021-02-04 01:55:16 +13:00
Hamish Mackenzie
0f7c5afc41
Add ghc 8.10.3 (#980) 2021-01-11 18:47:56 +13:00
Hamish Mackenzie
b611105898
Update version number of ghc8102-experimental (#927)
Sets the version number to `8.10.2.20201118` and compiler nix name to `ghc810220201118`
2020-12-07 17:19:39 +13:00
Hamish Mackenzie
7078b145e9
Add support for ghcjs 8.8 and making ghcjs bundles (#828)
Fixes ghcjs 8.6.5 and 8.8.4.

Uses emscripten for ghcjs 8.8 and adds scripts for building ghcjs 8.8.

Many fixes for ghcjs test failures.

Includes relocatableConfigFiles for making relocatable ghcjs bundles.
2020-11-17 22:22:53 +13:00
Moritz Angermann
23539aef9e
Add enableDWARF and useLLVM (#909)
(cherry picked from commit dc44dbcfe5)
2020-11-05 18:43:38 +13:00
Moritz Angermann
778f1ab81e
Enable ghci libraries (#908)
(cherry picked from commit 3e7fde0a2c)
2020-11-05 18:43:25 +13:00
Hamish Mackenzie
a526148954
Use ghc865 to build ghc8102-experimental (#891)
This change was made to ghc8102 already, but got missed on
ghc102-experimental
2020-10-22 02:59:10 +13:00
Hamish Mackenzie
cda15dc5b7
Add ghc8102-plutus as a compiler-nix-name (#848)
This change introduces a `ghc8102-experimental` compiler-nix-name that behaves much like the `ghc8102` version but includes @JoshMeredith's patch `./patches/ghc/ghc-8.10-ubxt.patch` that writes the `cg_binds` field with:

```haskell
  liftIO $ registerInterfaceDataWith "ghc/phase/core" hsc_env $ \bh ->
    putWithUserData (const $ return ()) bh (map toIfaceBind $ cg_binds cg_guts)
```

Some of the places where we used to depend on the output of `plan-to-nix` containing the correct `nix-name` for the compiler have been update to avoid using incompatible interface files from the `compiler-nix-name = "ghc8102"` version of GHC.
2020-10-21 17:04:47 +13:00
Le Tuan
ef6ca0f431
fix: ignore atomic primops on ARM architectures (GHC 8.8.3) (#857)
Fixes the #441 issue with GHC 8.8.3 (fix that was already applied to GHC 8.6.5 with PR #480).

Testing environment:

- GHC 8.8.3 (cross-compiler)
- NixOS 20.03
- Building host: x86_64
- Target host: armv6l

Without this PR, the symbol `__sync_val_compare_and_swap_8` was not found by `remote-iserv` as described in #441 but this time with GHC 8.8.3. The 8.6.5 patch also works for 8.8.3. Perhaps it would be preferable to apply this patch to a range of GHC versions rather than specific versions, but I have only tested it and verified that it works properly on those specific versions.

I have not submitted this patch to the GHC GitLab as I haven't encountered any problem building a cross-compiling version of GHC from there.
2020-10-15 01:57:45 +13:00
Hamish Mackenzie
ec96755bee
Add initial unboxed tuple patch for ghc 8.10 (#825)
* Add initial unboxed tuple patch for ghc 8.8

* ifdLevel 0

* ifdLevel 1

* ifdLevel 2

* Update unboxed tuple patch (ifdLevel 0)

* ifdLevel 1

* ifdLevel 2

* ifdLevel 1

* ifdLevel 2

* ifdLevel 1

* Make sure ghc and ghc-pkg run

* ifdLevel 2

* Remove show instances from unboxed tuple patch

* ifdLevel 1

* ifdLevel 2

* ifdLevel 3

* Add GHC 8.10 version of the unboxed tuple patch

* Fix patch

* ifdLevel 2

* ifdLevel 3

* Update unboxed tuple patch

* Delete old ghc 8.8 version of patch

* ifdLevel 1

* ifdLevel 2

* ifdLevel 3
2020-10-14 12:21:30 +13:00
Hamish Mackenzie
33cd29ee33
Add patch for undefined __acrt_iob_func issue (#870) 2020-10-09 14:18:02 +13:00
Hamish Mackenzie
6134e66e1d
Fix ghc 8.10 windows cross (boot with 8.6.5) (#865)
It looks like we can't use 8.8 for booting due to
https://gitlab.haskell.org/ghc/ghc/-/issues/18143

* Adds nixpkgs 20.09 to get mingw-w64 version 6
  (also needed for ghc 8.10 windows cross compile)

* Add materialization for ghc 8.10.2 windows cross

* Fix issue with harfbuzz override so it works with nixpkgs 20.09

* Fixes eval time issue for windows index-state test (turns off native-dns cabal flag for windows)

* Include exe extension for windows in coverage test

lib:ghc is still broken for ghc 8.10 (all variants), but it always has been and we should try to fix it properly, but it will be very tricky.
2020-10-07 15:42:32 +13:00
Julien Moutinho
565db54106
Fix #836 (#836) (#837)
* Fix #836 (#836)

* Fix cross compilers and use ghc 8.8 to build 8.10

Co-authored-by: Julien Moutinho <julm+haskell.nix@sourcephile.fr>
Co-authored-by: Hamish Mackenzie <Hamish.Mackenzie@iohk.io>
2020-09-08 02:38:36 +12:00
John A. Lotoski
09526c8555
Spelling, typo and whitespace fixes (#833)
* Spelling and typo fixes in doc and code comments
* Trailing whitespace or whitespace only truncation
* readTheDocs formatting corrections
2020-08-31 11:08:25 +12:00
Hamish Mackenzie
c7c7d6c43a
Add ghc 8.10.2 (#807) 2020-08-11 14:26:50 +12:00
Hamish Mackenzie
cacfba0b45
Replace ghc 8.8.3 with 8.8.4 (#766)
Also adds some tooling/docs for adding new ghc versions (see `docs/adding-new-ghc.md`)
2020-07-21 14:10:23 +12:00
Hamish Mackenzie
4cac8bd00f
Remove internal deps on default ghc and stackage (#738)
Changes to the interface of haskell.nix (from the changelog.md file):

* Removed `sources.nixpkgs-default`, use `sources.nixpkgs` instead.
* Removed `./nixpkgs` directory, use  `(import ./. {}).sources`
  or `./nix/sources.nix` instead.
* Removes V1 interface for details on how to fix old code see:
    https://github.com/input-output-hk/haskell.nix/issues/709
* Removed defaultCompilerNixName.
* cabalProject, cabalProject', hackage-project and hackage-package
  now require a `compiler-nix-name` argument.
* `haskell-nix.tool` and `.tools` now require a `compiler-nix-name` argument.
  New functions `p.tool` and `p.tools` (where p is a project) do not.
  Like `shellFor { tools = ... }` they will use the compiler nix name
  from the project (including stack projects where it is derived from
  the resolver).
* `haskell-nix.alex` and `haskell-nix.happy` have been removed. Use
  `p.tool "alex" "3.2.5"` or `shellFor { tools = { alex = "3.2.5"; } }`.
* `haskell-nix.nix-tools` -> `haskell-nix.nix-tools.ghc883` (it includes
  the hpack exe now).
* `haskell-nix.cabal-install` -> 
  `p.tool "cabal" "3.2.0.0"` or `shellFor { tools = { cabal = "3.2.0.0"; } }`
* `haskell-nix.haskellNixRoots` -> `haskell-nix.roots ghc883` or `p.roots`

Other changes:

Adds hpack executable to the nix-tools derivations.

Adds a `cabal-hpack` test to make sure `hpack` works with
`cabalProject`.

Reduces the number of calls to `cabalProject` (particularly when
checking materialization), by giving internal tools a per-compiler
attribute.

Uses happy 1.19.12 when building newer ghc versions.

Updates cabal-install 3.2.0.0 to use the source from github that
is compatible with ghc 8.10.1.

Updates the docs for callCabalProjectToNix.

Adds a license mapping to fix a common warning.
2020-07-08 22:54:01 +12:00
Moritz Angermann
a500f39da7
Musl changes (#700)
This should simplify the interaction with musl quite a but.
Musl specific mapping should go into the musl overlay now.
2020-06-23 09:45:22 +08:00
Moritz Angermann
74edd91659
backport ghc!3227 (#718)
This essentially backports the following two commits (make build system parts only)

- bec76733b8
- 67738db100

fixes #584
2020-06-22 08:03:57 +08:00
Hamish Mackenzie
8cbf979538
Add nix-tools to niv and update docs to fix #675 (#678)
* Updates docs/user-guide.md

Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
2020-06-15 14:36:05 +12:00
Hamish Mackenzie
15fc6b3774
Add ghc 8.10.1 (#541)
* ghc 8.10
* Adds/Updates/Removes materialization files
* Disable one-shot-kqueue-on-macos patch on ghc-8.10
* Test ghc883 and ghc8101 but only with nix 20.03
* Various smaller fixes.

This should fix the infinite recursion issue with #654

Co-authored-by: Lennart Spitzner <hexagoxel@hexagoxel.de>
2020-06-07 11:05:44 +08:00
Hamish Mackenzie
80e0e61a81
Fix arm cross compilation with ghc 8.6.5 (#654) 2020-06-06 13:32:09 +12:00
Travis Whitaker
ed673956e8
Native aarch64 support (#620)
* native aarch64 support

Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com>
2020-06-04 20:29:50 +08:00
Hamish Mackenzie
099d830db1
Update ghc 8.4.4 based tools to ghc 8.6.5 (#618)
Although the default ghc used by haskell.nix is ghc 8.6.5 many of
the tools used in haskell.nix are still built with the boot compiler
ghc 8.4.4.  These include

  * haskell-nix.cabal-install
  * haskell-nix.alex
  * haskell-nix.happy

This change updates those to ghc 8.6.5 and includes materializations
for the new versions.

When cabal-install is built it is careful to disable materialization
checks on the version of itself used during the build to avoid
infinite recursion.

There was a version of nix-tools built with the boot ghc which was
only used when `checkMaterialization = true`.  It was used for
the boot versions of alex, happy and hscolour.  These have been update
to use the default (ghc 8.6.5) version of nix-tools and
checkMaterialization is forced off when they are being used to build
ghc.  This means the materialization will only be checked for these
when they are built independently (they are included in the test set
via haskellNixRoots).

Three new arguments are added to `default.nix`:

* `defaultCompilerNixName` if not specified "ghc865" is used
* `checkMaterialization` makes it easier to switch on materialization checks
* `system` defaults to `builtins.currentSystem`

This change also moves the work needed for hydra eval to the eval
system using a new `evalPackages` feature.  This includes:

* Fetching from git with `fetchgit`
* Building scripts with `runCommand` and `writeTextFile`
* `git ls-files` in `cleanGit`
* running `cabal v2-configure`
* copying materialized files (we are not sure why this is necessary but
  if we do not `cp -r` the files nix will not load them on hydra)

Reduce size of `make-config-files.nix` strings by around 80%.
These are unlikely to be the cause of hydra eval time memory
issues in the GB range, but were still quite large (around 10MB for the
`cabal-simple` test case).

There was issue causing excessive builds of the `git` package when
cross compiling.  Gory details are a comment in `lib/defaults.nix`
but in short if you use `git` you need an extra `.buildPackages`
one is not enough because it depends on `gdb` and that will
be different in `buildPackages` compared to
`buildPackages.buildPackages`.

Adds missing materialization files for ghc 8.4.4 (only needed
when `checkMaterialization` is on because of other
materialiazations, but good to have).
2020-05-21 11:31:26 +12:00
Hamish Mackenzie
788e198376
Add compiler-nix-name to cabalProject (#610)
* Add compiler-nix-name to cabalProject

Setting the compiler explicitly does not make it easy for cross
compilation to also choose the correct compiler when compiling
build tools for the build platform.  Also it is easy to pass the
wrong compiler type.  Specifying just the nix-name of the compiler
makes that less likely.

Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com>
2020-05-16 21:48:48 +08:00
Moritz Angermann
f330b2407e
Add MR2537-use-one-shot-kqueue-on-macos.patch (#604)
This adds the one-shot-kqueue-on-macos MR from gitlab.
2020-05-14 14:26:30 +08:00
Hamish Mackenzie
71f31cef4a
Fix evalDeps package ids with - in name (#585) 2020-05-11 23:58:42 +12:00
Le Tuan
49ecc0e4db
fix: consider relocatable data as writable (#570)
When declared as constant, read-only relocatable data are written to an unwriteable .rel.ro.data section. Being unwriteable, the gold linker doesn't put them inside the GNU_RELRO segment, but in a always read-only segment. Starting the relocation phase of such a built program then ends in a segmentation fault.

By declaring read-only relocatable data as writeable, they will be put inside a writeable .rel.ro.data section. The gold linker will then assume that those can be put inside the GNU_RELRO segment, that will only be writeable during the relocation phase.

The as assembler and ld linker will always consider the .rel.ro.data as writeable before relocation, and put the associated data in the GNU_RELRO.

Co-authored-by: Michivi <webmaster@michvi.com>
2020-05-09 07:04:50 +08:00
Alexander Kudryashov
de3f82a419
Add native musl support (#578)
* Add native musl support

- adds haskellLibl.isNaviveMusl and related fixes (previously it was
assumed that for musl we always use cross-compilation)
- fixed some issues for musl intoduced in nixpkgs 20.03 (ssh/fetchcvs
infinite recursion, busybox pkgsMusl.pkgsStatic chain, etc.)
- cross-compilation fixes for ghc (absolute path for ar, always pass
target to configure, libffi and gmp packages for target platform) -
this needs more testing

* Better explanation for targetPlatform.{libffi, gmp}

* Ghc configure script now respect AR env variable


Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com>
2020-05-08 15:32:40 +08:00
Hamish Mackenzie
a2d97bd9ad
Flake (#589 and #567)
Allows haskell.nix to be used as a nix flake.

Authored-by: Alexander Bantyev <balsoft@balsoft.ru>
2020-05-07 11:16:38 +12:00
Hamish Mackenzie
e4d75d61f1
Allow materialized only (#563)
This change allows for just the materialized argument to be passed
and removes the sha256 values for haskell.nix's own materialized
nix files.
2020-04-27 23:20:32 +12:00
Hamish Mackenzie
d1102d342c
Add pins and materialization for ghc-boot-packages and ghc-extra-packages (#546)
* Include `tests` in path for cross compiled tests

* Add ghc-boot-packages-nix to haskellNixRoots

* Fix naming warnings in tests sources

* Uses a single cleanGit call for all the tests

* Add memoize code for ghc-boot and ghc-extra pkgs

* Memoize ghc-boot and ghc-extra pkgs nix

* Fix release.nix being more strict than ci.nix by updating filterAttrsOnlyRecursive in ci-lib.nix

* Nicer errors when materialized path does not exist

* Updated materialization docs

* Add internalHackageIndexState to set the index-state used within haskell.nix
2020-04-20 13:27:52 +12:00
Hamish Mackenzie
578e7dde6f
Fix reinstallable ghc for ghc 8.8.3 (#502) 2020-03-20 11:12:03 +13:00
Le Tuan
8099da8fe0
Fix cross-compilation for armv6l (#480)
This PR adds a patch for GHC 8.6.5 to properly remove the atomic primops fallbacks on ARM architectures. Those primops called some GCC legacy synchronization functions that were not loaded during TH, ending in failure within `remote-iserv`. It turns out that the condition `!defined(arm_HOST_ARCH)` was never `true`, as `arm_HOST_ARCH` was actually defined (on ARM architectures) in a dependency of the `Rts.h` file.

This patch works for my use case (GHC 8.6.5 for armv6l). I haven't done any test on the other GHC versions.

This PR also includes a patch to actually use the native `pkgconfig` during cross-compilation.

Fixes #441

Authored-by: Michivi <webmaster@michvi.com>
2020-03-11 23:04:57 +13:00
Hamish Mackenzie
775c8cf756
Fix cross compilation issues for musl and aarch64 (#322)
* Enables tests for Musl and AArch64 (also rasbery pi, but leaves them disabled for now) and includes many fixes for the tests that were broken.

* Makes Musl cross compiler more like native (including making `ghci` and `runghc` work)

* Updates selection of enableShared

* Works around missing configFiles attribute issue

* Use ghc-extra-packages and compiler.nix-name to pick the right extra packages

* Leaves out --cross-compile on hsc2hs for musl

* Fixes haddock and hoogle for musl and disables them for other cross compilers

* Adds ghc 8.8.3

* Static link components (except libraries and `all`) on musl

* Use qemu for the arm cross compile `testWrapper`

* Add isCrossHost and isCrossTarget functions

* Fixes profiling on AArch64

* Disable split sections when compiling for windows (fixes GHC 8.8 cross compile to windows)

* Disable hoogle in cross compiler shells for now
2020-03-04 16:07:01 +13:00
Kirill Elagin
f754c5bf4e
Cleanup iserv patches (#439)
This commit cleans up iserv-related patches, especially for GHC 8.4, by
making sure they are exactly changes made upstream (only with merge
conflicts resolved).

Overall, there are three groups of patches now:

1. move-iserv is merely an upstream change that was merged between 8.4
   and 8.6. The previous patch was probably some development version,
   now it is the same as upstream.
2. iserv-autoconf was merged upstream between 8.6 and 8.8. The patch
   consists entirely of replacing version numbers with variables,
   therefore applying the same patch to 8.4 and 8.6 causes conflicts, so
   we have two versions of the same patch for simplicity. Additionally,
   the 8.6 is different from the upstream one in that it does not remove
   the .cabal files, see the commit description in the patch for details.
3. iserv-cleanup was merged between 8.8 and 8.10. It applies cleanly to
   8.8 and 8.6, however there is conflict in one line when applying it
   to 8.4. As a workaround, when applying this patch to 8.4 we first
   prepare the source to avoid the conflict, and then undo this change.
   This allows us to use the same main patch for 8.4 as for 8.6 and 8.8.

Also, in all patches changes to .gitignore were manually removed, as
this file does not exist in the Nix checkout of src and this causes
the patches to fail.
2020-02-11 09:32:53 +08:00
Moritz Angermann
f5b150c98a
build ghcjs (#382)
Adds `ghcjs` to haskell.nix

Co-authored-by: Hamish Mackenzie <Hamish.K.Mackenzie@googlemail.com>
Co-authored-by: Michael Bishop <cleverca22@gmail.com>
2020-02-09 20:03:22 +08:00
Hamish Mackenzie
122bd81150
Add ghc 8.8.1 to the supported compilers (#342)
* Add ghc 8.8.1 to the supported compilers

The `overlays/ghc.nix` overrides were not applied to the `ghc` used
to by the `exactDeps` and `envDeps` `passthru` derivations.  This
resulted in each ghc building twice with only one of them being cached
by hydra.

This change fixes this by moving the exactDeps and envDeps for ghc
into sub directories of the output of the ghc derivation itself.

Co-authored-by: Hideaki KAWAI <kayhide@gmail.com>
2020-02-04 15:19:37 +08:00
Edward Amsden
563e18c3d5
Unbreak Aarch32 cross-compilation (#411)
* Use quick-cross for cross-compilation to avoid qemu crashes
* Bring over patches from my old fork of iohk-nix
* Expand Aarch32 patches to ghc-8.6.5
* Turn off shared builds when cross-compilging for linux ARM
* Update compiler/ghc/default.nix
2020-01-31 20:58:09 +08:00
Edward Amsden
a1432c1f49 Change LLVM versions for ghc-8.6 to LLVM 6 (#385)
The LLVM versions specified for the ghc-8.6 series compilers in overlays/bootstrap.nix was LLVM 5, but these compilers state on the download page that they require LLVM 6. This resulted in a warning about a wrong LLVM version for every module compiled with the LLVM backend (e,g, when cross-compiling.) This PR updates the LLVM versions for these compilers to LLVM 6.

Note: ghc-8.8.1 (and presumably future ghcs in the 8.8 series) requires LLVM 7. However it appears haskell.nix does not yet support ghc-8.8.1.
2020-01-07 19:12:32 +13:00
Hideaki Kawai
0e66dbd17f
Patch gcc version fix on macOS 2019-12-21 10:48:03 -07:00