summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@cs.stanford.edu>2014-04-10 18:28:11 -0700
committerEdward Z. Yang <ezyang@cs.stanford.edu>2014-04-10 18:28:11 -0700
commitc7498bbdaa74dadd976c75c4e303c2050aa78277 (patch)
treeb98830f1eb73dfba53ac1c79e440a2671142e7c8
parentc269b7e85524f4a8be3cd0f00e107207ab9197af (diff)
downloadhaskell-c7498bbdaa74dadd976c75c4e303c2050aa78277.tar.gz
Fix #8641, creating directories when we have stubs.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
-rw-r--r--compiler/main/DriverPipeline.hs2
-rw-r--r--testsuite/tests/driver/B042stub/C.hs6
-rw-r--r--testsuite/tests/driver/Makefile8
-rw-r--r--testsuite/tests/driver/all.T5
4 files changed, 21 insertions, 0 deletions
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 2c719670c5..2816c943fb 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -1259,6 +1259,7 @@ runPhase (RealPhase SplitAs) _input_fn dflags
osuf = objectSuf dflags
split_odir = base_o ++ "_" ++ osuf ++ "_split"
+ -- this also creates the hierarchy
liftIO $ createDirectoryIfMissing True split_odir
-- remove M_split/ *.o, because we're going to archive M_split/ *.o
@@ -1469,6 +1470,7 @@ runPhase (RealPhase MergeStub) input_fn dflags
= do
PipeState{maybe_stub_o} <- getPipeState
output_fn <- phaseOutputFilename StopLn
+ liftIO $ createDirectoryIfMissing True (takeDirectory output_fn)
case maybe_stub_o of
Nothing ->
panic "runPhase(MergeStub): no stub"
diff --git a/testsuite/tests/driver/B042stub/C.hs b/testsuite/tests/driver/B042stub/C.hs
new file mode 100644
index 0000000000..73f069cb92
--- /dev/null
+++ b/testsuite/tests/driver/B042stub/C.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+module B042stub.C where
+
+foreign export ccall foo :: IO ()
+foo :: IO ()
+foo = return ()
diff --git a/testsuite/tests/driver/Makefile b/testsuite/tests/driver/Makefile
index 767371343d..3603bb6bcd 100644
--- a/testsuite/tests/driver/Makefile
+++ b/testsuite/tests/driver/Makefile
@@ -222,6 +222,14 @@ test042:
"$(TEST_HC)" $(TEST_HC_OPTS_NO_RECOMP) -v0 --make B042/C.hs -odir obj042
test -f obj042/B042/C$(OBJSUFFIX)
+# test -odir with stubs
+test042stub:
+ $(RM) -rf obj042stub
+ mkdir obj042stub
+ $(RM) B042stub/C.hi
+ "$(TEST_HC)" $(TEST_HC_OPTS_NO_RECOMP) -v0 --make B042stub/C.hs -odir obj042stub
+ test -f obj042stub/B042stub/C$(OBJSUFFIX)
+
# test -hidir
test043:
$(RM) -f B043/C$(OBJSUFFIX)
diff --git a/testsuite/tests/driver/all.T b/testsuite/tests/driver/all.T
index aa4bc9b6cc..ed0ce0f8cb 100644
--- a/testsuite/tests/driver/all.T
+++ b/testsuite/tests/driver/all.T
@@ -142,6 +142,11 @@ test('driver042',
run_command,
['$MAKE -s --no-print-directory test042'])
+test('driver042stub',
+ extra_clean(['B042stub/C.hi', 'obj042stub/B042stub/C.o', 'obj042stub/B042stub/', 'obj042stub/']),
+ run_command,
+ ['$MAKE -s --no-print-directory test042stub'])
+
test('driver043',
extra_clean(['B043/C.hi', 'B043/C.o',
'hi043/B043/C.hi', 'hi043/B043', 'hi043']),