Skip to content

Commit 26d356a

Browse files
committed
Add allGhcOptExtra from all *-options
1 parent dd1dda7 commit 26d356a

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

Cabal/src/Distribution/Simple/GHC.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ libAbiHash verbosity _pkg_descr lbi lib clbi = do
744744
, ghcOptFPic = toFlag True
745745
, ghcOptHiSuffix = toFlag "dyn_hi"
746746
, ghcOptObjSuffix = toFlag "dyn_o"
747-
, ghcOptExtra = hcOptions GHC libBi ++ hcSharedOptions GHC libBi
747+
, ghcOptExtra = Internal.allGhcOptExtra libBi <> hcOptions GHC libBi ++ hcSharedOptions GHC libBi
748748
}
749749
profArgs =
750750
vanillaArgs
@@ -756,7 +756,7 @@ libAbiHash verbosity _pkg_descr lbi lib clbi = do
756756
(withProfLibDetail lbi)
757757
, ghcOptHiSuffix = toFlag "p_hi"
758758
, ghcOptObjSuffix = toFlag "p_o"
759-
, ghcOptExtra = hcOptions GHC libBi ++ hcProfOptions GHC libBi
759+
, ghcOptExtra = Internal.allGhcOptExtra libBi <> hcOptions GHC libBi ++ hcProfOptions GHC libBi
760760
}
761761
profDynArgs =
762762
vanillaArgs
@@ -770,7 +770,7 @@ libAbiHash verbosity _pkg_descr lbi lib clbi = do
770770
, ghcOptFPic = toFlag True
771771
, ghcOptHiSuffix = toFlag "p_dyn_hi"
772772
, ghcOptObjSuffix = toFlag "p_dyn_o"
773-
, ghcOptExtra = hcOptions GHC libBi ++ hcProfSharedOptions GHC libBi
773+
, ghcOptExtra = Internal.allGhcOptExtra libBi <> hcOptions GHC libBi ++ hcProfSharedOptions GHC libBi
774774
}
775775
ghcArgs =
776776
let (libWays, _, _) = buildWays lbi

Cabal/src/Distribution/Simple/GHC/Internal.hs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ module Distribution.Simple.GHC.Internal
3535
, substTopDir
3636
, checkPackageDbEnvVar
3737
, profDetailLevelFlag
38+
, allGhcOptExtra
3839

3940
-- * GHC platform and version strings
4041
, ghcArchString
@@ -377,6 +378,15 @@ includePaths lbi bi clbi odir =
377378
| dir <- mapMaybe (symbolicPathRelative_maybe . unsafeCoerceSymbolicPath) $ includeDirs bi
378379
]
379380

381+
allGhcOptExtra :: BuildInfo -> [String]
382+
allGhcOptExtra bi =
383+
["-optP" ++ opt | opt <- cppOptions bi]
384+
++ ["-optc" ++ opt | opt <- ccOptions bi]
385+
++ ["-optcxx" ++ opt | opt <- cxxOptions bi]
386+
++ ["-opta" ++ opt | opt <- asmOptions bi]
387+
++ ["-optl" ++ opt | opt <- ldOptions bi]
388+
++ ["-optJSP" ++ opt | opt <- jsppOptions bi]
389+
380390
componentCcGhcOptions
381391
:: Verbosity
382392
-> LocalBuildInfo
@@ -413,7 +423,7 @@ componentCcGhcOptions verbosity lbi bi clbi odir filename =
413423
programPath
414424
<$> lookupProgram gccProgram (withPrograms lbi)
415425
, ghcOptObjDir = toFlag odir
416-
, ghcOptExtra = hcOptions GHC bi
426+
, ghcOptExtra = allGhcOptExtra bi <> hcOptions GHC bi
417427
}
418428

419429
componentCxxGhcOptions
@@ -452,7 +462,7 @@ componentCxxGhcOptions verbosity lbi bi clbi odir filename =
452462
programPath
453463
<$> lookupProgram gccProgram (withPrograms lbi)
454464
, ghcOptObjDir = toFlag odir
455-
, ghcOptExtra = hcOptions GHC bi
465+
, ghcOptExtra = allGhcOptExtra bi <> hcOptions GHC bi
456466
}
457467

458468
componentAsmGhcOptions
@@ -487,7 +497,7 @@ componentAsmGhcOptions verbosity lbi bi clbi odir filename =
487497
)
488498
++ asmOptions bi
489499
, ghcOptObjDir = toFlag odir
490-
, ghcOptExtra = hcOptions GHC bi
500+
, ghcOptExtra = allGhcOptExtra bi <> hcOptions GHC bi
491501
}
492502

493503
componentJsGhcOptions
@@ -511,7 +521,7 @@ componentJsGhcOptions verbosity lbi bi clbi odir filename =
511521
, ghcOptPackageDBs = withPackageDB lbi
512522
, ghcOptPackages = toNubListR $ mkGhcOptPackages (promisedPkgs lbi) clbi
513523
, ghcOptObjDir = toFlag odir
514-
, ghcOptExtra = hcOptions GHC bi
524+
, ghcOptExtra = allGhcOptExtra bi <> hcOptions GHC bi
515525
}
516526

517527
componentGhcOptions
@@ -581,7 +591,7 @@ componentGhcOptions verbosity lbi bi clbi odir =
581591
, ghcOptOutputDir = toFlag $ coerceSymbolicPath odir
582592
, ghcOptOptimisation = toGhcOptimisation (withOptimization lbi)
583593
, ghcOptDebugInfo = toFlag (withDebugInfo lbi)
584-
, ghcOptExtra = hcOptions GHC bi
594+
, ghcOptExtra = allGhcOptExtra bi <> hcOptions GHC bi
585595
, ghcOptExtraPath = toNubListR exe_paths
586596
, ghcOptLanguage = toFlag (fromMaybe Haskell98 (defaultLanguage bi))
587597
, -- Unsupported extensions have already been checked by configure
@@ -626,7 +636,7 @@ componentCmmGhcOptions verbosity lbi bi clbi odir filename =
626636
, ghcOptPackages = toNubListR $ mkGhcOptPackages (promisedPkgs lbi) clbi
627637
, ghcOptOptimisation = toGhcOptimisation (withOptimization lbi)
628638
, ghcOptDebugInfo = toFlag (withDebugInfo lbi)
629-
, ghcOptExtra = hcOptions GHC bi <> cmmOptions bi
639+
, ghcOptExtra = allGhcOptExtra bi <> hcOptions GHC bi <> cmmOptions bi
630640
, ghcOptObjDir = toFlag odir
631641
}
632642

changelog.d/pr-10969.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
synopsis: Pass *-options to GHC when compiling ordinary Haskell sources
3+
packages: [Cabal, Cabal-syntax]
4+
prs: 10967
5+
---
6+
7+
*-options should be always passed when invoking GHC, similarly as ghc-options should be always used when invoking ghc - regardless of what is the intention of a particular GHC-call. GHC might use or not use the options, Cabal cannot know and should not guess.

0 commit comments

Comments
 (0)