Commit Graph
149 Commits
Author SHA1 Message Date
Moritz AngermannandHamish Mackenzie b06fdfa065 Adds experimental TSan logic. This will require a custom compiler (#910)
(cherry picked from commit 0f640b4285)

Co-authored-by: Hamish Mackenzie <Hamish.Mackenzie@iohk.io>
2020-11-06 18:23:12 +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
Eric WolfandHamish Mackenzie 0c3abc8a6d Allow for hoogle to be materialized in shellFor (#902)
Allow for hoogle to be materialized in `shellFor` by using `tools.hoogle` when passed in.

Co-authored-by: Hamish Mackenzie <Hamish.K.Mackenzie@googlemail.com>
2020-10-31 20:46:54 +13:00
andremarianiello ddbb4a50b9 Stop using deprecated lib.nixpkgsVersion (#876) 2020-10-13 15:38:12 +13:00
Hamish Mackenzie ab2f5a9b6d nixpkgs 20.09 pkg-config has a prefix (#874)
From nixpkgs 20.09, the pkg-config exe has a prefix matching the ghc one
2020-10-12 23:41:29 +13:00
Samuel Evans-Powell 48b8674f5f Add support for coverage (#762)
- Added the ability to generate coverage reports for packages and
  projects.
  - Outputs mix and tix information, as well as a HTML report.
- Added the "doCoverage" module option that allows users to choose
  packages to enable coverage for.
- Added a "doCoverage" flag to the component builder that outputs HPC
  information when coverage is enabled.
- Added the "overrideModules" library function to make it more
  ergonomic fo users to enable coverage on existing projects.
- Modified the "check" builder to also output ".tix" files (if they
  exist). This information is required to generate the coverage
  report.
- Added a test for coverage.
2020-09-29 11:56:24 +08:00
Ollie Charles f655e66777 Changes to allow opencv to be built (#834)
* Changes to allow opencv to be built

The opencv library needs:

1. pkgconfig for opencv should return OpenCV 3, not OpenCV 2 (which is
   what pkgs.opencv is)

2. hardeningDisable = [ "bindnow" ] (as per
   https://github.com/LumiGuide/haskell-opencv/commit/5ea490af7662fe74b3740619963d37f1fd91e3d4#)

This commit fixes (1) by adding an entry to lib/pkgconf-nixpkgs-map.nix,
and partially fixes (2) by adding a new `hardeningDisable` option to the
set of package options. The user will still need to specify:

  packages.opencv.hardeningDisable = [ "bindnow" ];

I'm not sure if there's a place to specify this as default in haskell.nix.

* Update comp-builder.nix
2020-09-08 00:28:38 +12:00
Hamish Mackenzie 41d731603f Fix warning message for checkPhase (#835) 2020-09-05 13:57:54 +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
Michael Peyton Jones 2db0b60816 Fix dependency filtering for shellFor (#819)
I had to refactor this a bit to understand what was going on, but the
kicker is two changes:
- `removeSelectedInput` was only removing *library* components. This was
fine when we were only looking at the `all` components, since they
always dependend on libraries. But now we're looking at all kinds of
components, and these can, for example, depend on internal libraries.
So we need to filter out dependencies on *any* component, not just a
library component. This fixes https://github.com/input-output-hk/haskell.nix/issues/818
- The filtering on `nativeBuildInputs` was wrong, since it was using the
filtering function that filters *packages*, not the one that filters
*derivations*. I didn't observe this causing a bug but it seems wrong.
2020-08-14 14:06:22 +12:00
Hamish Mackenzie e340658306 Use internal-nix-tools for hpack (#816) 2020-08-12 21:40:18 +12:00
Hamish Mackenzie 3c458f5c45 Add another check for #660 issues (#805)
Currently if the `ghc-pkg` fails during the last stage of building a library component
(perhaps because of https://github.com/NixOS/nix/issues/719) the failure is ignored.
This seems to be the most likely cause of the bad `config` derivation.

This change should cause the derivation build to fail instead of making invalid
files when this happens.
2020-08-09 11:57:30 +12:00
Michael Peyton Jones 1687b5d2a1 Fix types of some meta attributes (#806)
These can't be null. They could perhaps be absent, but I can't figure
out how to set an attribute only if something else isn't null in a nice
way, and having it be the empty string seems fine.

Fixes #804.
2020-08-08 13:20:16 +12:00
Hamish Mackenzie a904d403d8 Improve hpack support (#800)
Use up to date hpack in comp-builder.nix

Avoid running hpack when we have a .cabal file already
2020-08-05 01:02:47 +12:00
Hamish Mackenzie b6de6ef3b8 Remove components.all (#776)
It causes a lot of issues. To make this work:

* `shellFor` is updated to use `getAllComponents` instead of `.all`.
* `getAllComponents` is updated to work on the package rather than
  the package config.
* Tests updated to not use `.library` or `.exes.X` where appropriate.
* Documentation updated.
* Out of date examples removed.

As a bonus `shellFor` now takes a `components` argument that might be
useful for limiting the dependencies of the shell to just the ones
needed for the components you intend to work on.
2020-07-21 16:06:54 +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
Travis Whitaker 9d491b560f haddock: do preConfigure and postConfigure (#746) 2020-07-03 20:27:06 +12:00
Guillaume Desforges 7fec2a157c Fix #742 : packages in additional in shellFor are indeed added and displayed by ghc-pkg list as per documentation specification (#743) 2020-07-03 10:19:53 +12:00
Hamish Mackenzie 4e6c1a37bd Fix for #736 (#739) 2020-07-02 03:37:38 +12:00
Hamish Mackenzie 47f0cded18 Fix haddock when pkgconfig is needed to configure (#732)
Packages like haskell-gi need pkgconfig at configue time to generate
source files we want to run haddock on.

This change also brings back a `mkdir` for the $docs that is needed
for haddock of bytesting-builder (it was removed when haddock the
haddock derivation was split out).
2020-06-29 14:46:19 +12:00
Hamish Mackenzie 128dbef133 Replace lib.fix with recursive let in builders (#730) 2020-06-27 22:31:52 +12:00
Hamish MackenzieandRichard Wallace 1e3c1304c1 Split haddock out into its own derivation (#725)
Generation the Haddock documentation for a component in a dedicated
derivation (instead of as part of the derivation to build the component).
This means that the haddock documents will not be built until they are
required for instance in a shellFor shell.

Co-authored-by: Richard Wallace <richard.wallace@simspace.com>
2020-06-27 01:29:41 +12:00
Hamish Mackenzie 8fac80f3ea Use internalHackageIndexState to pin hoogle (#726)
Without this pin the plan choosen with the latest hackage is currently
broken and the build fails with:

```
src/General/Web.hs:21:1: error:
    Could not find module ‘Data.Aeson.Encoding’
    Perhaps you meant
      Data.Aeson.Encode (from aeson-0.11.3.0)
      Data.ASN1.Encoding (needs flag -package-key asn1-encoding-0.9.6)
      Data.Text.Encoding (from text-1.2.3.1)
    Use -v to see a list of the files searched for.
   |
21 | import Data.Aeson.Encoding
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^
```
2020-06-24 17:35:18 +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
Hamish Mackenzie 5291959d28 Add propagatedBuildInputs to shell (#717)
Now that the pkgconfig inputs are here we need this to make them
show up in the shell.  Also adds gtkglext pkgconfig mapping.
2020-06-21 19:40:14 +12:00
Hamish Mackenzie 9c6eb16428 Fix propagation of pkgconfig and frameworks (#715)
pkgconfig-depends that make use of propagatedBuildInputs and frameworks
are not propagated to the exe component that links them. This seems
to be because our libraries do not not include their dependencies
as `buildInputs`.  To make this work it also seems to be necessary
for pkgconfig depends themselves to be `propagaedBuildInputs`.
2020-06-21 16:40:52 +12:00
Hamish Mackenzie 1671a74789 Respect defaultCompilerNixName building hoogle (#676) 2020-06-12 14:37:34 +12:00
Hamish Mackenzie 6dc93ce1d4 Fix missing -lnuma when linking musl test exes (#652)
Also:

* Reduce the number of calls to override functions

* cp -L is not needed for user to cp calculateNoHash

* Update dummy-ghc files
2020-06-05 12:54:33 +12:00
Hamish Mackenzie 96f406263f Fix for #647 (cross builds broken on haddock) (#649)
In de3f82a419 a isNativeMusl function was
added, but we did not use it in `builder/ghc-for-component-wrapper.nix`
for selecting a ghc with a suitable `haddock` executable (it was only
used in builder/default.nix).
2020-06-03 23:04:59 +08:00
Moritz Angermann 6c57d4f978 Faster profiled builds (#623) 2020-05-22 21:50:05 +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 78bc7251d6 Use package version as component version (#615)
Currently we do not give components a version and this is inconvenient
as it means nix code that checks for a version does not work
with haskell.nix components.
2020-05-20 14:06:03 +12:00
Alexander KudryashovandMoritz Angermann 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
Richard Wallace aa69e618d2 Add build-tools as component builder argument (#579) 2020-05-03 11:42:21 +08:00
Richard Wallace a5e5138e8c Add more component attributes as component builder arguments (#577) 2020-05-02 10:56:45 +08:00
Moritz Angermann ccd52aa2fd Properly build profling executables (#571)
When building profiling executables we want the libraries also with
profiling. This change also adds a flag to link against the debug RTS.
This does not require everything to be built against the debug RTS and
only requires the final linking step, hence no threading is necessary.
2020-05-01 20:24:20 +08:00
Moritz Angermann 5813be54db Allow to override components (#572)
Not being able to override components values once they have been setup
and exclusively relying on the module system to do its thing, can be
quite constraining. This change allows us to override components.
2020-05-01 18:00:32 +08:00
Hamish MackenzieandRichard Wallace 49cbd34534 remove creation of relative links in package db (#569)
Changing from absolute links to relative links increases the length of
the parameters passed during linking by half. For things that have many
dependencies, this results in linking failing with an "argument list too
long" error.

Fixes #562

This change also updates the CI configuration files to help make
it easier for CI to cope with this sort of change.

Co-authored-by: Richard Wallace <richard.wallace@simspace.com>
2020-05-01 16:49:22 +12:00
Hamish Mackenzie 5ebce0eb3c Make it easier to access executable components (#565)
This overlay helps accessing common executable components.
Typically we want to make these available in a nix-shell
created with shellFor.  In most cases the package name
will be the same as the executable, but we have a
`toolPackageName` mapping to help when it is not.

```
# To get a single tool:
haskell-nix.tool "cabal" "3.2.0.0"

# This does the same thing as:
(haskell-nix.hackage-package {
  name = "cabal-install"
  version = "3.2.0.0"
}).components.exes.cabal

# To get an attr set containing multiple tools:
haskell-nix.tools { cabal = "3.2.0.0"; hlint = "2.2.11"; }

# To add tools to a shell:
shellFor { tools = { cabal = "3.2.0.0"; hlint = "2.2.11"; }; }
```

When used in shellFor the tools will be compiled with the same version
of ghc used in the shell (the build ghc in the case of cross
compilation).

Instead of a version string we can use an attr set containing
arguments that will be passed to `cabalProject`.

For instance to specify the ghc used to compile. Use:

```
haskell-nix.tool "cabal" {
  version = "3.2.0.0";
  ghc = haskell-nix.compiler.ghc883;
}
```
2020-04-29 19:10:14 +12:00
Michael Peyton Jones 701c83fb43 Update nixpkgs pins to include 20.03 (#557)
* Update nixpkgs pins to include 20.03, wobble

- Add 20.03
- Remove 19.03 (and old 18.09 file)
- Update 19.09 to latest
- Update github pin to 20.03
- Remove workarounds for 19.03

* Mark openssl as allowedInsecure

* Force python3 for mkdocs
2020-04-29 02:49:36 +12:00
Le TuanandMichivi e08db6b66f fix: don't use fast-llvm for aarch32 (#555)
* fix: don't use fast-llvm for aarch32

fast-llvm bypasses the GHC LLVM mangler and the GNU assembler. The latter is currently required when using the gold linker for valid relocation sections.

* feat: remove usage of the fast-llvm flag

The fast-llvm flag was intented to avoid potential incompatibilities between LLVM and the assembler/linker toolchain by making LLVM responsible for machine-code generation.

It bypasses necessary code transformation and prevents valid program generation in some cases (e.g. cross-compilation to armv6l). It is planned for removal from GHC.

References:
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3120

Co-authored-by: Michivi <webmaster@michvi.com>
2020-04-27 11:27:19 +08:00
Hamish Mackenzie a39b5a741a Add NIX_GHC_LIBDIR to shellFor (like nixpkgs does) (#559)
Tools like ghcide use this to find the correct global package db.
2020-04-24 15:48:55 +12:00
Le TuanandMichivi dc3d1a7bfc fix: not use ld.gold on aarch32 (#548)
It seems that using ld.gold for cross-compilation to aarch32 results in Haskell programs segfaulting when launched.

Co-authored-by: Michivi <webmaster@michvi.com>
2020-04-17 23:54:06 +12:00
Kirill Elagin 16f43b2b2f Allow .so dynamic libraries on Darwin (#534)
* Allow .so dynamic libraries on Darwin

This code is a hack that applied only to Darwin, it collects all
required dynamic libraries into a single directory. It does this by
listing all library dirs and then linkin all dynamic libraries in them.

Before this change, it would link only `*.dylib` files. This was a
problem, because (weirdly) a lot of libraries in Nixpkgs actually
produce .so even on Darwin (and, weirdly, this somehow works).

So we now link `.so` files as well.

* Fix linking of dynamic libs with static on Darwin

This piece of code `ln`s all libraries we might want to link with into a
single directory and then hides all previous directories from Cabal.
The problem is that this code only `ln`s dynamic libraries, however we
might want to link with some library that only comes in a static
version.

So, `ln` static `.a` libraries too so that they are found when linking.
2020-04-09 11:14:49 +08:00
Michael Peyton Jones eb15db0450 Expose our nixpkgs pins by restructuring default.nix (#514)
* Remove unused (and broken) test files

* Make default.nix expose pinned nixpkgs

Also make `nixpkgs/default.nix` just an attribute set of sources.
This is simpler, and consistent with what e.g. `niv` does.

* Add backwards compatibility shim, and version argument to allow evolution in future

* Fix some missed things

* Fix and improve quickstart
2020-03-31 09:12:40 +08:00
Yorick 13a88d15f3 ghcjs: copy and run tests (#494) 2020-03-17 22:20:08 +13:00
Yorick 73443ef1a8 comp-builder: fix for ghcjs (#487) 2020-03-13 12:44:47 +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