Fix system linker on Mac OS X

Summary:
Flag `-l:` is GNU ld specific and not supported by the
Mac OS X link editor. So we create a temporary file name
lib<tmpname>.<so_ext> and link with the standard -l<tmpname>
option on Linux and OS X.

Fixes #9875

Test Plan: validate on Mac OS X

Reviewers: austin, hvr, ezyang

Reviewed By: ezyang

Subscribers: carter, thomie, ezyang

Differential Revision: https://phabricator.haskell.org/D579

GHC Trac Issues: #9875