Skip to content

GHC not recognizing INPUT(-llibrary) in linker scripts

I have tried to build accelerate-llvm package and encountered an invalid behaviour of linker. I am using Arch Linux and GHC 7.8.2.

I have installed llvm-general-3.4.2.2 and llvm-general-pure-3.4.2.2 from this branch: https://github.com/tvh/llvm-general/tree/curatedTargetMachine, and accelerate from HEAD to common sandbox. Then I tried to build accelerate-llvm using the sandbox and got this output during building:

Building accelerate-llvm-0.15.0.0...
Preprocessing library accelerate-llvm-0.15.0.0...
[ 1 of 30] Compiling Data.Range.Range ( Data/Range/Range.hs, dist/build/Data/Range/Range.o )
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package primitive-0.5.3.0 ... linking ... done.
Loading package array-0.5.0.0 ... linking ... done.
Loading package deepseq-1.3.0.2 ... linking ... done.
Loading package old-locale-1.0.0.6 ... linking ... done.
Loading package time-1.4.2 ... linking ... done.
Loading package vector-0.10.11.0 ... linking ... done.
Loading package mwc-random-0.13.1.2 ... linking ... done.
Loading package bytestring-0.10.4.0 ... linking ... done.
Loading package containers-0.5.5.1 ... linking ... done.
Loading package transformers-0.4.1.0 ... linking ... done.
Loading package mtl-2.2.1 ... linking ... done.
Loading package text-1.1.1.3 ... linking ... done.
Loading package parsec-3.1.5 ... linking ... done.
Loading package unix-2.7.0.1 ... linking ... done.
Loading package setenv-0.1.1.1 ... linking ... done.
Loading package pretty-1.1.1.1 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package llvm-general-pure-3.4.2.2 ... linking ... done.
Loading package utf8-string-0.3.8 ... linking ... done.
Loading package llvm-general-3.4.2.2 ... <command line>: can't load .so/.DLL for: /usr/lib/libcurses.so (-lncursesw: cannot open shared object file: No such file or directory)

After some searching I narrowed down the issue to /usr/lib/libcurses.so file. In Arch, this file contains INPUT(-lncursesw). If I change it to INPUT(libncursesw.so) or INPUT(/usr/lib/libncursesw.so) it works fine. Symlinking /usr/lib/libcurses.so to /usr/lib/libncursesw.so also works.

This bug seems to be connected to #2615 (closed). GHC still doesn't follow INPUT commands containing -llibrary form. Ld documentation allows this: If you use INPUT (-lfile)', ld will transform the name to libfile.a, as with the command line argument -l'. (https://sourceware.org/binutils/docs/ld/File-Commands.html)

Trac metadata
Trac field Value
Version 7.8.2
Type Bug
TypeOfFailure CompileTimeCrash
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Unknown/Multiple
Architecture
Edited by Howard B. Golden
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information