[GHC] #14483: getExecutablePath from System.Environment in base should follow symlinks properly.
#14483: getExecutablePath from System.Environment in base should follow symlinks properly. -------------------------------------+------------------------------------- Reporter: angerman | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- During the implementation of relocation capabilities in GHC for linux and macOS it came to light, that windows (which has had this support for quite some time), uses a custom implementation of `getExecutablePath`. Ideally this logic should be moved into `base`. Phyx- noted in D4121 that this should be possible for 8.6, as at that point Win32 should be new enough to be usable in base for this. The result would be that the custom code in GHC (SysTools) and the older copy in GhcPkg of the same code can be unified with the linux and macOS CPP conditional branch. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14483> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14483: getExecutablePath from System.Environment in base should follow symlinks properly. -------------------------------------+------------------------------------- Reporter: angerman | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by angerman): Just to elaborate what is to be done here: 1. Look at `getBaseDir :: IO (Maybe String)` in `compiler/main/SysTools.hs`, and integrate the symbolic link resolution logic from there in `getExecutablePath` in the `System.Environment` Module from the `base` package. 2. If the `MIN_VERSION_base(...)` is high enough, use `getExecutablePath` also on Windows in `compiler/main/SysTools.hs`, `utils/ghc-pkg/Main.hs` and `utils/hsc2hs/Main.hs`. It looks like this should be rather easy, but requires someone with some windows exposure. Testcases in the testsuite for `getExecutablePath` would be a great bonus! -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14483#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14483: getExecutablePath from System.Environment in base should follow symlinks properly. -------------------------------------+------------------------------------- Reporter: angerman | Owner: alpmestan Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by alpmestan): * owner: (none) => alpmestan Comment: I'll give this a shot early next week. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14483#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14483: getExecutablePath from System.Environment in base should follow symlinks properly. -------------------------------------+------------------------------------- Reporter: angerman | Owner: alpmestan Type: bug | Status: patch Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): D4227 Wiki Page: | -------------------------------------+------------------------------------- Changes (by alpmestan): * status: new => patch * differential: => D4227 Comment: I have a patch that improves the windows implementation of `getExecutablePath` so that it follows symlinks at https://phabricator.haskell.org/D4227 -- feedback welcome. This however does not change ghc, ghc-pkg and hsc2hs to use `getExecutablePath` (instead of the current duplicated code that does something equivalent). -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14483#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14483: getExecutablePath from System.Environment in base should follow symlinks properly. -------------------------------------+------------------------------------- Reporter: angerman | Owner: alpmestan Type: bug | Status: patch Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): D4227 Wiki Page: | -------------------------------------+------------------------------------- Comment (by alpmestan): And here is a patch in which I switch ghc/ghc-pkg to using `getExecutablePath` when built with a recent enough `base`: https://phabricator.haskell.org/D4229 Eventually, in a few major versions, we'll be able to get rid of the `base < 4.11` code path and simply use `getExecutablePath`. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14483#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14483: getExecutablePath from System.Environment in base should follow symlinks properly. -------------------------------------+------------------------------------- Reporter: angerman | Owner: alpmestan Type: bug | Status: patch Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): D4227 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"62823668c48e13290e2ffe0d593a9f6a95cf628b/ghc" 62823668/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="62823668c48e13290e2ffe0d593a9f6a95cf628b" Follow symlinks in the Win32 code for System.Environment.getExecutablePath This partially addresses #14483 by fixing the Windows implementation of System.Environment.getExecutablePath. This is achieved by using GetFinalPathNameByHandleW to resolve potential symlinks, while making sure we do not get back a UNC path (see #14460). Test Plan: Validate Reviewers: Phyx, bgamari, angerman, hvr, goldfire Reviewed By: Phyx, bgamari GHC Trac Issues: #14483 Differential Revision: https://phabricator.haskell.org/D4227 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14483#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14483: getExecutablePath from System.Environment in base should follow symlinks properly. -------------------------------------+------------------------------------- Reporter: angerman | Owner: alpmestan Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): D4227 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14483#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14483: getExecutablePath from System.Environment in base should follow symlinks properly. -------------------------------------+------------------------------------- Reporter: angerman | Owner: alpmestan Type: bug | Status: closed Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): D4227 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.6.1 => 8.4.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14483#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14483: getExecutablePath from System.Environment in base should follow symlinks properly. -------------------------------------+------------------------------------- Reporter: angerman | Owner: alpmestan Type: bug | Status: closed Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): D4227 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Tamar Christina <tamar@…>): In [changeset:"c523525b0e434d848f6e47ea3f9a37485965fa79/ghc" c523525/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="c523525b0e434d848f6e47ea3f9a37485965fa79" ghc, ghc-pkg: use getExecutablePath on Windows when base >= 4.11.0 Summary: This completes the work started in D4227 by using just 'getExecutablePath' in ghc and ghc-pkg when building with base >= 4.11.0. On the long term, we will be able to simply kill the existing code that follows (or not) symlinks and just get this behaviour for free from getExecutable. For now we however have to require base >= 4.11.0 to be able to just use getExecutablePath under Windows, and use the current code when building with an older base. Original code by @alpmestan commandeering since patch has been stale and bug remains open. Test Plan: Validate Reviewers: angerman, bgamari, erikd, alpmestan Reviewed By: bgamari Subscribers: carter, rwbarton, thomie GHC Trac Issues: #14483 Differential Revision: https://phabricator.haskell.org/D4229 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14483#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14483: getExecutablePath from System.Environment in base should follow symlinks properly. -------------------------------------+------------------------------------- Reporter: angerman | Owner: alpmestan Type: bug | Status: closed Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): D4227 Wiki Page: | -------------------------------------+------------------------------------- Comment (by alpmestan): Thanks for picking this up, I've had to turn my attention to 2 urgent tasks lately, sorry for the delay! -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14483#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC