Commit Graph

300 Commits

Author SHA1 Message Date
Slava Gorbunov
718851b229 haskellPackages.mkDerivation: use emcc as C compiler for ghcjs
We need to set up EM_CACHE correctly so that it works, of course.

Note that the solution relies on the assumption that this should only
happen when we cross compile, i.e. the extra logic to account for the
cc-less stdenv in pkgsCross.ghcjs is only present in crossCabalFlags.

Co-authored-by: sternenseemann <sternenseemann@systemli.org>
2024-04-22 14:16:09 +02:00
Slava Gorbunov
78667e9c1b haskellPackages.mkDerivation: fix logic error
Co-authored-by: sternenseemann <sternenseemann@systemli.org>
2024-04-22 13:00:28 +02:00
github-actions[bot]
2178d8d857
Merge master into staging-next 2024-03-17 00:02:17 +00:00
a-n-n-a-l-e-e
ce789e7e35
llvmPackages_{12,13,14,15,16,17,git}.{libcxx,libcxxabi}: merge libcxxabi into libcxx (#292043)
- merge libcxxabi into libcxx for LLVM 12, 13, 14, 15, 16, 17, and git.
- remove the link time workaround `-lc++ -lc++abi` from 58 packages as it is no longer required.
- fixes https://github.com/NixOS/nixpkgs/issues/166205
- provides alternative fixes for. https://github.com/NixOS/nixpkgs/issues/269548 https://github.com/NixOS/nix/issues/9640
- pkgsCross.x86_64-freebsd builds work again

This change can be represented in 3 stages
1. merge libcxxabi into libcxx -- files: pkgs/development/compilers/llvm/[12, git]/{libcxx, libcxxabi}
2. update stdenv to account for merge -- files: stdenv.{adapters, cc.wrapper, darwin}
3. remove all references to libcxxabi outside of llvm (about 58 packages modified)

### merging libcxxabi into libcxx
- take the union of the libcxxabi and libcxx cmake flags
- eliminate the libcxx-headers-only package - it was only needed to break libcxx <-> libcxxabi circular dependency
- libcxx.cxxabi is removed. external cxxabi (freebsd) will symlink headers / libs into libcxx.
- darwin will re-export the libcxxabi symbols into libcxx so linking `-lc++` is sufficient.
- linux/freebsd `libc++.so` is a linker script `LINK(libc++.so.1, -lc++abi)` making `-lc++` sufficient.
- libcxx/default.nix [12, 17] are identical except for patches and `LIBCXX_ADDITIONAL_LIBRARIES` (only used in 16+)
- git/libcxx/defaul.nix  does not link with -nostdlib when useLLVM is true so flag is removed. this is not much different than before as libcxxabi used -nostdlib where libcxx did not, so libc was linked in anyway.

### stdenv changes
- darwin bootstrap, remove references to libcxxabi and cxxabi
- cc-wrapper: remove c++ link workaround when libcxx.cxxabi doesn't exist (still exists for LLVM pre 12)
- adapter: update overrideLibcxx to account for a pkgs.stdenv that only has libcxx

### 58 package updates
- remove `NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}` as no longer needed
- swift, nodejs_v8 remove libcxxabi references in the clang override

https://github.com/NixOS/nixpkgs/pull/292043
2024-03-11 03:53:37 -07:00
Wolfgang Walther
a2083c748f
haskellPackages.mkDerivation: refactor to use enableFeature for stripping 2024-02-08 14:39:03 +01:00
Wolfgang Walther
0e18284132
haskellPackages.mkDerivation: pass -split-sections when cross-compiling
This works around #286285 by passing --enable-split-sections instead of ghc-options.
2024-02-08 14:39:03 +01:00
Wolfgang Walther
9d57ec90d6
haskellPackages.mkDerivation: remove some empty lines and default arguments 2024-02-08 14:39:02 +01:00
Wolfgang Walther
eb56edbce0
haskellPackages.mkDerivation: remove version checks for unsupported GHC
Most of the version checks for GHC can be removed, because they target versions
which are not part of nixpkgs anymore.
2024-02-08 14:39:02 +01:00
sternenseemann
28a3508303 haskellPackages.mkDerivation: avoid forcing stdenv.cc if missing
If we don't check `hasCC`, we run into trouble on pkgsCross.ghcjs, one
of the few platforms where `cc` will throw
(so `stdenv.cc.isClang or false would` not be enough).

Problem introduced in 8164b190 / #266172.
2023-11-17 12:54:46 +01:00
Vladimír Čunát
b68f7e4ca4
Merge #266878: haskell-modules/generic-builder.nix: set NIX_LDFLAGS top-level
...into staging-next
2023-11-14 07:36:14 +01:00
Randy Eckenrode
251c69af0e
haskell-modules/generic-builder.nix: work around int conversion errors
Work around https://gitlab.haskell.org/ghc/ghc/-/issues/23456. Implicit
pointer to integer conversions have been an error since clang 15.
2023-11-13 19:12:07 -05:00
Randy Eckenrode
b974b808a0
haskell-modules/generic-builder.nix: set NIX_LDFLAGS at the top level
This is a follow-up PR to #266172 to address the feedback left by
@sternenseemann regarding `env`.

Rebuilds on staging-next #263535 should be limited if there are any.
2023-11-12 01:28:16 -05:00
Randy Eckenrode
8164b19096
haskell-modules/generic-builder.nix: work around libc++abi issue
Work around clang’s not linking libc++abi when invoked as `clang` or
`cc` even when it’s needed to link a C++ library or C++ code.

See https://github.com/NixOS/nixpkgs/issues/166205.
2023-11-08 21:54:55 -05:00
sternenseemann
2e876061cc haskellPackages.mkDerivation: allow overriding automatic propagation
Since we can't reliably (or easily at least) tell what Cabal version is
used, we should allow overriding whether to propagate or not, although
GHC >= 9.3 is correct in most cases.
2023-08-08 11:57:37 +02:00
sternenseemann
88f2062797 haskellPackages.mkDerivation: opt to only propagate pkgConfigModules
The main idea is to limit the amount of flags passed to Setup.hs as well
as, consequently, linkers and C compilers. E.g. in the case of
gi-javascriptcore, the default behavior causes the argv limit to be
exceeded.
2023-08-08 11:57:37 +02:00
sternenseemann
69b514d249 haskellPackages.mkDerivation: don't ev allPkgconfigDepends too early
Just getting the length of allPkgconfigDepends now may require a quite
expensive and involved function to be execute, so it should be put off
as long as possible. We can achieve this by moving the assert for
pkg-config being available next to its inclusion in nativeBuildInputs.

This solves the infinite recursion triggered by hercules-ci-cnix-store.
2023-08-07 13:58:06 +02:00
sternenseemann
a83158c7b9 haskellPackages.mkDerivation: propagate pc deps for GHC >= 9.4
This change essentially amounts to inlining
__CabalEagerPkgConfigWorkaround into haskellPackages.mkDerivation and
applying it automatically for the affected GHC versions. This is a bit
overeager, but the best automatic solution we can come up with for now.

Consequently, we don't need __CabalEagerPkgConfigWorkaround in nixpkgs
anymore nor downstream at least for “standard” haskellPackages builds.
__CabalEagerPkgConfigWorkaround is preserved for now since it is still
necessary if using GHC < 9.4 with Cabal >= 3.10 or cabal-install >= 3.10.

The one thing that may or may not be negatively affected by this change
is ghcWithPackages. I doubt this is a problem in practice though, since
it didn't provide pkg-config in the first place. passthru.env and
shellFor do and work correctly since they rely on mkDerivation.
2023-08-07 13:58:06 +02:00
sternenseemann
8aeb0de93d haskell: re-enable profiling on aarch64
The main problem was GHC exceeding the Hydra output limit with profiling
libs on aarch64-linux which made us disable the feature. Nowadays the
limit is 3GB, the GHC output is a bit over 2GB, so easily under the
limit.

aarch64-darwin uses a different codegen backend and was never really
affected by the problem: Its output with profiling enabled is around
1.6GB.

Consequently we can enable profiling for all platforms again, as we have
no output size issues for those we build on Hydra.

Thanks to flokli for helping me track down these up to date numbers.
2023-07-04 15:29:40 +02:00
sternenseemann
9dbcebd154 haskellPackages.mkDerivation: profiling depends on hostPlatform
Whether profiling should or should not be enabled does indeed depend on
GHC's target platform (or GHC in general, i.e. if it happens to be
ghcjs, we need to disable it). The profiling objects it produces are
excessively big if it is producing them for aarch64.

However, in a Haskell packages' derivation, GHC's and the resulting
derivation's platforms are offset

    GHC:  BUILD--HOST---TARGET
    DRV:         BUILD--HOST--(TARGET)

since we need to execute GHC in the derivation (so its host is our build
platform) and the machine code it produces need to be executable on the
host platform we are targeting. Unless our derivation is building a
compiler (or similar), the target platform of the derivation doesn't
matter.

stdenv exposes the platforms of the current derivation, not of GHC, so
checking the host platform is prudent. Changing this doesn't have a lot
of impact, since when cross-compiling Haskell packages (e.g. via
pkgsCross), host and target platform will usually be the same.
It does save unnecessary rebuilds in the buildHaskellPackages set
though, since most of the packages in here don't care about the target
platform, so they should be the same as their corresponding packages in
the ordinary (natively compiled) haskellPackages set. In short, after
this change

     pkgsCross.aarch64-multiplatform.hoogle == haskellPackages.hoogle

holds whereas it would erroneously be compiled with different profiling
settings before.
2023-06-08 18:17:38 +02:00
figsoda
c12654760c haskellPackages.mkDerivation: small clean up 2023-05-31 19:21:19 -04:00
Rebecca Turner
1535bd0c58
Move intermediates under share/haskell 2023-05-25 14:36:18 -07:00
Gabriella Gonzalez
72a70bd73b
haskellPackages.mkDerivation: New intermediates output
This adds a new `intermediates` output that can be used to
accelerate a Haskell build by importing build products
exported from a prior similar build.

The motivation for this is explained by the following post:

https://www.haskellforall.com/2022/12/nixpkgs-support-for-incremental-haskell.html
2023-05-25 14:32:55 -07:00
figsoda
98b9e41f61 pkgs: fix typos 2023-05-19 22:31:04 -04:00
sternenseemann
f45f7cb3e0 haskellPackages: support hadrian libdir layout 2023-02-05 14:01:25 +01:00
sternenseemann
a9b8a272ea haskellPackages.mkDerivation: refactor libdir calculation 2023-02-05 14:01:25 +01:00
sternenseemann
18c0c48857 haskellPackages.mkDerivation: buildPkgDb: use haskellCompilerName 2023-02-05 14:01:25 +01:00
sternenseemann
d9591db6f6 haskellPackages.mkDerivation: fix shebangs in JS backend binaries
The JavaScript backend emits `#!/usr/bin/env node` shebangs we need to
take care off using patchShebangs in fixupPhase.
2023-01-04 15:50:28 +01:00
sternenseemann
066591a359 haskellPackages.mkDerivation: disable stripping in ghcjs cross set
This line may look odd, but we should not set ghc.isGhcjs if we are
using the JavaScript backend. It is a normal cross backend and no
special code is required to make it work, i.e. everything will be named
as it would be normally. Additionally, passing --ghcjs to Cabal will
make it do the wrong thing.

We need to, of course, stop strip from being thrown at the JS objects in
both cases.
2023-01-04 15:50:28 +01:00
sternenseemann
ff2d74b329 haskellPackages.mkDerivation: use CC_FOR_BUILD if !stdenv.hasCC
Previously, we would try to calculate the name of
buildPackages.stdenv.cc and then just hope that it is in PATH somehow.
This definitely doesn't work in all cases.

The new approach is to add buildPackages.stdenv.cc to depsBuildBuild
which also populates CC_FOR_BUILD which we can directly re-use.
2023-01-04 15:50:28 +01:00
maralorn
62074a54da
Merge pull request #172365 from sternenseemann/haskell-mk-derivation-stream-test
haskellPackages.mkDerivation: show test outputs as they happen
2022-05-21 16:44:49 +02:00
sternenseemann
8f5c420450 haskellPackages.mkDerivation: show test outputs as they happen
Currently, the test output is only printed if the test suite fails. If a
test suite gets stuck, however, and is hit with a timeout by Hydra, it
can help to have the log available when diagnosing the issue.
2022-05-10 12:03:55 +02:00
Matthew Bauer
91e4fa278e haskell-modules/generic-builder.nix: use mktemp instead of TMPDIR
Using $TMPDIR here is problematic because it is not always cleared at
the end of each build, for instance when using "nix-shell --run
genericBuild". This can cause confusing errors when a nix-shell build
is trying to pull in dependencies from a previous build since it tries
to use older package conf files.

To fix, we can just use mktemp which will guarantee us a clean
directory for each build. Should have no effect in nix-build, but will
fix a common issue with using generic-builder in nix-shell.
2022-05-05 12:01:23 -05:00
sternenseemann
103d171526
Merge pull request #166548 from sternenseemann/fix-ghclibdir-computation
[haskell-updates] ghcWithPackages: fix ghclibdir computation with variantSuffix
2022-04-03 14:22:34 +02:00
rnhmjoj
f649fb8b4a
haskellPackages.mkDerivation: fix pkg-config cross
When cross compiling the pkg-config binary is prefixed and cabal
needs to be made aware of this.

Note: the `--with-pkg-config` flag can't be added unconditionally
because if the package doesn't need pkg-config (thus pkg-config
is not in the PATH) cabal consider this a hard failure.
2022-04-01 09:24:03 +02:00
sternenseemann
78a93b5352 haskellPackages.mkDerivation: get ghclibdir via haskellCompilerName
This is the correctest and clearest way to do it I can think of at the
moment that doesn't need us to add anything.
"${ghcCommand}-${ghc.version}" also works, but is clunkier and harder to
replicate for downstream users.
2022-03-31 12:47:54 +02:00
rnhmjoj
654940f36b haskellPackages.mkDerivation: check haddock availability
This change makes the haskell builder run the haddockPhase only if the
haddock program is availble (for example, it's not when cross-compiling).
2022-03-17 19:43:04 +01:00
Pepe Iborra
d68033afae haskellPackages.mkDerivation: add doHaddockInterfaces option
This adds a new builder option `doHaddockInterfaces` to enable the -haddock flag in GHC,
which results in Haddock comments parsed at compile-time and embedded in
interface files. These are used by the :doc command in GHCi, as well as IDE
tools like ghcide and hls to display docs on hover.

The `-haddock` flag has been around since at least 8.2, even though it does not
get a mention in the GHC Users guide.

There are two downsides to turning on this flag:

1. Increased compile times, since Haddocks must be parsed and then encoded
2. Haddock parse errors now become compile errors for GHC < 9.0.1
   (https://gitlab.haskell.org/ghc/ghc/-/issues/8944)

Thus we only enable the feature if we have GHC 9.0.1 and haddock is
enabled; when 9.0.1 becomes the default GHC, we may need to reevaluate
the performance concern.

Co-authored-by: sternenseemann <sternenseemann@systemli.org>
2021-11-10 21:10:35 +01:00
maralorn
1e61298bf5
Merge pull request #129093 from siraben/haskell-mainProgram
haskell-generic-build: allow mainProgram to be set
2021-07-03 13:45:40 +02:00
Ben Siraphob
06fb9a9421 haskell-generic-build: allow mainProgram to be set 2021-07-03 15:52:39 +07:00
sternenseemann
6955f4e4e6 haskell-generic-builder: support badPlatforms
meta.badPlatforms allows us to exclude specific platforms from the list
of supported platforms without the need to explicitly substract it from
lib.platforms.all (or our inferior equivalent allKnownPlatforms) in
platforms. Thus it'll map nicely to unsupported-platforms in the
hackage2nix configuration in the future.
2021-06-27 18:32:28 +02:00
sternenseemann
5e0c55b581 haskell-generic-builder: pass pname and version as is
This is a full set rebuild, however it improves the name generation
for the static and cross case since the respective additional
components are now inserted between pname and version instead of after
name like before. This prevents builtins.parseDrvName from mistaking a
platform config string for a version component.
2021-06-21 14:08:41 +02:00
sternenseemann
57ec1813ff haskell-generic-builder: allow passing flags to the test suite(s)
Every flag the generic builder receives via `testFlags` is passed via
`--test-option` [1] to `Setup.hs` which in turn passes them to the
underlying test suite binary. These wrapped options are added to
`checkFlagsArray` in `checkPhase`. This needs to be done in bash since
without structuredAttrs in nixpkgs so far, Nix arrays aren't properly
translated into bash arrays, so we'd have all sorts of quoting issues
when spaces are involved.

Re-using `checkFlags` and `checkFlagsArray` from standard stdenv
setup.sh also results in an additional feature: Using `overrideAttrs`
`checkFlags` and `checkFlagsArray` can additionally be overridden,
which allows passing extra flags to `Setup.hs` whithout being wrapped
with `--test-option`.

[1]: See also https://cabal.readthedocs.io/en/3.4/setup-commands.html?highlight=test-option#cmdoption-runhaskell-Setup.hs-test-test-option
     According to the cabal-install man page this also allows passing
     special variables which are substituted for other values
     depending on context.
2021-06-09 15:09:00 +02:00
sternenseemann
670d6ac458 haskell-generic-builder: fix buildTarget specification if isLibrary
If we don't pass buildTarget to ./Setup copy and buildTarget is not
empty it will try installing targets that don't exist and thus fail.
2021-06-06 18:40:13 +02:00
rnhmjoj
830ef6422f
haskell-generic-builder: disable static PIE 2021-05-22 01:54:51 +09:00
Isaac Shapira
d725ac7942
Add haskell.lib.setBuiltTarget, and support non library compiling of a single target 2021-05-02 13:35:07 +09:00
(cdep)illabout
c8ac41fafc haskellPackages: add changelog argument to Haskell generic-builder.nix
changelog was recently added as a new meta field in
https://github.com/NixOS/nixpkgs/pull/60371.

This commit adds similar support to the Haskell generic builder.
2021-04-09 21:32:00 +02:00
Ben Siraphob
2f78ee7e81 pkgs/development: stdenv.lib -> lib 2021-01-24 00:16:29 +07:00
Jonathan Ringer
9bb3fccb5b treewide: pkgs.pkgconfig -> pkgs.pkg-config, move pkgconfig to alias.nix
continuation of #109595

pkgconfig was aliased in 2018, however, it remained in
all-packages.nix due to its wide usage. This cleans
up the remaining references to pkgs.pkgsconfig and
moves the entry to aliases.nix.

python3Packages.pkgconfig remained unchanged because
it's the canonical name of the upstream package
on pypi.
2021-01-19 01:16:25 -08:00
John Ericson
a52f9a18bf haskell: Inline static overlay
We don't force `enableStaticLibraries` for Windows or WASM because it
will just fail an assertion.
2021-01-11 03:17:29 +00:00
Joe Hermaszewski
55a9078748 haskell-generic-builder: Add missing preHaddock and postHaddock arguments 2020-10-23 21:00:26 +02:00