···33, llvmPackages
44, symlinkJoin, makeWrapper, substituteAll
55, mkYarnModules
66+, emscripten
67}:
7889stdenv.mkDerivation rec {
···115116116117 runHook postInstall
117118 '';
119119+120120+ passthru = {
121121+ # HACK: Make emscripten look more like a cc-wrapper to GHC
122122+ # when building the javascript backend.
123123+ targetPrefix = "em";
124124+ bintools = emscripten;
125125+ };
118126119127 meta = with lib; {
120128 homepage = "https://github.com/emscripten-core/emscripten";
+3-1
pkgs/development/compilers/ghc/8.10.7.nix
···21212222, # If enabled, GHC will be built with the GPL-free but slower integer-simple
2323 # library instead of the faster but GPLed integer-gmp library.
2424- enableIntegerSimple ? !(lib.meta.availableOn stdenv.hostPlatform gmp), gmp
2424+ enableIntegerSimple ? !(lib.meta.availableOn stdenv.hostPlatform gmp
2525+ && lib.meta.availableOn stdenv.targetPlatform gmp)
2626+, gmp
25272628, # If enabled, use -fPIC when compiling static libs.
2729 enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
+3-1
pkgs/development/compilers/ghc/8.8.4.nix
···20202121, # If enabled, GHC will be built with the GPL-free but slower integer-simple
2222 # library instead of the faster but GPLed integer-gmp library.
2323- enableIntegerSimple ? !(lib.meta.availableOn stdenv.hostPlatform gmp), gmp
2323+ enableIntegerSimple ? !(lib.meta.availableOn stdenv.hostPlatform gmp
2424+ && lib.meta.availableOn stdenv.targetPlatform gmp)
2525+, gmp
24262527, # If enabled, use -fPIC when compiling static libs.
2628 enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
+2-1
pkgs/development/compilers/ghc/9.0.2.nix
···23232424, # If enabled, GHC will be built with the GPL-free but slightly slower native
2525 # bignum backend instead of the faster but GPLed gmp backend.
2626- enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp)
2626+ enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp
2727+ && lib.meta.availableOn stdenv.targetPlatform gmp)
2728, gmp
28292930, # If enabled, use -fPIC when compiling static libs.
+2-1
pkgs/development/compilers/ghc/9.2.4.nix
···23232424, # If enabled, GHC will be built with the GPL-free but slightly slower native
2525 # bignum backend instead of the faster but GPLed gmp backend.
2626- enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp)
2626+ enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp
2727+ && lib.meta.availableOn stdenv.targetPlatform gmp)
2728, gmp
28292930, # If enabled, use -fPIC when compiling static libs.
+2-1
pkgs/development/compilers/ghc/9.2.5.nix
···23232424, # If enabled, GHC will be built with the GPL-free but slightly slower native
2525 # bignum backend instead of the faster but GPLed gmp backend.
2626- enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp)
2626+ enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp
2727+ && lib.meta.availableOn stdenv.targetPlatform gmp)
2728, gmp
28292930, # If enabled, use -fPIC when compiling static libs.
+2-1
pkgs/development/compilers/ghc/9.4.2.nix
···25252626, # If enabled, GHC will be built with the GPL-free but slightly slower native
2727 # bignum backend instead of the faster but GPLed gmp backend.
2828- enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp)
2828+ enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp
2929+ && lib.meta.availableOn stdenv.targetPlatform gmp)
2930, gmp
30313132, # If enabled, use -fPIC when compiling static libs.
+2-1
pkgs/development/compilers/ghc/9.4.3.nix
···25252626, # If enabled, GHC will be built with the GPL-free but slightly slower native
2727 # bignum backend instead of the faster but GPLed gmp backend.
2828- enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp)
2828+ enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp
2929+ && lib.meta.availableOn stdenv.targetPlatform gmp)
2930, gmp
30313132, # If enabled, use -fPIC when compiling static libs.
+2-1
pkgs/development/compilers/ghc/9.4.4.nix
···25252626, # If enabled, GHC will be built with the GPL-free but slightly slower native
2727 # bignum backend instead of the faster but GPLed gmp backend.
2828- enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp)
2828+ enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp
2929+ && lib.meta.availableOn stdenv.targetPlatform gmp)
2930, gmp
30313132, # If enabled, use -fPIC when compiling static libs.
+27-15
pkgs/development/compilers/ghc/common-hadrian.nix
···3939, useLLVM ? !(stdenv.targetPlatform.isx86
4040 || stdenv.targetPlatform.isPower
4141 || stdenv.targetPlatform.isSparc
4242- || (stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin))
4242+ || (stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin)
4343+ || stdenv.targetPlatform.isGhcjs)
4344, # LLVM is conceptually a run-time-only depedendency, but for
4445 # non-x86, we need LLVM to bootstrap later stages, so it becomes a
4546 # build-time dependency too.
···48494950, # If enabled, GHC will be built with the GPL-free but slightly slower native
5051 # bignum backend instead of the faster but GPLed gmp backend.
5151- enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp)
5252+ enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp
5353+ && lib.meta.availableOn stdenv.targetPlatform gmp)
5454+ || stdenv.targetPlatform.isGhcjs
5255, gmp
53565457, # If enabled, use -fPIC when compiling static libs.
···6265 enableShared ? with stdenv.targetPlatform; !isWindows && !useiOSPrebuilt && !isStatic
63666467, # Whether to build terminfo.
6565- enableTerminfo ? !stdenv.targetPlatform.isWindows
6868+ enableTerminfo ? !(stdenv.targetPlatform.isWindows
6969+ || stdenv.targetPlatform.isGhcjs)
66706771, # Libdw.c only supports x86_64, i686 and s390x as of 2022-08-04
6872 enableDwarf ? (stdenv.targetPlatform.isx86 ||
···156160157161assert !enableNativeBignum -> gmp != null;
158162159159-assert stdenv.hostPlatform == stdenv.targetPlatform || throw ''
160160- hadrian doesn't support building an installable GHC cross-compiler at the moment.
161161- Consider using GHC 9.4 or lower which support this via the make build system.
162162- See also: https://gitlab.haskell.org/ghc/ghc/-/issues/22090
163163-'';
164164-165163let
166164 src = (if rev != null then fetchgit else fetchurl) ({
167165 inherit url sha256;
···201199202200 # Splicer will pull out correct variations
203201 libDeps = platform: lib.optional enableTerminfo ncurses
204204- ++ [libffi]
202202+ ++ lib.optionals (!targetPlatform.isGhcjs) [libffi]
205203 # Bindist configure script fails w/o elfutils in linker search path
206204 # https://gitlab.haskell.org/ghc/ghc/-/issues/22081
207205 ++ lib.optional enableDwarf elfutils
208206 ++ lib.optional (!enableNativeBignum) gmp
209209- ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
207207+ ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows && !targetPlatform.isGhcjs) libiconv;
210208211209 # TODO(@sternenseemann): is buildTarget LLVM unnecessary?
212210 # GHC doesn't seem to have {LLC,OPT}_HOST
213211 toolsForTarget = [
214214- pkgsBuildTarget.targetPackages.stdenv.cc
212212+ (if targetPlatform.isGhcjs
213213+ then pkgsBuildTarget.emscripten
214214+ else pkgsBuildTarget.targetPackages.stdenv.cc)
215215 ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
216216217217 targetCC = builtins.head toolsForTarget;
···251251# C compiler, bintools and LLVM are used at build time, but will also leak into
252252# the resulting GHC's settings file and used at runtime. This means that we are
253253# currently only able to build GHC if hostPlatform == buildPlatform.
254254-assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc;
254254+assert !targetPlatform.isGhcjs -> targetCC == pkgsHostTarget.targetPackages.stdenv.cc;
255255assert buildTargetLlvmPackages.llvm == llvmPackages.llvm;
256256assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang;
257257···334334 '*-android*|*-gnueabi*|*-musleabi*)'
335335 done
336336 ''
337337+ # Need to make writable EM_CACHE for emscripten
338338+ # https://gitlab.haskell.org/ghc/ghc/-/wikis/javascript-backend#configure-fails-with-sub-word-sized-atomic-operations-not-available
339339+ + lib.optionalString targetPlatform.isGhcjs ''
340340+ export EM_CACHE="$(mktemp -d emcache.XXXXXXXXXX)"
341341+ cp -Lr ${targetCC /* == emscripten */}/share/emscripten/cache/* "$EM_CACHE/"
342342+ chmod u+rwX -R "$EM_CACHE"
343343+ ''
337344 # Create bash array hadrianFlagsArray for use in buildPhase. Do it in
338345 # preConfigure, so overrideAttrs can be used to modify it effectively.
339346 # hadrianSettings are passed via the command line so they are more visible
···344351 ${lib.escapeShellArgs hadrianSettings}
345352 )
346353 '';
354354+355355+ ${if targetPlatform.isGhcjs then "configureScript" else null} = "emconfigure ./configure";
347356348357 # TODO(@Ericson2314): Always pass "--target" and always prefix.
349358 configurePlatforms = [ "build" "host" ]
···353362 configureFlags = [
354363 "--datadir=$doc/share/doc/ghc"
355364 "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
356356- ] ++ lib.optionals (libffi != null) [
365365+ ] ++ lib.optionals (libffi != null && !targetPlatform.isGhcjs) [
357366 "--with-system-libffi"
358367 "--with-ffi-includes=${targetPackages.libffi.dev}/include"
359368 "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
···392401 autoSignDarwinBinariesHook
393402 ] ++ lib.optionals enableDocs [
394403 sphinx
404404+ ] ++ lib.optionals targetPlatform.isGhcjs [
405405+ # emscripten itself is added via depBuildTarget / targetCC
406406+ python3
395407 ];
396408397409 # For building runtime libs
···450462 preInstall = ''
451463 pushd _build/bindist/*
452464453453- ./configure $configureFlags "''${configureFlagsArray[@]}"
465465+ $configureScript $configureFlags "''${configureFlagsArray[@]}"
454466 '';
455467456468 postInstall = ''
···2020# runtime dependencies
2121, cups
2222# runtime dependencies for GTK+ Look and Feel
2323-, gtkSupport ? true
2323+# TODO(@sternenseemann): gtk3 fails to evaluate in pkgsCross.ghcjs.buildPackages
2424+# which should be fixable, this is a no-rebuild workaround for GHC.
2525+, gtkSupport ? !stdenv.targetPlatform.isGhcjs
2426, cairo
2527, glib
2628, gtk3
···723723 '';
724724 }) super.haskell-language-server;
725725726726- # NOTE: this patch updates the hevm code to work with the latest packages that broke the build
727727- # it's temporary until hevm version 0.50.0 is released - https://github.com/ethereum/hevm/milestone/1
728728- # tests depend on a specific version of solc
729729- hevm = dontCheck (appendPatch ./patches/hevm-update-deps.patch super.hevm);
726726+ # there are three very heavy test suites that need external repos, one requires network access
727727+ hevm = dontCheck super.hevm;
730728731729 # hadolint enables static linking by default in the cabal file, so we have to explicitly disable it.
732730 # https://github.com/hadolint/hadolint/commit/e1305042c62d52c2af4d77cdce5d62f6a0a3ce7b
···70707171 # the (optional) BPF feature requires bpftool, libbpf, clang and llvm-strip to be available during build time.
7272 # Only libbpf should be a runtime dependency.
7373+ # Note: llvmPackages is explicitly taken from buildPackages instead of relying
7474+ # on splicing. Splicing will evaluate the adjacent (pkgsHostTarget) llvmPackages
7575+ # which is sometimes problematic: llvmPackages.clang looks at targetPackages.stdenv.cc
7676+ # which, in the unfortunate case of pkgsCross.ghcjs, `throw`s. If we explicitly
7777+ # take buildPackages.llvmPackages, this is no problem because
7878+ # `buildPackages.targetPackages.stdenv.cc == stdenv.cc` relative to us. Working
7979+ # around this is important, because systemd is in the dependency closure of
8080+ # GHC via emscripten and jdk.
7381, bpftools
7482, libbpf
7575-, llvmPackages
76837784, withAnalyze ? true
7885, withApparmor ? true
···8693, withHostnamed ? true
8794, withHwdb ? true
8895, withImportd ? !stdenv.hostPlatform.isMusl
8989-, withLibBPF ? lib.versionAtLeast llvmPackages.clang.version "10.0"
9696+, withLibBPF ? lib.versionAtLeast buildPackages.llvmPackages.clang.version "10.0"
9097, withLocaled ? true
9198, withLogind ? true
9299, withMachined ? true
···368375 ]
369376 ++ lib.optionals withLibBPF [
370377 bpftools
371371- llvmPackages.clang
372372- llvmPackages.libllvm
378378+ buildPackages.llvmPackages.clang
379379+ buildPackages.llvmPackages.libllvm
373380 ]
374381 ;
375382