@@ -1948,8 +1948,36 @@ createJSONFixItDiagnosticConsumerIfNeeded(
1948
1948
});
1949
1949
}
1950
1950
1951
+ // / Print information about a
1952
+ static void printCompatibilityLibrary (
1953
+ llvm::VersionTuple runtimeVersion, llvm::VersionTuple maxVersion,
1954
+ StringRef filter, StringRef libraryName, bool &printedAny,
1955
+ llvm::raw_ostream &out) {
1956
+ if (runtimeVersion > maxVersion)
1957
+ return ;
1958
+
1959
+ if (printedAny) {
1960
+ out << " ," ;
1961
+ }
1962
+
1963
+ out << " \n " ;
1964
+ out << " {\n " ;
1965
+
1966
+ out << " \" libraryName\" : \" " ;
1967
+ out.write_escaped (libraryName);
1968
+ out << " \" ,\n " ;
1969
+
1970
+ out << " \" filter\" : \" " ;
1971
+ out.write_escaped (filter);
1972
+ out << " \"\n " ;
1973
+ out << " }" ;
1974
+
1975
+ printedAny = true ;
1976
+ }
1977
+
1951
1978
// / Print information about the target triple in JSON.
1952
1979
static void printTripleInfo (const llvm::Triple &triple,
1980
+ llvm::Optional<llvm::VersionTuple> runtimeVersion,
1953
1981
llvm::raw_ostream &out) {
1954
1982
out << " {\n " ;
1955
1983
@@ -1965,11 +1993,26 @@ static void printTripleInfo(const llvm::Triple &triple,
1965
1993
out.write_escaped (getTargetSpecificModuleTriple (triple).getTriple ());
1966
1994
out << " \" ,\n " ;
1967
1995
1968
- if (auto runtimeVersion = getSwiftRuntimeCompatibilityVersionForTarget (
1969
- triple)) {
1996
+ if (runtimeVersion) {
1970
1997
out << " \" swiftRuntimeCompatibilityVersion\" : \" " ;
1971
1998
out.write_escaped (runtimeVersion->getAsString ());
1972
1999
out << " \" ,\n " ;
2000
+
2001
+ // Compatibility libraries that need to be linked.
2002
+ out << " \" compatibilityLibraries\" : [" ;
2003
+ bool printedAnyCompatibilityLibrary = false ;
2004
+ #define BACK_DEPLOYMENT_LIB (Version, Filter, LibraryName ) \
2005
+ printCompatibilityLibrary ( \
2006
+ *runtimeVersion, llvm::VersionTuple Version, #Filter, LibraryName, \
2007
+ printedAnyCompatibilityLibrary, out);
2008
+ #include " swift/Frontend/BackDeploymentLibs.def"
2009
+
2010
+ if (printedAnyCompatibilityLibrary) {
2011
+ out << " \n " ;
2012
+ }
2013
+ out << " ],\n " ;
2014
+ } else {
2015
+ out << " \" compatibilityLibraries\" : [ ],\n " ;
1973
2016
}
1974
2017
1975
2018
out << " \" librariesRequireRPath\" : "
@@ -1992,14 +2035,16 @@ static void printTargetInfo(const CompilerInvocation &invocation,
1992
2035
out << " \" ,\n " ;
1993
2036
1994
2037
// Target triple and target variant triple.
2038
+ auto runtimeVersion =
2039
+ invocation.getIRGenOptions ().AutolinkRuntimeCompatibilityLibraryVersion ;
1995
2040
auto &langOpts = invocation.getLangOptions ();
1996
2041
out << " \" target\" : " ;
1997
- printTripleInfo (langOpts.Target , out);
2042
+ printTripleInfo (langOpts.Target , runtimeVersion, out);
1998
2043
out << " ,\n " ;
1999
2044
2000
2045
if (auto &variant = langOpts.TargetVariant ) {
2001
2046
out << " \" targetVariant\" : " ;
2002
- printTripleInfo (*variant, out);
2047
+ printTripleInfo (*variant, runtimeVersion, out);
2003
2048
out << " ,\n " ;
2004
2049
}
2005
2050
0 commit comments