Commit 238f43bc authored by Alex D's avatar Alex D 🍄

Allow reusing temporary object files generated by GHCi by writing to -odir in...

Allow reusing temporary object files generated by GHCi by writing to -odir in case -fwrite-interface was specified (#16670)
parent 5af815f2
Pipeline #8115 passed with stages
in 378 minutes and 48 seconds
......@@ -2198,15 +2198,17 @@ enableCodeGenWhen condition should_modify staticLife dynLife target nodemap =
-- to by the user. But we need them, so we patch their locations in
-- the ModSummary with temporary files.
--
hi_file <-
(hi_file, o_file) <-
-- If ``-fwrite-interface` is specified, then the .o and .hi files
-- are written into `-odir` and `-hidir` respectively. #16670
if gopt Opt_WriteInterface dflags
then return $ ml_hi_file ms_location
else new_temp_file (hiSuf dflags) (dynHiSuf dflags)
o_temp_file <- new_temp_file (objectSuf dflags) (dynObjectSuf dflags)
then return (ml_hi_file ms_location, ml_obj_file ms_location)
else (,) <$> (new_temp_file (hiSuf dflags) (dynHiSuf dflags))
<*> (new_temp_file (objectSuf dflags) (dynObjectSuf dflags))
return $
ms
{ ms_location =
ms_location {ml_hi_file = hi_file, ml_obj_file = o_temp_file}
ms_location {ml_hi_file = hi_file, ml_obj_file = o_file}
, ms_hspp_opts = updOptLevel 0 $ dflags {hscTarget = target}
}
| otherwise = return ms
......
TOP=../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
clean:
$(RM) -rf my-odir
T16670_unboxed:
@echo "~~~~~~~~ testing T16670_unboxed"
$(MAKE) -s --no-print-directory clean
mkdir my-odir
echo ":load T16670_unboxed.hs" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) \
-v0 -fwrite-interface -odir my-odir
find . -name T16670_unboxed.o
test -f my-odir/T16670_unboxed.o
T16670_th:
@echo "~~~~~~~~ testing T16670_th"
$(MAKE) -s --no-print-directory clean
mkdir my-odir
echo ":load T16670_th.hs" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) \
-v0 -fno-code -fwrite-interface -odir my-odir
find . -name T16670_th.o
test -f my-odir/T16670_th.o
{-# LANGUAGE TemplateHaskell #-}
module T16670_th where
import TH
x = $(th)
~~~~~~~~ testing T16670_th
./my-odir/T16670_th.o
{-# LANGUAGE UnboxedTuples #-}
{-# OPTIONS_GHC -fwrite-interface #-}
module T16670_unboxed where
data UnboxedTupleData = MkUTD (# (),() #)
doThings :: UnboxedTupleData -> ()
doThings (MkUTD t) = ()
~~~~~~~~ testing T16670_unboxed
./my-odir/T16670_unboxed.o
{-# LANGUAGE TemplateHaskell #-}
module TH where
th = [|909|]
test('T16670_unboxed', [extra_files(['T16670_unboxed.hs']),
req_interp, omit_ways(prof_ways), unless(have_dynamic(), skip)],
makefile_test, ['T16670_unboxed'])
test('T16670_th', [extra_files(['T16670_th.hs', 'TH.hs']),
req_interp, omit_ways(prof_ways), unless(have_dynamic(), skip)],
makefile_test, ['T16670_th'])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment