Skip to content

library not found when building with TemplateHaskell: add additional search -rpath to "@loader_path/" #8704

Closed
@kencu

Description

@kencu

Describe the bug
When building unicode-collation, a linker error occurs:

[ 8 of 10] Compiling Text.Collate.Tailorings [Text.Collate.Collation changed]
ghc: panic! (the 'impossible' happened)
  (GHC version 8.10.4:
	Loading temp shared object failed: dlopen(/var/folders/I0/I0fOotq3ErGZHYxrmmWiqU+++TI/-Tmp-/ghc85250_0/libghc_43.dylib, 5): Library not loaded: @rpath/libghc_21.dylib
  Referenced from: /var/folders/I0/I0fOotq3ErGZHYxrmmWiqU+++TI/-Tmp-/ghc85250_0/libghc_43.dylib
  Reason: image not found

both ghc85250_0/libghc_43.dylib and ghc85250_0/libghc_43.dylib exist in the same folder, but ghc85250_0/libghc_43.dylib does not look in it's local directory for ghc85250_0/libghc_43.dylib.

I would like to add an rpath search path to '.' to allow the dylib to search it's local directory as well as the rpath search paths it is already using ... that appears to be managed in this function I believe:

https://github.com/ghc/ghc/blob/e902d771197fd93488938b5eacb1ad6f23d408b7/compiler/GHC/Linker/MacOS.hs#L53

however I am not sure of the Haskell code to use to do that, exactly.

I tried various flags for ghc, gcc, and cabal but I could not find a way to add this rpath entry to the generated dylib using a flag.

The build system is officially not supported -- macOS 10.6.8 using a very slightly modified ghc 8.10.4 (https://github.com/kencu/ghc-for-older-darwin-systems/releases/) with trivial patch for missing strnlen in 10.6.8's libSystem, cabal 3.8.1.0, with clang-11 as the compiler and ld64-450 as the linker. The dyld is stock 10.6.8. I have tried other ghc versions (9.2.5, for example) with the same outcome.

I realize the system is not officially supported, but there has been very solid success building with this toolchain until this linker error in this one dependency needed for pandoc, and we're hoping it might build.

link to original ticket report is here:

jgm/unicode-collation#13

Thanks for any consideration, and in particular perhaps for the bit of code I might use to add the rpath matching -Wl,-rpath,.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions