diff --git a/Cabal/Cabal.cabal b/Cabal/Cabal.cabal index 1383588445d..a2873501231 100644 --- a/Cabal/Cabal.cabal +++ b/Cabal/Cabal.cabal @@ -125,7 +125,6 @@ library Distribution.Simple.FileMonitor.Types Distribution.Simple.Flag Distribution.Simple.GHC - Distribution.Simple.GHCJS Distribution.Simple.Haddock Distribution.Simple.Glob Distribution.Simple.Glob.Internal diff --git a/Cabal/src/Distribution/Simple/Build.hs b/Cabal/src/Distribution/Simple/Build.hs index 2e41bb1aa35..4d40d7da6b5 100644 --- a/Cabal/src/Distribution/Simple/Build.hs +++ b/Cabal/src/Distribution/Simple/Build.hs @@ -70,7 +70,6 @@ import Distribution.Backpack import Distribution.Backpack.DescribeUnitId import Distribution.Package import qualified Distribution.Simple.GHC as GHC -import qualified Distribution.Simple.GHCJS as GHCJS import qualified Distribution.Simple.PackageIndex as Index import qualified Distribution.Simple.UHC as UHC @@ -311,7 +310,6 @@ dumpBuildInfo verbosity distPref dumpBuildInfoFlag pkg_descr lbi flags = do -- which program we need. flavorToProgram :: CompilerFlavor -> Maybe Program flavorToProgram GHC = Just ghcProgram - flavorToProgram GHCJS = Just ghcjsProgram flavorToProgram UHC = Just uhcProgram flavorToProgram JHC = Just jhcProgram flavorToProgram _ = Nothing @@ -443,7 +441,6 @@ startInterpreter startInterpreter verbosity programDb comp platform packageDBs = case compilerFlavor comp of GHC -> GHC.startInterpreter verbosity programDb comp platform packageDBs - GHCJS -> GHCJS.startInterpreter verbosity programDb comp platform packageDBs _ -> dieWithException verbosity REPLNotSupported buildComponent @@ -983,7 +980,6 @@ buildLib verbHandles flags numJobs pkg_descr lbi lib clbi = let verbosity = mkVerbosity verbHandles $ fromFlag $ buildVerbosity flags in case compilerFlavor (compiler lbi) of GHC -> GHC.buildLib verbHandles flags numJobs pkg_descr lbi lib clbi - GHCJS -> GHCJS.buildLib verbosity numJobs pkg_descr lbi lib clbi UHC -> UHC.buildLib verbosity pkg_descr lbi lib clbi _ -> dieWithException verbosity BuildingNotSupportedWithCompiler @@ -1015,7 +1011,6 @@ buildExe buildExe verbosity numJobs pkg_descr lbi exe clbi = case compilerFlavor (compiler lbi) of GHC -> GHC.buildExe verbosity numJobs pkg_descr lbi exe clbi - GHCJS -> GHCJS.buildExe verbosity numJobs pkg_descr lbi exe clbi UHC -> UHC.buildExe verbosity pkg_descr lbi exe clbi _ -> dieWithException verbosity BuildingNotSupportedWithCompiler @@ -1029,12 +1024,10 @@ replLib -> IO () replLib verbHandles replFlags pkg_descr lbi lib clbi = let verbosity = mkVerbosity verbHandles (fromFlag $ replVerbosity replFlags) - opts = replReplOptions replFlags in case compilerFlavor (compiler lbi) of -- 'cabal repl' doesn't need to support 'ghc --make -j', so we just pass -- NoFlag as the numJobs parameter. GHC -> GHC.replLib verbHandles replFlags NoFlag pkg_descr lbi lib clbi - GHCJS -> GHCJS.replLib (replOptionsFlags opts) verbosity NoFlag pkg_descr lbi lib clbi _ -> dieWithException verbosity REPLNotSupported replExe @@ -1049,15 +1042,6 @@ replExe verbHandles flags pkg_descr lbi exe clbi = let verbosity = mkVerbosity verbHandles $ fromFlag $ replVerbosity flags in case compilerFlavor (compiler lbi) of GHC -> GHC.replExe verbHandles flags NoFlag pkg_descr lbi exe clbi - GHCJS -> - GHCJS.replExe - (replOptionsFlags $ replReplOptions flags) - verbosity - NoFlag - pkg_descr - lbi - exe - clbi _ -> dieWithException verbosity REPLNotSupported replFLib diff --git a/Cabal/src/Distribution/Simple/Build/PathsModule.hs b/Cabal/src/Distribution/Simple/Build/PathsModule.hs index 525c19598b8..d26dd9917a7 100644 --- a/Cabal/src/Distribution/Simple/Build/PathsModule.hs +++ b/Cabal/src/Distribution/Simple/Build/PathsModule.hs @@ -73,7 +73,6 @@ generatePathsModule pkg_descr lbi clbi = _ -> False supportsRelocatableProgs GHC = isWindows - supportsRelocatableProgs GHCJS = isWindows supportsRelocatableProgs _ = False cid = componentUnitId clbi diff --git a/Cabal/src/Distribution/Simple/Compiler.hs b/Cabal/src/Distribution/Simple/Compiler.hs index fbf159f11a6..629ded37533 100644 --- a/Cabal/src/Distribution/Simple/Compiler.hs +++ b/Cabal/src/Distribution/Simple/Compiler.hs @@ -158,7 +158,7 @@ compilerVersion = (\(CompilerId _ v) -> v) . compilerId -- | Is this compiler compatible with the compiler flavour we're interested in? -- -- For example this checks if the compiler is actually GHC or is another --- compiler that claims to be compatible with some version of GHC, e.g. GHCJS. +-- compiler that claims to be compatible with some version of GHC. -- -- > if compilerCompatFlavor GHC compiler then ... else ... compilerCompatFlavor :: CompilerFlavor -> Compiler -> Bool @@ -517,7 +517,6 @@ coverageSupported :: Compiler -> Bool coverageSupported comp = case compilerFlavor comp of GHC -> True - GHCJS -> True _ -> False -- | Does this compiler support profiling? @@ -525,7 +524,6 @@ profilingSupported :: Compiler -> Bool profilingSupported comp = case compilerFlavor comp of GHC -> True - GHCJS -> True _ -> False -- | Returns Just if we can certainly determine whether a way is supported @@ -595,7 +593,6 @@ ghcSupported :: String -> Compiler -> Bool ghcSupported key comp = case compilerFlavor comp of GHC -> checkProp - GHCJS -> checkProp _ -> False where checkProp = diff --git a/Cabal/src/Distribution/Simple/Configure.hs b/Cabal/src/Distribution/Simple/Configure.hs index 53c3b35caa0..cd7d13d397f 100644 --- a/Cabal/src/Distribution/Simple/Configure.hs +++ b/Cabal/src/Distribution/Simple/Configure.hs @@ -130,7 +130,6 @@ import Distribution.Verbosity import Distribution.Version import qualified Distribution.Simple.GHC as GHC -import qualified Distribution.Simple.GHCJS as GHCJS import qualified Distribution.Simple.UHC as UHC import Control.Exception @@ -823,8 +822,6 @@ buildOptionsFromConfigFlags verbosity cfg comp = do -- been changed to read shared libraries instead of archive -- files (see next code block). GHC.compilerBuildWay comp `notElem` [DynWay, ProfDynWay] - CompilerId GHCJS _ -> - not (GHCJS.isDynamic comp) _ -> False let sharedLibsByDefault @@ -837,8 +834,6 @@ buildOptionsFromConfigFlags verbosity cfg comp = do -- if ghc is dynamic, then ghci needs a shared -- library, so we build one by default. GHC.compilerBuildWay comp == DynWay - CompilerId GHCJS _ -> - GHCJS.isDynamic comp _ -> False withSharedLib_ = -- build shared libraries if required by GHC or by the @@ -932,13 +927,11 @@ adjustBuildOptions comp programDb opts = | GHC <- compilerFlavor comp , compilerVersion comp >= mkVersion [8, 0] = True - | GHCJS <- compilerFlavor comp = True | otherwise = False -- not supported by this compiler splitObj | not (LBC.splitObjs opts) = False | splitSec = False -- mutually exclusive with split-sections | GHC <- compilerFlavor comp = True - | GHCJS <- compilerFlavor comp = True | otherwise = False -- not supported by this compiler linkerSupportsRelocations :: Maybe Bool linkerSupportsRelocations = @@ -2254,7 +2247,6 @@ getInstalledPackages verbosity comp mbWorkDir packageDBs progdb = do packageDBs' <- filterM packageDBExists packageDBs case compilerFlavor comp of GHC -> GHC.getInstalledPackages verbosity mbWorkDir packageDBs' progdb - GHCJS -> GHCJS.getInstalledPackages verbosity mbWorkDir packageDBs' progdb UHC -> UHC.getInstalledPackages verbosity comp mbWorkDir packageDBs' progdb flv -> dieWithException verbosity $ HowToFindInstalledPackages flv @@ -2289,8 +2281,6 @@ getPackageDBContents verbosity comp mbWorkDir packageDB progdb = do info verbosity "Reading installed packages..." case compilerFlavor comp of GHC -> GHC.getPackageDBContents verbosity mbWorkDir packageDB progdb - GHCJS -> GHCJS.getPackageDBContents verbosity mbWorkDir packageDB progdb - -- For other compilers, try to fall back on 'getInstalledPackages'. _ -> getInstalledPackages verbosity comp mbWorkDir [packageDB] progdb -- | A set of files (or directories) that can be monitored to detect when @@ -2688,8 +2678,8 @@ configCompilerEx Nothing _ _ _ verbosity = dieWithException verbosity UnknownCom configCompilerEx (Just hcFlavor) hcPath hcPkg progdb verbosity = do (comp, maybePlatform, programDb) <- case hcFlavor of GHC -> GHC.configure verbosity hcPath hcPkg progdb - GHCJS -> GHCJS.configure verbosity hcPath hcPkg progdb UHC -> UHC.configure verbosity hcPath progdb + GHCJS -> dieWithException verbosity GHCJSNotSupported _ -> dieWithException verbosity UnknownCompilerException return (comp, fromMaybe buildPlatform maybePlatform, programDb) @@ -2708,8 +2698,8 @@ configCompiler mbFlavor hcPath progdb verbosity = do Just hcFlavor -> case hcFlavor of GHC -> GHC.configureCompiler verbosity hcPath progdb - GHCJS -> GHCJS.configureCompiler verbosity hcPath progdb UHC -> UHC.configure verbosity hcPath progdb + GHCJS -> dieWithException verbosity GHCJSNotSupported _ -> dieWithException verbosity UnknownCompilerException return (comp, fromMaybe buildPlatform maybePlatform, programDb) @@ -2726,7 +2716,6 @@ configCompilerProgDb configCompilerProgDb verbosity comp hcProgDb hcPkgPath = do case compilerFlavor comp of GHC -> GHC.compilerProgramDb verbosity comp hcProgDb hcPkgPath - GHCJS -> GHCJS.compilerProgramDb verbosity comp hcProgDb hcPkgPath _ -> return hcProgDb -- ----------------------------------------------------------------------------- diff --git a/Cabal/src/Distribution/Simple/Errors.hs b/Cabal/src/Distribution/Simple/Errors.hs index 4dc21def00d..24b4891f0c3 100644 --- a/Cabal/src/Distribution/Simple/Errors.hs +++ b/Cabal/src/Distribution/Simple/Errors.hs @@ -81,8 +81,6 @@ data CabalException | PkgDumpFailed | FailedToParseOutput | CantFindSourceModule ModuleName - | VersionMismatchJS FilePath Version FilePath Version - | VersionMismatchGHCJS FilePath Version FilePath Version | GlobalPackageDBLimitation | GlobalPackageDBSpecifiedFirst | MatchDirFileGlob String @@ -133,6 +131,7 @@ data CabalException | PkgConfigNotFound String String | BadVersion String String PkgconfigVersion | UnknownCompilerException + | GHCJSNotSupported | NoWorkingGcc | NoOSSupport OS String | NoCompilerSupport String @@ -214,8 +213,8 @@ exceptionCode e = case e of PkgDumpFailed{} -> 2291 FailedToParseOutput{} -> 5500 CantFindSourceModule{} -> 8870 - VersionMismatchJS{} -> 9001 - VersionMismatchGHCJS{} -> 4001 + -- Retired: VersionMismatchJS{} -> 9001 + -- Retired: VersionMismatchGHCJS{} -> 4001 GlobalPackageDBLimitation{} -> 5002 GlobalPackageDBSpecifiedFirst{} -> 3901 MatchDirFileGlob{} -> 9760 @@ -267,6 +266,7 @@ exceptionCode e = case e of PkgConfigNotFound{} -> 7123 BadVersion{} -> 7600 UnknownCompilerException{} -> 3022 + GHCJSNotSupported{} -> 4002 NoWorkingGcc{} -> 1088 NoOSSupport{} -> 3339 NoCompilerSupport{} -> 2290 @@ -368,24 +368,6 @@ exceptionMessage e = case e of PkgDumpFailed -> "pkg dump failed" FailedToParseOutput -> "failed to parse output of 'pkg dump'" CantFindSourceModule moduleName -> "can't find source for module " ++ prettyShow moduleName - VersionMismatchJS ghcjsProgPath ghcjsVersion ghcjsPkgProgPath ghcjsPkgGhcjsVersion -> - "Version mismatch between ghcjs and ghcjs-pkg: " - ++ show ghcjsProgPath - ++ " is version " - ++ prettyShow ghcjsVersion - ++ " " - ++ show ghcjsPkgProgPath - ++ " is version " - ++ prettyShow ghcjsPkgGhcjsVersion - VersionMismatchGHCJS ghcjsProgPath ghcjsGhcVersion ghcjsPkgProgPath ghcjsPkgVersion -> - "Version mismatch between ghcjs and ghcjs-pkg: " - ++ show ghcjsProgPath - ++ " was built with GHC version " - ++ prettyShow ghcjsGhcVersion - ++ " " - ++ show ghcjsPkgProgPath - ++ " was built with GHC version " - ++ prettyShow ghcjsPkgVersion GlobalPackageDBLimitation -> "With current ghc versions the global package db is always used " ++ "and must be listed first. This ghc limitation may be lifted in " @@ -607,6 +589,9 @@ exceptionMessage e = case e of ++ " system is version " ++ prettyShow v UnknownCompilerException -> "Unknown compiler" + GHCJSNotSupported -> + "GHCJS is no longer supported. Use the JavaScript backend of GHC instead, " + ++ "for example with --with-compiler=javascript-unknown-ghcjs-ghc." NoWorkingGcc -> unlines [ "No working gcc" diff --git a/Cabal/src/Distribution/Simple/GHC/ImplInfo.hs b/Cabal/src/Distribution/Simple/GHC/ImplInfo.hs index 6fc9bad442e..a7899e77066 100644 --- a/Cabal/src/Distribution/Simple/GHC/ImplInfo.hs +++ b/Cabal/src/Distribution/Simple/GHC/ImplInfo.hs @@ -13,7 +13,6 @@ module Distribution.Simple.GHC.ImplInfo ( GhcImplInfo (..) , getImplInfo , ghcVersionImplInfo - , ghcjsVersionImplInfo ) where import Distribution.Compat.Prelude @@ -22,7 +21,6 @@ import Prelude () import Distribution.Simple.Compiler ( Compiler , CompilerFlavor (..) - , compilerCompatVersion , compilerFlavor , compilerVersion ) @@ -60,17 +58,10 @@ getImplInfo :: Compiler -> GhcImplInfo getImplInfo comp = case compilerFlavor comp of GHC -> ghcVersionImplInfo (compilerVersion comp) - GHCJS -> case compilerCompatVersion GHC comp of - Just ghcVer -> ghcjsVersionImplInfo (compilerVersion comp) ghcVer - _ -> - error - ( "Distribution.Simple.GHC.Props.getImplProps: " - ++ "could not find GHC version for GHCJS compiler" - ) x -> error - ( "Distribution.Simple.GHC.Props.getImplProps only works" - ++ "for GHC-like compilers (GHC, GHCJS)" + ( "Distribution.Simple.GHC.ImplInfo.getImplInfo only works" + ++ " for GHC" ++ ", but found " ++ show x ) @@ -88,22 +79,3 @@ ghcVersionImplInfo ver = } where v = versionNumbers ver - -ghcjsVersionImplInfo - :: Version - -- ^ The GHCJS version - -> Version - -- ^ The GHC version - -> GhcImplInfo -ghcjsVersionImplInfo _ghcjsver ghcver = - GhcImplInfo - { supportsGHC2021 = ghcv >= [9, 1] - , supportsGHC2024 = ghcv >= [9, 9] - , flagProfLate = ghcv >= [9, 4] - , flagHie = ghcv >= [8, 8] - , supportsPkgEnvFiles = ghcv >= [8, 0, 2] -- TODO: check this works in ghcjs - , flagWarnMissingHomeModules = ghcv >= [8, 2] - , unitIdForExes = ghcv >= [9, 2] - } - where - ghcv = versionNumbers ghcver diff --git a/Cabal/src/Distribution/Simple/GHCJS.hs b/Cabal/src/Distribution/Simple/GHCJS.hs deleted file mode 100644 index 73eed6eefde..00000000000 --- a/Cabal/src/Distribution/Simple/GHCJS.hs +++ /dev/null @@ -1,2056 +0,0 @@ -{-# LANGUAGE DataKinds #-} - -module Distribution.Simple.GHCJS - ( getGhcInfo - , configure - , configureCompiler - , compilerProgramDb - , getInstalledPackages - , getInstalledPackagesMonitorFiles - , getPackageDBContents - , buildLib - , buildFLib - , buildExe - , replLib - , replFLib - , replExe - , startInterpreter - , installLib - , installFLib - , installExe - , libAbiHash - , hcPkgInfo - , registerPackage - , componentGhcOptions - , getLibDir - , isDynamic - , getGlobalPackageDB - , pkgRoot - , runCmd - - -- * Constructing and deconstructing GHC environment files - , Internal.GhcEnvironmentFileEntry (..) - , Internal.simpleGhcEnvironmentFile - , Internal.renderGhcEnvironmentFile - , Internal.writeGhcEnvironmentFile - , Internal.ghcPlatformAndVersionString - , readGhcEnvironmentFile - , parseGhcEnvironmentFile - , ParseErrorExc (..) - - -- * Version-specific implementation quirks - , getImplInfo - , GhcImplInfo (..) - ) where - -import Distribution.Compat.Prelude -import Prelude () - -import Distribution.CabalSpecVersion -import Distribution.InstalledPackageInfo (InstalledPackageInfo) -import qualified Distribution.InstalledPackageInfo as InstalledPackageInfo -import Distribution.ModuleName (ModuleName) -import qualified Distribution.ModuleName as ModuleName -import Distribution.Package -import Distribution.PackageDescription as PD -import Distribution.PackageDescription.Utils (cabalBug) -import Distribution.Pretty -import Distribution.Simple.BuildPaths -import Distribution.Simple.Compiler -import Distribution.Simple.Errors -import Distribution.Simple.Flag -import Distribution.Simple.GHC.Build.Link (hasThreaded) -import Distribution.Simple.GHC.Build.Utils (isCxx, isHaskell) -import Distribution.Simple.GHC.EnvironmentParser -import Distribution.Simple.GHC.ImplInfo -import qualified Distribution.Simple.GHC.Internal as Internal -import qualified Distribution.Simple.Hpc as Hpc -import Distribution.Simple.LocalBuildInfo -import Distribution.Simple.PackageIndex (InstalledPackageIndex) -import qualified Distribution.Simple.PackageIndex as PackageIndex -import Distribution.Simple.PreProcess.Types -import Distribution.Simple.Program -import Distribution.Simple.Program.GHC -import qualified Distribution.Simple.Program.HcPkg as HcPkg -import qualified Distribution.Simple.Program.Strip as Strip -import Distribution.Simple.Setup.Common -import Distribution.Simple.Utils -import Distribution.System -import Distribution.Types.ComponentLocalBuildInfo -import Distribution.Types.PackageName.Magic -import Distribution.Types.ParStrat -import Distribution.Utils.NubList -import Distribution.Utils.Path -import Distribution.Verbosity (Verbosity (..), VerbosityLevel, verbosityLevel) -import Distribution.Version - -import Control.Arrow ((***)) -import Control.Monad (msum) -import Data.Char (isLower) -import qualified Data.Map as Map -import Data.Maybe (fromJust) -import System.Directory - ( canonicalizePath - , createDirectoryIfMissing - , doesFileExist - , getAppUserDataDirectory - , renameFile - ) -import System.FilePath - ( isRelative - , replaceExtension - , takeDirectory - , takeExtension - ) -import qualified System.Info - --- ----------------------------------------------------------------------------- --- Configuring - --- | Configure GHCJS, and then auxiliary programs such as @ghc-pkg@, @haddock@ --- as well as toolchain programs such as @ar@, @ld. -configure - :: Verbosity - -> Maybe FilePath - -- ^ user-specified @ghcjs@ path (optional) - -> Maybe FilePath - -- ^ user-specified @ghcjs-pkg@ path (optional) - -> ProgramDb - -> IO (Compiler, Maybe Platform, ProgramDb) -configure verbosity hcPath hcPkgPath conf0 = do - (comp, compPlatform, progdb1) <- configureCompiler verbosity hcPath conf0 - compProgDb <- compilerProgramDb verbosity comp progdb1 hcPkgPath - return (comp, compPlatform, compProgDb) - --- | Configure GHCJS. -configureCompiler - :: Verbosity - -> Maybe FilePath - -- ^ user-specified @ghc@ path (optional) - -> ProgramDb - -> IO (Compiler, Maybe Platform, ProgramDb) -configureCompiler verbosity hcPath conf0 = do - (ghcjsProg, ghcjsVersion, progdb1) <- - requireProgramVersion - verbosity - ghcjsProgram - (orLaterVersion (mkVersion [0, 1])) - (userMaybeSpecifyPath "ghcjs" hcPath conf0) - - Just ghcjsGhcVersion <- findGhcjsGhcVersion verbosity (programPath ghcjsProg) - unless (ghcjsGhcVersion < mkVersion [8, 8]) $ - warn verbosity $ - "Unknown/unsupported 'ghc' version detected " - ++ "(Cabal " - ++ prettyShow cabalVersion - ++ " supports 'ghc' version < 8.8): " - ++ programPath ghcjsProg - ++ " is based on GHC version " - ++ prettyShow ghcjsGhcVersion - - let implInfo = ghcjsVersionImplInfo ghcjsVersion ghcjsGhcVersion - - languages <- Internal.getLanguages implInfo - extensions <- Internal.getExtensions verbosity ghcjsProg - - ghcjsInfo <- Internal.getGhcInfo verbosity implInfo ghcjsProg - let ghcInfoMap = Map.fromList ghcjsInfo - - let comp = - Compiler - { compilerId = CompilerId GHCJS ghcjsVersion - , compilerAbiTag = - AbiTag $ - "ghc" ++ intercalate "_" (map show . versionNumbers $ ghcjsGhcVersion) - , compilerCompat = [CompilerId GHC ghcjsGhcVersion] - , compilerLanguages = languages - , compilerExtensions = extensions - , compilerProperties = ghcInfoMap - , compilerWiredInUnitIds = Nothing - } - compPlatform = Internal.targetPlatform ghcjsInfo - return (comp, compPlatform, progdb1) - --- | Given a configured @ghcjs@ program, configure auxiliary programs such --- as @ghcjs-pkg@ or @haddock@, based on the location of the @ghcjs@ executable. -compilerProgramDb - :: Verbosity - -> Compiler - -> ProgramDb - -> Maybe FilePath - -- ^ user-specified @ghc-pkg@ path (optional) - -> IO ProgramDb -compilerProgramDb verbosity comp progdb1 hcPkgPath = do - let - ghcjsProg = fromJust $ lookupProgram ghcjsProgram progdb1 - ghcjsVersion = compilerVersion comp - ghcjsGhcVersion = case compilerCompat comp of - [CompilerId GHC ghcjsGhcVer] -> ghcjsGhcVer - compat -> error $ "could not parse ghcjsGhcVersion:" ++ show compat - - -- This is slightly tricky, we have to configure ghc first, then we use the - -- location of ghc to help find ghc-pkg in the case that the user did not - -- specify the location of ghc-pkg directly: - (ghcjsPkgProg, ghcjsPkgVersion, progdb2) <- - requireProgramVersion - verbosity - ghcjsPkgProgram - { programFindLocation = guessGhcjsPkgFromGhcjsPath ghcjsProg - } - anyVersion - (userMaybeSpecifyPath "ghcjs-pkg" hcPkgPath progdb1) - - Just ghcjsPkgGhcjsVersion <- - findGhcjsPkgGhcjsVersion - verbosity - (programPath ghcjsPkgProg) - - when (ghcjsVersion /= ghcjsPkgGhcjsVersion) $ - dieWithException verbosity $ - VersionMismatchJS - (programPath ghcjsProg) - ghcjsVersion - (programPath ghcjsPkgProg) - ghcjsPkgGhcjsVersion - - when (ghcjsGhcVersion /= ghcjsPkgVersion) $ - dieWithException verbosity $ - VersionMismatchGHCJS (programPath ghcjsProg) ghcjsGhcVersion (programPath ghcjsPkgProg) ghcjsPkgVersion - - -- Likewise we try to find the matching hsc2hs and haddock programs. - let hsc2hsProgram' = - hsc2hsProgram - { programFindLocation = - guessHsc2hsFromGhcjsPath ghcjsProg - } - haddockProgram' = - haddockProgram - { programFindLocation = - guessHaddockFromGhcjsPath ghcjsProg - } - hpcProgram' = - hpcProgram - { programFindLocation = guessHpcFromGhcjsPath ghcjsProg - } - {- - runghcProgram' = runghcProgram { - programFindLocation = guessRunghcFromGhcjsPath ghcjsProg - } -} - progdb3 = - addKnownProgram haddockProgram' $ - addKnownProgram hsc2hsProgram' $ - addKnownProgram hpcProgram' {- addKnownProgram runghcProgram' -} progdb2 - - return progdb3 - -guessGhcjsPkgFromGhcjsPath - :: ConfiguredProgram - -> Verbosity - -> ProgramSearchPath - -> IO (Maybe (FilePath, [FilePath])) -guessGhcjsPkgFromGhcjsPath = guessToolFromGhcjsPath ghcjsPkgProgram - -guessHsc2hsFromGhcjsPath - :: ConfiguredProgram - -> Verbosity - -> ProgramSearchPath - -> IO (Maybe (FilePath, [FilePath])) -guessHsc2hsFromGhcjsPath = guessToolFromGhcjsPath hsc2hsProgram - -guessHaddockFromGhcjsPath - :: ConfiguredProgram - -> Verbosity - -> ProgramSearchPath - -> IO (Maybe (FilePath, [FilePath])) -guessHaddockFromGhcjsPath = guessToolFromGhcjsPath haddockProgram - -guessHpcFromGhcjsPath - :: ConfiguredProgram - -> Verbosity - -> ProgramSearchPath - -> IO (Maybe (FilePath, [FilePath])) -guessHpcFromGhcjsPath = guessToolFromGhcjsPath hpcProgram - -guessToolFromGhcjsPath - :: Program - -> ConfiguredProgram - -> Verbosity - -> ProgramSearchPath - -> IO (Maybe (FilePath, [FilePath])) -guessToolFromGhcjsPath tool ghcjsProg verbosity searchpath = - do - let toolname = programName tool - given_path = programPath ghcjsProg - given_dir = takeDirectory given_path - real_path <- canonicalizePath given_path - let real_dir = takeDirectory real_path - versionSuffix path = takeVersionSuffix (dropExeExtension path) - given_suf = versionSuffix given_path - real_suf = versionSuffix real_path - guessNormal dir = dir toolname <.> exeExtension buildPlatform - guessGhcjs dir = - dir - (toolname ++ "-ghcjs") - <.> exeExtension buildPlatform - guessGhcjsVersioned dir suf = - dir - (toolname ++ "-ghcjs" ++ suf) - <.> exeExtension buildPlatform - guessVersioned dir suf = - dir - (toolname ++ suf) - <.> exeExtension buildPlatform - mkGuesses dir suf - | null suf = [guessGhcjs dir, guessNormal dir] - | otherwise = - [ guessGhcjsVersioned dir suf - , guessVersioned dir suf - , guessGhcjs dir - , guessNormal dir - ] - guesses = - mkGuesses given_dir given_suf - ++ if real_path == given_path - then [] - else mkGuesses real_dir real_suf - info verbosity $ - "looking for tool " - ++ toolname - ++ " near compiler in " - ++ given_dir - debug verbosity $ "candidate locations: " ++ show guesses - exists <- traverse doesFileExist guesses - case [file | (file, True) <- zip guesses exists] of - -- If we can't find it near ghc, fall back to the usual - -- method. - [] -> programFindLocation tool verbosity searchpath - (fp : _) -> do - info verbosity $ "found " ++ toolname ++ " in " ++ fp - let lookedAt = - map fst - . takeWhile (\(_file, exist) -> not exist) - $ zip guesses exists - return (Just (fp, lookedAt)) - where - takeVersionSuffix :: FilePath -> String - takeVersionSuffix = takeWhileEndLE isSuffixChar - - isSuffixChar :: Char -> Bool - isSuffixChar c = isDigit c || c == '.' || c == '-' - -getGhcInfo :: Verbosity -> ConfiguredProgram -> IO [(String, String)] -getGhcInfo verbosity ghcjsProg = Internal.getGhcInfo verbosity implInfo ghcjsProg - where - version = fromMaybe (error "GHCJS.getGhcInfo: no version") $ programVersion ghcjsProg - implInfo = ghcVersionImplInfo version - --- | Given a single package DB, return all installed packages. -getPackageDBContents - :: Verbosity - -> Maybe (SymbolicPath CWD (Dir from)) - -> PackageDBX (SymbolicPath from (Dir PkgDB)) - -> ProgramDb - -> IO InstalledPackageIndex -getPackageDBContents verbosity mbWorkDir packagedb progdb = do - pkgss <- getInstalledPackages' verbosity mbWorkDir [packagedb] progdb - toPackageIndex verbosity pkgss progdb - --- | Given a package DB stack, return all installed packages. -getInstalledPackages - :: Verbosity - -> Maybe (SymbolicPath CWD (Dir from)) - -> PackageDBStackX (SymbolicPath from (Dir PkgDB)) - -> ProgramDb - -> IO InstalledPackageIndex -getInstalledPackages verbosity mbWorkDir packagedbs progdb = do - checkPackageDbEnvVar verbosity - checkPackageDbStack verbosity packagedbs - pkgss <- getInstalledPackages' verbosity mbWorkDir packagedbs progdb - index <- toPackageIndex verbosity pkgss progdb - return $! index - -toPackageIndex - :: Verbosity - -> [(PackageDBX a, [InstalledPackageInfo])] - -> ProgramDb - -> IO InstalledPackageIndex -toPackageIndex verbosity pkgss progdb = do - -- On Windows, various fields have $topdir/foo rather than full - -- paths. We need to substitute the right value in so that when - -- we, for example, call gcc, we have proper paths to give it. - topDir <- getLibDir' verbosity ghcjsProg - let indices = - [ PackageIndex.fromList (map (Internal.substTopDir topDir) pkgs) - | (_, pkgs) <- pkgss - ] - return $! mconcat indices - where - ghcjsProg = fromMaybe (error "GHCJS.toPackageIndex no ghcjs program") $ lookupProgram ghcjsProgram progdb - -getLibDir :: Verbosity -> LocalBuildInfo -> IO FilePath -getLibDir verbosity lbi = - dropWhileEndLE isSpace - `fmap` getDbProgramOutput - verbosity - ghcjsProgram - (withPrograms lbi) - ["--print-libdir"] - -getLibDir' :: Verbosity -> ConfiguredProgram -> IO FilePath -getLibDir' verbosity ghcjsProg = - dropWhileEndLE isSpace - `fmap` getProgramOutput verbosity ghcjsProg ["--print-libdir"] - --- | Return the 'FilePath' to the global GHC package database. -getGlobalPackageDB :: Verbosity -> ConfiguredProgram -> IO FilePath -getGlobalPackageDB verbosity ghcProg = - dropWhileEndLE isSpace - `fmap` getProgramOutput verbosity ghcProg ["--print-global-package-db"] - --- | Return the 'FilePath' to the per-user GHC package database. -getUserPackageDB :: Verbosity -> ConfiguredProgram -> Platform -> IO FilePath -getUserPackageDB _verbosity ghcjsProg platform = do - -- It's rather annoying that we have to reconstruct this, because ghc - -- hides this information from us otherwise. But for certain use cases - -- like change monitoring it really can't remain hidden. - appdir <- getAppUserDataDirectory "ghcjs" - return (appdir platformAndVersion packageConfFileName) - where - platformAndVersion = - Internal.ghcPlatformAndVersionString - platform - ghcjsVersion - packageConfFileName = "package.conf.d" - ghcjsVersion = fromMaybe (error "GHCJS.getUserPackageDB: no version") $ programVersion ghcjsProg - -checkPackageDbEnvVar :: Verbosity -> IO () -checkPackageDbEnvVar verbosity = - Internal.checkPackageDbEnvVar verbosity "GHCJS" "GHCJS_PACKAGE_PATH" - -checkPackageDbStack :: Eq fp => Verbosity -> PackageDBStackX fp -> IO () -checkPackageDbStack _ (GlobalPackageDB : rest) - | GlobalPackageDB `notElem` rest = return () -checkPackageDbStack verbosity rest - | GlobalPackageDB `notElem` rest = - dieWithException verbosity GlobalPackageDBLimitation -checkPackageDbStack verbosity _ = - dieWithException verbosity GlobalPackageDBSpecifiedFirst - -getInstalledPackages' - :: Verbosity - -> Maybe (SymbolicPath CWD (Dir from)) - -> [PackageDBX (SymbolicPath from (Dir PkgDB))] - -> ProgramDb - -> IO [(PackageDBX (SymbolicPath from (Dir PkgDB)), [InstalledPackageInfo])] -getInstalledPackages' verbosity mbWorkDir packagedbs progdb = - sequenceA - [ do - pkgs <- HcPkg.dump (hcPkgInfo progdb) verbosity mbWorkDir packagedb - return (packagedb, pkgs) - | packagedb <- packagedbs - ] - --- | Get the packages from specific PackageDBs, not cumulative. -getInstalledPackagesMonitorFiles - :: Verbosity - -> Platform - -> Maybe (SymbolicPath CWD (Dir Pkg)) - -> ProgramDb - -> [PackageDB] - -> IO [FilePath] -getInstalledPackagesMonitorFiles verbosity platform mbWorkDir progdb = - traverse getPackageDBPath - where - getPackageDBPath :: PackageDB -> IO FilePath - getPackageDBPath GlobalPackageDB = - selectMonitorFile =<< getGlobalPackageDB verbosity ghcjsProg - getPackageDBPath UserPackageDB = - selectMonitorFile =<< getUserPackageDB verbosity ghcjsProg platform - getPackageDBPath (SpecificPackageDB path) = selectMonitorFile (interpretSymbolicPath mbWorkDir path) - - -- GHC has old style file dbs, and new style directory dbs. - -- Note that for dir style dbs, we only need to monitor the cache file, not - -- the whole directory. The ghc program itself only reads the cache file - -- so it's safe to only monitor this one file. - selectMonitorFile path0 = do - let path = - if isRelative path0 - then interpretSymbolicPath mbWorkDir (makeRelativePathEx path0) - else path0 - isFileStyle <- doesFileExist path - if isFileStyle - then return path - else return (path "package.cache") - - ghcjsProg = fromMaybe (error "GHCJS.toPackageIndex no ghcjs program") $ lookupProgram ghcjsProgram progdb - -toJSLibName :: String -> String -toJSLibName lib - | takeExtension lib `elem` [".dll", ".dylib", ".so"] = - replaceExtension lib "js_so" - | takeExtension lib == ".a" = replaceExtension lib "js_a" - | otherwise = lib <.> "js_a" - --- ----------------------------------------------------------------------------- --- Building a library - -buildLib - :: Verbosity - -> Flag ParStrat - -> PackageDescription - -> LocalBuildInfo - -> Library - -> ComponentLocalBuildInfo - -> IO () -buildLib = buildOrReplLib Nothing - -replLib - :: [String] - -> Verbosity - -> Flag ParStrat - -> PackageDescription - -> LocalBuildInfo - -> Library - -> ComponentLocalBuildInfo - -> IO () -replLib = buildOrReplLib . Just - -buildOrReplLib - :: Maybe [String] - -> Verbosity - -> Flag ParStrat - -> PackageDescription - -> LocalBuildInfo - -> Library - -> ComponentLocalBuildInfo - -> IO () -buildOrReplLib mReplFlags verbosity numJobs _pkg_descr lbi lib clbi = do - let uid = componentUnitId clbi - libTargetDir = componentBuildDir lbi clbi - whenVanillaLib forceVanilla = - when (forceVanilla || withVanillaLib lbi) - whenProfLib = when (withProfLib lbi) - whenSharedLib forceShared = - when (forceShared || withSharedLib lbi) - whenStaticLib forceStatic = - when (forceStatic || withStaticLib lbi) - -- whenGHCiLib = when (withGHCiLib lbi) - forRepl = isJust mReplFlags - -- ifReplLib = when forRepl - comp = compiler lbi - implInfo = getImplInfo comp - platform@(Platform _hostArch _hostOS) = hostPlatform lbi - has_code = not (componentIsIndefinite clbi) - mbWorkDir = mbWorkDirLBI lbi - - -- See Note [Symbolic paths] in Distribution.Utils.Path - i = interpretSymbolicPathLBI lbi - u :: SymbolicPathX allowAbs Pkg to -> FilePath - u = getSymbolicPath - - (ghcjsProg, _) <- requireProgram verbosity ghcjsProgram (withPrograms lbi) - let runGhcjsProg = runGHC verbosity ghcjsProg comp platform mbWorkDir - - let libBi = libBuildInfo lib - - -- fixme flags shouldn't depend on ghcjs being dynamic or not - let isGhcjsDynamic = isDynamic comp - dynamicTooSupported = supportsDynamicToo comp - doingTH = usesTemplateHaskellOrQQ libBi - forceVanillaLib = doingTH && not isGhcjsDynamic - forceSharedLib = doingTH && isGhcjsDynamic - -- TH always needs default libs, even when building for profiling - - -- Determine if program coverage should be enabled and if so, what - -- '-hpcdir' should be. - let isCoverageEnabled = libCoverage lbi - hpcdir way - | forRepl = mempty -- HPC is not supported in ghci - | isCoverageEnabled = toFlag $ Hpc.mixDir (coerceSymbolicPath libTargetDir coerceSymbolicPath extraCompilationArtifacts) way - | otherwise = mempty - - createDirectoryIfMissingVerbose verbosity True $ i libTargetDir - -- TODO: do we need to put hs-boot files into place for mutually recursive - -- modules? - let cLikeFiles = fromNubListR $ toNubListR (cSources libBi) <> toNubListR (cxxSources libBi) - jsSrcs = jsSources libBi - cObjs = map (`replaceExtensionSymbolicPath` objExtension) cLikeFiles - baseOpts = componentGhcOptions (verbosityLevel verbosity) lbi libBi clbi libTargetDir - linkJsLibOpts = - mempty - { ghcOptExtra = - [ "-link-js-lib" - , getHSLibraryName uid - , "-js-lib-outputdir" - , u libTargetDir - ] - ++ map u jsSrcs - } - vanillaOptsNoJsLib = - baseOpts - <> mempty - { ghcOptMode = toFlag GhcModeMake - , ghcOptNumJobs = numJobs - , ghcOptInputModules = toNubListR $ allLibModules lib clbi - , ghcOptHPCDir = hpcdir Hpc.Vanilla - } - vanillaOpts = vanillaOptsNoJsLib <> linkJsLibOpts - - profOpts = - adjustExts "p_hi" "p_o" vanillaOpts - <> mempty - { ghcOptProfilingMode = toFlag True - , ghcOptProfilingAuto = - Internal.profDetailLevelFlag - True - (withProfLibDetail lbi) - , -- ghcOptHiSuffix = toFlag "p_hi", - -- ghcOptObjSuffix = toFlag "p_o", - ghcOptExtra = hcProfOptions GHC libBi - , ghcOptHPCDir = hpcdir Hpc.Prof - } - - sharedOpts = - adjustExts "dyn_hi" "dyn_o" vanillaOpts - <> mempty - { ghcOptDynLinkMode = toFlag GhcDynamicOnly - , ghcOptFPic = toFlag True - , -- ghcOptHiSuffix = toFlag "dyn_hi", - -- ghcOptObjSuffix = toFlag "dyn_o", - ghcOptExtra = hcOptions GHC libBi ++ hcSharedOptions GHC libBi - , ghcOptHPCDir = hpcdir Hpc.Dyn - } - - vanillaSharedOpts = - vanillaOpts - <> mempty - { ghcOptDynLinkMode = toFlag GhcStaticAndDynamic - , ghcOptDynHiSuffix = toFlag "js_dyn_hi" - , ghcOptDynObjSuffix = toFlag "js_dyn_o" - , ghcOptHPCDir = hpcdir Hpc.Dyn - } - - unless (forRepl || null (allLibModules lib clbi) && null jsSrcs && null cObjs) $ - do - let vanilla = whenVanillaLib forceVanillaLib (runGhcjsProg vanillaOpts) - shared = whenSharedLib forceSharedLib (runGhcjsProg sharedOpts) - useDynToo = - dynamicTooSupported - && (forceVanillaLib || withVanillaLib lbi) - && (forceSharedLib || withSharedLib lbi) - && null (hcSharedOptions GHC libBi) - if not has_code - then vanilla - else - if useDynToo - then do - runGhcjsProg vanillaSharedOpts - case (hpcdir Hpc.Dyn, hpcdir Hpc.Vanilla) of - (Flag dynDir, Flag vanillaDir) -> - -- When the vanilla and shared library builds are done - -- in one pass, only one set of HPC module interfaces - -- are generated. This set should suffice for both - -- static and dynamically linked executables. We copy - -- the modules interfaces so they are available under - -- both ways. - copyDirectoryRecursive verbosity (i dynDir) (i vanillaDir) - _ -> return () - else - if isGhcjsDynamic - then do shared; vanilla - else do vanilla; shared - whenProfLib (runGhcjsProg profOpts) - - -- Build any C++ sources separately. - {- - unless (not has_code || null (cxxSources libBi) || not nativeToo) $ do - info verbosity "Building C++ Sources..." - sequence_ - [ do let baseCxxOpts = Internal.componentCxxGhcOptions verbosity implInfo - lbi libBi clbi libTargetDir filename - vanillaCxxOpts = if isGhcjsDynamic - then baseCxxOpts { ghcOptFPic = toFlag True } - else baseCxxOpts - profCxxOpts = vanillaCxxOpts <> mempty { - ghcOptProfilingMode = toFlag True, - ghcOptObjSuffix = toFlag "p_o" - } - sharedCxxOpts = vanillaCxxOpts <> mempty { - ghcOptFPic = toFlag True, - ghcOptDynLinkMode = toFlag GhcDynamicOnly, - ghcOptObjSuffix = toFlag "dyn_o" - } - odir = fromFlag (ghcOptObjDir vanillaCxxOpts) - createDirectoryIfMissingVerbose verbosity True odir - let runGhcProgIfNeeded cxxOpts = do - needsRecomp <- checkNeedsRecompilation filename cxxOpts - when needsRecomp $ runGhcjsProg cxxOpts - runGhcProgIfNeeded vanillaCxxOpts - unless forRepl $ - whenSharedLib forceSharedLib (runGhcProgIfNeeded sharedCxxOpts) - unless forRepl $ whenProfLib (runGhcProgIfNeeded profCxxOpts) - | filename <- cxxSources libBi] - - ifReplLib $ do - when (null (allLibModules lib clbi)) $ warn verbosity "No exposed modules" - ifReplLib (runGhcjsProg replOpts) - -} - -- build any C sources - -- TODO: Add support for S and CMM files. - {- - unless (not has_code || null (cSources libBi) || not nativeToo) $ do - info verbosity "Building C Sources..." - sequence_ - [ do let baseCcOpts = Internal.componentCcGhcOptions verbosity implInfo - lbi libBi clbi libTargetDir filename - vanillaCcOpts = if isGhcjsDynamic - -- Dynamic GHC requires C sources to be built - -- with -fPIC for REPL to work. See #2207. - then baseCcOpts { ghcOptFPic = toFlag True } - else baseCcOpts - profCcOpts = vanillaCcOpts <> mempty { - ghcOptProfilingMode = toFlag True, - ghcOptObjSuffix = toFlag "p_o" - } - sharedCcOpts = vanillaCcOpts <> mempty { - ghcOptFPic = toFlag True, - ghcOptDynLinkMode = toFlag GhcDynamicOnly, - ghcOptObjSuffix = toFlag "dyn_o" - } - odir = fromFlag (ghcOptObjDir vanillaCcOpts) - createDirectoryIfMissingVerbose verbosity True odir - let runGhcProgIfNeeded ccOpts = do - needsRecomp <- checkNeedsRecompilation filename ccOpts - when needsRecomp $ runGhcjsProg ccOpts - runGhcProgIfNeeded vanillaCcOpts - unless forRepl $ - whenSharedLib forceSharedLib (runGhcProgIfNeeded sharedCcOpts) - unless forRepl $ whenProfLib (runGhcProgIfNeeded profCcOpts) - | filename <- cSources libBi] - -} - -- TODO: problem here is we need the .c files built first, so we can load them - -- with ghci, but .c files can depend on .h files generated by ghc by ffi - -- exports. - - -- link: - - when has_code . when False {- fixme nativeToo -} . unless forRepl $ do - info verbosity "Linking..." - let cSharedObjs = - map - (`replaceExtensionSymbolicPath` ("dyn_" ++ objExtension)) - (cSources libBi ++ cxxSources libBi) - compiler_id = compilerId (compiler lbi) - sharedLibFilePath = libTargetDir makeRelativePathEx (mkSharedLibName (hostPlatform lbi) compiler_id uid) - staticLibFilePath = libTargetDir makeRelativePathEx (mkStaticLibName (hostPlatform lbi) compiler_id uid) - - let stubObjs = [] - stubSharedObjs = [] - - hObjs <- - Internal.getHaskellObjects - implInfo - lib - lbi - clbi - (coerceSymbolicPath libTargetDir) - objExtension - True - hSharedObjs <- - if withSharedLib lbi - then - Internal.getHaskellObjects - implInfo - lib - lbi - clbi - (coerceSymbolicPath libTargetDir) - ("dyn_" ++ objExtension) - False - else return [] - - unless (null hObjs && null cObjs && null stubObjs) $ do - rpaths <- getRPaths lbi clbi - - let staticObjectFiles = - hObjs - ++ map (makeSymbolicPath . (getSymbolicPath libTargetDir ) . getSymbolicPath) cObjs - ++ stubObjs - dynamicObjectFiles = - hSharedObjs - ++ map (makeSymbolicPath . (getSymbolicPath libTargetDir ) . getSymbolicPath) cSharedObjs - ++ stubSharedObjs - -- After the relocation lib is created we invoke ghc -shared - -- with the dependencies spelled out as -package arguments - -- and ghc invokes the linker with the proper library paths - ghcSharedLinkArgs = - mempty - { ghcOptShared = toFlag True - , ghcOptDynLinkMode = toFlag GhcDynamicOnly - , ghcOptInputFiles = toNubListR dynamicObjectFiles - , ghcOptOutputFile = toFlag sharedLibFilePath - , ghcOptExtra = hcOptions GHC libBi ++ hcSharedOptions GHC libBi - , ghcOptHideAllPackages = toFlag True - , ghcOptNoAutoLinkPackages = toFlag True - , ghcOptPackageDBs = withPackageDB lbi - , ghcOptThisUnitId = case clbi of - LibComponentLocalBuildInfo{componentCompatPackageKey = pk} -> - toFlag pk - _ -> mempty - , ghcOptThisComponentId = case clbi of - LibComponentLocalBuildInfo{componentInstantiatedWith = insts} -> - if null insts - then mempty - else toFlag (componentComponentId clbi) - _ -> mempty - , ghcOptInstantiatedWith = case clbi of - LibComponentLocalBuildInfo{componentInstantiatedWith = insts} -> - insts - _ -> [] - , ghcOptPackages = - toNubListR $ - Internal.mkGhcOptPackages mempty clbi - , ghcOptLinkLibs = extraLibs libBi - , ghcOptLinkLibPath = toNubListR $ extraLibDirs libBi - , ghcOptLinkFrameworks = toNubListR $ map getSymbolicPath $ PD.frameworks libBi - , ghcOptLinkFrameworkDirs = - toNubListR $ PD.extraFrameworkDirs libBi - , ghcOptRPaths = rpaths - } - ghcStaticLinkArgs = - mempty - { ghcOptStaticLib = toFlag True - , ghcOptInputFiles = toNubListR staticObjectFiles - , ghcOptOutputFile = toFlag staticLibFilePath - , ghcOptExtra = hcStaticOptions GHC libBi - , ghcOptHideAllPackages = toFlag True - , ghcOptNoAutoLinkPackages = toFlag True - , ghcOptPackageDBs = withPackageDB lbi - , ghcOptThisUnitId = case clbi of - LibComponentLocalBuildInfo{componentCompatPackageKey = pk} -> - toFlag pk - _ -> mempty - , ghcOptThisComponentId = case clbi of - LibComponentLocalBuildInfo{componentInstantiatedWith = insts} -> - if null insts - then mempty - else toFlag (componentComponentId clbi) - _ -> mempty - , ghcOptInstantiatedWith = case clbi of - LibComponentLocalBuildInfo{componentInstantiatedWith = insts} -> - insts - _ -> [] - , ghcOptPackages = - toNubListR $ - Internal.mkGhcOptPackages mempty clbi - , ghcOptLinkLibs = extraLibs libBi - , ghcOptLinkLibPath = toNubListR $ extraLibDirs libBi - } - - info verbosity (show (ghcOptPackages ghcSharedLinkArgs)) - {- - whenVanillaLib False $ do - Ar.createArLibArchive verbosity lbi vanillaLibFilePath staticObjectFiles - whenGHCiLib $ do - (ldProg, _) <- requireProgram verbosity ldProgram (withPrograms lbi) - Ld.combineObjectFiles verbosity lbi ldProg - ghciLibFilePath staticObjectFiles - -} - {- - whenProfLib $ do - Ar.createArLibArchive verbosity lbi profileLibFilePath profObjectFiles - whenGHCiLib $ do - (ldProg, _) <- requireProgram verbosity ldProgram (withPrograms lbi) - Ld.combineObjectFiles verbosity lbi ldProg - ghciProfLibFilePath profObjectFiles - -} - whenSharedLib False $ - runGhcjsProg ghcSharedLinkArgs - - whenStaticLib False $ - runGhcjsProg ghcStaticLinkArgs - --- | Start a REPL without loading any source files. -startInterpreter - :: Verbosity - -> ProgramDb - -> Compiler - -> Platform - -> PackageDBStack - -> IO () -startInterpreter verbosity progdb comp platform packageDBs = do - let replOpts = - mempty - { ghcOptMode = toFlag GhcModeInteractive - , ghcOptPackageDBs = packageDBs - } - checkPackageDbStack verbosity packageDBs - (ghcjsProg, _) <- requireProgram verbosity ghcjsProgram progdb - runGHC verbosity ghcjsProg comp platform Nothing replOpts - --- ----------------------------------------------------------------------------- --- Building an executable or foreign library - --- | Build a foreign library -buildFLib - :: Verbosity - -> Flag ParStrat - -> PackageDescription - -> LocalBuildInfo - -> ForeignLib - -> ComponentLocalBuildInfo - -> IO () -buildFLib v njobs pkg lbi = gbuild v njobs pkg lbi . GBuildFLib - -replFLib - :: [String] - -> Verbosity - -> Flag ParStrat - -> PackageDescription - -> LocalBuildInfo - -> ForeignLib - -> ComponentLocalBuildInfo - -> IO () -replFLib replFlags v njobs pkg lbi = - gbuild v njobs pkg lbi . GReplFLib replFlags - --- | Build an executable with GHC. -buildExe - :: Verbosity - -> Flag ParStrat - -> PackageDescription - -> LocalBuildInfo - -> Executable - -> ComponentLocalBuildInfo - -> IO () -buildExe v njobs pkg lbi = gbuild v njobs pkg lbi . GBuildExe - -replExe - :: [String] - -> Verbosity - -> Flag ParStrat - -> PackageDescription - -> LocalBuildInfo - -> Executable - -> ComponentLocalBuildInfo - -> IO () -replExe replFlags v njobs pkg lbi = - gbuild v njobs pkg lbi . GReplExe replFlags - --- | Building an executable, starting the REPL, and building foreign --- libraries are all very similar and implemented in 'gbuild'. The --- 'GBuildMode' distinguishes between the various kinds of operation. -data GBuildMode - = GBuildExe Executable - | GReplExe [String] Executable - | GBuildFLib ForeignLib - | GReplFLib [String] ForeignLib - -gbuildInfo :: GBuildMode -> BuildInfo -gbuildInfo (GBuildExe exe) = buildInfo exe -gbuildInfo (GReplExe _ exe) = buildInfo exe -gbuildInfo (GBuildFLib flib) = foreignLibBuildInfo flib -gbuildInfo (GReplFLib _ flib) = foreignLibBuildInfo flib - -gbuildName :: GBuildMode -> String -gbuildName (GBuildExe exe) = unUnqualComponentName $ exeName exe -gbuildName (GReplExe _ exe) = unUnqualComponentName $ exeName exe -gbuildName (GBuildFLib flib) = unUnqualComponentName $ foreignLibName flib -gbuildName (GReplFLib _ flib) = unUnqualComponentName $ foreignLibName flib - -gbuildTargetName :: LocalBuildInfo -> GBuildMode -> String -gbuildTargetName lbi (GBuildExe exe) = exeTargetName (hostPlatform lbi) exe -gbuildTargetName lbi (GReplExe _ exe) = exeTargetName (hostPlatform lbi) exe -gbuildTargetName lbi (GBuildFLib flib) = flibTargetName lbi flib -gbuildTargetName lbi (GReplFLib _ flib) = flibTargetName lbi flib - -exeTargetName :: Platform -> Executable -> String -exeTargetName platform exe = unUnqualComponentName (exeName exe) `withExt` exeExtension platform - --- | Target name for a foreign library (the actual file name) --- --- We do not use mkLibName and co here because the naming for foreign libraries --- is slightly different (we don't use "_p" or compiler version suffices, and we --- don't want the "lib" prefix on Windows). --- --- TODO: We do use `dllExtension` and co here, but really that's wrong: they --- use the OS used to build cabal to determine which extension to use, rather --- than the target OS (but this is wrong elsewhere in Cabal as well). -flibTargetName :: LocalBuildInfo -> ForeignLib -> String -flibTargetName lbi flib = - case (os, foreignLibType flib) of - (Windows, ForeignLibNativeShared) -> nm <.> "dll" - (Windows, ForeignLibNativeStatic) -> nm <.> "lib" - (Linux, ForeignLibNativeShared) -> "lib" ++ nm <.> versionedExt - (_other, ForeignLibNativeShared) -> "lib" ++ nm <.> dllExtension (hostPlatform lbi) - (_other, ForeignLibNativeStatic) -> "lib" ++ nm <.> staticLibExtension (hostPlatform lbi) - (_any, ForeignLibTypeUnknown) -> cabalBug "unknown foreign lib type" - where - nm :: String - nm = unUnqualComponentName $ foreignLibName flib - - os :: OS - os = - let (Platform _ os') = hostPlatform lbi - in os' - - -- If a foreign lib foo has lib-version-info 5:1:2 or - -- lib-version-linux 3.2.1, it should be built as libfoo.so.3.2.1 - -- Libtool's version-info data is translated into library versions in a - -- nontrivial way: so refer to libtool documentation. - versionedExt :: String - versionedExt = - let nums = foreignLibVersion flib os - in foldl (<.>) "so" (map show nums) - --- | Name for the library when building. --- --- If the `lib-version-info` field or the `lib-version-linux` field of --- a foreign library target is set, we need to incorporate that --- version into the SONAME field. --- --- If a foreign library foo has lib-version-info 5:1:2, it should be --- built as libfoo.so.3.2.1. We want it to get soname libfoo.so.3. --- However, GHC does not allow overriding soname by setting linker --- options, as it sets a soname of its own (namely the output --- filename), after the user-supplied linker options. Hence, we have --- to compile the library with the soname as its filename. We rename --- the compiled binary afterwards. --- --- This method allows to adjust the name of the library at build time --- such that the correct soname can be set. -flibBuildName :: LocalBuildInfo -> ForeignLib -> String -flibBuildName lbi flib - -- On linux, if a foreign-library has version data, the first digit is used - -- to produce the SONAME. - | (os, foreignLibType flib) - == (Linux, ForeignLibNativeShared) = - let nums = foreignLibVersion flib os - in "lib" ++ nm <.> foldl (<.>) "so" (map show (take 1 nums)) - | otherwise = flibTargetName lbi flib - where - os :: OS - os = - let (Platform _ os') = hostPlatform lbi - in os' - - nm :: String - nm = unUnqualComponentName $ foreignLibName flib - -gbuildIsRepl :: GBuildMode -> Bool -gbuildIsRepl (GBuildExe _) = False -gbuildIsRepl (GReplExe _ _) = True -gbuildIsRepl (GBuildFLib _) = False -gbuildIsRepl (GReplFLib _ _) = True - -gbuildNeedDynamic :: LocalBuildInfo -> GBuildMode -> Bool -gbuildNeedDynamic lbi bm = - case bm of - GBuildExe _ -> withDynExe lbi - GReplExe _ _ -> withDynExe lbi - GBuildFLib flib -> withDynFLib flib - GReplFLib _ flib -> withDynFLib flib - where - withDynFLib flib = - case foreignLibType flib of - ForeignLibNativeShared -> - ForeignLibStandalone `notElem` foreignLibOptions flib - ForeignLibNativeStatic -> - False - ForeignLibTypeUnknown -> - cabalBug "unknown foreign lib type" - -gbuildModDefFiles :: GBuildMode -> [RelativePath Source File] -gbuildModDefFiles (GBuildExe _) = [] -gbuildModDefFiles (GReplExe _ _) = [] -gbuildModDefFiles (GBuildFLib flib) = foreignLibModDefFile flib -gbuildModDefFiles (GReplFLib _ flib) = foreignLibModDefFile flib - --- | "Main" module name when overridden by @ghc-options: -main-is ...@ --- or 'Nothing' if no @-main-is@ flag could be found. --- --- In case of 'Nothing', 'Distribution.ModuleName.main' can be assumed. -exeMainModuleName :: Executable -> Maybe ModuleName -exeMainModuleName Executable{buildInfo = bnfo} = - -- GHC honors the last occurrence of a module name updated via -main-is - -- - -- Moreover, -main-is when parsed left-to-right can update either - -- the "Main" module name, or the "main" function name, or both, - -- see also 'decodeMainIsArg'. - msum $ reverse $ map decodeMainIsArg $ findIsMainArgs ghcopts - where - ghcopts = hcOptions GHC bnfo - - findIsMainArgs [] = [] - findIsMainArgs ("-main-is" : arg : rest) = arg : findIsMainArgs rest - findIsMainArgs (_ : rest) = findIsMainArgs rest - --- | Decode argument to '-main-is' --- --- Returns 'Nothing' if argument set only the function name. --- --- This code has been stolen/refactored from GHC's DynFlags.setMainIs --- function. The logic here is deliberately imperfect as it is --- intended to be bug-compatible with GHC's parser. See discussion in --- https://github.com/haskell/cabal/pull/4539#discussion_r118981753. -decodeMainIsArg :: String -> Maybe ModuleName -decodeMainIsArg arg - | headOf main_fn isLower = - -- The arg looked like "Foo.Bar.baz" - Just (ModuleName.fromString main_mod) - | headOf arg isUpper -- The arg looked like "Foo" or "Foo.Bar" - = - Just (ModuleName.fromString arg) - | otherwise -- The arg looked like "baz" - = - Nothing - where - headOf :: String -> (Char -> Bool) -> Bool - headOf str pred' = any pred' (safeHead str) - - (main_mod, main_fn) = splitLongestPrefix arg (== '.') - - splitLongestPrefix :: String -> (Char -> Bool) -> (String, String) - splitLongestPrefix str pred' - | null r_pre = (str, []) - | otherwise = (reverse (safeTail r_pre), reverse r_suf) - where - -- 'safeTail' drops the char satisfying 'pred' - (r_suf, r_pre) = break pred' (reverse str) - --- | A collection of: --- * C input files --- * C++ input files --- * GHC input files --- * GHC input modules --- --- Used to correctly build and link sources. -data BuildSources = BuildSources - { cSourcesFiles :: [SymbolicPath Pkg File] - , cxxSourceFiles :: [SymbolicPath Pkg File] - , inputSourceFiles :: [SymbolicPath Pkg File] - , inputSourceModules :: [ModuleName] - } - --- | Locate and return the 'BuildSources' required to build and link. -gbuildSources - :: Verbosity - -> Maybe (SymbolicPath CWD ('Dir Pkg)) - -> PackageId - -> CabalSpecVersion - -> SymbolicPath Pkg (Dir Source) - -> GBuildMode - -> IO BuildSources -gbuildSources verbosity mbWorkDir pkgId specVer tmpDir bm = - case bm of - GBuildExe exe -> exeSources exe - GReplExe _ exe -> exeSources exe - GBuildFLib flib -> return $ flibSources flib - GReplFLib _ flib -> return $ flibSources flib - where - exeSources :: Executable -> IO BuildSources - exeSources exe@Executable{buildInfo = bnfo, modulePath = modPath} = do - main <- findFileCwd verbosity mbWorkDir (tmpDir : hsSourceDirs bnfo) modPath - let mainModName = fromMaybe ModuleName.main $ exeMainModuleName exe - otherModNames = exeModules exe - haskellMain = isHaskell (getSymbolicPath main) - - -- Scripts have fakePackageId and are always Haskell but can have any extension. - if haskellMain || pkgId == fakePackageId - then - if specVer < CabalSpecV2_0 && (mainModName `elem` otherModNames) - then do - -- The cabal manual clearly states that `other-modules` is - -- intended for non-main modules. However, there's at least one - -- important package on Hackage (happy-1.19.5) which - -- violates this. We workaround this here so that we don't - -- invoke GHC with e.g. 'ghc --make Main src/Main.hs' which - -- would result in GHC complaining about duplicate Main - -- modules. - -- - -- Finally, we only enable this workaround for - -- specVersion < 2, as 'cabal-version:>=2.0' cabal files - -- have no excuse anymore to keep doing it wrong... ;-) - warn verbosity $ - "Enabling workaround for Main module '" - ++ prettyShow mainModName - ++ "' listed in 'other-modules' illegally!" - - return - BuildSources - { cSourcesFiles = cSources bnfo - , cxxSourceFiles = cxxSources bnfo - , inputSourceFiles = [main] - , inputSourceModules = filter (/= mainModName) $ exeModules exe - } - else - return - BuildSources - { cSourcesFiles = cSources bnfo - , cxxSourceFiles = cxxSources bnfo - , inputSourceFiles = [main] - , inputSourceModules = exeModules exe - } - else - let (csf, cxxsf) - | isCxx (getSymbolicPath main) = (cSources bnfo, main : cxxSources bnfo) - -- if main is not a Haskell source - -- and main is not a C++ source - -- then we assume that it is a C source - | otherwise = (main : cSources bnfo, cxxSources bnfo) - in return - BuildSources - { cSourcesFiles = csf - , cxxSourceFiles = cxxsf - , inputSourceFiles = [] - , inputSourceModules = exeModules exe - } - - flibSources :: ForeignLib -> BuildSources - flibSources flib@ForeignLib{foreignLibBuildInfo = bnfo} = - BuildSources - { cSourcesFiles = cSources bnfo - , cxxSourceFiles = cxxSources bnfo - , inputSourceFiles = [] - , inputSourceModules = foreignLibModules flib - } - --- | Generic build function. See comment for 'GBuildMode'. -gbuild - :: Verbosity - -> Flag ParStrat - -> PackageDescription - -> LocalBuildInfo - -> GBuildMode - -> ComponentLocalBuildInfo - -> IO () -gbuild verbosity numJobs pkg_descr lbi bm clbi = do - (ghcjsProg, _) <- requireProgram verbosity ghcjsProgram (withPrograms lbi) - let replFlags = case bm of - GReplExe flags _ -> flags - GReplFLib flags _ -> flags - GBuildExe{} -> mempty - GBuildFLib{} -> mempty - comp = compiler lbi - platform = hostPlatform lbi - mbWorkDir = mbWorkDirLBI lbi - runGhcProg = runGHC verbosity ghcjsProg comp platform mbWorkDir - - let (bnfo, threaded) = case bm of - GBuildFLib _ -> popThreadedFlag (gbuildInfo bm) - _ -> (gbuildInfo bm, False) - - -- the name that GHC really uses (e.g., with .exe on Windows for executables) - let targetName = gbuildTargetName lbi bm - targetDir = buildDir lbi makeRelativePathEx (gbuildName bm) - tmpDir = targetDir makeRelativePathEx (gbuildName bm ++ "-tmp") - - -- See Note [Symbolic paths] in Distribution.Utils.Path - i = interpretSymbolicPath mbWorkDir - - createDirectoryIfMissingVerbose verbosity True $ i targetDir - createDirectoryIfMissingVerbose verbosity True $ i tmpDir - - -- TODO: do we need to put hs-boot files into place for mutually recursive - -- modules? FIX: what about exeName.hi-boot? - - -- Determine if program coverage should be enabled and if so, what - -- '-hpcdir' should be. - let isCoverageEnabled = exeCoverage lbi - hpcdir way - | gbuildIsRepl bm = mempty -- HPC is not supported in ghci - | isCoverageEnabled = toFlag $ Hpc.mixDir (tmpDir coerceSymbolicPath extraCompilationArtifacts) way - | otherwise = mempty - - rpaths <- getRPaths lbi clbi - buildSources <- gbuildSources verbosity mbWorkDir (package pkg_descr) (specVersion pkg_descr) tmpDir bm - - let cSrcs = cSourcesFiles buildSources - cxxSrcs = cxxSourceFiles buildSources - inputFiles = inputSourceFiles buildSources - inputModules = inputSourceModules buildSources - isGhcDynamic = isDynamic comp - dynamicTooSupported = supportsDynamicToo comp - cObjs = map (`replaceExtensionSymbolicPath` objExtension) cSrcs - cxxObjs = map (`replaceExtensionSymbolicPath` objExtension) cxxSrcs - needDynamic = gbuildNeedDynamic lbi bm - needProfiling = withProfExe lbi - - -- build executables - buildRunner = case clbi of - LibComponentLocalBuildInfo{} -> False - FLibComponentLocalBuildInfo{} -> False - ExeComponentLocalBuildInfo{} -> True - TestComponentLocalBuildInfo{} -> True - BenchComponentLocalBuildInfo{} -> True - baseOpts = - componentGhcOptions (verbosityLevel verbosity) lbi bnfo clbi tmpDir - <> mempty - { ghcOptMode = toFlag GhcModeMake - , ghcOptInputFiles = - toNubListR $ - if package pkg_descr == fakePackageId - then filter (isHaskell . getSymbolicPath) inputFiles - else inputFiles - , ghcOptInputScripts = - toNubListR $ - if package pkg_descr == fakePackageId - then filter (not . isHaskell . getSymbolicPath) inputFiles - else [] - , ghcOptInputModules = toNubListR inputModules - , -- for all executable components (exe/test/bench), - -- GHCJS must be passed the "-build-runner" option - ghcOptExtra = - if buildRunner - then ["-build-runner"] - else mempty - } - staticOpts = - baseOpts - <> mempty - { ghcOptDynLinkMode = toFlag GhcStaticOnly - , ghcOptHPCDir = hpcdir Hpc.Vanilla - } - profOpts = - baseOpts - <> mempty - { ghcOptProfilingMode = toFlag True - , ghcOptProfilingAuto = - Internal.profDetailLevelFlag - False - (withProfExeDetail lbi) - , ghcOptHiSuffix = toFlag "p_hi" - , ghcOptObjSuffix = toFlag "p_o" - , ghcOptExtra = hcProfOptions GHC bnfo - , ghcOptHPCDir = hpcdir Hpc.Prof - } - dynOpts = - baseOpts - <> mempty - { ghcOptDynLinkMode = toFlag GhcDynamicOnly - , -- TODO: Does it hurt to set -fPIC for executables? - ghcOptFPic = toFlag True - , ghcOptHiSuffix = toFlag "dyn_hi" - , ghcOptObjSuffix = toFlag "dyn_o" - , ghcOptExtra = hcOptions GHC bnfo ++ hcSharedOptions GHC bnfo - , ghcOptHPCDir = hpcdir Hpc.Dyn - } - dynTooOpts = - staticOpts - <> mempty - { ghcOptDynLinkMode = toFlag GhcStaticAndDynamic - , ghcOptDynHiSuffix = toFlag "dyn_hi" - , ghcOptDynObjSuffix = toFlag "dyn_o" - , ghcOptHPCDir = hpcdir Hpc.Dyn - } - linkerOpts = - mempty - { ghcOptLinkOptions = PD.ldOptions bnfo - , ghcOptLinkLibs = extraLibs bnfo - , ghcOptLinkLibPath = toNubListR $ extraLibDirs bnfo - , ghcOptLinkFrameworks = - toNubListR $ - map getSymbolicPath $ - PD.frameworks bnfo - , ghcOptLinkFrameworkDirs = - toNubListR $ - PD.extraFrameworkDirs bnfo - , ghcOptInputFiles = - toNubListR - [makeSymbolicPath $ getSymbolicPath tmpDir getSymbolicPath x | x <- cObjs ++ cxxObjs] - } - dynLinkerOpts = - mempty - { ghcOptRPaths = rpaths - } - replOpts = - baseOpts - { ghcOptExtra = - Internal.filterGhciFlags - (ghcOptExtra baseOpts) - <> replFlags - } - -- For a normal compile we do separate invocations of ghc for - -- compiling as for linking. But for repl we have to do just - -- the one invocation, so that one has to include all the - -- linker stuff too, like -l flags and any .o files from C - -- files etc. - <> linkerOpts - <> mempty - { ghcOptMode = toFlag GhcModeInteractive - , ghcOptOptimisation = toFlag GhcNoOptimisation - } - commonOpts - | needProfiling = profOpts - | needDynamic = dynOpts - | otherwise = staticOpts - compileOpts - | useDynToo = dynTooOpts - | otherwise = commonOpts - withStaticExe = not needProfiling && not needDynamic - - -- For building exe's that use TH with -prof or -dynamic we actually have - -- to build twice, once without -prof/-dynamic and then again with - -- -prof/-dynamic. This is because the code that TH needs to run at - -- compile time needs to be the vanilla ABI so it can be loaded up and run - -- by the compiler. - -- With dynamic-by-default GHC the TH object files loaded at compile-time - -- need to be .dyn_o instead of .o. - doingTH = usesTemplateHaskellOrQQ bnfo - -- Should we use -dynamic-too instead of compiling twice? - useDynToo = - dynamicTooSupported - && isGhcDynamic - && doingTH - && withStaticExe - && null (hcSharedOptions GHC bnfo) - compileTHOpts - | isGhcDynamic = dynOpts - | otherwise = staticOpts - compileForTH - | gbuildIsRepl bm = False - | useDynToo = False - | isGhcDynamic = doingTH && (needProfiling || withStaticExe) - | otherwise = doingTH && (needProfiling || needDynamic) - - -- Build static/dynamic object files for TH, if needed. - when compileForTH $ - runGhcProg - compileTHOpts - { ghcOptNoLink = toFlag True - , ghcOptNumJobs = numJobs - } - - -- Do not try to build anything if there are no input files. - -- This can happen if the cabal file ends up with only cSrcs - -- but no Haskell modules. - unless - ( (null inputFiles && null inputModules) - || gbuildIsRepl bm - ) - $ runGhcProg - compileOpts - { ghcOptNoLink = toFlag True - , ghcOptNumJobs = numJobs - } - - -- build any C++ sources - unless (null cxxSrcs) $ do - info verbosity "Building C++ Sources..." - sequence_ - [ do - let baseCxxOpts = - Internal.splitCandCxxOptions Internal.CxxProgram (verbosityLevel verbosity) lbi bnfo clbi odir filename - vanillaCxxOpts = - if isGhcDynamic - then -- Dynamic GHC requires C++ sources to be built - -- with -fPIC for REPL to work. See #2207. - baseCxxOpts{ghcOptFPic = toFlag True} - else baseCxxOpts - profCxxOpts = - vanillaCxxOpts - <> mempty - { ghcOptProfilingMode = toFlag True - } - sharedCxxOpts = - vanillaCxxOpts - <> mempty - { ghcOptFPic = toFlag True - , ghcOptDynLinkMode = toFlag GhcDynamicOnly - } - opts - | needProfiling = profCxxOpts - | needDynamic = sharedCxxOpts - | otherwise = vanillaCxxOpts - -- TODO: Placing all Haskell, C, & C++ objects in a single directory - -- Has the potential for file collisions. In general we would - -- consider this a user error. However, we should strive to - -- add a warning if this occurs. - odir = fromFlag (ghcOptObjDir opts) - createDirectoryIfMissingVerbose verbosity True (i odir) - needsRecomp <- checkNeedsRecompilation mbWorkDir filename opts - when needsRecomp $ - runGhcProg opts - | filename <- cxxSrcs - ] - - -- build any C sources - unless (null cSrcs) $ do - info verbosity "Building C Sources..." - sequence_ - [ do - let baseCcOpts = - Internal.splitCandCxxOptions Internal.CcProgram (verbosityLevel verbosity) lbi bnfo clbi tmpDir filename - vanillaCcOpts = - if isGhcDynamic - then -- Dynamic GHC requires C sources to be built - -- with -fPIC for REPL to work. See #2207. - baseCcOpts{ghcOptFPic = toFlag True} - else baseCcOpts - profCcOpts = - vanillaCcOpts - <> mempty - { ghcOptProfilingMode = toFlag True - } - sharedCcOpts = - vanillaCcOpts - <> mempty - { ghcOptFPic = toFlag True - , ghcOptDynLinkMode = toFlag GhcDynamicOnly - } - opts - | needProfiling = profCcOpts - | needDynamic = sharedCcOpts - | otherwise = vanillaCcOpts - odir = fromFlag (ghcOptObjDir opts) - createDirectoryIfMissingVerbose verbosity True (i odir) - needsRecomp <- checkNeedsRecompilation mbWorkDir filename opts - when needsRecomp $ - runGhcProg opts - | filename <- cSrcs - ] - - -- TODO: problem here is we need the .c files built first, so we can load them - -- with ghci, but .c files can depend on .h files generated by ghc by ffi - -- exports. - case bm of - GReplExe _ _ -> runGhcProg replOpts - GReplFLib _ _ -> runGhcProg replOpts - GBuildExe _ -> do - let linkOpts = - commonOpts - <> linkerOpts - <> mempty - { ghcOptLinkNoHsMain = toFlag (null inputFiles) - } - <> (if withDynExe lbi then dynLinkerOpts else mempty) - - info verbosity "Linking..." - -- Work around old GHCs not relinking in this - -- situation, see #3294 - let target = targetDir makeRelativePathEx targetName - runGhcProg linkOpts{ghcOptOutputFile = toFlag target} - GBuildFLib flib -> do - let rtsInfo = extractRtsInfo lbi - rtsOptLinkLibs = - [ if needDynamic - then - if threaded - then dynRtsThreadedLib (rtsDynamicInfo rtsInfo) - else dynRtsVanillaLib (rtsDynamicInfo rtsInfo) - else - if threaded - then statRtsThreadedLib (rtsStaticInfo rtsInfo) - else statRtsVanillaLib (rtsStaticInfo rtsInfo) - ] - linkOpts = case foreignLibType flib of - ForeignLibNativeShared -> - commonOpts - <> linkerOpts - <> dynLinkerOpts - <> mempty - { ghcOptLinkNoHsMain = toFlag True - , ghcOptShared = toFlag True - , ghcOptLinkLibs = rtsOptLinkLibs - , ghcOptLinkLibPath = toNubListR $ map makeSymbolicPath $ rtsLibPaths rtsInfo - , ghcOptFPic = toFlag True - , ghcOptLinkModDefFiles = toNubListR (getSymbolicPath <$> gbuildModDefFiles bm) - } - ForeignLibNativeStatic -> - -- this should be caught by buildFLib - -- (and if we do implement this, we probably don't even want to call - -- ghc here, but rather Ar.createArLibArchive or something) - cabalBug "static libraries not yet implemented" - ForeignLibTypeUnknown -> - cabalBug "unknown foreign lib type" - -- We build under a (potentially) different filename to set a - -- soname on supported platforms. See also the note for - -- @flibBuildName@. - info verbosity "Linking..." - let buildName = flibBuildName lbi flib - buildFile = targetDir makeRelativePathEx buildName - runGhcProg linkOpts{ghcOptOutputFile = toFlag buildFile} - renameFile (i buildFile) (i targetDir targetName) - -data DynamicRtsInfo = DynamicRtsInfo - { dynRtsVanillaLib :: FilePath - , dynRtsThreadedLib :: FilePath - , dynRtsDebugLib :: FilePath - , dynRtsEventlogLib :: FilePath - , dynRtsThreadedDebugLib :: FilePath - , dynRtsThreadedEventlogLib :: FilePath - } - -data StaticRtsInfo = StaticRtsInfo - { statRtsVanillaLib :: FilePath - , statRtsThreadedLib :: FilePath - , statRtsDebugLib :: FilePath - , statRtsEventlogLib :: FilePath - , statRtsThreadedDebugLib :: FilePath - , statRtsThreadedEventlogLib :: FilePath - , statRtsProfilingLib :: FilePath - , statRtsThreadedProfilingLib :: FilePath - } - -data RtsInfo = RtsInfo - { rtsDynamicInfo :: DynamicRtsInfo - , rtsStaticInfo :: StaticRtsInfo - , rtsLibPaths :: [FilePath] - } - --- | Extract (and compute) information about the RTS library --- --- TODO: This hardcodes the name as @HSrts-ghc@. I don't know if we can --- find this information somewhere. We can lookup the 'hsLibraries' field of --- 'InstalledPackageInfo' but it will tell us @["HSrts", "Cffi"]@, which --- doesn't really help. -extractRtsInfo :: LocalBuildInfo -> RtsInfo -extractRtsInfo lbi = - case PackageIndex.lookupPackageName (installedPkgs lbi) (mkPackageName "rts") of - [(_, [rts])] -> aux rts - _otherwise -> error "No (or multiple) ghc rts package is registered" - where - aux :: InstalledPackageInfo -> RtsInfo - aux rts = - RtsInfo - { rtsDynamicInfo = - DynamicRtsInfo - { dynRtsVanillaLib = withGhcVersion "HSrts" - , dynRtsThreadedLib = withGhcVersion "HSrts_thr" - , dynRtsDebugLib = withGhcVersion "HSrts_debug" - , dynRtsEventlogLib = withGhcVersion "HSrts_l" - , dynRtsThreadedDebugLib = withGhcVersion "HSrts_thr_debug" - , dynRtsThreadedEventlogLib = withGhcVersion "HSrts_thr_l" - } - , rtsStaticInfo = - StaticRtsInfo - { statRtsVanillaLib = "HSrts" - , statRtsThreadedLib = "HSrts_thr" - , statRtsDebugLib = "HSrts_debug" - , statRtsEventlogLib = "HSrts_l" - , statRtsThreadedDebugLib = "HSrts_thr_debug" - , statRtsThreadedEventlogLib = "HSrts_thr_l" - , statRtsProfilingLib = "HSrts_p" - , statRtsThreadedProfilingLib = "HSrts_thr_p" - } - , rtsLibPaths = InstalledPackageInfo.libraryDirs rts - } - withGhcVersion = (++ ("-ghc" ++ prettyShow (compilerVersion (compiler lbi)))) - --- | Returns True if the modification date of the given source file is newer than --- the object file we last compiled for it, or if no object file exists yet. -checkNeedsRecompilation - :: Maybe (SymbolicPath CWD (Dir Pkg)) - -> SymbolicPath Pkg File - -> GhcOptions - -> IO Bool -checkNeedsRecompilation mbWorkDir filename opts = - i filename `moreRecentFile` oname - where - oname = getObjectFileName mbWorkDir filename opts - i = interpretSymbolicPath mbWorkDir -- See Note [Symbolic paths] in Distribution.Utils.Path - --- | Finds the object file name of the given source file -getObjectFileName - :: Maybe (SymbolicPath CWD (Dir Pkg)) - -> SymbolicPath Pkg File - -> GhcOptions - -> FilePath -getObjectFileName mbWorkDir filename opts = oname - where - i = interpretSymbolicPath mbWorkDir -- See Note [Symbolic paths] in Distribution.Utils.Path - odir = i $ fromFlag (ghcOptObjDir opts) - oext = fromFlagOrDefault "o" (ghcOptObjSuffix opts) - -- NB: the filepath might be absolute, e.g. if it is the path to - -- an autogenerated .hs file. - oname = odir replaceExtension (getSymbolicPath filename) oext - --- | Calculate the RPATHs for the component we are building. --- --- Calculates relative RPATHs when 'relocatable' is set. -getRPaths - :: LocalBuildInfo - -> ComponentLocalBuildInfo - -- ^ Component we are building - -> IO (NubListR FilePath) -getRPaths lbi clbi | supportRPaths hostOS = do - libraryPaths <- depLibraryPaths False (relocatable lbi) lbi clbi - let hostPref = case hostOS of - OSX -> "@loader_path" - _ -> "$ORIGIN" - relPath p = if isRelative p then hostPref p else p - rpaths = toNubListR (map relPath libraryPaths) - return rpaths - where - (Platform _ hostOS) = hostPlatform lbi - compid = compilerId . compiler $ lbi - - -- The list of RPath-supported operating systems below reflects the - -- platforms on which Cabal's RPATH handling is tested. It does _NOT_ - -- reflect whether the OS supports RPATH. - - -- E.g. when this comment was written, the *BSD operating systems were - -- untested with regards to Cabal RPATH handling, and were hence set to - -- 'False', while those operating systems themselves do support RPATH. - supportRPaths Linux = True - supportRPaths Windows = False - supportRPaths OSX = True - supportRPaths FreeBSD = - case compid of - CompilerId GHC _ -> True - _ -> False - supportRPaths OpenBSD = False - supportRPaths NetBSD = False - supportRPaths DragonFly = False - supportRPaths Solaris = False - supportRPaths AIX = False - supportRPaths HPUX = False - supportRPaths IRIX = False - supportRPaths HaLVM = False - supportRPaths IOS = False - supportRPaths Android = False - supportRPaths Ghcjs = False - supportRPaths Wasi = False - supportRPaths Hurd = True - supportRPaths Haiku = False - supportRPaths (OtherOS _) = False --- Do _not_ add a default case so that we get a warning here when a new OS --- is added. - -getRPaths _ _ = return mempty - --- | Remove the "-threaded" flag when building a foreign library, as it has no --- effect when used with "-shared". Returns the updated 'BuildInfo', along --- with whether or not the flag was present, so we can use it to link against --- the appropriate RTS on our own. -popThreadedFlag :: BuildInfo -> (BuildInfo, Bool) -popThreadedFlag bi = - ( bi{options = filterHcOptions (/= "-threaded") (options bi)} - , hasThreaded bi - ) - where - filterHcOptions - :: (String -> Bool) - -> PerCompilerFlavor [String] - -> PerCompilerFlavor [String] - filterHcOptions p (PerCompilerFlavor ghc ghcjs) = - PerCompilerFlavor (filter p ghc) ghcjs - --- | Extracts a String representing a hash of the ABI of a built --- library. It can fail if the library has not yet been built. -libAbiHash - :: Verbosity - -> PackageDescription - -> LocalBuildInfo - -> Library - -> ComponentLocalBuildInfo - -> IO String -libAbiHash verbosity _pkg_descr lbi lib clbi = do - let - libBi = libBuildInfo lib - comp = compiler lbi - platform = hostPlatform lbi - mbWorkDir = mbWorkDirLBI lbi - vanillaArgs = - componentGhcOptions (verbosityLevel verbosity) lbi libBi clbi (componentBuildDir lbi clbi) - <> mempty - { ghcOptMode = toFlag GhcModeAbiHash - , ghcOptInputModules = toNubListR $ exposedModules lib - } - sharedArgs = - vanillaArgs - <> mempty - { ghcOptDynLinkMode = toFlag GhcDynamicOnly - , ghcOptFPic = toFlag True - , ghcOptHiSuffix = toFlag "js_dyn_hi" - , ghcOptObjSuffix = toFlag "js_dyn_o" - , ghcOptExtra = hcOptions GHC libBi ++ hcSharedOptions GHC libBi - } - profArgs = - vanillaArgs - <> mempty - { ghcOptProfilingMode = toFlag True - , ghcOptProfilingAuto = - Internal.profDetailLevelFlag - True - (withProfLibDetail lbi) - , ghcOptHiSuffix = toFlag "js_p_hi" - , ghcOptObjSuffix = toFlag "js_p_o" - , ghcOptExtra = hcProfOptions GHC libBi - } - ghcArgs - | withVanillaLib lbi = vanillaArgs - | withSharedLib lbi = sharedArgs - | withProfLib lbi = profArgs - | otherwise = error "libAbiHash: Can't find an enabled library way" - - (ghcjsProg, _) <- requireProgram verbosity ghcjsProgram (withPrograms lbi) - hash <- - getProgramInvocationOutput - verbosity - =<< ghcInvocation verbosity ghcjsProg comp platform mbWorkDir ghcArgs - return (takeWhile (not . isSpace) hash) - -componentGhcOptions - :: VerbosityLevel - -> LocalBuildInfo - -> BuildInfo - -> ComponentLocalBuildInfo - -> SymbolicPath Pkg (Dir build) - -> GhcOptions -componentGhcOptions verbosity lbi bi clbi odir = - let opts = Internal.componentGhcOptions verbosity lbi bi clbi odir - in opts - { ghcOptExtra = ghcOptExtra opts <> hcOptions GHCJS bi - } - --- ----------------------------------------------------------------------------- --- Installing - --- | Install executables for GHCJS. -installExe - :: Verbosity - -> LocalBuildInfo - -> FilePath - -- ^ Where to copy the files to - -> FilePath - -- ^ Build location - -> (FilePath, FilePath) - -- ^ Executable (prefix,suffix) - -> PackageDescription - -> Executable - -> IO () -installExe - verbosity - lbi - binDir - buildPref - (progprefix, progsuffix) - _pkg - exe = do - createDirectoryIfMissingVerbose verbosity True binDir - let exeName' = unUnqualComponentName $ exeName exe - exeFileName = exeName' - fixedExeBaseName = progprefix ++ exeName' ++ progsuffix - installBinary dest = do - runDbProgramCwd verbosity (mbWorkDirLBI lbi) ghcjsProgram (withPrograms lbi) $ - [ "--install-executable" - , buildPref exeName' exeFileName - , "-o" - , dest - ] - ++ case (stripExes lbi, lookupProgram stripProgram $ withPrograms lbi) of - (True, Just strip) -> ["-strip-program", programPath strip] - _ -> [] - installBinary (binDir fixedExeBaseName) - --- | Install foreign library for GHC. -installFLib - :: Verbosity - -> LocalBuildInfo - -> FilePath - -- ^ install location - -> FilePath - -- ^ Build location - -> PackageDescription - -> ForeignLib - -> IO () -installFLib verbosity lbi targetDir builtDir _pkg flib = - install - (foreignLibIsShared flib) - builtDir - targetDir - (flibTargetName lbi flib) - where - install _isShared srcDir dstDir name = do - let src = srcDir name - dst = dstDir name - createDirectoryIfMissingVerbose verbosity True targetDir - installOrdinaryFile verbosity src dst - --- | Install for ghc, .hi, .a and, if --with-ghci given, .o -installLib - :: Verbosity - -> LocalBuildInfo - -> FilePath - -- ^ install location - -> FilePath - -- ^ install location for dynamic libraries - -> FilePath - -- ^ install location for bytecode libraries - -> FilePath - -- ^ Build location - -> PackageDescription - -> Library - -> ComponentLocalBuildInfo - -> IO () -installLib verbosity lbi targetDir dynlibTargetDir _bytecodeTargetDir _builtDir _pkg lib clbi = do - whenVanilla $ copyModuleFiles $ Suffix "js_hi" - whenProf $ copyModuleFiles $ Suffix "js_p_hi" - whenShared $ copyModuleFiles $ Suffix "js_dyn_hi" - - -- whenVanilla $ installOrdinary builtDir targetDir $ toJSLibName vanillaLibName - -- whenProf $ installOrdinary builtDir targetDir $ toJSLibName profileLibName - -- whenShared $ installShared builtDir dynlibTargetDir $ toJSLibName sharedLibName - -- fixme do these make the correct lib names? - whenHasCode $ do - whenVanilla $ do - sequence_ - [ installOrdinary builtDir' targetDir (toJSLibName $ mkGenericStaticLibName (l ++ f)) - | l <- getHSLibraryName (componentUnitId clbi) : extraBundledLibs (libBuildInfo lib) - , f <- "" : extraLibFlavours (libBuildInfo lib) - ] - -- whenGHCi $ installOrdinary builtDir targetDir (toJSLibName ghciLibName) - whenProf $ do - installOrdinary builtDir' targetDir (toJSLibName profileLibName) - -- whenGHCi $ installOrdinary builtDir targetDir (toJSLibName ghciProfLibName) - whenShared $ - sequence_ - [ installShared - builtDir' - dynlibTargetDir - (toJSLibName $ mkGenericSharedLibName platform compiler_id (l ++ f)) - | l <- getHSLibraryName uid : extraBundledLibs (libBuildInfo lib) - , f <- "" : extraDynLibFlavours (libBuildInfo lib) - ] - where - i = interpretSymbolicPathLBI lbi -- See Note [Symbolic paths] in Distribution.Utils.Path - builtDir' = componentBuildDir lbi clbi - mbWorkDir = mbWorkDirLBI lbi - - install isShared isJS srcDir dstDir name = do - let src = i $ srcDir makeRelativePathEx name - dst = dstDir name - createDirectoryIfMissingVerbose verbosity True dstDir - - if isShared - then installExecutableFile verbosity src dst - else installOrdinaryFile verbosity src dst - - when (stripLibs lbi && not isJS) $ - Strip.stripLib - verbosity - (hostPlatform lbi) - (withPrograms lbi) - dst - - installOrdinary = install False True - installShared = install True True - - copyModuleFiles ext = do - files <- findModuleFilesCwd verbosity mbWorkDir [builtDir'] [ext] (allLibModules lib clbi) - let files' = map (i *** getSymbolicPath) files - installOrdinaryFiles verbosity targetDir files' - - compiler_id = compilerId (compiler lbi) - platform = hostPlatform lbi - uid = componentUnitId clbi - -- vanillaLibName = mkLibName uid - profileLibName = mkProfLibName uid - -- sharedLibName = (mkSharedLibName (hostPlatform lbi) compiler_id) uid - - hasLib = - not $ - null (allLibModules lib clbi) - && null (cSources (libBuildInfo lib)) - && null (cxxSources (libBuildInfo lib)) - && null (jsSources (libBuildInfo lib)) - has_code = not (componentIsIndefinite clbi) - whenHasCode = when has_code - whenVanilla = when (hasLib && withVanillaLib lbi) - whenProf = when (hasLib && withProfLib lbi && has_code) - -- whenGHCi = when (hasLib && withGHCiLib lbi && has_code) - whenShared = when (hasLib && withSharedLib lbi && has_code) - -adjustExts :: String -> String -> GhcOptions -> GhcOptions -adjustExts hiSuf objSuf opts = - opts - <> mempty - { ghcOptHiSuffix = toFlag hiSuf - , ghcOptObjSuffix = toFlag objSuf - } - -isDynamic :: Compiler -> Bool -isDynamic = Internal.ghcLookupProperty "GHC Dynamic" - -supportsDynamicToo :: Compiler -> Bool -supportsDynamicToo = Internal.ghcLookupProperty "Support dynamic-too" - -withExt :: FilePath -> String -> FilePath -withExt fp ext = fp <.> if takeExtension fp /= ('.' : ext) then ext else "" - -findGhcjsGhcVersion :: Verbosity -> FilePath -> IO (Maybe Version) -findGhcjsGhcVersion verbosity pgm = - findProgramVersion "--numeric-ghc-version" id verbosity pgm - -findGhcjsPkgGhcjsVersion :: Verbosity -> FilePath -> IO (Maybe Version) -findGhcjsPkgGhcjsVersion verbosity pgm = - findProgramVersion "--numeric-ghcjs-version" id verbosity pgm - --- ----------------------------------------------------------------------------- --- Registering - -hcPkgInfo :: ProgramDb -> HcPkg.ConfiguredProgram -hcPkgInfo progdb = - fromMaybe (error "GHCJS.hcPkgInfo no ghcjs program") $ lookupProgram ghcjsPkgProgram progdb - -registerPackage - :: Verbosity - -> ProgramDb - -> Maybe (SymbolicPath CWD (Dir from)) - -> PackageDBStackS from - -> InstalledPackageInfo - -> HcPkg.RegisterOptions - -> IO () -registerPackage verbosity progdb mbWorkDir packageDbs installedPkgInfo registerOptions = - HcPkg.register - (hcPkgInfo progdb) - verbosity - mbWorkDir - packageDbs - installedPkgInfo - registerOptions - -pkgRoot :: Verbosity -> LocalBuildInfo -> PackageDB -> IO FilePath -pkgRoot verbosity lbi = pkgRoot' - where - pkgRoot' GlobalPackageDB = - let ghcjsProg = fromMaybe (error "GHCJS.pkgRoot: no ghcjs program") $ lookupProgram ghcjsProgram (withPrograms lbi) - in fmap takeDirectory (getGlobalPackageDB verbosity ghcjsProg) - pkgRoot' UserPackageDB = do - appDir <- getAppUserDataDirectory "ghcjs" - -- fixme correct this version - let ver = compilerVersion (compiler lbi) - subdir = - System.Info.arch - ++ '-' - : System.Info.os - ++ '-' - : prettyShow ver - rootDir = appDir subdir - -- We must create the root directory for the user package database if it - -- does not yet exists. Otherwise '${pkgroot}' will resolve to a - -- directory at the time of 'ghc-pkg register', and registration will - -- fail. - createDirectoryIfMissing True rootDir - return rootDir - pkgRoot' (SpecificPackageDB fp) = - return $ - takeDirectory $ - interpretSymbolicPathLBI lbi fp - --- | Get the JavaScript file name and command and arguments to run a --- program compiled by GHCJS --- the exe should be the base program name without exe extension -runCmd - :: ProgramDb - -> FilePath - -> (FilePath, FilePath, [String]) -runCmd progdb exe = - ( script - , programPath ghcjsProg - , programDefaultArgs ghcjsProg ++ programOverrideArgs ghcjsProg ++ ["--run"] - ) - where - script = exe <.> "jsexe" "all" <.> "js" - ghcjsProg = fromMaybe (error "GHCJS.runCmd: no ghcjs program") $ lookupProgram ghcjsProgram progdb diff --git a/Cabal/src/Distribution/Simple/Haddock.hs b/Cabal/src/Distribution/Simple/Haddock.hs index 201bb8c4b30..4578579d07f 100644 --- a/Cabal/src/Distribution/Simple/Haddock.hs +++ b/Cabal/src/Distribution/Simple/Haddock.hs @@ -31,7 +31,6 @@ import Distribution.Compat.Prelude import Prelude () import qualified Distribution.Simple.GHC as GHC -import qualified Distribution.Simple.GHCJS as GHCJS -- local @@ -657,11 +656,10 @@ componentGhcOptions componentGhcOptions verbosity lbi bi clbi odir = let f = case compilerFlavor (compiler lbi) of GHC -> GHC.componentGhcOptions - GHCJS -> GHCJS.componentGhcOptions _ -> error $ "Distribution.Simple.Haddock.componentGhcOptions:" - ++ "haddock only supports GHC and GHCJS" + ++ "haddock only supports GHC" in f verbosity lbi bi clbi odir {- @@ -1041,8 +1039,7 @@ getGhcLibDir getGhcLibDir verbosity lbi = do l <- case compilerFlavor (compiler lbi) of GHC -> GHC.getLibDir verbosity lbi - GHCJS -> GHCJS.getLibDir verbosity lbi - _ -> error "haddock only supports GHC and GHCJS" + _ -> error "haddock only supports GHC" return $ mempty{argGhcLibDir = Flag l} -- | If Hi Haddock is supported, this function creates temporary directories diff --git a/Cabal/src/Distribution/Simple/Install.hs b/Cabal/src/Distribution/Simple/Install.hs index 52163b31be1..ffcaad97556 100644 --- a/Cabal/src/Distribution/Simple/Install.hs +++ b/Cabal/src/Distribution/Simple/Install.hs @@ -68,7 +68,6 @@ import Distribution.Utils.Path import Distribution.Compat.Graph (IsNode (..)) import Distribution.Simple.Errors import qualified Distribution.Simple.GHC as GHC -import qualified Distribution.Simple.GHCJS as GHCJS import Distribution.Simple.Setup.Common import qualified Distribution.Simple.UHC as UHC @@ -244,7 +243,6 @@ copyComponent verbosity pkg_descr lbi (CLib lib) clbi copydest = do case compilerFlavor (compiler lbi) of GHC -> GHC.installLib verbosity lbi libPref dynlibPref bytecodeLibPref buildPref pkg_descr lib clbi - GHCJS -> GHCJS.installLib verbosity lbi libPref dynlibPref bytecodeLibPref buildPref pkg_descr lib clbi UHC -> UHC.installLib verbosity lbi libPref dynlibPref bytecodeLibPref buildPref pkg_descr lib clbi _ -> dieWithException verbosity $ CompilerNotInstalled (compilerFlavor (compiler lbi)) @@ -260,7 +258,6 @@ copyComponent verbosity pkg_descr lbi (CFLib flib) clbi copydest = do case compilerFlavor (compiler lbi) of GHC -> GHC.installFLib verbosity lbi flibPref buildPref pkg_descr flib - GHCJS -> GHCJS.installFLib verbosity lbi flibPref buildPref pkg_descr flib _ -> dieWithException verbosity $ CompilerNotInstalled (compilerFlavor (compiler lbi)) copyComponent verbosity pkg_descr lbi (CExe exe) clbi copydest = do let installDirs = absoluteComponentInstallDirs pkg_descr lbi (componentUnitId clbi) copydest @@ -292,7 +289,6 @@ copyComponent verbosity pkg_descr lbi (CExe exe) clbi copydest = do ) case compilerFlavor (compiler lbi) of GHC -> GHC.installExe verbosity lbi binPref buildPref progFix pkg_descr exe - GHCJS -> GHCJS.installExe verbosity lbi binPref buildPref progFix pkg_descr exe UHC -> return () _ -> dieWithException verbosity $ CompilerNotInstalled (compilerFlavor (compiler lbi)) diff --git a/Cabal/src/Distribution/Simple/PreProcess.hs b/Cabal/src/Distribution/Simple/PreProcess.hs index 0bc8972f7fa..6af3e15051e 100644 --- a/Cabal/src/Distribution/Simple/PreProcess.hs +++ b/Cabal/src/Distribution/Simple/PreProcess.hs @@ -401,32 +401,24 @@ ppCpp = ppCpp' [] ppCpp' :: [String] -> BuildInfo -> LocalBuildInfo -> ComponentLocalBuildInfo -> PreProcessor ppCpp' extraArgs bi lbi clbi = case compilerFlavor (compiler lbi) of - GHC -> ppGhcCpp ghcProgram (const True) args bi lbi clbi - GHCJS -> ppGhcCpp ghcjsProgram (const True) args bi lbi clbi + GHC -> ppGhcCpp args bi lbi clbi _ -> ppCpphs args bi lbi clbi where cppArgs = getCppOptions bi lbi args = cppArgs ++ extraArgs ppGhcCpp - :: Program - -> (Version -> Bool) - -> [String] + :: [String] -> BuildInfo -> LocalBuildInfo -> ComponentLocalBuildInfo -> PreProcessor -ppGhcCpp program xHs extraArgs _bi lbi clbi = +ppGhcCpp extraArgs _bi lbi clbi = PreProcessor { platformIndependent = False , ppOrdering = unsorted , runPreProcessor = mkSimplePreProcessor $ \inFile outFile verbosity -> do - (prog, version, _) <- - requireProgramVersion - verbosity - program - anyVersion - (withPrograms lbi) + (prog, _) <- requireProgram verbosity ghcProgram (withPrograms lbi) runProgramCwd verbosity (mbWorkDirLBI lbi) prog $ ["-E", "-cpp"] -- This is a bit of an ugly hack. We're going to @@ -434,7 +426,7 @@ ppGhcCpp program xHs extraArgs _bi lbi clbi = -- so we need GHC not to unlit it now or it'll get -- double-unlitted. In the future we might switch to -- using cpphs --unlit instead. - ++ (if xHs version then ["-x", "hs"] else []) + ++ ["-x", "hs"] ++ ["-optP-include", "-optP" ++ u (autogenComponentModulesDir lbi clbi makeRelativePathEx cppHeaderName)] ++ ["-o", outFile, inFile] ++ extraArgs @@ -637,7 +629,6 @@ ppHsc2hs bi lbi clbi = isELF = case buildOS of OSX -> False; Windows -> False; AIX -> False; _ -> True packageHacks = case compilerFlavor (compiler lbi) of GHC -> hackRtsPackage - GHCJS -> hackRtsPackage _ -> id -- We don't link in the actual Haskell libraries of our dependencies, so -- the -u flags in the ldOptions of the rts package mean linking fails on @@ -739,23 +730,11 @@ platformDefines lbi = ++ ["-D" ++ arch ++ "_BUILD_ARCH=1"] ++ map (\os' -> "-D" ++ os' ++ "_HOST_OS=1") osStr ++ map (\arch' -> "-D" ++ arch' ++ "_HOST_ARCH=1") archStr - GHCJS -> - compatGlasgowHaskell - ++ ["-D__GHCJS__=" ++ versionInt version] - ++ ["-D" ++ os ++ "_BUILD_OS=1"] - ++ ["-D" ++ arch ++ "_BUILD_ARCH=1"] - ++ map (\os' -> "-D" ++ os' ++ "_HOST_OS=1") osStr - ++ map (\arch' -> "-D" ++ arch' ++ "_HOST_ARCH=1") archStr _ -> [] where comp = compiler lbi Platform hostArch hostOS = hostPlatform lbi version = compilerVersion comp - compatGlasgowHaskell = - maybe - [] - (\v -> ["-D__GLASGOW_HASKELL__=" ++ versionInt v]) - (compilerCompatVersion GHC comp) -- TODO: move this into the compiler abstraction -- FIXME: this forces GHC's crazy 4.8.2 -> 408 convention on all -- the other compilers. Check if that's really what they want. @@ -825,7 +804,6 @@ ppHappy _ lbi _ = pp{platformIndependent = True} pp = standardPP lbi happyProgram (hcFlags hc) hc = compilerFlavor (compiler lbi) hcFlags GHC = ["-agc"] - hcFlags GHCJS = ["-agc"] hcFlags _ = [] ppAlex :: BuildInfo -> LocalBuildInfo -> ComponentLocalBuildInfo -> PreProcessor @@ -834,7 +812,6 @@ ppAlex _ lbi _ = pp{platformIndependent = True} pp = standardPP lbi alexProgram (hcFlags hc) hc = compilerFlavor (compiler lbi) hcFlags GHC = ["-g"] - hcFlags GHCJS = ["-g"] hcFlags _ = [] standardPP :: LocalBuildInfo -> Program -> [String] -> PreProcessor diff --git a/Cabal/src/Distribution/Simple/Program.hs b/Cabal/src/Distribution/Simple/Program.hs index 9b329feeb51..87e2e97827a 100644 --- a/Cabal/src/Distribution/Simple/Program.hs +++ b/Cabal/src/Distribution/Simple/Program.hs @@ -105,8 +105,6 @@ module Distribution.Simple.Program -- * Programs that Cabal knows about , ghcProgram , ghcPkgProgram - , ghcjsProgram - , ghcjsPkgProgram , jhcProgram , uhcProgram , gccProgram diff --git a/Cabal/src/Distribution/Simple/Program/Builtin.hs b/Cabal/src/Distribution/Simple/Program/Builtin.hs index c66d9362f0c..ad57a6dd02f 100644 --- a/Cabal/src/Distribution/Simple/Program/Builtin.hs +++ b/Cabal/src/Distribution/Simple/Program/Builtin.hs @@ -18,8 +18,6 @@ module Distribution.Simple.Program.Builtin , ghcProgram , ghcPkgProgram , runghcProgram - , ghcjsProgram - , ghcjsPkgProgram , jhcProgram , uhcProgram , gccProgram @@ -72,8 +70,6 @@ builtinPrograms = ghcProgram , runghcProgram , ghcPkgProgram - , ghcjsProgram - , ghcjsPkgProgram , jhcProgram , uhcProgram , hpcProgram @@ -142,24 +138,6 @@ ghcPkgProgram = _ -> "" } -ghcjsProgram :: Program -ghcjsProgram = - (simpleProgram "ghcjs") - { programFindVersion = findProgramVersion "--numeric-ghcjs-version" id - } - --- note: version is the version number of the GHC version that ghcjs-pkg was built with -ghcjsPkgProgram :: Program -ghcjsPkgProgram = - (simpleProgram "ghcjs-pkg") - { programFindVersion = findProgramVersion "--version" $ \str -> - -- Invoking "ghcjs-pkg --version" gives a string like - -- "GHCJS package manager version 6.4.1" - case words str of - (_ : _ : _ : _ : ver : _) -> ver - _ -> "" - } - jhcProgram :: Program jhcProgram = (simpleProgram "jhc") diff --git a/Cabal/src/Distribution/Simple/Program/GHC.hs b/Cabal/src/Distribution/Simple/Program/GHC.hs index 1b6a1857d11..ccefdabd553 100644 --- a/Cabal/src/Distribution/Simple/Program/GHC.hs +++ b/Cabal/src/Distribution/Simple/Program/GHC.hs @@ -765,10 +765,10 @@ ghcInvocation verbosity ghcProg comp platform mbWorkDir opts = do renderGhcOptions :: Compiler -> Platform -> GhcOptions -> [String] renderGhcOptions comp _platform@(Platform _arch os) opts - | compilerFlavor comp `notElem` [GHC, GHCJS] = + | compilerFlavor comp /= GHC = error $ "Distribution.Simple.Program.GHC.renderGhcOptions: " - ++ "compiler flavor must be 'GHC' or 'GHCJS'!" + ++ "compiler flavor must be 'GHC'!" | otherwise = concat [ case flagToMaybe (ghcOptMode opts) of diff --git a/Cabal/src/Distribution/Simple/Program/HcPkg.hs b/Cabal/src/Distribution/Simple/Program/HcPkg.hs index b3177a9d316..0f4234bd883 100644 --- a/Cabal/src/Distribution/Simple/Program/HcPkg.hs +++ b/Cabal/src/Distribution/Simple/Program/HcPkg.hs @@ -9,7 +9,7 @@ -- Portability : portable -- -- This module provides an library interface to the @hc-pkg@ program. --- Currently only GHC and GHCJS have hc-pkg programs. +-- Currently only GHC has an hc-pkg program. module Distribution.Simple.Program.HcPkg ( -- * Types ConfiguredProgram (..) diff --git a/Cabal/src/Distribution/Simple/Register.hs b/Cabal/src/Distribution/Simple/Register.hs index 4e4aa8c1ae1..c11f52b2107 100644 --- a/Cabal/src/Distribution/Simple/Register.hs +++ b/Cabal/src/Distribution/Simple/Register.hs @@ -56,7 +56,6 @@ import Distribution.Simple.BuildTarget import Distribution.Simple.LocalBuildInfo import qualified Distribution.Simple.GHC as GHC -import qualified Distribution.Simple.GHCJS as GHCJS import qualified Distribution.Simple.PackageIndex as Index import qualified Distribution.Simple.UHC as UHC @@ -327,10 +326,7 @@ abiHash -> IO AbiHash abiHash verbosity pkg distPref lbi lib clbi = case compilerFlavor comp of - GHC -> do - mkAbiHash <$> GHC.libAbiHash verbosity pkg lbi' lib clbi - GHCJS -> do - mkAbiHash <$> GHCJS.libAbiHash verbosity pkg lbi' lib clbi + GHC -> mkAbiHash <$> GHC.libAbiHash verbosity pkg lbi' lib clbi _ -> return (mkAbiHash "") where comp = compiler lbi @@ -379,7 +375,6 @@ createPackageDB createPackageDB verbosity comp progdb dbPath = case compilerFlavor comp of GHC -> HcPkg.init (GHC.hcPkgInfo progdb) verbosity dbPath - GHCJS -> HcPkg.init (GHCJS.hcPkgInfo progdb) verbosity dbPath UHC -> return () _ -> dieWithException verbosity CreatePackageDB @@ -424,7 +419,6 @@ withHcPkg withHcPkg verbosity name comp progdb f = case compilerFlavor comp of GHC -> f (GHC.hcPkgInfo progdb) - GHCJS -> f (GHCJS.hcPkgInfo progdb) _ -> dieWithException verbosity $ WithHcPkg name registerPackage @@ -439,7 +433,6 @@ registerPackage registerPackage verbosity comp progdb mbWorkDir packageDbs installedPkgInfo registerOptions = case compilerFlavor comp of GHC -> GHC.registerPackage verbosity progdb mbWorkDir packageDbs installedPkgInfo registerOptions - GHCJS -> GHCJS.registerPackage verbosity progdb mbWorkDir packageDbs installedPkgInfo registerOptions _ | HcPkg.registerMultiInstance registerOptions -> dieWithException verbosity RegisMultiplePkgNotSupported @@ -751,7 +744,7 @@ unregisterWithHandles verbHandles pkg lbi regFlags = do setupMessage verbosity "Unregistering" pkgid withHcPkg verbosity - "unregistering is only implemented for GHC and GHCJS" + "unregistering is only implemented for GHC" (compiler lbi) (withPrograms lbi) unreg diff --git a/Cabal/src/Distribution/Simple/Setup/Config.hs b/Cabal/src/Distribution/Simple/Setup/Config.hs index 40bcd24b46c..aa8222e5ce9 100644 --- a/Cabal/src/Distribution/Simple/Setup/Config.hs +++ b/Cabal/src/Distribution/Simple/Setup/Config.hs @@ -435,7 +435,6 @@ configureOptions showOrParseArgs = (\v flags -> flags{configHcFlavor = v}) ( choiceOpt [ (Flag GHC, ("g", ["ghc"]), "Compile with GHC") - , (Flag GHCJS, ([], ["ghcjs"]), "Compile with GHCJS") , (Flag UHC, ([], ["uhc"]), "Compile with UHC") ] ) diff --git a/Cabal/src/Distribution/Simple/ShowBuildInfo.hs b/Cabal/src/Distribution/Simple/ShowBuildInfo.hs index 489c237c27c..e10f2b69e3a 100644 --- a/Cabal/src/Distribution/Simple/ShowBuildInfo.hs +++ b/Cabal/src/Distribution/Simple/ShowBuildInfo.hs @@ -201,7 +201,6 @@ getCompilerArgs getCompilerArgs bi lbi clbi = case compilerFlavor $ compiler lbi of GHC -> ([], ghcArgs) - GHCJS -> ([], ghcArgs) c -> ( [ "ShowBuildInfo.getCompilerArgs: Don't know how to get build " diff --git a/cabal-install/parser-tests/Tests/ParserTests.hs b/cabal-install/parser-tests/Tests/ParserTests.hs index 33debe829f9..36c54be6849 100644 --- a/cabal-install/parser-tests/Tests/ParserTests.hs +++ b/cabal-install/parser-tests/Tests/ParserTests.hs @@ -188,7 +188,7 @@ testProjectConfigShared = do projectConfigProjectDir = toFlag "my-project-dir" projectConfigProjectFile = toFlag "my-project" projectConfigIgnoreProject = toFlag False - projectConfigHcFlavor = toFlag GHCJS + projectConfigHcFlavor = toFlag UHC projectConfigHcPath = toFlag "/some/path/to/compiler" projectConfigHcPkg = toFlag "/some/path/to/ghc-pkg" projectConfigHaddockIndex = toFlag $ toPathTemplate "/path/to/haddock-index" diff --git a/cabal-install/parser-tests/Tests/files/project-config-shared/cabal.project b/cabal-install/parser-tests/Tests/files/project-config-shared/cabal.project index 90f00f96278..a413d6f6cf8 100644 --- a/cabal-install/parser-tests/Tests/files/project-config-shared/cabal.project +++ b/cabal-install/parser-tests/Tests/files/project-config-shared/cabal.project @@ -5,7 +5,7 @@ store-dir: a/store/dir/path per-component: True independent-goals: True ignore-project: False -compiler: ghcjs +compiler: uhc with-compiler: /some/path/to/compiler with-hc-pkg: /some/path/to/ghc-pkg doc-index-file: /path/to/haddock-index diff --git a/cabal-install/src/Distribution/Client/CmdInstall.hs b/cabal-install/src/Distribution/Client/CmdInstall.hs index 1215af9fc7b..50e55e14c82 100644 --- a/cabal-install/src/Distribution/Client/CmdInstall.hs +++ b/cabal-install/src/Distribution/Client/CmdInstall.hs @@ -1288,7 +1288,7 @@ getExistingEnvEntries :: Verbosity -> CompilerFlavor -> Bool -> FilePath -> IO ( getExistingEnvEntries verbosity compilerFlavor supportsPkgEnvFiles envFile = do envFileExists <- doesFileExist envFile (usedExisting, allEntries) <- - if (compilerFlavor == GHC || compilerFlavor == GHCJS) + if compilerFlavor == GHC && supportsPkgEnvFiles && envFileExists then catch ((True,) <$> readGhcEnvironmentFile envFile) $ \(ParseErrorExc parseError) -> diff --git a/cabal-install/src/Distribution/Client/CmdPath.hs b/cabal-install/src/Distribution/Client/CmdPath.hs index 6307cc30c64..49e88a15e58 100644 --- a/cabal-install/src/Distribution/Client/CmdPath.hs +++ b/cabal-install/src/Distribution/Client/CmdPath.hs @@ -306,7 +306,6 @@ requireCompilerProg :: Verbosity -> Compiler -> IO Program requireCompilerProg verbosity compiler = case compilerFlavor compiler of GHC -> pure ghcProgram - GHCJS -> pure ghcjsProgram flavour -> die' verbosity $ "path: Unsupported compiler flavour: " diff --git a/cabal-install/src/Distribution/Client/ProjectOrchestration.hs b/cabal-install/src/Distribution/Client/ProjectOrchestration.hs index 42316e2149e..ca321b8987b 100644 --- a/cabal-install/src/Distribution/Client/ProjectOrchestration.hs +++ b/cabal-install/src/Distribution/Client/ProjectOrchestration.hs @@ -967,7 +967,7 @@ availableTargetIndexesFromSourcePackages pkgSpecifiers = AvailableTargetIndexes{ -- TODO: [research required] what if the solution has multiple -- versions of this package? -- e.g. due to setup deps or due to multiple independent sets --- of packages being built (e.g. ghc + ghcjs in a project) +-- of packages being built (e.g. native ghc + the ghc javascript backend in a project) filterTargetsKind :: ComponentKind -> [AvailableTarget k] -> [AvailableTarget k] filterTargetsKind ckind = filterTargetsKindWith (== ckind) diff --git a/cabal-install/src/Distribution/Client/ProjectPlanOutput.hs b/cabal-install/src/Distribution/Client/ProjectPlanOutput.hs index 7ba35583ca0..1976da2869a 100644 --- a/cabal-install/src/Distribution/Client/ProjectPlanOutput.hs +++ b/cabal-install/src/Distribution/Client/ProjectPlanOutput.hs @@ -853,7 +853,6 @@ writePlanGhcEnvironment postBuildStatus | compilerFlavor compiler == GHC , supportsPkgEnvFiles (getImplInfo compiler) = - -- TODO: check ghcjs compat Just <$> writeGhcEnvironmentFile path @@ -903,8 +902,7 @@ argsEquivalentOfGhcEnvironmentFile argsEquivalentOfGhcEnvironmentFile compiler = case compilerId compiler of CompilerId GHC _ -> argsEquivalentOfGhcEnvironmentFileGhc - CompilerId GHCJS _ -> argsEquivalentOfGhcEnvironmentFileGhc - CompilerId _ _ -> error "Only GHC and GHCJS are supported" + CompilerId _ _ -> error "Only GHC is supported" -- TODO remove this when we drop support for non-.ghc.env ghc argsEquivalentOfGhcEnvironmentFileGhc diff --git a/cabal-install/src/Distribution/Client/ProjectPlanning.hs b/cabal-install/src/Distribution/Client/ProjectPlanning.hs index f49c4279e14..da185e990c0 100644 --- a/cabal-install/src/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/src/Distribution/Client/ProjectPlanning.hs @@ -28,10 +28,10 @@ -- -- The division between the shared and per-package config is not set in stone -- for all time. For example if we wanted to generalise the install plan to --- describe a situation where we want to build some packages with GHC and some --- with GHCJS then the platform and compiler would no longer be shared between --- all packages but would have to be per-package (probably with some sanity --- condition on the graph structure). +-- describe a situation where we want to build some packages with one compiler +-- and some with another then the platform and compiler would no longer be +-- shared between all packages but would have to be per-package (probably with +-- some sanity condition on the graph structure). module Distribution.Client.ProjectPlanning ( -- * Types for the elaborated install plan ElaboratedInstallPlan @@ -214,7 +214,6 @@ import qualified Distribution.PackageDescription as PD import qualified Distribution.PackageDescription.Configuration as PD import qualified Distribution.Simple.Configure as Cabal import qualified Distribution.Simple.GHC as GHC -import qualified Distribution.Simple.GHCJS as GHCJS import qualified Distribution.Simple.InstallDirs as InstallDirs import qualified Distribution.Simple.LocalBuildInfo as Cabal import qualified Distribution.Simple.Setup as Cabal @@ -1540,7 +1539,7 @@ planPackages | isGHC, compVer >= mkVersion [8, 2] = mkVersion [2, 0] | otherwise = mkVersion [1, 24] where - isGHC = compFlav `elem` [GHC, GHCJS] + isGHC = compFlav == GHC compFlav = compilerFlavor comp compVer = compilerVersion comp @@ -2585,7 +2584,6 @@ elaborateInstallPlan compilerShouldUseSharedLibByDefault = case compilerFlavor compiler of GHC -> GHC.compilerBuildWay compiler == DynWay && canBuildSharedLibs - GHCJS -> GHCJS.isDynamic compiler _ -> False compilerShouldUseProfilingLibByDefault = diff --git a/cabal-install/src/Distribution/Client/ProjectPlanning/Types.hs b/cabal-install/src/Distribution/Client/ProjectPlanning/Types.hs index 15d91232441..67e10c46813 100644 --- a/cabal-install/src/Distribution/Client/ProjectPlanning/Types.hs +++ b/cabal-install/src/Distribution/Client/ProjectPlanning/Types.hs @@ -179,7 +179,7 @@ showElaboratedInstallPlan = InstallPlan.showInstallPlan_gen showNode -- TODO: [code cleanup] decide if we really need this, there's not much in it, and in principle -- even platform and compiler could be different if we're building things --- like a server + client with ghc + ghcjs +-- like a server + client with native ghc + the ghc javascript backend data ElaboratedSharedConfig = ElaboratedSharedConfig { pkgConfigPlatform :: Platform , pkgConfigCompiler :: Compiler -- TODO: [code cleanup] replace with CompilerInfo diff --git a/cabal-install/src/Distribution/Client/Run.hs b/cabal-install/src/Distribution/Client/Run.hs index 0b18235ff01..6a09dd97289 100644 --- a/cabal-install/src/Distribution/Client/Run.hs +++ b/cabal-install/src/Distribution/Client/Run.hs @@ -25,7 +25,6 @@ import Distribution.PackageDescription import Distribution.Simple (PackageDBX (..)) import Distribution.Simple.Build (addInternalBuildTools) import Distribution.Simple.BuildPaths (exeExtension) -import Distribution.Simple.Compiler (CompilerFlavor (..), compilerFlavor) import Distribution.Simple.Flag (fromFlag) import Distribution.Simple.LocalBuildInfo ( ComponentName (..) @@ -52,8 +51,6 @@ import Distribution.Simple.Utils import Distribution.System (Platform (..)) import Distribution.Types.UnqualComponentName -import qualified Distribution.Simple.GHCJS as GHCJS - import Distribution.Client.Errors import Distribution.Utils.Path @@ -137,7 +134,8 @@ splitRunArgs verbosity lbi args = -- | Run a given executable. run :: Verbosity -> LocalBuildInfo -> Executable -> [String] -> IO () -run verbosity lbi exe exeArgs = do +run verbosity lbi exe@Executable{exeName} exeArgs = do + let exeName' = prettyShow exeName curDir <- absoluteWorkingDirLBI lbi let distPref = fromFlag $ configDistPref $ configFlags lbi buildPref = buildDir lbi @@ -158,21 +156,9 @@ run verbosity lbi exe exeArgs = do (withPrograms lbi) } - (path, runArgs) <- - let exeName' = prettyShow $ exeName exe - in case compilerFlavor (compiler lbiForExe) of - GHCJS -> do - let (script, cmd, cmdArgs) = - GHCJS.runCmd - (withPrograms lbiForExe) - (i buildPref exeName' exeName') - script' <- tryCanonicalizePath script - return (cmd, cmdArgs ++ [script']) - _ -> do - p <- - tryCanonicalizePath $ - i buildPref exeName' (exeName' <.> exeExtension (hostPlatform lbiForExe)) - return (p, []) + exePath <- + tryCanonicalizePath $ + i buildPref exeName' (exeName' <.> exeExtension (hostPlatform lbiForExe)) -- Compute the appropriate environment for running the executable let progDb = withPrograms lbiForExe @@ -186,7 +172,7 @@ run verbosity lbi exe exeArgs = do if withDynExe lbiForExe then do let (Platform _ os) = hostPlatform lbiForExe - clbi <- case componentNameTargets' pkg_descr lbiForExe (CExeName (exeName exe)) of + clbi <- case componentNameTargets' pkg_descr lbiForExe (CExeName exeName) of [target] -> return (targetCLBI target) [] -> dieWithException verbosity CouldNotFindExecutable _ -> dieWithException verbosity FoundMultipleMatchingExes @@ -194,5 +180,5 @@ run verbosity lbi exe exeArgs = do return (addLibraryPath os paths env) else return env - notice verbosity $ "Running " ++ prettyShow (exeName exe) ++ "..." - rawSystemExitWithEnvCwd verbosity mbWorkDir path (runArgs ++ exeArgs) env' + notice verbosity $ "Running " ++ exeName' ++ "..." + rawSystemExitWithEnvCwd verbosity mbWorkDir exePath exeArgs env' diff --git a/cabal-install/src/Distribution/Client/SetupWrapper.hs b/cabal-install/src/Distribution/Client/SetupWrapper.hs index 4feb5e1827b..93faf44e53a 100644 --- a/cabal-install/src/Distribution/Client/SetupWrapper.hs +++ b/cabal-install/src/Distribution/Client/SetupWrapper.hs @@ -1155,27 +1155,25 @@ getCachedSetupExecutable True createDirectoryIfMissingVerbose verbosity True setupCacheDir installExecutableFile verbosity src cachedSetupProgFile - -- Do not strip if we're using GHCJS, since the result may be a script - when (maybe True ((/= GHCJS) . compilerFlavor) $ useCompiler options') $ do - -- Add the relevant PATH overrides for the package to the - -- program database. + -- Add the relevant PATH overrides for the package to the + -- program database. + setupProgDb + <- prependProgramSearchPath verbosity + (useExtraPathEnv options') + (useExtraEnvOverrides options') + (useProgramDb options') + >>= configureAllKnownPrograms verbosity + Strip.stripExe + verbosity + platform setupProgDb - <- prependProgramSearchPath verbosity - (useExtraPathEnv options') - (useExtraEnvOverrides options') - (useProgramDb options') - >>= configureAllKnownPrograms verbosity - Strip.stripExe - verbosity - platform - setupProgDb - cachedSetupProgFile + cachedSetupProgFile return cachedSetupProgFile where criticalSection' = maybe id criticalSection $ setupCacheLock options' -- | If the Setup.hs is out of date wrt the executable then recompile it. --- Currently this is GHC/GHCJS only. It should really be generalised. +-- Currently this is GHC only. It should really be generalised. compileExe :: Verbosity -> Platform @@ -1267,10 +1265,6 @@ compileSetupX (compiler, progdb, options'') <- configureCompiler verbosity options' pkgDbs <- traverse (traverse (makeRelativeToDirS mbWorkDir)) (coercePackageDBStack (usePackageDB options'')) let cabalPkgid = PackageIdentifier (mkPackageName "Cabal") cabalLibVersion - (program, extraOpts) = - case compilerFlavor compiler of - GHCJS -> (ghcjsProgram, ["-build-runner"]) - _ -> (ghcProgram, ["-threaded"]) cabalDep = maybe [] @@ -1319,7 +1313,7 @@ compileSetupX [ cppMacrosFile | useVersionMacros options' ] - , ghcOptExtra = extraOpts + , ghcOptExtra = ["-threaded"] , ghcOptExtensions = toNubListR $ [ Simple.DisableExtension Simple.ImplicitPrelude | not $ bt == Custom || any (isBasePkgId . snd) selectedDeps @@ -1346,7 +1340,7 @@ compileSetupX rewriteFileEx verbosity (i cppMacrosFile) $ generatePackageVersionMacros (pkgVersion pkgId) (map snd selectedDeps) case useLoggingHandle options' of - Nothing -> runDbProgramCwd verbosity mbWorkDir program progdb ghcCmdLine + Nothing -> runDbProgramCwd verbosity mbWorkDir ghcProgram progdb ghcCmdLine -- If build logging is enabled, redirect compiler output to -- the log file. Just logHandle -> do @@ -1354,7 +1348,7 @@ compileSetupX getDbProgramOutputCwd verbosity mbWorkDir - program + ghcProgram progdb ghcCmdLine hPutStr logHandle output diff --git a/cabal-install/tests/IntegrationTests2.hs b/cabal-install/tests/IntegrationTests2.hs index a3d9e20820a..2d840724dd9 100644 --- a/cabal-install/tests/IntegrationTests2.hs +++ b/cabal-install/tests/IntegrationTests2.hs @@ -2705,8 +2705,6 @@ testConfigOptionComments = do " -- gcc-location" `assertHasCommentLine` "gcc-location" " -- ghc-location" `assertHasCommentLine` "ghc-location" " -- ghc-pkg-location" `assertHasCommentLine` "ghc-pkg-location" - " -- ghcjs-location" `assertHasCommentLine` "ghcjs-location" - " -- ghcjs-pkg-location" `assertHasCommentLine` "ghcjs-pkg-location" " -- haddock-location" `assertHasCommentLine` "haddock-location" " -- happy-location" `assertHasCommentLine` "happy-location" " -- hpc-location" `assertHasCommentLine` "hpc-location" @@ -2727,8 +2725,6 @@ testConfigOptionComments = do " -- gcc-options" `assertHasCommentLine` "gcc-options" " -- ghc-options" `assertHasCommentLine` "ghc-options" " -- ghc-pkg-options" `assertHasCommentLine` "ghc-pkg-options" - " -- ghcjs-options" `assertHasCommentLine` "ghcjs-options" - " -- ghcjs-pkg-options" `assertHasCommentLine` "ghcjs-pkg-options" " -- haddock-options" `assertHasCommentLine` "haddock-options" " -- happy-options" `assertHasCommentLine` "happy-options" " -- hpc-options" `assertHasCommentLine` "hpc-options" diff --git a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/BuildRunner.cabal b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/BuildRunner.cabal deleted file mode 100644 index e31edc28d4c..00000000000 --- a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/BuildRunner.cabal +++ /dev/null @@ -1,21 +0,0 @@ -name: BuildRunner -version: 1.0 -build-type: Simple -cabal-version: >= 1.10 - -test-suite ghcjs-test - type: exitcode-stdio-1.0 - main-is: BuildRunner.hs - build-depends: base - default-language: Haskell2010 - -executable ghcjs-exe - main-is: BuildRunner.hs - build-depends: base - default-language: Haskell2010 - -benchmark ghcjs-bench - type: exitcode-stdio-1.0 - main-is: BuildRunner.hs - build-depends: base - default-language: Haskell2010 diff --git a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/BuildRunner.hs b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/BuildRunner.hs deleted file mode 100644 index 84cf435b65a..00000000000 --- a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/BuildRunner.hs +++ /dev/null @@ -1,7 +0,0 @@ -module Main where - -import System.Exit (exitSuccess) - -main :: IO () -main = do - exitSuccess diff --git a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/README.md b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/README.md deleted file mode 100644 index a58eb5ed102..00000000000 --- a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/README.md +++ /dev/null @@ -1,6 +0,0 @@ -This test verifies that the `-build-runner` option is passed to GHCJS when the cabal commands `test`/`run`/`bench` are run with the `--ghcjs` option. - -This test was created in order to avoid regressions in running GHCJS executables, e.g.: - -* https://github.com/haskell/cabal/issues/6175 -* https://github.com/haskell/cabal/issues/6361 diff --git a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/cabal.project b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/cabal.project deleted file mode 100644 index e6fdbadb439..00000000000 --- a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/cabal.project +++ /dev/null @@ -1 +0,0 @@ -packages: . diff --git a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/cabal.test.hs b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/cabal.test.hs deleted file mode 100644 index da8afae103e..00000000000 --- a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/cabal.test.hs +++ /dev/null @@ -1,21 +0,0 @@ -import Test.Cabal.Prelude - -main = do - cabalTest . recordMode DoNotRecord $ do - cwd <- fmap testCurrentDir getTestEnv - testInvokedWithBuildRunner cwd "test" [] - testInvokedWithBuildRunner cwd "run" ["ghcjs-exe"] - testInvokedWithBuildRunner cwd "bench" [] - -magicString = "SUCCESS! GHCJS was invoked with '-build-runner' option" - -testInvokedWithBuildRunner cwd cabalCmd extraArgs = do - output <- fails $ cabal' cabalCmd $ extraArgs ++ - [ "--ghcjs" - , "--with-compiler", cwd fakeGhcjsPath - ] - -- On windows point cabal to the right cc - ++ if isWindows then ["--with-gcc", "scripts/cc.bat"] else [] - assertOutputContains magicString output - where - fakeGhcjsPath = if isWindows then "scripts/fake-ghcjs.exe" else "scripts/fake-ghcjs.sh" diff --git a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/cc.bat b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/cc.bat deleted file mode 100644 index b2300d2fd6b..00000000000 --- a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/cc.bat +++ /dev/null @@ -1,45 +0,0 @@ -@ECHO off - -FOR /f "delims=" %%A in ('call ghc.exe --print-libdir') do set "libdir=%%A" -FOR /f "delims=" %%A in ('call ghc.exe --numeric-version') do set "numVersion=%%A" -setlocal EnableDelayedExpansion - -call :compareVersions 9.4.1 %numVersion% -if %errorlevel% == 1 (set "cc=gcc.exe") else (set "cc=clang.exe") -CALL !libdir:lib=mingw\bin\!%cc% %* -EXIT /B %ERRORLEVEL% - -REM taken from https://stackoverflow.com/questions/15807762/compare-version-numbers-in-batch-file - -:compareVersions version1 version2 -:: -:: Compares two version numbers and returns the result in the ERRORLEVEL -:: -:: Returns 1 if version1 > version2 -:: 0 if version1 = version2 -:: -1 if version1 < version2 -:: -:: The nodes must be delimited by . or , or - -:: -:: Nodes are normally strictly numeric, without a 0 prefix. A letter suffix -:: is treated as a separate node -:: -setlocal enableDelayedExpansion -set "v1=%~1" -set "v2=%~2" -:loop -call :parseNode "%v1%" n1 v1 -call :parseNode "%v2%" n2 v2 -if %n1% gtr %n2% exit /b 1 -if %n1% lss %n2% exit /b -1 -if not defined v1 if not defined v2 exit /b 0 -if not defined v1 exit /b -1 -if not defined v2 exit /b 1 -goto :loop - - -:parseNode version nodeVar remainderVar -for /f "tokens=1* delims=." %%A in ("%~1") do ( - set "%~2=%%A" - set "%~3=%%B" -) diff --git a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/fake-ghcjs.exe b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/fake-ghcjs.exe deleted file mode 100644 index 537023174dc..00000000000 Binary files a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/fake-ghcjs.exe and /dev/null differ diff --git a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/fake-ghcjs.sh b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/fake-ghcjs.sh deleted file mode 100755 index ba6e3667519..00000000000 --- a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/fake-ghcjs.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -# A script that will print out $MAGIC_STRING when invoked with the -# '-build-runner' option. -# -# When cabal is invoked with the '--ghcjs' option and the '--with-compiler' -# option set to the path of this script, cabal will successfully get to the linking -# stage (where it *should* call this script with the '-build-runner' option). - -MAGIC_STRING="SUCCESS! GHCJS was invoked with '-build-runner' option" - -if [ "$1" == "--numeric-ghcjs-version" ]; then - ghc --numeric-version -elif [ "$1" == "--numeric-ghc-version" ]; then - ghc --numeric-version -elif [[ "$*" == *-build-runner* ]]; then - echo "$MAGIC_STRING" -else - ghc "$@" -fi diff --git a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/fake-ghcjs.shim b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/fake-ghcjs.shim deleted file mode 100644 index 725429e82d7..00000000000 --- a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/fake-ghcjs.shim +++ /dev/null @@ -1,2 +0,0 @@ -path = "sh.exe" -args = "scripts/fake-ghcjs.sh" diff --git a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/ghcjs-pkg b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/ghcjs-pkg deleted file mode 100755 index 0fcfa2f1f21..00000000000 --- a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/ghcjs-pkg +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -if [ "$1" == "--numeric-ghcjs-version" ]; then - ghc --numeric-version -elif [ "$1" == "--numeric-ghc-version" ]; then - ghc --numeric-version -else - ghc-pkg "$@" -fi diff --git a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/ghcjs-pkg.exe b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/ghcjs-pkg.exe deleted file mode 100644 index 537023174dc..00000000000 Binary files a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/ghcjs-pkg.exe and /dev/null differ diff --git a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/ghcjs-pkg.shim b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/ghcjs-pkg.shim deleted file mode 100644 index d330fc23e3e..00000000000 --- a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/ghcjs-pkg.shim +++ /dev/null @@ -1,2 +0,0 @@ -path = "sh.exe" -args = "scripts/ghcjs-pkg" diff --git a/cabal-testsuite/PackageTests/GHCJS/NotSupported/cabal.out b/cabal-testsuite/PackageTests/GHCJS/NotSupported/cabal.out new file mode 100644 index 00000000000..e590e3952f2 --- /dev/null +++ b/cabal-testsuite/PackageTests/GHCJS/NotSupported/cabal.out @@ -0,0 +1,3 @@ +# cabal v2-build +Error: [Cabal-4002] +GHCJS is no longer supported. Use the JavaScript backend of GHC instead, for example with --with-compiler=javascript-unknown-ghcjs-ghc. diff --git a/cabal-testsuite/PackageTests/GHCJS/NotSupported/cabal.project b/cabal-testsuite/PackageTests/GHCJS/NotSupported/cabal.project new file mode 100644 index 00000000000..faa04288180 --- /dev/null +++ b/cabal-testsuite/PackageTests/GHCJS/NotSupported/cabal.project @@ -0,0 +1,2 @@ +packages: . +compiler: ghcjs diff --git a/cabal-testsuite/PackageTests/GHCJS/NotSupported/cabal.test.hs b/cabal-testsuite/PackageTests/GHCJS/NotSupported/cabal.test.hs new file mode 100644 index 00000000000..ddf83ef512a --- /dev/null +++ b/cabal-testsuite/PackageTests/GHCJS/NotSupported/cabal.test.hs @@ -0,0 +1,7 @@ +import Test.Cabal.Prelude + +-- Selecting the removed GHCJS compiler flavor must fail with a message that +-- points at the JavaScript backend of GHC. +main = cabalTest $ do + result <- fails $ cabal' "v2-build" ["all"] + assertOutputContains "GHCJS is no longer supported" result diff --git a/cabal-testsuite/PackageTests/GHCJS/NotSupported/ghcjs-not-supported.cabal b/cabal-testsuite/PackageTests/GHCJS/NotSupported/ghcjs-not-supported.cabal new file mode 100644 index 00000000000..d96fdfca3be --- /dev/null +++ b/cabal-testsuite/PackageTests/GHCJS/NotSupported/ghcjs-not-supported.cabal @@ -0,0 +1,11 @@ +cabal-version: 3.0 +name: ghcjs-not-supported +version: 0.1.0.0 +license: NONE +build-type: Simple + +library + exposed-modules: MyLib + build-depends: base + hs-source-dirs: src + default-language: Haskell2010 diff --git a/cabal-testsuite/PackageTests/GHCJS/NotSupported/src/MyLib.hs b/cabal-testsuite/PackageTests/GHCJS/NotSupported/src/MyLib.hs new file mode 100644 index 00000000000..e657c4403f6 --- /dev/null +++ b/cabal-testsuite/PackageTests/GHCJS/NotSupported/src/MyLib.hs @@ -0,0 +1,4 @@ +module MyLib (someFunc) where + +someFunc :: IO () +someFunc = putStrLn "someFunc" diff --git a/changelog.d/12396.md b/changelog.d/12396.md new file mode 100644 index 00000000000..976b4351cf2 --- /dev/null +++ b/changelog.d/12396.md @@ -0,0 +1,16 @@ +--- +synopsis: Remove GHCJS +packages: [Cabal, cabal-install] +prs: 12396 +issues: 11609 +significance: significant +--- + +Removes GHCJS, the standalone compiler that predates the JavaScript backend of +GHC. The `Distribution.Simple.GHCJS` module, the `ghcjs` and `ghcjs-pkg` +programs, the `--ghcjs` flag and the GHCJS-only code paths are gone. Selecting +`compiler: ghcjs` now fails with an error that points at the JavaScript backend +of GHC. The `ghcjs-options` family of fields in a package description still +parse but have no effect. In a project file or the user config, +`ghcjs-options`, `ghcjs-location`, `ghcjs-pkg-options` and +`ghcjs-pkg-location` are now unrecognised fields and warn like any other. diff --git a/doc/cabal-package-description-file.rst b/doc/cabal-package-description-file.rst index 0607caec290..9f31a228dda 100644 --- a/doc/cabal-package-description-file.rst +++ b/doc/cabal-package-description-file.rst @@ -1820,20 +1820,32 @@ system-dependent values for these fields. generate the ``.dyn_o`` files). .. pkg-field:: ghcjs-options: token list + :deprecated: - Like :pkg-field:`ghc-options` but applies to GHCJS + Formerly like :pkg-field:`ghc-options` but for GHCJS. Still accepted so + that existing packages parse, but ignored since GHCJS support was + removed. .. pkg-field:: ghcjs-prof-options: token list + :deprecated: - Like :pkg-field:`ghc-prof-options` but applies to GHCJS + Formerly like :pkg-field:`ghc-prof-options` but for GHCJS. Still accepted + so that existing packages parse, but ignored since GHCJS support was + removed. .. pkg-field:: ghcjs-shared-options: token list + :deprecated: - Like :pkg-field:`ghc-shared-options` but applies to GHCJS + Formerly like :pkg-field:`ghc-shared-options` but for GHCJS. Still + accepted so that existing packages parse, but ignored since GHCJS support + was removed. .. pkg-field:: ghcjs-prof-shared-options: token list + :deprecated: - Like :pkg-field:`ghc-prof-shared-options` but applies to GHCJS + Formerly like :pkg-field:`ghc-prof-shared-options` but for GHCJS. Still + accepted so that existing packages parse, but ignored since GHCJS support + was removed. .. pkg-field:: includes: filename list :since: 1.0 diff --git a/doc/cabal-project-description-file.rst b/doc/cabal-project-description-file.rst index 4b3858862f4..3530cf23051 100644 --- a/doc/cabal-project-description-file.rst +++ b/doc/cabal-project-description-file.rst @@ -1074,7 +1074,7 @@ feature was added. Specify the path to a particular compiler to be used. If not an absolute path, it will be resolved according to the ``PATH`` - environment. The type of the compiler (GHC, GHCJS, etc) must be + environment. The type of the compiler (GHC, UHC, etc) must be consistent with the setting of the :cfg-field:`compiler` field. The most common use of this option is to specify a different version @@ -1157,7 +1157,7 @@ feature was added. The command line variant of this flag is ``--configure-option=arg``, which can be specified multiple times to pass multiple options. -.. cfg-field:: compiler: ghc, ghcjs, jhc, lhc, or uhc +.. cfg-field:: compiler: ghc, jhc, lhc, or uhc --compiler=compiler :synopsis: Compiler to build with. diff --git a/doc/cmd-v1-help/build.txt b/doc/cmd-v1-help/build.txt index d8ef015e678..8d4873dae7d 100644 --- a/doc/cmd-v1-help/build.txt +++ b/doc/cmd-v1-help/build.txt @@ -30,8 +30,8 @@ Examples: cabal v1-build foo A component (i.e. lib, exe, test suite) The flags --with-PROG and --PROG-option(s) can be used with the following programs: - alex ar c2hs cpphs doctest gcc ghc ghc-pkg ghcjs ghcjs-pkg haddock happy hpc - hsc2hs hscolour jhc ld pkg-config runghc strip tar uhc + alex ar c2hs cpphs doctest gcc ghc ghc-pkg haddock happy hpc hsc2hs hscolour + jhc ld pkg-config runghc strip tar uhc The v1-build command is a part of the legacy v1 style of cabal usage. diff --git a/doc/cmd-v1-help/configure.txt b/doc/cmd-v1-help/configure.txt index 7059ef5d400..8ae0e879c7b 100644 --- a/doc/cmd-v1-help/configure.txt +++ b/doc/cmd-v1-help/configure.txt @@ -16,7 +16,6 @@ Flags for v1-configure: --cabal-file=PATH # use this Cabal file --keep-temp-files # Keep temporary files. -g, --ghc # Compile with GHC - --ghcjs # Compile with GHCJS --uhc # Compile with UHC -w PATH or -wPATH, --with-compiler=PATH # Give the path to a particular compiler @@ -206,8 +205,8 @@ Flags for v1-configure: after a successful build (v2-build only) The flags --with-PROG and --PROG-option(s) can be used with the following programs: - alex ar c2hs cpphs doctest gcc ghc ghc-pkg ghcjs ghcjs-pkg haddock happy hpc - hsc2hs hscolour jhc ld pkg-config runghc strip tar uhc + alex ar c2hs cpphs doctest gcc ghc ghc-pkg haddock happy hpc hsc2hs hscolour + jhc ld pkg-config runghc strip tar uhc Examples: cabal v1-configure diff --git a/doc/cmd-v1-help/install.txt b/doc/cmd-v1-help/install.txt index b4937a719cc..9ff8d062e2e 100644 --- a/doc/cmd-v1-help/install.txt +++ b/doc/cmd-v1-help/install.txt @@ -27,7 +27,6 @@ Flags for v1-install: --cabal-file=PATH # use this Cabal file --keep-temp-files # Keep temporary files. -g, --ghc # Compile with GHC - --ghcjs # Compile with GHCJS --uhc # Compile with UHC -w PATH or -wPATH, --with-compiler=PATH # Give the path to a particular compiler @@ -375,8 +374,8 @@ Flags for v1-install: $arch, $benchmark) The flags --with-PROG and --PROG-option(s) can be used with the following programs: - alex ar c2hs cpphs doctest gcc ghc ghc-pkg ghcjs ghcjs-pkg haddock happy hpc - hsc2hs hscolour jhc ld pkg-config runghc strip tar uhc + alex ar c2hs cpphs doctest gcc ghc ghc-pkg haddock happy hpc hsc2hs hscolour + jhc ld pkg-config runghc strip tar uhc Examples: cabal v1-install Package in the current directory diff --git a/doc/cmd-v1-help/reconfigure.txt b/doc/cmd-v1-help/reconfigure.txt index 15d821d1358..8d32929356b 100644 --- a/doc/cmd-v1-help/reconfigure.txt +++ b/doc/cmd-v1-help/reconfigure.txt @@ -15,7 +15,6 @@ Flags for v1-reconfigure: --cabal-file=PATH # use this Cabal file --keep-temp-files # Keep temporary files. -g, --ghc # Compile with GHC - --ghcjs # Compile with GHCJS --uhc # Compile with UHC -w PATH or -wPATH, --with-compiler=PATH # Give the path to a particular compiler diff --git a/doc/cmd-v2-help/bench.txt b/doc/cmd-v2-help/bench.txt index c5ba5a99f02..3673a0135e5 100644 --- a/doc/cmd-v2-help/bench.txt +++ b/doc/cmd-v2-help/bench.txt @@ -20,7 +20,6 @@ Flags for bench: files (default dist) --keep-temp-files # Keep temporary files. -g, --ghc # Compile with GHC - --ghcjs # Compile with GHCJS --uhc # Compile with UHC -w PATH or -wPATH, --with-compiler=PATH # Give the path to a particular compiler diff --git a/doc/cmd-v2-help/build.txt b/doc/cmd-v2-help/build.txt index c4d2f57a62f..026d5f13a39 100644 --- a/doc/cmd-v2-help/build.txt +++ b/doc/cmd-v2-help/build.txt @@ -20,7 +20,6 @@ Flags for build: files (default dist) --keep-temp-files # Keep temporary files. -g, --ghc # Compile with GHC - --ghcjs # Compile with GHCJS --uhc # Compile with UHC -w PATH or -wPATH, --with-compiler=PATH # Give the path to a particular compiler diff --git a/doc/cmd-v2-help/configure.txt b/doc/cmd-v2-help/configure.txt index c97f66063b1..4fe69c01f31 100644 --- a/doc/cmd-v2-help/configure.txt +++ b/doc/cmd-v2-help/configure.txt @@ -33,7 +33,6 @@ Flags for configure: files (default dist) --keep-temp-files # Keep temporary files. -g, --ghc # Compile with GHC - --ghcjs # Compile with GHCJS --uhc # Compile with UHC -w PATH or -wPATH, --with-compiler=PATH # Give the path to a particular compiler diff --git a/doc/cmd-v2-help/exec.txt b/doc/cmd-v2-help/exec.txt index ea4368e9cd8..e6418914ff0 100644 --- a/doc/cmd-v2-help/exec.txt +++ b/doc/cmd-v2-help/exec.txt @@ -22,7 +22,6 @@ Flags for exec: files (default dist) --keep-temp-files # Keep temporary files. -g, --ghc # Compile with GHC - --ghcjs # Compile with GHCJS --uhc # Compile with UHC -w PATH or -wPATH, --with-compiler=PATH # Give the path to a particular compiler diff --git a/doc/cmd-v2-help/freeze.txt b/doc/cmd-v2-help/freeze.txt index 64269ce7f8e..923faf4f2eb 100644 --- a/doc/cmd-v2-help/freeze.txt +++ b/doc/cmd-v2-help/freeze.txt @@ -25,7 +25,6 @@ Flags for freeze: files (default dist) --keep-temp-files # Keep temporary files. -g, --ghc # Compile with GHC - --ghcjs # Compile with GHCJS --uhc # Compile with UHC -w PATH or -wPATH, --with-compiler=PATH # Give the path to a particular compiler diff --git a/doc/cmd-v2-help/gen-bounds.txt b/doc/cmd-v2-help/gen-bounds.txt index 8764aac5bda..2343eb8c497 100644 --- a/doc/cmd-v2-help/gen-bounds.txt +++ b/doc/cmd-v2-help/gen-bounds.txt @@ -11,7 +11,6 @@ Flags for gen-bounds: files (default dist) --keep-temp-files # Keep temporary files. -g, --ghc # Compile with GHC - --ghcjs # Compile with GHCJS --uhc # Compile with UHC -w PATH or -wPATH, --with-compiler=PATH # Give the path to a particular compiler diff --git a/doc/cmd-v2-help/haddock.txt b/doc/cmd-v2-help/haddock.txt index 2e5046e47f7..06647d8dd98 100644 --- a/doc/cmd-v2-help/haddock.txt +++ b/doc/cmd-v2-help/haddock.txt @@ -25,7 +25,6 @@ Flags for haddock: files (default dist) --keep-temp-files # Keep temporary files. -g, --ghc # Compile with GHC - --ghcjs # Compile with GHCJS --uhc # Compile with UHC -w PATH or -wPATH, --with-compiler=PATH # Give the path to a particular compiler diff --git a/doc/cmd-v2-help/install.txt b/doc/cmd-v2-help/install.txt index 8850a2a2890..2ec898208b7 100644 --- a/doc/cmd-v2-help/install.txt +++ b/doc/cmd-v2-help/install.txt @@ -21,7 +21,6 @@ Flags for install: files (default dist) --keep-temp-files # Keep temporary files. -g, --ghc # Compile with GHC - --ghcjs # Compile with GHCJS --uhc # Compile with UHC -w PATH or -wPATH, --with-compiler=PATH # Give the path to a particular compiler diff --git a/doc/cmd-v2-help/list-bin.txt b/doc/cmd-v2-help/list-bin.txt index 3b8b8f01156..4813a871a17 100644 --- a/doc/cmd-v2-help/list-bin.txt +++ b/doc/cmd-v2-help/list-bin.txt @@ -12,7 +12,6 @@ Flags for list-bin: files (default dist) --keep-temp-files # Keep temporary files. -g, --ghc # Compile with GHC - --ghcjs # Compile with GHCJS --uhc # Compile with UHC -w PATH or -wPATH, --with-compiler=PATH # Give the path to a particular compiler diff --git a/doc/cmd-v2-help/outdated.txt b/doc/cmd-v2-help/outdated.txt index 85a07dd7493..7c8ac302dde 100644 --- a/doc/cmd-v2-help/outdated.txt +++ b/doc/cmd-v2-help/outdated.txt @@ -13,7 +13,6 @@ Flags for outdated: files (default dist) --keep-temp-files # Keep temporary files. -g, --ghc # Compile with GHC - --ghcjs # Compile with GHCJS --uhc # Compile with UHC -w PATH or -wPATH, --with-compiler=PATH # Give the path to a particular compiler diff --git a/doc/cmd-v2-help/path.txt b/doc/cmd-v2-help/path.txt index 74f4a3b3355..85d6a0fcf66 100644 --- a/doc/cmd-v2-help/path.txt +++ b/doc/cmd-v2-help/path.txt @@ -14,7 +14,6 @@ Flags for path: files (default dist) --keep-temp-files # Keep temporary files. -g, --ghc # Compile with GHC - --ghcjs # Compile with GHCJS --uhc # Compile with UHC -w PATH or -wPATH, --with-compiler=PATH # Give the path to a particular compiler diff --git a/doc/cmd-v2-help/repl.txt b/doc/cmd-v2-help/repl.txt index 2913c652167..7a8d67a106d 100644 --- a/doc/cmd-v2-help/repl.txt +++ b/doc/cmd-v2-help/repl.txt @@ -23,7 +23,6 @@ Flags for repl: files (default dist) --keep-temp-files # Keep temporary files. -g, --ghc # Compile with GHC - --ghcjs # Compile with GHCJS --uhc # Compile with UHC -w PATH or -wPATH, --with-compiler=PATH # Give the path to a particular compiler diff --git a/doc/cmd-v2-help/run.txt b/doc/cmd-v2-help/run.txt index f8dd2b32a58..315e1f8ec1f 100644 --- a/doc/cmd-v2-help/run.txt +++ b/doc/cmd-v2-help/run.txt @@ -26,7 +26,6 @@ Flags for run: files (default dist) --keep-temp-files # Keep temporary files. -g, --ghc # Compile with GHC - --ghcjs # Compile with GHCJS --uhc # Compile with UHC -w PATH or -wPATH, --with-compiler=PATH # Give the path to a particular compiler diff --git a/doc/cmd-v2-help/target.txt b/doc/cmd-v2-help/target.txt index 6dddae62364..7ee4373a095 100644 --- a/doc/cmd-v2-help/target.txt +++ b/doc/cmd-v2-help/target.txt @@ -42,7 +42,6 @@ Flags for target: files (default dist) --keep-temp-files # Keep temporary files. -g, --ghc # Compile with GHC - --ghcjs # Compile with GHCJS --uhc # Compile with UHC -w PATH or -wPATH, --with-compiler=PATH # Give the path to a particular compiler diff --git a/doc/cmd-v2-help/test.txt b/doc/cmd-v2-help/test.txt index 00c529d1a3b..5011fa949e6 100644 --- a/doc/cmd-v2-help/test.txt +++ b/doc/cmd-v2-help/test.txt @@ -22,7 +22,6 @@ Flags for test: files (default dist) --keep-temp-files # Keep temporary files. -g, --ghc # Compile with GHC - --ghcjs # Compile with GHCJS --uhc # Compile with UHC -w PATH or -wPATH, --with-compiler=PATH # Give the path to a particular compiler diff --git a/doc/cmd-v2-help/update.txt b/doc/cmd-v2-help/update.txt index cc4e6a3ea26..ff6cdee8feb 100644 --- a/doc/cmd-v2-help/update.txt +++ b/doc/cmd-v2-help/update.txt @@ -12,7 +12,6 @@ Flags for update: files (default dist) --keep-temp-files # Keep temporary files. -g, --ghc # Compile with GHC - --ghcjs # Compile with GHCJS --uhc # Compile with UHC -w PATH or -wPATH, --with-compiler=PATH # Give the path to a particular compiler diff --git a/doc/config.rst b/doc/config.rst index 00032a459ca..bc46a86cb79 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -339,10 +339,6 @@ The list of known programs is: +-----------------------+------------------------------------------------------------------------------------------------------------------------------------+ | ``ghc-pkg`` | | +-----------------------+------------------------------------------------------------------------------------------------------------------------------------+ -| ``ghcjs`` | | -+-----------------------+------------------------------------------------------------------------------------------------------------------------------------+ -| ``ghcjs-pkg`` | | -+-----------------------+------------------------------------------------------------------------------------------------------------------------------------+ | ``haddock`` | ``_ | +-----------------------+------------------------------------------------------------------------------------------------------------------------------------+ | ``happy`` | ``_ | diff --git a/doc/setup-commands.rst b/doc/setup-commands.rst index bdb8b34dfcd..d53fa6a809d 100644 --- a/doc/setup-commands.rst +++ b/doc/setup-commands.rst @@ -167,7 +167,6 @@ The following options govern the programs used to process the source files of a package: .. option:: -g, --ghc - --ghcjs --uhc --haskell-suite @@ -203,9 +202,8 @@ files of a package: ``--with-cpphs=/usr/local/bin/cpphs``. The full list of accepted programs is as follows: ``alex``, ``ar``, ``c2hs``, ``cpphs``, ``doctest``, ``gcc``, ``ghc``, - ``ghc-pkg``, ``ghcjs``, ``ghcjs-pkg``, ``haddock``, ``happy``, - ``hpc``, ``hsc2hs``, ``hscolour``, ``jhc``, ``ld``, ``pkg-config``, - ``runghc``, ``strip``, ``tar``, ``uhc``. + ``ghc-pkg``, ``haddock``, ``happy``, ``hpc``, ``hsc2hs``, ``hscolour``, + ``jhc``, ``ld``, ``pkg-config``, ``runghc``, ``strip``, ``tar``, ``uhc``. .. option:: --PROG-options=OPTS @@ -451,8 +449,9 @@ $arch e.g. ``i386``, ``x86_64``, ``ppc`` or ``sparc`` $abitag An optional tag that a compiler can use for telling incompatible - ABI's on the same architecture apart. GHCJS encodes the underlying - GHC version in the ABI tag. + ABI's on the same architecture apart. GHC uses the part of its project + unit id that is not already in its version, e.g. ``inplace`` for an + in-tree build. $abi A shortcut for getting a path that completely identifies the platform in terms of binary compatibility. Expands to the same value diff --git a/doc/setup-help/build.txt b/doc/setup-help/build.txt index 720d2ef784a..e2fa52204a8 100644 --- a/doc/setup-help/build.txt +++ b/doc/setup-help/build.txt @@ -30,5 +30,5 @@ Examples: cabal build foo A component (i.e. lib, exe, test suite) The flags --with-PROG and --PROG-option(s) can be used with the following programs: - alex ar c2hs cpphs doctest gcc ghc ghc-pkg ghcjs ghcjs-pkg haddock happy hpc - hsc2hs hscolour jhc ld pkg-config runghc strip tar uhc + alex ar c2hs cpphs doctest gcc ghc ghc-pkg haddock happy hpc hsc2hs hscolour + jhc ld pkg-config runghc strip tar uhc diff --git a/doc/setup-help/configure.txt b/doc/setup-help/configure.txt index a5b3587cdd3..4d89ab66c29 100644 --- a/doc/setup-help/configure.txt +++ b/doc/setup-help/configure.txt @@ -16,7 +16,6 @@ Flags for configure: --cabal-file=PATH # use this Cabal file --keep-temp-files # Keep temporary files. -g, --ghc # Compile with GHC - --ghcjs # Compile with GHCJS --uhc # Compile with UHC -w PATH or -wPATH, --with-compiler=PATH # Give the path to a particular compiler @@ -192,5 +191,5 @@ Flags for configure: use "" to prevent splitting) The flags --with-PROG and --PROG-option(s) can be used with the following programs: - alex ar c2hs cpphs doctest gcc ghc ghc-pkg ghcjs ghcjs-pkg haddock happy hpc - hsc2hs hscolour jhc ld pkg-config runghc strip tar uhc + alex ar c2hs cpphs doctest gcc ghc ghc-pkg haddock happy hpc hsc2hs hscolour + jhc ld pkg-config runghc strip tar uhc