check that the number of parallel build is greater than 0
authorRuey-Lin Hsu <petercommand@gmail.com>
Thu, 4 Aug 2016 11:41:57 +0000 (13:41 +0200)
committerBen Gamari <ben@smart-cactus.org>
Fri, 5 Aug 2016 08:40:45 +0000 (10:40 +0200)
Fixes #12062.

Reviewers: bgamari, thomie, austin, simonmar

Reviewed By: bgamari, thomie, simonmar

Subscribers: simonmar, thomie

Differential Revision: https://phabricator.haskell.org/D2415

GHC Trac Issues: #12062

compiler/main/DynFlags.hs
docs/users_guide/using.rst
testsuite/driver/extra_files.py
testsuite/tests/driver/T12062/A.hs [new file with mode: 0644]
testsuite/tests/driver/T12062/A.hs-boot [new file with mode: 0644]
testsuite/tests/driver/T12062/C.hs [new file with mode: 0644]
testsuite/tests/driver/T12062/Makefile [new file with mode: 0644]
testsuite/tests/driver/T12062/T12062.hs [new file with mode: 0644]
testsuite/tests/driver/T12062/T12062.stderr [new file with mode: 0644]
testsuite/tests/driver/T12062/all.T [new file with mode: 0644]

index 744562e..c1ccfcd 100644 (file)
@@ -2343,8 +2343,17 @@ dynamic_flags_deps = [
                   "deprecated: They no longer have any effect"))))
   , make_ord_flag defFlag "v"        (OptIntSuffix setVerbosity)
 
-  , make_ord_flag defGhcFlag "j"     (OptIntSuffix (\n ->
-                                            upd (\d -> d {parMakeCount = n})))
+  , make_ord_flag defGhcFlag "j"     (OptIntSuffix
+        (\n -> case n of
+                 Just n
+                     | n > 0     -> upd (\d -> d { parMakeCount = Just n })
+                     | otherwise -> addErr "Syntax: -j[n] where n > 0"
+                 Nothing -> upd (\d -> d { parMakeCount = Nothing })))
+                 -- When the number of parallel builds
+                 -- is omitted, it is the same
+                 -- as specifing that the number of
+                 -- parallel builds is equal to the
+                 -- result of getNumProcessors
   , make_ord_flag defFlag "sig-of"   (sepArg setSigOf)
 
     -- RTS options -------------------------------------------------------------
index 3d3ef34..1d7f52c 100644 (file)
@@ -418,7 +418,8 @@ The main advantages to using ``ghc --make`` over traditional
    dependencies never get out of sync with the source.
 
 -  Using the :ghc-flag:`-j` flag, you can compile modules in parallel. Specify
-   ``-j⟨N⟩`` to compile ⟨N⟩ jobs in parallel.
+   ``-j⟨N⟩`` to compile ⟨N⟩ jobs in parallel. If N is omitted,
+   then it defaults to the number of processors.
 
 Any of the command-line options described in the rest of this chapter
 can be used with ``--make``, but note that any options you give on the
@@ -444,11 +445,12 @@ The source files for the program don't all need to be in the same
 directory; the :ghc-flag:`-i` option can be used to add directories to the
 search path (see :ref:`search-path`).
 
-.. ghc-flag:: -j <N>
+.. ghc-flag:: -j [N]
 
     Perform compilation in parallel when possible. GHC will use up to ⟨N⟩
-    threads during compilation. Note that compilation of a module may not
-    begin until its dependencies have been built.
+    threads during compilation. If N is omitted, then it defaults to the
+    number of processors. Note that compilation of a module may not begin
+    until its dependencies have been built.
 
 .. _eval-mode:
 
index bc5d460..ee09182 100644 (file)
@@ -82,6 +82,7 @@ extra_src_files = {
   'T11430': ['Test11430.hs', 't11430.hs'],
   'T11824': ['TyCon.hs', 'Type.hs', 'Type.hs-boot', 'Unbound/'],
   'T11827': ['A.hs', 'A.hs-boot', 'B.hs'],
+  'T12062': ['A.hs', 'A.hs-boot', 'C.hs'],
   'T1372': ['p1/', 'p2/'],
   'T1407': ['A.c'],
   'T1959': ['B.hs', 'C.hs', 'D.hs', 'E1.hs', 'E2.hs'],
diff --git a/testsuite/tests/driver/T12062/A.hs b/testsuite/tests/driver/T12062/A.hs
new file mode 100644 (file)
index 0000000..b1ea7a4
--- /dev/null
@@ -0,0 +1,2 @@
+module A where
+import C
diff --git a/testsuite/tests/driver/T12062/A.hs-boot b/testsuite/tests/driver/T12062/A.hs-boot
new file mode 100644 (file)
index 0000000..d843c00
--- /dev/null
@@ -0,0 +1 @@
+module A where
diff --git a/testsuite/tests/driver/T12062/C.hs b/testsuite/tests/driver/T12062/C.hs
new file mode 100644 (file)
index 0000000..0f2a5b3
--- /dev/null
@@ -0,0 +1,7 @@
+module C where
+
+import Language.Haskell.TH
+
+import {-# SOURCE #-} A
+
+nothing = return [] :: Q [Dec]
diff --git a/testsuite/tests/driver/T12062/Makefile b/testsuite/tests/driver/T12062/Makefile
new file mode 100644 (file)
index 0000000..1c39d1c
--- /dev/null
@@ -0,0 +1,3 @@
+TOP=../../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/driver/T12062/T12062.hs b/testsuite/tests/driver/T12062/T12062.hs
new file mode 100644 (file)
index 0000000..ed581c0
--- /dev/null
@@ -0,0 +1,6 @@
+{-# LANGUAGE TemplateHaskell #-}
+module T12062 where
+
+import C
+
+$(nothing)
diff --git a/testsuite/tests/driver/T12062/T12062.stderr b/testsuite/tests/driver/T12062/T12062.stderr
new file mode 100644 (file)
index 0000000..8262940
--- /dev/null
@@ -0,0 +1,2 @@
+ghc-stage2: on the commandline: Syntax: -j[n] where n > 0
+Usage: For basic information, try the `--help' option.
diff --git a/testsuite/tests/driver/T12062/all.T b/testsuite/tests/driver/T12062/all.T
new file mode 100644 (file)
index 0000000..1372ae3
--- /dev/null
@@ -0,0 +1,2 @@
+test('T12062', extra_clean(['T12062.o','T12062.hi', 'A.hi', 'A.o', 'A.hi-boot', 'A.o-boot', 'C.hi', 'C.o']),
+                      multimod_compile_fail, ['T12062', '-v0 -j0'])