@@ -1948,8 +1948,36 @@ createJSONFixItDiagnosticConsumerIfNeeded(
19481948 });
19491949}
19501950
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+
19511978// / Print information about the target triple in JSON.
19521979static void printTripleInfo (const llvm::Triple &triple,
1980+ llvm::Optional<llvm::VersionTuple> runtimeVersion,
19531981 llvm::raw_ostream &out) {
19541982 out << " {\n " ;
19551983
@@ -1965,11 +1993,26 @@ static void printTripleInfo(const llvm::Triple &triple,
19651993 out.write_escaped (getTargetSpecificModuleTriple (triple).getTriple ());
19661994 out << " \" ,\n " ;
19671995
1968- if (auto runtimeVersion = getSwiftRuntimeCompatibilityVersionForTarget (
1969- triple)) {
1996+ if (runtimeVersion) {
19701997 out << " \" swiftRuntimeCompatibilityVersion\" : \" " ;
19711998 out.write_escaped (runtimeVersion->getAsString ());
19721999 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 " ;
19732016 }
19742017
19752018 out << " \" librariesRequireRPath\" : "
@@ -1992,14 +2035,16 @@ static void printTargetInfo(const CompilerInvocation &invocation,
19922035 out << " \" ,\n " ;
19932036
19942037 // Target triple and target variant triple.
2038+ auto runtimeVersion =
2039+ invocation.getIRGenOptions ().AutolinkRuntimeCompatibilityLibraryVersion ;
19952040 auto &langOpts = invocation.getLangOptions ();
19962041 out << " \" target\" : " ;
1997- printTripleInfo (langOpts.Target , out);
2042+ printTripleInfo (langOpts.Target , runtimeVersion, out);
19982043 out << " ,\n " ;
19992044
20002045 if (auto &variant = langOpts.TargetVariant ) {
20012046 out << " \" targetVariant\" : " ;
2002- printTripleInfo (*variant, out);
2047+ printTripleInfo (*variant, runtimeVersion, out);
20032048 out << " ,\n " ;
20042049 }
20052050
0 commit comments