Skip to content

Commit

Permalink
Merge pull request #8488 from haskell/t8487-build-profile-msg-reflect…
Browse files Browse the repository at this point in the history
…-global-config

"Build profile" now reflects optimization level set in global config
  • Loading branch information
mergify[bot] authored Oct 1, 2022
2 parents f13a189 + f33e5e9 commit a5106be
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cabal-install/src/Distribution/Client/ProjectOrchestration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -859,8 +859,10 @@ printPlan verbosity
ProjectBaseContext {
buildSettings = BuildTimeSettings{buildSettingDryRun},
projectConfig = ProjectConfig {
projectConfigAllPackages =
PackageConfig {packageConfigOptimization = globalOptimization},
projectConfigLocalPackages =
PackageConfig {packageConfigOptimization}
PackageConfig {packageConfigOptimization = localOptimization}
}
}
ProjectBuildContext {
Expand Down Expand Up @@ -994,7 +996,7 @@ printPlan verbosity
showBuildProfile :: String
showBuildProfile = "Build profile: " ++ unwords [
"-w " ++ (showCompilerId . pkgConfigCompiler) elaboratedShared,
"-O" ++ (case packageConfigOptimization of
"-O" ++ (case globalOptimization <> localOptimization of -- if local is not set, read global
Setup.Flag NoOptimisation -> "0"
Setup.Flag NormalOptimisation -> "1"
Setup.Flag MaximumOptimisation -> "2"
Expand Down
8 changes: 8 additions & 0 deletions cabal-testsuite/PackageTests/ConfigFile/T8487/cabal.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# cabal build
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O2
In order, the following will be built:
- test-0.1.0.0 (lib) (first run)
Configuring library for test-0.1.0.0..
Preprocessing library for test-0.1.0.0..
Building library for test-0.1.0.0..
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: .
7 changes: 7 additions & 0 deletions cabal-testsuite/PackageTests/ConfigFile/T8487/cabal.test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- 2022-09-20, issue #8487
--

import Test.Cabal.Prelude

main = cabalTest $ do
cabalG [ "--config-file", "config.file" ] "build" [ "test" ]
1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/ConfigFile/T8487/config.file
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
optimization: 2
4 changes: 4 additions & 0 deletions cabal-testsuite/PackageTests/ConfigFile/T8487/src/MyLib.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module MyLib (someFunc) where

someFunc :: IO ()
someFunc = putStrLn "someFunc"
13 changes: 13 additions & 0 deletions cabal-testsuite/PackageTests/ConfigFile/T8487/test.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cabal-version: 3.0
name: test
version: 0.1.0.0
license: NONE
author: [email protected]
maintainer: Artem Pelenitsyn
build-type: Simple

library
exposed-modules: MyLib
build-depends: base
hs-source-dirs: src
default-language: Haskell2010
12 changes: 12 additions & 0 deletions changelog.d/issue-8487
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
synopsis: "Build profile" message now reflects optimization level set in global config
packages: cabal-install
prs: #8488
issues: #8487

description: {

Imagine you have `optimization: 2` in your `~/.cabal/config`, and you call `cabal build`
in a project that doesn't have optimization level explicitly set in its project file.
You will still see 'Build profile: -w ghc-<VER> -O1'. This is incorrect and was fixed
in this patch: now you'll see '-O2'.
}

0 comments on commit a5106be

Please sign in to comment.