Skip to content

Commit 00537e3

Browse files
Mikolajmergify[bot]
authored andcommitted
Revert "Fix project-local build flags being ignored."
This reverts commit b547ead from #8623. Unexpected side-effect has been found, so these code improvements have to be done differently. The other commit in the PR is a test and it's retained. (cherry picked from commit 533cbc1)
1 parent b4d3ca1 commit 00537e3

File tree

7 files changed

+8
-64
lines changed

7 files changed

+8
-64
lines changed

cabal-install/src/Distribution/Client/Configure.hs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,6 @@ configure verbosity packageDBs repoCtxt comp platform progdb
154154
(fromFlagOrDefault
155155
(useDistPref defaultSetupScriptOptions)
156156
(configDistPref configFlags))
157-
(fromFlagOrDefault
158-
(setupConfigDynamic defaultSetupScriptOptions)
159-
(configDynExe configFlags))
160157
(chooseCabalVersion
161158
configExFlags
162159
(flagToMaybe (configCabalVersion configExFlags)))
@@ -170,7 +167,6 @@ configureSetupScript :: PackageDBStack
170167
-> Platform
171168
-> ProgramDb
172169
-> FilePath
173-
-> Bool
174170
-> VersionRange
175171
-> Maybe Lock
176172
-> Bool
@@ -182,7 +178,6 @@ configureSetupScript packageDBs
182178
platform
183179
progdb
184180
distPref
185-
dynExe
186181
cabalVersion
187182
lock
188183
forceExternal
@@ -214,7 +209,6 @@ configureSetupScript packageDBs
214209
, useDependenciesExclusive = not defaultSetupDeps && isJust explicitSetupDeps
215210
, useVersionMacros = not defaultSetupDeps && isJust explicitSetupDeps
216211
, isInteractive = False
217-
, setupConfigDynamic = dynExe
218212
}
219213
where
220214
-- When we are compiling a legacy setup script without an explicit

cabal-install/src/Distribution/Client/Install.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,6 @@ performInstallations verbosity
10591059
platform
10601060
progdb
10611061
distPref
1062-
(fromFlagOrDefault (setupConfigDynamic defaultSetupScriptOptions) $ configDynExe configFlags)
10631062
(chooseCabalVersion configExFlags (libVersion miscOptions))
10641063
(Just lock)
10651064
parallelInstall

cabal-install/src/Distribution/Client/ProjectPlanOutput.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,9 @@ encodePlanAsJson distDirLayout elaboratedInstallPlan elaboratedSharedConfig =
272272
comp2str = prettyShow
273273

274274
style2str :: Bool -> BuildStyle -> String
275-
style2str _ BuildAndInstall = "global"
276275
style2str True _ = "local"
277276
style2str False BuildInplaceOnly = "inplace"
277+
style2str False BuildAndInstall = "global"
278278

279279
jdisplay :: Pretty a => a -> J.Value
280280
jdisplay = J.String . prettyShow

cabal-install/src/Distribution/Client/ProjectPlanning.hs

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,6 @@ rebuildInstallPlan verbosity
672672
projectConfigAllPackages,
673673
projectConfigLocalPackages,
674674
projectConfigSpecificPackage,
675-
projectPackagesNamed,
676675
projectConfigBuildOnly
677676
}
678677
(compiler, platform, progdb) pkgConfigDB
@@ -698,7 +697,6 @@ rebuildInstallPlan verbosity
698697
localPackages
699698
sourcePackageHashes
700699
installDirs
701-
projectPackagesNamed
702700
projectConfigShared
703701
projectConfigAllPackages
704702
projectConfigLocalPackages
@@ -1363,7 +1361,6 @@ elaborateInstallPlan
13631361
-> [PackageSpecifier (SourcePackage (PackageLocation loc))]
13641362
-> Map PackageId PackageSourceHash
13651363
-> InstallDirs.InstallDirTemplates
1366-
-> [PackageVersionConstraint]
13671364
-> ProjectConfigShared
13681365
-> PackageConfig
13691366
-> PackageConfig
@@ -1375,7 +1372,6 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB
13751372
solverPlan localPackages
13761373
sourcePackageHashes
13771374
defaultInstallDirs
1378-
extraPackages
13791375
sharedPackageConfig
13801376
allPackagesConfig
13811377
localPackagesConfig
@@ -2046,21 +2042,15 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB
20462042
$ map packageId
20472043
$ SolverInstallPlan.reverseDependencyClosure
20482044
solverPlan
2049-
(map PlannedId (Set.toList pkgsInplaceToProject))
2045+
(map PlannedId (Set.toList pkgsLocalToProject))
20502046

20512047
isLocalToProject :: Package pkg => pkg -> Bool
20522048
isLocalToProject pkg = Set.member (packageId pkg)
20532049
pkgsLocalToProject
20542050

2055-
pkgsInplaceToProject :: Set PackageId
2056-
pkgsInplaceToProject =
2057-
Set.fromList (catMaybes (map shouldBeLocal localPackages))
2058-
--TODO: localPackages is a misnomer, it's all project packages
2059-
-- here is where we decide which ones will be local!
2060-
20612051
pkgsLocalToProject :: Set PackageId
20622052
pkgsLocalToProject =
2063-
Set.fromList (catMaybes (map (isInLocal extraPackages) localPackages))
2053+
Set.fromList (catMaybes (map shouldBeLocal localPackages))
20642054
--TODO: localPackages is a misnomer, it's all project packages
20652055
-- here is where we decide which ones will be local!
20662056

@@ -2129,28 +2119,6 @@ shouldBeLocal (SpecificSourcePackage pkg) = case srcpkgSource pkg of
21292119
LocalUnpackedPackage _ -> Just (packageId pkg)
21302120
_ -> Nothing
21312121

2132-
-- Used to determine which packages are affected by local package configuration
2133-
-- flags like ‘--enable-shared --enable-executable-dynamic --disable-library-vanilla’.
2134-
isInLocal :: [PackageVersionConstraint] -> PackageSpecifier (SourcePackage (PackageLocation loc)) -> Maybe PackageId
2135-
isInLocal _ NamedPackage{} = Nothing
2136-
isInLocal _extraPackages (SpecificSourcePackage pkg) = case srcpkgSource pkg of
2137-
LocalUnpackedPackage _ -> Just (packageId pkg)
2138-
-- LocalTarballPackage is matched here too, because otherwise ‘sdistize’
2139-
-- produces for ‘localPackages’ in the ‘ProjectBaseContext’ a
2140-
-- LocalTarballPackage, and ‘shouldBeLocal’ will make flags like
2141-
-- ‘--disable-library-vanilla’ have no effect for a typical
2142-
-- ‘cabal install --lib --enable-shared enable-executable-dynamic --disable-library-vanilla’,
2143-
-- as these flags would apply to local packages, but the sdist would
2144-
-- erroneously not get categorized as a local package, so the flags would be
2145-
-- ignored and produce a package with an unchanged hash.
2146-
LocalTarballPackage _ -> Just (packageId pkg)
2147-
-- TODO: the docs say ‘extra-packages’ is implemented in cabal project
2148-
-- files. We can fix that here by checking that the version range matches.
2149-
--RemoteTarballPackage _ -> _
2150-
--RepoTarballPackage _ -> _
2151-
--RemoteSourceRepoPackage _ -> _
2152-
_ -> Nothing
2153-
21542122
-- | Given a 'ElaboratedPlanPackage', report if it matches a 'ComponentName'.
21552123
matchPlanPkg :: (ComponentName -> Bool) -> ElaboratedPlanPackage -> Bool
21562124
matchPlanPkg p = InstallPlan.foldPlanPackage (p . ipiComponentName) (matchElabPkg p)
@@ -3430,8 +3398,7 @@ setupHsScriptOptions (ReadyPackage elab@ElaboratedConfiguredPackage{..})
34303398
useWin32CleanHack = False, --TODO: [required eventually]
34313399
forceExternalSetupMethod = isParallelBuild,
34323400
setupCacheLock = Just cacheLock,
3433-
isInteractive = False,
3434-
setupConfigDynamic = elabDynExe
3401+
isInteractive = False
34353402
}
34363403

34373404

cabal-install/src/Distribution/Client/SetupWrapper.hs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ import Distribution.Simple.BuildPaths
7171
import Distribution.Simple.Command
7272
( CommandUI(..), commandShowOptions )
7373
import Distribution.Simple.Program.GHC
74-
( GhcMode(..), GhcDynLinkMode(..), GhcOptions(..), renderGhcOptions )
74+
( GhcMode(..), GhcOptions(..), renderGhcOptions )
7575
import qualified Distribution.Simple.PackageIndex as PackageIndex
7676
import Distribution.Simple.PackageIndex (InstalledPackageIndex)
7777
import qualified Distribution.InstalledPackageInfo as IPI
@@ -249,12 +249,7 @@ data SetupScriptOptions = SetupScriptOptions {
249249
-- | Is the task we are going to run an interactive foreground task,
250250
-- or an non-interactive background task? Based on this flag we
251251
-- decide whether or not to delegate ctrl+c to the spawned task
252-
isInteractive :: Bool,
253-
254-
-- Also track build output artifact configuration.
255-
256-
-- | Pass `-dynamic` to `ghc` for dynamic rather than static linking.
257-
setupConfigDynamic :: Bool
252+
isInteractive :: Bool
258253
}
259254

260255
defaultSetupScriptOptions :: SetupScriptOptions
@@ -277,8 +272,7 @@ defaultSetupScriptOptions = SetupScriptOptions {
277272
useWin32CleanHack = False,
278273
forceExternalSetupMethod = False,
279274
setupCacheLock = Nothing,
280-
isInteractive = False,
281-
setupConfigDynamic = False
275+
isInteractive = False
282276
}
283277

284278
workingDir :: SetupScriptOptions -> FilePath
@@ -846,9 +840,6 @@ getExternalSetupMethod verbosity options pkg bt = do
846840
-- --ghc-option=-v instead!
847841
ghcOptVerbosity = Flag (min verbosity normal)
848842
, ghcOptMode = Flag GhcModeMake
849-
, ghcOptDynLinkMode = case setupConfigDynamic options'' of
850-
True -> Flag GhcDynamicOnly
851-
False -> Flag GhcStaticOnly
852843
, ghcOptInputFiles = toNubListR [setupHs]
853844
, ghcOptOutputFile = Flag setupProgFile
854845
, ghcOptObjDir = Flag setupDir

cabal-install/tests/IntegrationTests2.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,7 @@ testProgramOptionsLocal config0 = do
15911591
(Just [ghcFlag])
15921592
(getProgArgs localPackages "q")
15931593
assertEqual "p"
1594-
(Just [ghcFlag])
1594+
Nothing
15951595
(getProgArgs localPackages "p")
15961596
where
15971597
testdir = "regression/program-options"

changelog.d/pr-8623

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)