@@ -858,46 +858,6 @@ static std::string createResponseFile(const opt::InputArgList &args,
858
858
return std::string (data.str ());
859
859
}
860
860
861
- enum class DebugKind {
862
- Unknown,
863
- None,
864
- Full,
865
- FastLink,
866
- GHash,
867
- NoGHash,
868
- Dwarf,
869
- Symtab
870
- };
871
-
872
- static DebugKind parseDebugKind (const opt::InputArgList &args) {
873
- auto *a = args.getLastArg (OPT_debug, OPT_debug_opt);
874
- if (!a)
875
- return DebugKind::None;
876
- if (a->getNumValues () == 0 )
877
- return DebugKind::Full;
878
-
879
- DebugKind debug = StringSwitch<DebugKind>(a->getValue ())
880
- .CaseLower (" none" , DebugKind::None)
881
- .CaseLower (" full" , DebugKind::Full)
882
- .CaseLower (" fastlink" , DebugKind::FastLink)
883
- // LLD extensions
884
- .CaseLower (" ghash" , DebugKind::GHash)
885
- .CaseLower (" noghash" , DebugKind::NoGHash)
886
- .CaseLower (" dwarf" , DebugKind::Dwarf)
887
- .CaseLower (" symtab" , DebugKind::Symtab)
888
- .Default (DebugKind::Unknown);
889
-
890
- if (debug == DebugKind::FastLink) {
891
- warn (" /debug:fastlink unsupported; using /debug:full" );
892
- return DebugKind::Full;
893
- }
894
- if (debug == DebugKind::Unknown) {
895
- error (" /debug: unknown option: " + Twine (a->getValue ()));
896
- return DebugKind::None;
897
- }
898
- return debug;
899
- }
900
-
901
861
static unsigned parseDebugTypes (const opt::InputArgList &args) {
902
862
unsigned debugTypes = static_cast <unsigned >(DebugType::None);
903
863
@@ -1647,13 +1607,47 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
1647
1607
if (args.hasArg (OPT_force, OPT_force_multipleres))
1648
1608
config->forceMultipleRes = true ;
1649
1609
1610
+ // Don't warn about long section names, such as .debug_info, for mingw (or
1611
+ // when -debug:dwarf is requested, handled below).
1612
+ if (config->mingw )
1613
+ config->warnLongSectionNames = false ;
1614
+
1615
+ bool doGC = true ;
1616
+
1650
1617
// Handle /debug
1651
- DebugKind debug = parseDebugKind (args);
1652
- if (debug == DebugKind::Full || debug == DebugKind::Dwarf ||
1653
- debug == DebugKind::GHash || debug == DebugKind::NoGHash) {
1654
- config->debug = true ;
1655
- config->incremental = true ;
1656
- config->includeDwarfChunks = true ;
1618
+ bool shouldCreatePDB = false ;
1619
+ if (auto *arg = args.getLastArg (OPT_debug, OPT_debug_opt)) {
1620
+ std::string s;
1621
+ if (arg->getOption ().getID () == OPT_debug)
1622
+ s = " full" ;
1623
+ else
1624
+ s = StringRef (arg->getValue ()).lower ();
1625
+ if (s == " fastlink" ) {
1626
+ warn (" /debug:fastlink unsupported; using /debug:full" );
1627
+ s = " full" ;
1628
+ }
1629
+ if (s == " none" ) {
1630
+ } else if (s == " full" || s == " ghash" || s == " noghash" ) {
1631
+ config->debug = true ;
1632
+ config->incremental = true ;
1633
+ config->includeDwarfChunks = true ;
1634
+ if (s == " full" || s == " ghash" )
1635
+ config->debugGHashes = true ;
1636
+ shouldCreatePDB = true ;
1637
+ doGC = false ;
1638
+ } else if (s == " dwarf" ) {
1639
+ config->debug = true ;
1640
+ config->incremental = true ;
1641
+ config->includeDwarfChunks = true ;
1642
+ config->writeSymtab = true ;
1643
+ config->warnLongSectionNames = false ;
1644
+ doGC = false ;
1645
+ } else if (s == " symtab" ) {
1646
+ config->writeSymtab = true ;
1647
+ doGC = false ;
1648
+ } else {
1649
+ error (" /debug: unknown option: " + s);
1650
+ }
1657
1651
}
1658
1652
1659
1653
// Handle /demangle
@@ -1673,9 +1667,6 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
1673
1667
config->driverUponly || config->driverWdm || args.hasArg (OPT_driver);
1674
1668
1675
1669
// Handle /pdb
1676
- bool shouldCreatePDB =
1677
- (debug == DebugKind::Full || debug == DebugKind::GHash ||
1678
- debug == DebugKind::NoGHash);
1679
1670
if (shouldCreatePDB) {
1680
1671
if (auto *arg = args.getLastArg (OPT_pdb))
1681
1672
config->pdbPath = arg->getValue ();
@@ -1838,8 +1829,9 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
1838
1829
1839
1830
config->noimplib = args.hasArg (OPT_noimplib);
1840
1831
1832
+ if (args.hasArg (OPT_profile))
1833
+ doGC = true ;
1841
1834
// Handle /opt.
1842
- bool doGC = debug == DebugKind::None || args.hasArg (OPT_profile);
1843
1835
std::optional<ICFLevel> icfLevel;
1844
1836
if (args.hasArg (OPT_profile))
1845
1837
icfLevel = ICFLevel::None;
@@ -2030,8 +2022,6 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
2030
2022
parseSwaprun (arg->getValue ());
2031
2023
config->terminalServerAware =
2032
2024
!config->dll && args.hasFlag (OPT_tsaware, OPT_tsaware_no, true );
2033
- config->debugGHashes = debug == DebugKind::GHash || debug == DebugKind::Full;
2034
- config->writeSymtab = debug == DebugKind::Dwarf || debug == DebugKind::Symtab;
2035
2025
config->autoImport =
2036
2026
args.hasFlag (OPT_auto_import, OPT_auto_import_no, config->mingw );
2037
2027
config->pseudoRelocs = args.hasFlag (
@@ -2048,11 +2038,6 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
2048
2038
if (args.hasFlag (OPT_inferasanlibs, OPT_inferasanlibs_no, false ))
2049
2039
warn (" ignoring '/inferasanlibs', this flag is not supported" );
2050
2040
2051
- // Don't warn about long section names, such as .debug_info, for mingw or
2052
- // when -debug:dwarf is requested.
2053
- if (config->mingw || debug == DebugKind::Dwarf)
2054
- config->warnLongSectionNames = false ;
2055
-
2056
2041
if (config->incremental && args.hasArg (OPT_profile)) {
2057
2042
warn (" ignoring '/incremental' due to '/profile' specification" );
2058
2043
config->incremental = false ;
0 commit comments