diff --git a/Cabal/src/Distribution/Simple/GHC/Build/Link.hs b/Cabal/src/Distribution/Simple/GHC/Build/Link.hs index 9f454e0ea5f096e8e5803e2eb9d5f67ae56f0dca..ee0f21ffa6d49c2f7978d708a5381177b3bb1ca0 100644 --- a/Cabal/src/Distribution/Simple/GHC/Build/Link.hs +++ b/Cabal/src/Distribution/Simple/GHC/Build/Link.hs @@ -711,7 +711,9 @@ runReplOrWriteFlags ghcProg lbi rflags ghcOpts pkg_name target = writeFileAtomic (out_dir </> this_unit) $ BS.pack $ escapeArgs $ - extra_opts ++ renderGhcOptions comp platform (ghcOpts{ghcOptMode = NoFlag}) + extra_opts + ++ renderGhcOptions comp platform (ghcOpts{ghcOptMode = NoFlag}) + ++ programOverrideArgs ghcProg replNoLoad :: Ord a => ReplOptions -> NubListR a -> NubListR a replNoLoad replFlags l diff --git a/cabal-install/src/Distribution/Client/CmdRepl.hs b/cabal-install/src/Distribution/Client/CmdRepl.hs index 39468a8e545f4b0cf7f7218cb5504b676b4ee07f..e381b291d7d74650992db3154e69b2445d3fb56e 100644 --- a/cabal-install/src/Distribution/Client/CmdRepl.hs +++ b/cabal-install/src/Distribution/Client/CmdRepl.hs @@ -139,6 +139,7 @@ import Distribution.Types.Library ( Library (..) , emptyLibrary ) +import Distribution.Types.ParStrat import Distribution.Types.Version ( Version , mkVersion @@ -467,6 +468,10 @@ replAction flags@NixStyleFlags{extraFlags = r@ReplFlags{..}, ..} targetStrings g in -- GHC considers the last unit passed to be the active one other_units ++ active_unit_files + render_j Serial = "1" + render_j (UseSem n) = show @Int n + render_j (NumJobs mn) = maybe "" (show @Int) mn + -- run ghc --interactive with runProgramInvocation verbosity $ programInvocation ghcProg' $ @@ -475,7 +480,7 @@ replAction flags@NixStyleFlags{extraFlags = r@ReplFlags{..}, ..} targetStrings g , "-package-env" , "-" -- to ignore ghc.environment.* files , "-j" - , show (buildSettingNumJobs (buildSettings ctx)) + , render_j (buildSettingNumJobs (buildSettings ctx)) ] : [ ["-unit", "@" ++ dir </> unit] | unit <- unit_files_ordered diff --git a/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/CHANGELOG.md b/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..fd67fc8144e0b55ad97d2d8d45d1c0925d87b20b --- /dev/null +++ b/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/CHANGELOG.md @@ -0,0 +1,5 @@ +# Revision history for extra-options + +## 0.1.0.0 -- YYYY-mm-dd + +* First version. Released on an unsuspecting world. diff --git a/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/LICENSE b/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..5c92e310c868a20d5cac64ea049bade4e6a28b67 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/LICENSE @@ -0,0 +1,30 @@ +Copyright (c) 2024, Matthew Pickering + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of Matthew Pickering nor the names of other + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/app/Main.hs b/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/app/Main.hs new file mode 100644 index 0000000000000000000000000000000000000000..576a1174fe8c999cc1680fe4ce439efda470f129 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/app/Main.hs @@ -0,0 +1,10 @@ +module Main where + +import qualified MyLib (someFunc) + +#ifdef FOO +main :: IO () +main = do + putStrLn "Hello, Haskell!" + MyLib.someFunc +#endif diff --git a/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/cabal.out b/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/cabal.out new file mode 100644 index 0000000000000000000000000000000000000000..2032e6d4542e5a73495683bb37e679a0b681e4c4 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/cabal.out @@ -0,0 +1,13 @@ +# cabal v2-repl +Resolving dependencies... +Build profile: -w ghc-<GHCVER> -O1 +In order, the following will be built: + - extra-options-0.1.0.0 (interactive) (lib) (first run) + - extra-options-0.1.0.0 (interactive) (test:extra-options-test) (first run) + - extra-options-0.1.0.0 (interactive) (exe:extra-options) (first run) +Configuring library for extra-options-0.1.0.0... +Preprocessing library for extra-options-0.1.0.0... +Configuring test suite 'extra-options-test' for extra-options-0.1.0.0... +Preprocessing test suite 'extra-options-test' for extra-options-0.1.0.0... +Configuring executable 'extra-options' for extra-options-0.1.0.0... +Preprocessing executable 'extra-options' for extra-options-0.1.0.0... diff --git a/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/cabal.project b/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/cabal.project new file mode 100644 index 0000000000000000000000000000000000000000..f991c04133ae3071c0a0a5a0ac8240e0648ae11e --- /dev/null +++ b/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/cabal.project @@ -0,0 +1,6 @@ +packages: . + +tests: True + +program-options + ghc-options: -XCPP -DFOO diff --git a/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/cabal.test.hs b/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/cabal.test.hs new file mode 100644 index 0000000000000000000000000000000000000000..313609f30ad7814637ceb63cc379df93d3c4d0a7 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/cabal.test.hs @@ -0,0 +1,6 @@ +import Test.Cabal.Prelude + +main = do + cabalTest $ do + skipUnlessGhcVersion ">= 9.4" + void $ cabalWithStdin "v2-repl" ["--enable-multi-repl","all"] "" diff --git a/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/extra-options.cabal b/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/extra-options.cabal new file mode 100644 index 0000000000000000000000000000000000000000..e1b9c13aadc5d6d4ed281368bd73e7d09de2b703 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/extra-options.cabal @@ -0,0 +1,39 @@ +cabal-version: 3.0 +name: extra-options +version: 0.1.0.0 +license: BSD-3-Clause +license-file: LICENSE +author: Matthew Pickering +maintainer: matthewtpickering@gmail.com +build-type: Simple +extra-doc-files: CHANGELOG.md + +common warnings + ghc-options: -Wall + +library + import: warnings + exposed-modules: MyLib + build-depends: base + hs-source-dirs: src + default-language: Haskell2010 + +executable extra-options + import: warnings + main-is: Main.hs + build-depends: + base, + extra-options + + hs-source-dirs: app + default-language: Haskell2010 + +test-suite extra-options-test + import: warnings + default-language: Haskell2010 + type: exitcode-stdio-1.0 + hs-source-dirs: test + main-is: Main.hs + build-depends: + base, + extra-options diff --git a/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/src/MyLib.hs b/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/src/MyLib.hs new file mode 100644 index 0000000000000000000000000000000000000000..acdf14c0c9ef2ff0974f4f43ff6a8259443b991a --- /dev/null +++ b/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/src/MyLib.hs @@ -0,0 +1,6 @@ +module MyLib (someFunc) where + +#ifdef FOO +someFunc :: IO () +someFunc = putStrLn "someFunc" +#endif diff --git a/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/test/Main.hs b/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/test/Main.hs new file mode 100644 index 0000000000000000000000000000000000000000..f60b8ae537979cb68c1f9703364f47f2cb75cb21 --- /dev/null +++ b/cabal-testsuite/PackageTests/MultiRepl/ExtraOptions/test/Main.hs @@ -0,0 +1,6 @@ +module Main (main) where + +#ifdef FOO +main :: IO () +main = putStrLn "Test suite not yet implemented." +#endif