Fix system linker on Mac OS X

Summary:
Flag `-ld:` 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

Subscribers: carter, thomie, ezyang

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

GHC Trac Issues: #9875
newTempLibname: Return file name and ld arguments