Commit 48db13d2 authored by thomie's avatar thomie

Don't drop last char of file if -osuf contains dot

 * `file = "foo.a.b"`
 * `osuf = ".a.b"`  -- Note the initial dot.
 * `new_osuf = "c"`

Before (bad, the last character of the filename is dropped):
  `dropTail (length osuf + 1) file <.> new_osuf == "fo.c"`
After (good):
  `stripExtension osuf file <.> new_osuf` == "foo.c"

This regression was introduced in commit c489af73 (#5554). That commit
fixed a similar but different bug, and care has been taken to not
reintroduce it (using the the newly introduced

 * `file = "foo.a.b"`
 * `osuf = "a.b"`
 * `new_osuf = "c"`

Before c489af73 (bad, the full suffix should get replaced):
  `replaceExtension file new_osuf == "foo.a.c"`
After c489af73 (good):
  `dropTail (length osuf + 1) file <.> new_osuf == "foo.c"`
After this commit (still good):
  `stripExtension osuf file <.> new_osuf == "foo.c"`

Reviewed by: bgamari

Differential Revision:

GHC Trac Issues: #9760
parent e3383767
......@@ -683,7 +683,7 @@ getLinkDeps hsc_env hpt pls replace_osuf span mods
adjust_ul new_osuf (DotO file) = do
MASSERT(osuf `isSuffixOf` file)
let file_base = dropTail (length osuf + 1) file
let file_base = fromJust (stripExtension osuf file)
new_file = file_base <.> new_osuf
ok <- doesFileExist new_file
if (not ok)
......@@ -125,6 +125,7 @@ def req_haddock( name, opts ):
opts.expect = 'missing-lib'
def req_profiling( name, opts ):
'''Require the profiling libraries (add 'GhcLibWays += p' to mk/'''
if not config.have_profiling:
opts.expect = 'fail'
......@@ -15,9 +15,11 @@ T7445:
HC_OPTS = -XTemplateHaskell -package template-haskell
$(RM) TH_spliceE5_prof*.o TH_spliceE5_prof*.hi TH_spliceE5_prof*.p.o
$(RM) TH_spliceE5_prof*.o TH_spliceE5_prof*.hi TH_spliceE5_prof*.dyn_o TH_spliceE5_prof*.dyn_hi TH_spliceE5_prof
'$(TEST_HC)' $(TEST_HC_OPTS) $(HC_OPTS) $(ghcThWayFlags) --make -v0 TH_spliceE5_prof.hs -c
'$(TEST_HC)' $(TEST_HC_OPTS) $(HC_OPTS) --make -v0 TH_spliceE5_prof.hs -prof -auto-all -osuf p.o -o $@
# Using `-osuf .p.o` should work. Note the dot before the `p` (#9760), and
# the dot between the `p` and the `o` (#5554).
'$(TEST_HC)' $(TEST_HC_OPTS) $(HC_OPTS) --make -v0 TH_spliceE5_prof.hs -prof -auto-all -osuf .p.o -o $@
# With -fexternal-interpreter, we don't have to build the non-profiled
......@@ -47,6 +47,8 @@ test('TH_spliceE5_prof',
extra_clean(['TH_spliceE5_prof_Lib.p.o', 'TH_spliceE5_prof_Lib.hi',
'TH_spliceE5_prof_Lib.dyn_o', 'TH_spliceE5_prof_Lib.dyn_hi',
'TH_spliceE5_prof.dyn_o', 'TH_spliceE5_prof.dyn_hi',
['$MAKE -s --no-print-directory TH_spliceE5_prof'])
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment