compiler/main: fixes #9776

Test Plan: test T9776 under tests/driver

Reviewers: jstolarek, austin

Reviewed By: jstolarek, austin

Subscribers: jstolarek, thomie, carter

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

GHC Trac Issues: #9776