Skip to content

Commit a5106be

Browse files
authored
Merge pull request #8488 from haskell/t8487-build-profile-msg-reflect-global-config
"Build profile" now reflects optimization level set in global config
2 parents f13a189 + f33e5e9 commit a5106be

File tree

8 files changed

+50
-2
lines changed

8 files changed

+50
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -859,8 +859,10 @@ printPlan verbosity
859859
ProjectBaseContext {
860860
buildSettings = BuildTimeSettings{buildSettingDryRun},
861861
projectConfig = ProjectConfig {
862+
projectConfigAllPackages =
863+
PackageConfig {packageConfigOptimization = globalOptimization},
862864
projectConfigLocalPackages =
863-
PackageConfig {packageConfigOptimization}
865+
PackageConfig {packageConfigOptimization = localOptimization}
864866
}
865867
}
866868
ProjectBuildContext {
@@ -994,7 +996,7 @@ printPlan verbosity
994996
showBuildProfile :: String
995997
showBuildProfile = "Build profile: " ++ unwords [
996998
"-w " ++ (showCompilerId . pkgConfigCompiler) elaboratedShared,
997-
"-O" ++ (case packageConfigOptimization of
999+
"-O" ++ (case globalOptimization <> localOptimization of -- if local is not set, read global
9981000
Setup.Flag NoOptimisation -> "0"
9991001
Setup.Flag NormalOptimisation -> "1"
10001002
Setup.Flag MaximumOptimisation -> "2"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# cabal build
2+
Resolving dependencies...
3+
Build profile: -w ghc-<GHCVER> -O2
4+
In order, the following will be built:
5+
- test-0.1.0.0 (lib) (first run)
6+
Configuring library for test-0.1.0.0..
7+
Preprocessing library for test-0.1.0.0..
8+
Building library for test-0.1.0.0..
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: .
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- 2022-09-20, issue #8487
2+
--
3+
4+
import Test.Cabal.Prelude
5+
6+
main = cabalTest $ do
7+
cabalG [ "--config-file", "config.file" ] "build" [ "test" ]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
optimization: 2
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module MyLib (someFunc) where
2+
3+
someFunc :: IO ()
4+
someFunc = putStrLn "someFunc"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cabal-version: 3.0
2+
name: test
3+
version: 0.1.0.0
4+
license: NONE
5+
6+
maintainer: Artem Pelenitsyn
7+
build-type: Simple
8+
9+
library
10+
exposed-modules: MyLib
11+
build-depends: base
12+
hs-source-dirs: src
13+
default-language: Haskell2010

changelog.d/issue-8487

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
synopsis: "Build profile" message now reflects optimization level set in global config
2+
packages: cabal-install
3+
prs: #8488
4+
issues: #8487
5+
6+
description: {
7+
8+
Imagine you have `optimization: 2` in your `~/.cabal/config`, and you call `cabal build`
9+
in a project that doesn't have optimization level explicitly set in its project file.
10+
You will still see 'Build profile: -w ghc-<VER> -O1'. This is incorrect and was fixed
11+
in this patch: now you'll see '-O2'.
12+
}

0 commit comments

Comments
 (0)