From f09d65474ed042360999cb88221d65b07bfb4b5f Mon Sep 17 00:00:00 2001 From: Ruey-Lin Hsu Date: Thu, 4 Aug 2016 13:41:57 +0200 Subject: check that the number of parallel build is greater than 0 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 | 13 +++++++++++-- docs/users_guide/using.rst | 10 ++++++---- testsuite/driver/extra_files.py | 1 + testsuite/tests/driver/T12062/A.hs | 2 ++ testsuite/tests/driver/T12062/A.hs-boot | 1 + testsuite/tests/driver/T12062/C.hs | 7 +++++++ testsuite/tests/driver/T12062/Makefile | 3 +++ testsuite/tests/driver/T12062/T12062.hs | 6 ++++++ testsuite/tests/driver/T12062/T12062.stderr | 2 ++ testsuite/tests/driver/T12062/all.T | 2 ++ 10 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 testsuite/tests/driver/T12062/A.hs create mode 100644 testsuite/tests/driver/T12062/A.hs-boot create mode 100644 testsuite/tests/driver/T12062/C.hs create mode 100644 testsuite/tests/driver/T12062/Makefile create mode 100644 testsuite/tests/driver/T12062/T12062.hs create mode 100644 testsuite/tests/driver/T12062/T12062.stderr create mode 100644 testsuite/tests/driver/T12062/all.T diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 744562e26e..c1ccfcd95c 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -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 ------------------------------------------------------------- diff --git a/docs/users_guide/using.rst b/docs/users_guide/using.rst index 3d3ef34d02..1d7f52c8e6 100644 --- a/docs/users_guide/using.rst +++ b/docs/users_guide/using.rst @@ -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 +.. 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: diff --git a/testsuite/driver/extra_files.py b/testsuite/driver/extra_files.py index bc5d460b77..ee09182b20 100644 --- a/testsuite/driver/extra_files.py +++ b/testsuite/driver/extra_files.py @@ -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 index 0000000000..b1ea7a4d24 --- /dev/null +++ b/testsuite/tests/driver/T12062/A.hs @@ -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 index 0000000000..d843c00b78 --- /dev/null +++ b/testsuite/tests/driver/T12062/A.hs-boot @@ -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 index 0000000000..0f2a5b3a37 --- /dev/null +++ b/testsuite/tests/driver/T12062/C.hs @@ -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 index 0000000000..1c39d1c1fe --- /dev/null +++ b/testsuite/tests/driver/T12062/Makefile @@ -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 index 0000000000..ed581c000a --- /dev/null +++ b/testsuite/tests/driver/T12062/T12062.hs @@ -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 index 0000000000..8262940b08 --- /dev/null +++ b/testsuite/tests/driver/T12062/T12062.stderr @@ -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 index 0000000000..1372ae3ea5 --- /dev/null +++ b/testsuite/tests/driver/T12062/all.T @@ -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']) -- cgit v1.2.1