Rodrigo Mesquita pushed to branch wip/romes/24212 at Glasgow Haskell Compiler / GHC

Commits:

4 changed files:

Changes:

  • compiler/GHC/Driver/DynFlags.hs
    ... ... @@ -145,6 +145,7 @@ import GHC.Foreign (withCString, peekCString)
    145 145
     import qualified Data.Set as Set
    
    146 146
     
    
    147 147
     import qualified GHC.LanguageExtensions as LangExt
    
    148
    +import GHC.Toolchain.Target (Target)
    
    148 149
     
    
    149 150
     -- -----------------------------------------------------------------------------
    
    150 151
     -- DynFlags
    
    ... ... @@ -178,6 +179,7 @@ data DynFlags = DynFlags {
    178 179
       toolSettings      :: {-# UNPACK #-} !ToolSettings,
    
    179 180
       platformMisc      :: {-# UNPACK #-} !PlatformMisc,
    
    180 181
       rawSettings       :: [(String, String)],
    
    182
    +  rawTarget         :: Target,
    
    181 183
       tmpDir            :: TempDir,
    
    182 184
     
    
    183 185
       llvmOptLevel          :: Int,         -- ^ LLVM optimisation level
    
    ... ... @@ -656,6 +658,7 @@ defaultDynFlags mySettings =
    656 658
             targetPlatform = sTargetPlatform mySettings,
    
    657 659
             platformMisc = sPlatformMisc mySettings,
    
    658 660
             rawSettings = sRawSettings mySettings,
    
    661
    +        rawTarget   = sRawTarget mySettings,
    
    659 662
     
    
    660 663
             tmpDir                  = panic "defaultDynFlags: uninitialized tmpDir",
    
    661 664
     
    

  • compiler/GHC/Driver/Session.hs
    ... ... @@ -3454,8 +3454,68 @@ compilerInfo dflags
    3454 3454
           -- Next come the settings, so anything else can be overridden
    
    3455 3455
           -- in the settings file (as "lookup" uses the first match for the
    
    3456 3456
           -- key)
    
    3457
    -    : map (fmap $ expandDirectories (topDir dflags) (toolDir dflags))
    
    3458
    -          (rawSettings dflags)
    
    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
    +      ]
    
    3459 3519
        ++ [("Project version",             projectVersion dflags),
    
    3460 3520
            ("Project Git commit id",       cProjectGitCommitId),
    
    3461 3521
            ("Project Version Int",         cProjectVersionInt),
    
    ... ... @@ -3513,8 +3573,8 @@ compilerInfo dflags
    3513 3573
         showBool False = "NO"
    
    3514 3574
         platform  = targetPlatform dflags
    
    3515 3575
         isWindows = platformOS platform == OSMinGW32
    
    3516
    -    expandDirectories :: FilePath -> Maybe FilePath -> String -> String
    
    3517
    -    expandDirectories topd mtoold = expandToolDir mtoold . expandTopDir topd
    
    3576
    +    expandDirectories = expandToolDir (toolDir dflags) . expandTopDir (topDir dflags)
    
    3577
    +    query f = f (rawTarget dflags)
    
    3518 3578
     
    
    3519 3579
     -- Note [Special unit-ids]
    
    3520 3580
     -- ~~~~~~~~~~~~~~~~~~~~~~~
    

  • compiler/GHC/Settings.hs
    ... ... @@ -74,6 +74,7 @@ import GHC.Utils.CliOption
    74 74
     import GHC.Utils.Fingerprint
    
    75 75
     import GHC.Platform
    
    76 76
     import GHC.Unit.Types
    
    77
    +import GHC.Toolchain.Target
    
    77 78
     
    
    78 79
     data Settings = Settings
    
    79 80
       { sGhcNameVersion    :: {-# UNPACk #-} !GhcNameVersion
    
    ... ... @@ -86,6 +87,10 @@ data Settings = Settings
    86 87
       -- You shouldn't need to look things up in rawSettings directly.
    
    87 88
       -- They should have their own fields instead.
    
    88 89
       , sRawSettings       :: [(String, String)]
    
    90
    +
    
    91
    +  -- Store the target to print out information about the raw target description
    
    92
    +  -- (e.g. in --info)
    
    93
    +  , sRawTarget         :: Target
    
    89 94
       }
    
    90 95
     
    
    91 96
     data UnitSettings = UnitSettings { unitSettings_baseUnitId :: !UnitId }
    

  • compiler/GHC/Settings/IO.hs
    ... ... @@ -239,6 +239,7 @@ initSettings top_dir = do
    239 239
           }
    
    240 240
     
    
    241 241
         , sRawSettings    = settingsList
    
    242
    +    , sRawTarget      = target
    
    242 243
         }
    
    243 244
     
    
    244 245
     getTargetPlatform :: Bool {-^ Does target have libm -} -> Target -> Platform