... |
... |
@@ -279,6 +279,10 @@ import GHC.Parser (parseIdentifier) |
279
|
279
|
import GHC.Parser.Lexer (mkParserOpts, initParserState, P(..), ParseResult(..))
|
280
|
280
|
|
281
|
281
|
import GHC.SysTools.BaseDir ( expandToolDir, expandTopDir )
|
|
282
|
+import GHC.ResponseFile
|
|
283
|
+
|
|
284
|
+import GHC.Toolchain
|
|
285
|
+import GHC.Toolchain.Program
|
282
|
286
|
|
283
|
287
|
import Data.IORef
|
284
|
288
|
import Control.Arrow ((&&&))
|
... |
... |
@@ -3454,69 +3458,58 @@ compilerInfo dflags |
3454
|
3458
|
-- Next come the settings, so anything else can be overridden
|
3455
|
3459
|
-- in the settings file (as "lookup" uses the first match for the
|
3456
|
3460
|
-- key)
|
3457
|
|
- -- TODO:
|
3458
|
|
- -- : map (fmap $ )
|
3459
|
|
- -- (rawSettings dflags)
|
3460
|
|
- :
|
3461
|
|
- [("C compiler command", query),
|
3462
|
|
- ("C compiler flags", "$(SettingsCCompilerFlags)"),
|
3463
|
|
- ("C++ compiler command", "$(SettingsCxxCompilerCommand)"),
|
3464
|
|
- ("C++ compiler flags", "$(SettingsCxxCompilerFlags)"),
|
3465
|
|
- ("C compiler link flags", "$(SettingsCCompilerLinkFlags)"),
|
3466
|
|
- ("C compiler supports -no-pie", "$(SettingsCCompilerSupportsNoPie)"),
|
3467
|
|
- ("CPP command", "$(SettingsCPPCommand)"),
|
3468
|
|
- ("CPP flags", "$(SettingsCPPFlags)"),
|
3469
|
|
- ("Haskell CPP command", "$(SettingsHaskellCPPCommand)"),
|
3470
|
|
- ("Haskell CPP flags", "$(SettingsHaskellCPPFlags)"),
|
3471
|
|
- ("JavaScript CPP command", "$(SettingsJavaScriptCPPCommand)"),
|
3472
|
|
- ("JavaScript CPP flags", "$(SettingsJavaScriptCPPFlags)"),
|
3473
|
|
- ("C-- CPP command", "$(SettingsCmmCPPCommand)"),
|
3474
|
|
- ("C-- CPP flags", "$(SettingsCmmCPPFlags)"),
|
3475
|
|
- ("C-- CPP supports -g0", "$(SettingsCmmCPPSupportsG0)"),
|
3476
|
|
- ("ld supports compact unwind", "$(LdHasNoCompactUnwind)"),
|
3477
|
|
- ("ld supports filelist", "$(LdHasFilelist)"),
|
3478
|
|
- ("ld supports single module", "$(LdHasSingleModule)"),
|
3479
|
|
- ("ld is GNU ld", "$(LdIsGNULd)"),
|
3480
|
|
- ("Merge objects command", "$(SettingsMergeObjectsCommand)"),
|
3481
|
|
- ("Merge objects flags", "$(SettingsMergeObjectsFlags)"),
|
3482
|
|
- ("Merge objects supports response files", "$(MergeObjsSupportsResponseFiles)"),
|
3483
|
|
- ("ar command", "$(SettingsArCommand)"),
|
3484
|
|
- ("ar flags", "$(ArArgs)"),
|
3485
|
|
- ("ar supports at file", "$(ArSupportsAtFile)"),
|
3486
|
|
- ("ar supports -L", "$(ArSupportsDashL)"),
|
3487
|
|
- ("ranlib command", "$(SettingsRanlibCommand)"),
|
3488
|
|
- ("otool command", "$(SettingsOtoolCommand)"),
|
3489
|
|
- ("install_name_tool command", "$(SettingsInstallNameToolCommand)"),
|
3490
|
|
- ("windres command", "$(SettingsWindresCommand)"),
|
3491
|
|
- ("unlit command", "$$topdir/../bin/$(CrossCompilePrefix)unlit"),
|
3492
|
|
- ("cross compiling", "$(CrossCompiling)"),
|
3493
|
|
- ("target platform string", "$(TARGETPLATFORM)"),
|
3494
|
|
- ("target os", "$(HaskellTargetOs)"),
|
3495
|
|
- ("target arch", "$(HaskellTargetArch)"),
|
3496
|
|
- ("target word size", "$(TargetWordSize)"),
|
3497
|
|
- ("target word big endian", "$(TargetWordBigEndian)"),
|
3498
|
|
- ("target has GNU nonexec stack", "$(TargetHasGnuNonexecStack)"),
|
3499
|
|
- ("target has .ident directive", "$(TargetHasIdentDirective)"),
|
3500
|
|
- ("target has subsections via symbols", "$(TargetHasSubsectionsViaSymbols)"),
|
3501
|
|
- ("target has libm", "$(TargetHasLibm)"),
|
3502
|
|
- ("Unregisterised", "$(GhcUnregisterised)"),
|
3503
|
|
- ("LLVM target", "$(LLVMTarget)"),
|
3504
|
|
- ("LLVM llc command", "$(SettingsLlcCommand)"),
|
3505
|
|
- ("LLVM opt command", "$(SettingsOptCommand)"),
|
3506
|
|
- ("LLVM llvm-as command", "$(SettingsLlvmAsCommand)"),
|
3507
|
|
- ("LLVM llvm-as flags", "$(SettingsLlvmAsFlags)"),
|
3508
|
|
- ("target RTS linker only supports shared libraries", "$(TargetRTSLinkerOnlySupportsSharedLibs)"),
|
3509
|
|
- ("Use interpreter", "$(GhcWithInterpreter)"),
|
3510
|
|
- ("Support SMP", "$(GhcWithSMP)"),
|
3511
|
|
- ("RTS ways", "$(GhcRTSWays)"),
|
3512
|
|
- ("Tables next to code", "$(TablesNextToCode)"),
|
3513
|
|
- ("Leading underscore", "$(LeadingUnderscore)"),
|
3514
|
|
- ("Use LibFFI", "$(UseLibffiForAdjustors)"),
|
3515
|
|
- ("RTS expects libdw", "$(GhcRtsWithLibdw)"),
|
3516
|
|
- ("Relative Global Package DB", "package.conf.d"),
|
3517
|
|
- ("base unit-id", "$(BaseUnitId)")
|
3518
|
|
- ]
|
3519
|
|
- ++ [("Project version", projectVersion dflags),
|
|
3461
|
+ : map (fmap expandDirectories)
|
|
3462
|
+ (rawSettings dflags)
|
|
3463
|
+ ++
|
|
3464
|
+ [("C compiler command", queryCmd $ ccProgram . tgtCCompiler),
|
|
3465
|
+ ("C compiler flags", queryFlags $ ccProgram . tgtCCompiler),
|
|
3466
|
+ ("C++ compiler command", queryCmd $ cxxProgram . tgtCxxCompiler),
|
|
3467
|
+ ("C++ compiler flags", queryFlags $ cxxProgram . tgtCxxCompiler),
|
|
3468
|
+ ("C compiler link flags", queryFlags $ ccLinkProgram . tgtCCompilerLink),
|
|
3469
|
+ ("C compiler supports -no-pie", queryBool $ ccLinkSupportsNoPie . tgtCCompilerLink),
|
|
3470
|
+ ("CPP command", queryCmd $ cppProgram . tgtCPreprocessor),
|
|
3471
|
+ ("CPP flags", queryFlags $ cppProgram . tgtCPreprocessor),
|
|
3472
|
+ ("Haskell CPP command", queryCmd $ hsCppProgram . tgtHsCPreprocessor),
|
|
3473
|
+ ("Haskell CPP flags", queryFlags $ hsCppProgram . tgtHsCPreprocessor),
|
|
3474
|
+ ("JavaScript CPP command", queryCmdMaybe jsCppProgram tgtJsCPreprocessor),
|
|
3475
|
+ ("JavaScript CPP flags", queryFlagsMaybe jsCppProgram tgtJsCPreprocessor),
|
|
3476
|
+ ("C-- CPP command", queryCmd $ cmmCppProgram . tgtCmmCPreprocessor),
|
|
3477
|
+ ("C-- CPP flags", queryFlags $ cmmCppProgram . tgtCmmCPreprocessor),
|
|
3478
|
+ ("C-- CPP supports -g0", queryBool $ cmmCppSupportsG0 . tgtCmmCPreprocessor),
|
|
3479
|
+ ("ld supports compact unwind", queryBool $ ccLinkSupportsCompactUnwind . tgtCCompilerLink),
|
|
3480
|
+ ("ld supports filelist", queryBool $ ccLinkSupportsFilelist . tgtCCompilerLink),
|
|
3481
|
+ ("ld supports single module", queryBool $ ccLinkSupportsSingleModule . tgtCCompilerLink),
|
|
3482
|
+ ("ld is GNU ld", queryBool $ ccLinkIsGnu . tgtCCompilerLink),
|
|
3483
|
+ ("Merge objects command", queryCmdMaybe mergeObjsProgram tgtMergeObjs),
|
|
3484
|
+ ("Merge objects flags", queryFlagsMaybe mergeObjsProgram tgtMergeObjs),
|
|
3485
|
+ ("Merge objects supports response files", queryBool $ maybe False mergeObjsSupportsResponseFiles . tgtMergeObjs),
|
|
3486
|
+ ("ar command", queryCmd $ arMkArchive . tgtAr),
|
|
3487
|
+ ("ar flags", queryFlags $ arMkArchive . tgtAr),
|
|
3488
|
+ ("ar supports at file", queryBool $ arSupportsAtFile . tgtAr),
|
|
3489
|
+ ("ar supports -L", queryBool $ arSupportsDashL . tgtAr),
|
|
3490
|
+ ("ranlib command", queryCmdMaybe ranlibProgram tgtRanlib),
|
|
3491
|
+ ("otool command", queryCmdMaybe id tgtOtool),
|
|
3492
|
+ ("install_name_tool command", queryCmdMaybe id tgtInstallNameTool),
|
|
3493
|
+ ("windres command", queryCmd $ fromMaybe (Program "/bin/false" []) . tgtWindres),
|
|
3494
|
+ ("cross compiling", queryBool (not . tgtLocallyExecutable)),
|
|
3495
|
+ ("target platform string", query targetPlatformTriple),
|
|
3496
|
+ ("target os", query (show . archOS_OS . tgtArchOs)),
|
|
3497
|
+ ("target arch", query (show . archOS_arch . tgtArchOs)),
|
|
3498
|
+ ("target word size", query $ show . wordSize2Bytes . tgtWordSize),
|
|
3499
|
+ ("target word big endian", queryBool $ (\case BigEndian -> True; LittleEndian -> False) . tgtEndianness),
|
|
3500
|
+ ("target has GNU nonexec stack", queryBool tgtSupportsGnuNonexecStack),
|
|
3501
|
+ ("target has .ident directive", queryBool tgtSupportsIdentDirective),
|
|
3502
|
+ ("target has subsections via symbols", queryBool tgtSupportsSubsectionsViaSymbols),
|
|
3503
|
+ ("Unregisterised", queryBool tgtUnregisterised),
|
|
3504
|
+ ("LLVM target", query tgtLlvmTarget),
|
|
3505
|
+ ("LLVM llc command", queryCmdMaybe id tgtLlc),
|
|
3506
|
+ ("LLVM opt command", queryCmdMaybe id tgtOpt),
|
|
3507
|
+ ("LLVM llvm-as command", queryCmdMaybe id tgtLlvmAs),
|
|
3508
|
+ ("LLVM llvm-as flags", queryFlagsMaybe id tgtLlvmAs),
|
|
3509
|
+ ("Tables next to code", queryBool tgtTablesNextToCode),
|
|
3510
|
+ ("Leading underscore", queryBool tgtSymbolsHaveLeadingUnderscore)
|
|
3511
|
+ ] ++
|
|
3512
|
+ [("Project version", projectVersion dflags),
|
3520
|
3513
|
("Project Git commit id", cProjectGitCommitId),
|
3521
|
3514
|
("Project Version Int", cProjectVersionInt),
|
3522
|
3515
|
("Project Patch Level", cProjectPatchLevel),
|
... |
... |
@@ -3574,7 +3567,15 @@ compilerInfo dflags |
3574
|
3567
|
platform = targetPlatform dflags
|
3575
|
3568
|
isWindows = platformOS platform == OSMinGW32
|
3576
|
3569
|
expandDirectories = expandToolDir (toolDir dflags) . expandTopDir (topDir dflags)
|
|
3570
|
+ query :: (Target -> a) -> a
|
3577
|
3571
|
query f = f (rawTarget dflags)
|
|
3572
|
+ queryFlags f = query (escapeArgs . prgFlags . f)
|
|
3573
|
+ queryCmd f = expandDirectories (query (prgPath . f))
|
|
3574
|
+ queryBool = showBool . query
|
|
3575
|
+
|
|
3576
|
+ queryCmdMaybe, queryFlagsMaybe :: (a -> Program) -> (Target -> Maybe a) -> String
|
|
3577
|
+ queryCmdMaybe p f = expandDirectories (query (maybe "" (prgPath . p) . f))
|
|
3578
|
+ queryFlagsMaybe p f = query (maybe "" (escapeArgs . prgFlags . p) . f)
|
3578
|
3579
|
|
3579
|
3580
|
-- Note [Special unit-ids]
|
3580
|
3581
|
-- ~~~~~~~~~~~~~~~~~~~~~~~
|