[GHC] #12674: GHC doesn't handle ./ prefixed paths correctly
GHC
ghc-devs at haskell.org
Wed Jul 4 17:17:16 UTC 2018
#12674: GHC doesn't handle ./ prefixed paths correctly
-------------------------------------+-------------------------------------
Reporter: dobenour | Owner: RolandSenn
Type: bug | Status: new
Priority: normal | Milestone:
Component: Driver | Version: 8.0.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: GHC rejects | Unknown/Multiple
valid program | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by RolandSenn):
== The Problem
I have looked into this and found the following:
Assume we use:
{{{
ghc ./-Module.hs
}}}
In the module ''ghc/Main.hs'' we have the following code in the function
''main' '' :
{{{
let
-- To simplify the handling of filepaths, we normalise all filepaths
right
-- away - e.g., for win32 platforms, backslashes are converted
-- into forward slashes.
normal_fileish_paths = map (normalise . unLoc) fileish_args
(srcs, objs) = partition_args normal_fileish_paths [] []
<-- --- some lines dropped --- -->
---------------- Final sanity checking -----------
liftIO $ checkOptions postLoadMode dflags6 srcs objs
}}}
In the ''normalise'' function the FilePath **./-Module.hs** get normalised
to **-Module.hs**.
Then the ''checkOptions'' function reports an error, because
''-Module.hs'' is not a valid flag
and processing stops!
I see two possible solutions to fix this:
== The hacky solution:
We send non-normalised filenames to the ''checkOptions'' function. Then
the processing continues.
But we get problems, when we send the ''-Module.hs'' file to the
preprocessor or the
''-Module.o'' file to the linker. At these locations (and maybe at some
more) we have to
prepend the ./ to the module name again, but only if it starts with a
hyphen.
== The radical solution:
We extend the function
''library/filepath/System/FilePath/Internal/normalise''
so it works the following way:
**./Module.hs** is normalised to **Module.hs** (as it does now)
**./-Module.hs** is not normalised and remains **./-Module.hs**
(this is new!!)
This change in the library is a little bit more dangerous.
With both solutions, only users with filenames starting with a hyphen
should be affected.
Please advice!
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12674#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list