Resolve symlinks when attempting to find GHC's lib folder on Windows
ClosedPublic

Authored by Phyx on Apr 10 2016, 8:01 AM.

Details

Summary

Systools makes some pretty hard assumptions about where GHC is on Windows.
One of these is that ghc be in a folder named bin and that ../lib exists.

This pattern doesn't hold for symlinks as a link C:\ghc-bin\
pointing to C:\ghc\ghc-7.10.3\bin will break this assumption.

This patch resolves symlinks by finding where they point to and uses that location
as the base for GHC.

This uses an API that's been introduced in Vista. For older systems it falls back to
the current behavior of not resolving symlinks.

Test Plan
  1. Create symlink to GHC's bin folder.
  2. Run GHC from that folder.

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
Phyx retitled this revision from to Resolve symlinks when attempting to find GHC's lib folder on Windows.Apr 10 2016, 8:01 AM
Phyx updated this object.
Phyx edited the test plan for this revision. (Show Details)
Phyx updated the Trac tickets for this revision.
Phyx added a subscriber: Restricted Project.Apr 10 2016, 8:03 AM
Phyx updated this revision to Diff 7230.Apr 10 2016, 8:12 AM
  • T11759: Added some comments
Phyx updated this object.Apr 10 2016, 8:36 AM
bgamari requested changes to this revision.Apr 10 2016, 6:21 PM

A couple of changes.

compiler/main/SysTools.hs
1543

A note here explaining that this call is only available in Vista and later, hence the check, would be helpful.

1562

Why not move the GetFinalPath type next to this?

This revision now requires changes to proceed.Apr 10 2016, 6:21 PM
Phyx updated this revision to Diff 7254.Apr 11 2016, 3:31 PM
  • T11759: Updated comments and moved type
Phyx marked 2 inline comments as done.Apr 11 2016, 3:34 PM

Added comments from feedback.

austin accepted this revision.Apr 13 2016, 2:59 PM

[flashbacks of writing NTFS code intensifies]

Phyx updated this revision to Diff 7309.Apr 17 2016, 9:37 AM

Rebased on master

Phyx added a comment.Apr 17 2016, 9:38 AM

Thanks for the review @austin and @bgamari

Phyx updated this revision to Diff 7310.Apr 17 2016, 10:13 AM
  • T11759: removed trailing whitespace
This revision was automatically updated to reflect the committed changes.