amnh / PCG

𝙋𝙝𝙮𝙡𝙤𝙜𝙚𝙣𝙚𝙩𝙞𝙘 𝘾𝙤𝙢𝙥𝙤𝙣𝙚𝙣𝙩 𝙂𝙧𝙖𝙥𝙝 ⸺ Haskell program and libraries for general phylogenetic graph search
28 stars 1 forks source link

Fix linking error on OSX #49

Closed recursion-ninja closed 7 years ago

recursion-ninja commented 7 years ago

We get the following build error on OSX

Linking .stack-work/dist/x86_64-osx/Cabal-2.0.0.2/build/file-tests/file-tests ...   
ld: library not found for -lcrt0.o    
clang: error: linker command failed with exit code 1 (use -v to see invocation)    
`gcc' failed in phase `Linker'. (Exit code: 1)

Seems to be related to the sub-packages in the new build.

ima-hima commented 7 years ago

Did a lot of research. I think this is a C++ issue, and not C, but not sure. It does seem that OS X/Darwin doesn't allow static linking, at least anymore.

Annoyingly, found a bunch of info on it from a long time ago, but all of the suggested fixes seem to be specific to gcc. And weirdly no one seems to be having these problems with GHC or Stack.

Here's what I've tried so far:

  1. Changing clang to gcc. Using MacPorts I tried: • gcc6---Turns out this won't even compile on OS X versions >=10.10. • gcc7---Threw a bunch of new errors before pooping out on the same missing library BS.
  2. Changing ghcs settings, located in ~/.stack/programs/x86-64-osx/ghc-8.2.1/lib/ghc-8.2.1/settings (took me a while to find that). Added -static -optl-pthread -optl-static to force everything to compile statically, as I read that might be an option.
  3. Finding Stack-specific settings to change static settings. No dice.
  4. Removing multiple cabal files. Couldn't figure out how to do so.
  5. Hand merge. Spend a couple of days on this. Pretty arduous, plus not convinced it's going anywhere.
  6. Give up, compile on Ubuntu and work from the VM. <-- Success!

Next steps:

  1. Alex has successfully merged eNewick into master on Linux. Maybe try hand merge those two again, with more similar code?
  2. Changing linkers? Not clear on where, exactly, llvm and ld are used in the process---llvm partially compiles the Haskell code. Maybe trading out ld for llvm in the C/C++ linking procedure will help? I'm not that familiar with llvm, so this might be a pipe dream, because they do different things.
recursion-ninja commented 7 years ago

Removed the -optl-static flag from the test suite "executable" int he pcg-file-parser sub-library.

See commit: 568fbe6