[commit: ghc] master: Don't drop last char of file if -osuf contains dot (48db13d)

git at git.haskell.org git at git.haskell.org
Thu Dec 24 18:52:32 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/48db13d279d592ed3044cbaf3513854bcb0d3dce/ghc

>---------------------------------------------------------------

commit 48db13d279d592ed3044cbaf3513854bcb0d3dce
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date:   Wed Mar 18 20:08:08 2015 +0100

    Don't drop last char of file if -osuf contains dot
    
    Given:
     * `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
    `System.Filepath.stripExtension`).
    
    Given:
     * `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: https://phabricator.haskell.org/D1692
    
    GHC Trac Issues: #9760


>---------------------------------------------------------------

48db13d279d592ed3044cbaf3513854bcb0d3dce
 compiler/ghci/Linker.hs     | 2 +-
 testsuite/driver/testlib.py | 1 +
 testsuite/tests/th/Makefile | 6 ++++--
 testsuite/tests/th/all.T    | 2 ++
 4 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/compiler/ghci/Linker.hs b/compiler/ghci/Linker.hs
index a95120d..7e86e11 100644
--- a/compiler/ghci/Linker.hs
+++ b/compiler/ghci/Linker.hs
@@ -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)
diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py
index 44eebd6..cf5a226 100644
--- a/testsuite/driver/testlib.py
+++ b/testsuite/driver/testlib.py
@@ -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/build.mk)'''
     if not config.have_profiling:
         opts.expect = 'fail'
 
diff --git a/testsuite/tests/th/Makefile b/testsuite/tests/th/Makefile
index b759a81..4fb508f 100644
--- a/testsuite/tests/th/Makefile
+++ b/testsuite/tests/th/Makefile
@@ -15,9 +15,11 @@ T7445:
 HC_OPTS = -XTemplateHaskell -package template-haskell
 
 TH_spliceE5_prof::
-	$(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
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index 9d00d8e..fb429bc 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -47,6 +47,8 @@ test('TH_spliceE5_prof',
      [req_profiling,
       omit_ways(['ghci']),
       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',
                    'TH_spliceE5_prof_Lib.o','TH_spliceE5_prof.p.o'])],
      run_command,
      ['$MAKE -s --no-print-directory TH_spliceE5_prof'])



More information about the ghc-commits mailing list