-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
haskell.compiler.ghc902Binary: bump LLVM by wrapping opt(1)
#440271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,6 @@ | |
| libiconv, | ||
| numactl, | ||
| libffi, | ||
| llvmPackages, | ||
| coreutils, | ||
| targetPackages, | ||
|
|
||
|
|
@@ -193,8 +192,6 @@ let | |
| ) binDistUsed.archSpecificLibraries | ||
| )).nixPackage; | ||
|
|
||
| useLLVM = !(import ./common-have-ncg.nix { inherit lib stdenv version; }); | ||
|
|
||
| libPath = lib.makeLibraryPath ( | ||
| # Add arch-specific libraries. | ||
| map ({ nixPackage, ... }: nixPackage) binDistUsed.archSpecificLibraries | ||
|
|
@@ -207,16 +204,15 @@ let | |
| targetPackages.stdenv.cc.bintools | ||
| coreutils # for cat | ||
| ] | ||
| ++ lib.optionals useLLVM [ | ||
| (lib.getBin llvmPackages.llvm) | ||
| ] | ||
| # On darwin, we need unwrapped bintools as well (for otool) | ||
| ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [ | ||
| targetPackages.stdenv.cc.bintools.bintools | ||
| ]; | ||
|
|
||
| in | ||
|
|
||
| assert import ./common-have-ncg.nix { inherit lib stdenv version; }; | ||
|
|
||
|
Comment on lines
+214
to
+215
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right.. these asserts should not be placed at the top-level, otherwise they will prevent evaluating This assert could either be deferred until after
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Can put up a PR in an hour or so.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in #441069. |
||
| stdenv.mkDerivation { | ||
| inherit version; | ||
| pname = "ghc-binary${binDistUsed.variantSuffix}"; | ||
|
|
@@ -470,7 +466,7 @@ stdenv.mkDerivation { | |
| targetPrefix = ""; | ||
| enableShared = true; | ||
|
|
||
| inherit llvmPackages; | ||
| llvmPackages = null; | ||
|
|
||
| # Our Cabal compiler name | ||
| haskellCompilerName = "ghc-${version}"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| #!@shell@ | ||
|
|
||
| # This script wraps the LLVM `opt(1)` executable and maps the options | ||
| # passed by old versions of GHC to the equivalents passed by newer | ||
| # versions that support recent versions of LLVM. | ||
| # | ||
| # It achieves the same effect as the following GHC change externally: | ||
| # <https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8999>. | ||
| # | ||
| # This is used solely for bootstrapping newer GHCs from the GHC 9.0.2 | ||
| # binary on AArch64, as that is the only architecture supported by that | ||
| # binary distribution that requires LLVM, and our later binary packages | ||
| # all use the native code generator for all supported platforms. | ||
| # | ||
| # No attempt is made to support custom LLVM optimization flags, or the | ||
| # undocumented flag to disable TBAA, or avoid | ||
| # <https://gitlab.haskell.org/ghc/ghc/-/issues/23870>, as these are not | ||
| # required to bootstrap GHC and at worst will produce an error message. | ||
| # | ||
| # It is called `subopt` to reflect the fact that it uses `opt(1)` as a | ||
| # subprocess, and the fact that the GHC build system situation | ||
| # requiring this hack is suboptimal. | ||
|
|
||
| set -e | ||
|
|
||
| expect() { | ||
| if [[ $1 != $2 ]]; then | ||
| printf >&2 'subopt: got %q; expected %q\n' "$1" "$2" | ||
| return 2 | ||
| fi | ||
| } | ||
|
|
||
| if [[ $NIX_DEBUG -ge 1 ]]; then | ||
| printf >&2 'subopt: before:' | ||
| printf >&2 ' %q' "$@" | ||
| printf >&2 '\n' | ||
| fi | ||
|
|
||
| args=() | ||
|
|
||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| -enable-new-pm=0) | ||
| shift 1 | ||
| ;; | ||
| -mem2reg) | ||
| expect "$2" -globalopt | ||
| expect "$3" -lower-expect | ||
| expect "$4" -enable-tbaa | ||
| expect "$5" -tbaa | ||
|
||
| args+=('-passes=function(require<tbaa>),function(mem2reg),globalopt,function(lower-expect)') | ||
| shift 5 | ||
| ;; | ||
| -O1) | ||
| expect "$2" -globalopt | ||
| expect "$3" -enable-tbaa | ||
| expect "$4" -tbaa | ||
| args+=('-passes=default<O1>') | ||
| shift 4 | ||
| ;; | ||
| -O2) | ||
| expect "$2" -enable-tbaa | ||
| expect "$3" -tbaa | ||
| args+=('-passes=default<O2>') | ||
| shift 3 | ||
| ;; | ||
| *) | ||
| args+=("$1") | ||
| shift 1 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| if [[ $NIX_DEBUG -ge 1 ]]; then | ||
| printf >&2 'subopt: after:' | ||
| printf >&2 ' %q' "${args[@]}" | ||
| printf >&2 '\n' | ||
| fi | ||
|
|
||
| exec @opt@ "${args[@]}" | ||
Uh oh!
There was an error while loading. Please reload this page.