mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Make the DWARF version emitted by the Swift compiler configurable.
Previously it was hardcoded to version 4 on all platforms. This patch introduces a driver and frontend option -dwarf-version to configure it if needed.
This commit is contained in:
@@ -625,6 +625,28 @@ toolchains::Darwin::addDeploymentTargetArgs(ArgStringList &Arguments,
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned getDWARFVersionForTriple(const llvm::Triple &triple) {
|
||||
llvm::VersionTuple osVersion;
|
||||
const DarwinPlatformKind kind = getDarwinPlatformKind(triple);
|
||||
switch (kind) {
|
||||
case DarwinPlatformKind::MacOS:
|
||||
triple.getMacOSXVersion(osVersion);
|
||||
if (osVersion < llvm::VersionTuple(10, 11))
|
||||
return 2;
|
||||
return 4;
|
||||
case DarwinPlatformKind::IPhoneOSSimulator:
|
||||
case DarwinPlatformKind::IPhoneOS:
|
||||
case DarwinPlatformKind::TvOS:
|
||||
case DarwinPlatformKind::TvOSSimulator:
|
||||
osVersion = triple.getiOSVersion();
|
||||
if (osVersion < llvm::VersionTuple(9))
|
||||
return 2;
|
||||
return 4;
|
||||
default:
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
void toolchains::Darwin::addCommonFrontendArgs(
|
||||
const OutputInfo &OI, const CommandOutput &output,
|
||||
const llvm::opt::ArgList &inputArgs,
|
||||
@@ -643,6 +665,16 @@ void toolchains::Darwin::addCommonFrontendArgs(
|
||||
inputArgs.MakeArgString(variantSDKVersion->getAsString()));
|
||||
}
|
||||
}
|
||||
std::string dwarfVersion;
|
||||
{
|
||||
llvm::raw_string_ostream os(dwarfVersion);
|
||||
os << "-dwarf-version=";
|
||||
if (OI.DWARFVersion)
|
||||
os << *OI.DWARFVersion;
|
||||
else
|
||||
os << getDWARFVersionForTriple(getTriple());
|
||||
}
|
||||
arguments.push_back(inputArgs.MakeArgString(dwarfVersion));
|
||||
}
|
||||
|
||||
/// Add the frontend arguments needed to find external plugins in standard
|
||||
|
||||
Reference in New Issue
Block a user