@@ -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+
380390componentCcGhcOptions
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
419429componentCxxGhcOptions
@@ -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
458468componentAsmGhcOptions
@@ -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
493503componentJsGhcOptions
@@ -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
517527componentGhcOptions
@@ -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
0 commit comments