From d8244b7917204877c01212e063bc90f1de610db3 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Tue, 15 Dec 2020 17:09:59 +0000 Subject: [PATCH] Rescue stack windows build (#954) * Revert "Drop stack Windows CI" This reverts commit 919d3bce57db94462e96d3d7a133f655e5569bd8. * Fix stack Windows build I finally figured this puzzle out --- .azure/windows-stack.yml | 41 ++++++++++++++++++++++++++++++++++++++++ azure-pipelines.yml | 1 + stack-windows.yaml | 12 +++++++++--- 3 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 .azure/windows-stack.yml diff --git a/.azure/windows-stack.yml b/.azure/windows-stack.yml new file mode 100644 index 00000000..21b99fc0 --- /dev/null +++ b/.azure/windows-stack.yml @@ -0,0 +1,41 @@ +jobs: +- job: ghcide_stack_windows + timeoutInMinutes: 120 + pool: + vmImage: 'windows-2019' + variables: + STACK_ROOT: "C:\\sr" + steps: + - checkout: self + - task: Cache@2 + inputs: + key: stack-root-cache | $(Agent.OS) | $(Build.SourcesDirectory)/stack-windows.yaml | $(Build.SourcesDirectory)/ghcide.cabal + path: $(STACK_ROOT) + cacheHitVar: STACK_ROOT_CACHE_RESTORED + displayName: "Cache stack root" + - task: Cache@2 + inputs: + key: stack-work-cache | $(Agent.OS) | $(Build.SourcesDirectory)/stack-windows.yaml | $(Build.SourcesDirectory)/ghcide.cabal + path: .stack-work + cacheHitVar: STACK_WORK_CACHE_RESTORED + displayName: "Cache stack work" + - bash: | + ./fmt.sh + displayName: "HLint via ./fmt.sh" + - bash: | + curl -sSkL http://www.stackage.org/stack/windows-x86_64 -o /usr/bin/stack.zip + unzip -o /usr/bin/stack.zip -d /usr/bin/ + mkdir -p "$STACK_ROOT" + displayName: 'Install Stack' + - bash: stack setup --stack-yaml stack-windows.yaml + displayName: 'stack setup' + - bash: | + # Installing happy and alex standalone to avoid error "strip.exe: unable to rename ../*.exe; reason: File exists" + stack install happy --stack-yaml stack-windows.yaml + stack install alex --stack-yaml stack-windows.yaml + choco install -y cabal --version=$CABAL_VERSION + $(cygpath $ProgramData)/chocolatey/bin/RefreshEnv.cmd + # GHC 8.10.1 fails with ghc segfaults, using -fexternal-interpreter seems to make it working + # There are other transient errors like timeouts downloading from stackage so we retry 3 times + stack build --test --no-run-tests --stack-yaml stack-windows.yaml --ghc-options="-fexternal-interpreter" || stack build --test --no-run-tests --stack-yaml stack-windows.yaml --ghc-options="-fexternal-interpreter" || stack build --test --no-run-tests --stack-yaml stack-windows.yaml --ghc-options="-fexternal-interpreter" + displayName: 'stack build --test' diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 941c6915..4021f118 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -15,3 +15,4 @@ pr: jobs: - template: ./.azure/linux-stack.yml + - template: ./.azure/windows-stack.yml diff --git a/stack-windows.yaml b/stack-windows.yaml index 80b83108..49bc9b06 100644 --- a/stack-windows.yaml +++ b/stack-windows.yaml @@ -37,10 +37,11 @@ nix: packages: [zlib] configure-options: + ghcide: + - --disable-library-for-ghci heapsize: - --disable-library-for-ghci - - --disable-library-stripping -# Otherwise the ghcide will fail with: +# Otherwise the ghcide build will fail with: # ``` # ghcide > ghc.exe: unable to load package `heapsize-0.2' # ghcide > ghc-iserv: | D:\a\1\s\.stack-work\install\52d658b2\lib\x86_64-windows-ghc-8.10.1\heapsize-0.2-KCPoGpPDcevACNftTTY2at\HSheapsize-0.2-KCPoGpPDcevACNftTTY2at.o: unknown symbol `heap_view_closurePtrs' @@ -48,7 +49,12 @@ configure-options: # Cause: # The pre-linked object file is missing the heapsize_prim.o symbols table (from the cbits object) # -# Reason: The ld invocation is stripping too much +# Reason: Not sure, maybe the ld invocation is stripping too much +# +# Fix: do not generate the pre-linked object to prevent ghc from using it at link time. +# There are two instances where this must be prevented: +# 1. When linking the ghcide library (using the heapsize pre-linked object) +# 2. When linking the ghcide executable (using the ghcide pre-linked object) # # Quoting https://downloads.haskell.org/ghc/latest/docs/html/users_guide/packages.html #