Skip to content

Commit 166cf1f

Browse files
authored
Disable PIC on Windows (it breaks GHC annotations) (input-output-hk#2146)
* Disable PIC on Windows (it breaks GHC annotations) * Disable PIC on Windows (it breaks GHC annotations) * Disable test on ghcjs for now * Disable broken test
1 parent 9cbdd6f commit 166cf1f

File tree

6 files changed

+40
-1
lines changed

6 files changed

+40
-1
lines changed

compiler/ghc/default.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,10 @@ let
311311
# For cross compilers only the RTS should be built with -mno-outline-atomics
312312
+ lib.optionalString (!hostPlatform.isAarch64 && targetPlatform.isLinux && targetPlatform.isAarch64)
313313
" '*.rts.ghc.c.opts += -optc-mno-outline-atomics'"
314-
+ lib.optionalString enableRelocatedStaticLibs
314+
# PIC breaks GHC annotations on windows (see test/annotations for a test case)
315+
+ lib.optionalString (enableRelocatedStaticLibs && !targetPlatform.isWindows)
315316
" '*.*.ghc.*.opts += -fPIC' '*.*.cc.*.opts += -fPIC'"
317+
# `-fexternal-dynamic-refs` causes `undefined reference` errors when building GHC cross compiler for windows
316318
+ lib.optionalString (enableRelocatedStaticLibs && targetPlatform.isx86_64 && !targetPlatform.isWindows)
317319
" '*.*.ghc.*.opts += -fexternal-dynamic-refs'"
318320
# The following is required if we build on aarch64-darwin for aarch64-iOS. Otherwise older

test/annotations/Lib.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Lib where
2+
3+
{-# ANN module "HLint: ignore Use fmap" #-}
4+
5+
x=1

test/annotations/cabal.project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: .

test/annotations/default.nix

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{ stdenv, lib, util, project', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name, evalPackages }:
2+
3+
with lib;
4+
5+
let
6+
project = project' {
7+
inherit compiler-nix-name evalPackages;
8+
src = testSrc "annotations";
9+
};
10+
11+
in recurseIntoAttrs {
12+
meta.disabled = stdenv.hostPlatform.isGhcjs
13+
# Failed to lookup symbol: __aarch64_swp8_acq_rel
14+
|| (builtins.elem compiler-nix-name ["ghc947" "ghc948"] && haskellLib.isCrossHost && stdenv.hostPlatform.isAarch64);
15+
ifdInputs = {
16+
inherit (project) plan-nix;
17+
};
18+
19+
build = project.hsPkgs.test-annotations.components.library;
20+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cabal-version: 1.24
2+
name: test-annotations
3+
version: 1
4+
build-type: Simple
5+
6+
library
7+
exposed-modules: Lib
8+
hs-source-dirs: .
9+
build-depends: base
10+
default-language: Haskell2010

test/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ let
217217
ca-derivations = callTest ./ca-derivations { inherit CADerivationsEnabled; };
218218
ca-derivations-include = callTest ./ca-derivations-include { inherit CADerivationsEnabled; };
219219
test-only = callTest ./test-only { inherit util; };
220+
annotations = callTest ./annotations { inherit util; };
220221
cabal-project-nix-path = callTest ./cabal-project-nix-path {};
221222
plugin = callTest ./plugin {};
222223
unit = unitTests;

0 commit comments

Comments
 (0)