ギークもどきの日記帳

雑多な知識が垂れ流される場所。ほとんど無害。

stack ghciでllvm-hs読み込めないときにすること

$ stack ghci
Configuring GHCi with the following ...

lookupSymbol failed in relocateSection (relocate external)
/usr/local/Cellar/llvm-4.0/4.0.0/lib/llvm-4.0/lib/libLLVMLTO.a: unknown symbol `__ZN4llvm3lto11thinBackendERNS0_6ConfigEjNSt3__18functionIFNS3_10unique_ptrINS0_18NativeObjectStreamENS3_14default_deleteIS6_EEEEjEEERNS_6ModuleERNS_18ModuleSummaryIndexERKNS_9StringMapINS3_3mapIyjNS3_4lessIyEENS3_9allocatorINS3_4pairIKyjEEEEEENS_15MallocAllocatorEEERKNSH_IyPNS_18GlobalValueSummaryESJ_NSK_INSL_ISM_SV_EEEEEERNS_9MapVectorINS_9StringRefENS_13BitcodeModuleENS_8DenseMapIS12_jNS_12DenseMapInfoIS12_EENS_6detail12DenseMapPairIS12_jEEEENS3_6vectorINSL_IS12_S13_EENSK_IS1C_EEEEEE'
ghc: Could not on-demand load symbol '__ZN4llvm11raw_ostream13SetUnbufferedEv'

GHC runtime linker: fatal error: I found a duplicate definition for symbol
   __ZN4llvm11raw_ostream13SetUnbufferedEv
whilst processing object file
   /usr/local/Cellar/llvm-4.0/4.0.0/lib/llvm-4.0/lib/libLLVMLTO.a
The symbol was previously defined in
   /usr/local/Cellar/llvm-4.0/4.0.0/lib/llvm-4.0/lib/libLLVMLTO.a(LTO.cpp.o)
This could be caused by:
   * Loading two different object files which export the same symbol
   * Specifying the same object file twice on the GHCi command line
   * An incorrect `package.conf' entry, causing some object to be
     loaded twice.
ghc: Could not on-demand load symbol '__ZN4llvm9StringMapIcNS_15MallocAllocatorEE11try_emplaceIJcEEENSt3__14pairINS_17StringMapIteratorIcEEbEENS_9StringRefEDpOT_'

GHC runtime linker: fatal error: I found a duplicate definition for symbol
   __ZN4llvm9StringMapIcNS_15MallocAllocatorEE11try_emplaceIJcEEENSt3__14pairINS_17StringMapIteratorIcEEbEENS_9StringRefEDpOT_
whilst processing object file
   /usr/local/Cellar/llvm-4.0/4.0.0/lib/llvm-4.0/lib/libLLVMLTO.a
The symbol was previously defined in
   /usr/local/Cellar/llvm-4.0/4.0.0/lib/llvm-4.0/lib/libLLVMLTO.a(LTOBackend.cpp.o)
This could be caused by:

などと吐いてstack ghciが死ぬ。 intero-modeはstack ghciに依存しているのでつらい。 REPLでゴニョゴニョできないのもつらい。

解決策

stack.yamlflags: {}を次のように書き換える

flags:
  llvm-hs:
    shared-llvm: true