Avoid linking if possible

The discussion is on https://github.com/haskell/cabal/issues/1177 (let's keep it there unless it's direct code comments).