[Haskell-cafe] Problems using ghc 7.8.2 with options -staticlib and -threaded on osx
Frode Nerbråten
frode at nerbraten.no
Tue Jun 10 09:15:56 UTC 2014
Thank you Bob! I tried your workaround (and fixed the lib path in my
project) and it worked perfectly. Calling my Haskell functions from
multiple ObjectiveC threads now works as expected. You saved my day :)
I'll report this as a bug in GHC. Thank you for the source link.
Regards,
Frode
On Mon, Jun 9, 2014 at 9:49 PM, Bob Ippolito <bob at redivi.com> wrote:
> After patching your Xcode project file to use $(PROJECT_DIR) instead of
> /Users/frode/dev/haskell/digipostarkiv I was able to build this. I changed
> the "libtool command" in my lib/ghc-7.8.2/settings to a shim that removes
> -lpthread and then calls /usr/bin/libtool. Not pretty but it worked, I'm
> sure there's a better workaround, but I think the real solution should be to
> simply special-case OSDarwin in the same way as OSiOS in GHC.
>
>
> On Mon, Jun 9, 2014 at 12:33 PM, Bob Ippolito <bob at redivi.com> wrote:
>>
>> This seems like a bug, you shouldn't need to link to libpthread at all on
>> Mac. /usr/lib/libpthread.dylib is just a symlink to libSystem… Not sure how
>> to get around the issue without rebuilding GHC, it looks like iOS is special
>> cased in the compiler (OSiOS) but not Mac OS X (OSDarwin) [1].
>>
>> [1]
>> https://github.com/ghc/ghc/blob/master/compiler/main/DriverPipeline.hs#L1869-L1873
>>
>>
>> On Mon, Jun 9, 2014 at 11:36 AM, Frode Nerbråten <frode at nerbraten.no>
>> wrote:
>>>
>>> Hi,
>>>
>>> I'm having trouble building my Haskell library with GHC 7.8.2 and
>>> Cabal 1.20.0.2 on OSX 10.9.3 with both -staticlib and -threaded
>>> enabled.
>>>
>>> The library I'm building exports several functions using FFI to be
>>> called from ObjectiveC in an Xcode project. This works fine with just
>>> -staticlib enabled, but now I realize I need to call into my Haskell
>>> library from multiple OS-threads simultaneously. But when I add
>>> -threaded to ghc-options I get an error when linking:
>>>
>>> error: libtool: can't locate file for: -lpthread
>>> error: libtool: file: -lpthread is not an object file (not allowed
>>> in a library)
>>>
>>> The linker command that fails looks like this (... replaces a bunch of
>>> -l and -L options):
>>>
>>> libtool -static -o liba.a dist/build/HsCocoa.o ... -lCffi -lpthread
>>>
>>> In /usr/lib I have a libpthread.dylib that links to libSystem.dylib,
>>> but no libpthread.a. I was under the impression that libpthread was
>>> included with the system install.
>>>
>>> Is this supposed to work or am I misunderstanding something basic? :)
>>> Any help would be greatly appreciated!
>>>
>>> The project source is available on github:
>>> https://github.com/froden/digipostarkiv
>>> (I asked the same question on stackoverflow:
>>> http://stackoverflow.com/q/24096257/777411)
>>>
>>> Best regards,
>>> Frode Nerbråten
>>> _______________________________________________
>>> Haskell-Cafe mailing list
>>> Haskell-Cafe at haskell.org
>>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>>
>
More information about the Haskell-Cafe
mailing list