I’ve hit a wall when trying to get a small project building for some old laptops running on 32-bit architecture, with the error message in the title. I tried asking around in /r/haskell with no luck, not sure if I’m facing something really odd here .
Replicating the failure that I’m seeing is quite easy with stack
and nix
:
stack new cross-compile
cd cross-compile
Add wreq
as dependency:
diff --git a/package.yaml b/package.yaml
index 26d1d00..b0fbd01 100644
--- a/package.yaml
+++ b/package.yaml
@@ -21,6 +21,7 @@ description: Please see the README on GitHub at <https://github.com/gith
dependencies:
- base >= 4.7 && < 5
+- wreq
library:
source-dirs: src
Run stack-to-nix -o nix
, and make the following edit:
diff --git a/nix/default.nix b/nix/default.nix
index 769a99c..3b1267b 100644
--- a/nix/default.nix
+++ b/nix/default.nix
@@ -1,14 +1,16 @@
-{ haskellNixSrc ? builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz
+{ haskellNixSrc ? builtins.fetchTarball { url = https://github.com/input-output-hk/haskell.nix/archive/e6fc81b36e725312d18ff7d7e02629a22c302676.tar.gz; sha256 = "1g10ln8bdzqabkxf0bkiajz028zrzmqyq8p61hjswy9bmqs4jbjs"; }
}:
let
- haskellNix = import haskellNixSrc { };
- pkgs = import haskellNix.sources.nixpkgs-2003 haskellNix.nixpkgsArgs;
+ pkgs = import <nixpkgs> (import haskellNixSrc {}).nixpkgsArgs;
- pkgSet = pkgs.haskell-nix.mkStackPkgSet {
+ pkgSet = pkgs.pkgsCross.gnu32.haskell-nix.mkStackPkgSet {
stack-pkgs = import ./pkgs.nix;
pkg-def-extras = [];
- modules = [];
+ modules = [
+ { configureFlags = [ "--ghc-option=-fexternal-interpreter" ]; }
+ { hardeningDisable = [ "pic" "pie" ]; }
+ ];
};
in
and build (this will take a very long time):
cd nix/
nix-build -A cross-compile.components.exes.cross-compile-exe
This runs fine (actually it works great before adding wreq
), until building wreq
. That fails, log for failure:
building '/nix/store/bxajk3vy8r4iam3jwqvii2sqr2fn3j0p-i686-unknown-linux-gnu-wreq-lib-wreq-0.5.3.2-config.drv'...
building '/nix/store/1q1sxik8si8d6knhm4hgn83xdibga9an-wreq-lib-wreq-0.5.3.2-i686-unknown-linux-gnu-ghc-8.8.4-env.drv'...
building '/nix/store/ssyry01ii3a278rkqx7g2fzw6fzlb1sk-wreq-lib-wreq-0.5.3.2-i686-unknown-linux-gnu.drv'...
unpacking sources
unpacking source archive /nix/store/x724p4654ghgmz61nwbydw7dpip33pbd-wreq-0.5.3.2.tar.gz
source root is wreq-0.5.3.2
setting SOURCE_DATE_EPOCH to timestamp 1548373057 of file wreq-0.5.3.2/changelog.md
patching sources
configuring
Configure flags:
--prefix=/nix/store/k9zak4hp73ngqdwch5s3bwjln9w25k36-wreq-lib-wreq-0.5.3.2-i686-unknown-linux-gnu lib:wreq --package-db=clear --package-db=/nix/store/shk3xfa4y09gcj1z69sjx7x3lrb9w5cs-i686-unknown-linux-gnu-wreq-lib-wreq-0.5.3.2-config/lib/i686-unknown-linux-gnu-ghc-8.8.4/package.conf.d --flags=-aws --flags=-developer --flags=doctest --flags=-httpbin --exact-configuration --dependency=psqueues=psqueues-0.2.7.2-98MvnsYlud4D5Ova214VaA --dependency=aeson=aeson-1.4.7.1-HJdu2VtAAPjHpKAiBiNAY3 --dependency=attoparsec=attoparsec-0.13.2.4-AHmlmm44dvnKaiPmUJc2M1 --dependency=authenticate-oauth=authenticate-oauth-1.6.0.1-ABoVouYl8cA4H4V1KcNVT --dependency=base16-bytestring=base16-bytestring-0.1.1.7-2HvGuPUoCaNGygqsAweNZU --dependency=case-insensitive=case-insensitive-1.2.1.0-G9PczGupAuw6LFLG2ltB3E --dependency=cryptonite=cryptonite-0.26-uW20Ihb9exKb8mVxuIoSG --dependency=exceptions=exceptions-0.10.4-81QDloBYG3X96Ltk5oek71 --dependency=hashable=hashable-1.3.0.0-JWT2qDutWgo91wFdMlkvGp --dependency=http-client=http-client-0.6.4.1-1TmxSgGwd4q63we5xPq2E3 --dependency=http-client-tls=http-client-tls-0.3.5.3-3dFd8XvcMr87KgbLNGFoLW --dependency=http-types=http-types-0.12.3-7sHAayybOZ277OqgdJvdHt --dependency=lens=lens-4.18.1-6d6HqJb2u4V28oluSqRsqw --dependency=lens-aeson=lens-aeson-1.1-ASmUDrzHEkuLVOoNPXtLz8 --dependency=memory=memory-0.15.0-7KxDq0VAYz22HAxgR54OFq --dependency=mime-types=mime-types-0.1.0.9-6tcnoU41MtD67Ac6R3FZLh --dependency=time-locale-compat=time-locale-compat-0.1.1.5-6zntZXPahUaLWVI6yBz8vC --dependency=unordered-containers=unordered-containers-0.2.10.0-L0UCiFV6BpAyFeQZxTEW6 --dependency=rts=rts --dependency=ghc-heap=ghc-heap-8.8.4 --dependency=ghc-prim=ghc-prim-0.5.3 --dependency=integer-gmp=integer-gmp-1.0.2.0 --dependency=base=base-4.13.0.0 --dependency=deepseq=deepseq-1.4.4.0 --dependency=array=array-0.5.4.0 --dependency=ghc-boot-th=ghc-boot-th-8.8.4 --dependency=pretty=pretty-1.1.3.6 --dependency=template-haskell=template-haskell-2.15.0.0 --dependency=ghc-boot=ghc-boot-8.8.4 --dependency=Cabal=Cabal-3.0.1.0 --dependency=array=array-0.5.4.0 --dependency=binary=binary-0.8.7.0 --dependency=bytestring=bytestring-0.10.10.1 --dependency=containers=containers-0.6.2.1 --dependency=directory=directory-1.3.6.0 --dependency=filepath=filepath-1.4.2.1 --dependency=ghc-boot=ghc-boot-8.8.4 --dependency=ghc-compact=ghc-compact-0.1.0.0 --dependency=ghc-prim=ghc-prim-0.5.3 --dependency=hpc=hpc-0.6.0.3 --dependency=mtl=mtl-2.2.2 --dependency=parsec=parsec-3.1.14.0 --dependency=process=process-1.6.9.0 --dependency=text=text-1.2.4.0 --dependency=time=time-1.9.3 --dependency=transformers=transformers-0.5.6.2 --dependency=unix=unix-2.7.2.2 --with-ghc=i686-unknown-linux-gnu-ghc --with-ghc-pkg=i686-unknown-linux-gnu-ghc-pkg --with-hsc2hs=i686-unknown-linux-gnu-hsc2hs --with-gcc=i686-unknown-linux-gnu-cc --with-ld=i686-unknown-linux-gnu-ld.gold --ghc-option=-optl-fuse-ld=gold --ld-option=-fuse-ld=gold --with-ar=i686-unknown-linux-gnu-ar --with-strip=i686-unknown-linux-gnu-strip --disable-executable-stripping --disable-library-stripping --disable-library-profiling --disable-executable-profiling --enable-static --disable-shared --disable-coverage --enable-library-for-ghci --enable-split-sections --hsc2hs-option=--cross-compile --ghc-option=-fexternal-interpreter
Configuring library for wreq-0.5.3.2..
Warning: The flag --disable-executable-profiling is deprecated. Please use
--disable-profiling instead.
building
Preprocessing library for wreq-0.5.3.2..
Building library for wreq-0.5.3.2..
[ 1 of 15] Compiling Network.Wreq.Cache.Store ( Network/Wreq/Cache/Store.hs, dist/build/Network/Wreq/Cache/Store.o )
[ 2 of 15] Compiling Network.Wreq.Internal.OAuth1 ( Network/Wreq/Internal/OAuth1.hs, dist/build/Network/Wreq/Internal/OAuth1.o )
[ 3 of 15] Compiling Network.Wreq.Internal.Types ( Network/Wreq/Internal/Types.hs, dist/build/Network/Wreq/Internal/Types.o )
Network/Wreq/Internal/Types.hs:49:1: warning: [-Wunused-imports]
The import of ‘Data.Monoid’ is redundant
except perhaps to import instances from ‘Data.Monoid’
To import instances alone, use: import Data.Monoid()
|
49 | import Data.Monoid ((<>), mconcat)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ 4 of 15] Compiling Network.Wreq.Lens.Machinery ( Network/Wreq/Lens/Machinery.hs, dist/build/Network/Wreq/Lens/Machinery.o )
[ 5 of 15] Compiling Network.Wreq.Internal.Lens ( Network/Wreq/Internal/Lens.hs, dist/build/Network/Wreq/Internal/Lens.o )
ghc-iserv: /nix/store/8s6rab4s507m83f88aik45vhkrn3i8gs-i686-unknown-linux-gnu-ghc-8.8.4/lib/i686-unknown-linux-gnu-ghc-8.8.4/ghc-prim-0.5.3/HSghc-prim-0.5.3.o: unknown symbol `_GLOBAL_OFFSET_TABLE_'
<no location info>: error:
ghc: unable to load package `ghc-prim-0.5.3'
[12 of 15] Compiling Paths_wreq ( dist/build/autogen/Paths_wreq.hs, dist/build/Paths_wreq.o )
builder for '/nix/store/ssyry01ii3a278rkqx7g2fzw6fzlb1sk-wreq-lib-wreq-0.5.3.2-i686-unknown-linux-gnu.drv' failed with exit code 1
cannot build derivation '/nix/store/lhirc7l3fdkbh883f3spisg5zjdl5g2h-cross-compile-exe-cross-compile-exe-0.1.0.0-i686-unknown-linux-gnu.drv': 1 dependencies couldn't be built
error: build of '/nix/store/lhirc7l3fdkbh883f3spisg5zjdl5g2h-cross-compile-exe-cross-compile-exe-0.1.0.0-i686-unknown-linux-gnu.drv' failed
Without the configureFlags
module there’s a failure about requiring the external-interpreter
flag. hardeningDisable
is my last attempt at trying to figure out the unknown symbol
error, as many sources mentioned that it might be caused by having something called “Position Independent Code” generation on. But I’m now unsure if that’s related, or if this is even the way to disable it.
Does anyone have experience on something like this? All help appreciated, and thanks for reading this far .