1414
1515#include " swift/AST/DiagnosticsDriver.h"
1616#include " swift/AST/PlatformKind.h"
17- #include " swift/Basic/Dwarf.h"
1817#include " swift/Basic/LLVM.h"
1918#include " swift/Basic/Platform.h"
2019#include " swift/Basic/Range.h"
@@ -626,6 +625,28 @@ toolchains::Darwin::addDeploymentTargetArgs(ArgStringList &Arguments,
626625 }
627626}
628627
628+ static unsigned getDWARFVersionForTriple (const llvm::Triple &triple) {
629+ llvm::VersionTuple osVersion;
630+ const DarwinPlatformKind kind = getDarwinPlatformKind (triple);
631+ switch (kind) {
632+ case DarwinPlatformKind::MacOS:
633+ triple.getMacOSXVersion (osVersion);
634+ if (osVersion < llvm::VersionTuple (10 , 11 ))
635+ return 2 ;
636+ return 4 ;
637+ case DarwinPlatformKind::IPhoneOSSimulator:
638+ case DarwinPlatformKind::IPhoneOS:
639+ case DarwinPlatformKind::TvOS:
640+ case DarwinPlatformKind::TvOSSimulator:
641+ osVersion = triple.getiOSVersion ();
642+ if (osVersion < llvm::VersionTuple (9 ))
643+ return 2 ;
644+ return 4 ;
645+ default :
646+ return 4 ;
647+ }
648+ }
649+
629650void toolchains::Darwin::addCommonFrontendArgs (
630651 const OutputInfo &OI, const CommandOutput &output,
631652 const llvm::opt::ArgList &inputArgs,
@@ -644,6 +665,16 @@ void toolchains::Darwin::addCommonFrontendArgs(
644665 inputArgs.MakeArgString (variantSDKVersion->getAsString ()));
645666 }
646667 }
668+ std::string dwarfVersion;
669+ {
670+ llvm::raw_string_ostream os (dwarfVersion);
671+ os << " -dwarf-version=" ;
672+ if (OI.DWARFVersion )
673+ os << *OI.DWARFVersion ;
674+ else
675+ os << getDWARFVersionForTriple (getTriple ());
676+ }
677+ arguments.push_back (inputArgs.MakeArgString (dwarfVersion));
647678}
648679
649680// / Add the frontend arguments needed to find external plugins in standard
0 commit comments