@@ -63,6 +63,28 @@ getVersionTuple(const llvm::Triple &triple) {
63
63
return triple.getOSVersion ();
64
64
}
65
65
66
+ void CompilerInvocation::computeRuntimeResourcePathForTargetInfo () {
67
+ const auto &frontendOpts = getFrontendOptions ();
68
+ const auto &searchPathOpts = getSearchPathOptions ();
69
+ const auto &langOpts = getLangOptions ();
70
+ SmallString<128 > resourceDirPath;
71
+ if (!searchPathOpts.RuntimeResourcePath .empty ()) {
72
+ resourceDirPath = searchPathOpts.RuntimeResourcePath ;
73
+ } else if (!langOpts.Target .isOSDarwin () &&
74
+ !searchPathOpts.getSDKPath ().empty ()) {
75
+ StringRef value = searchPathOpts.getSDKPath ();
76
+ resourceDirPath.append (value.begin (), value.end ());
77
+ llvm::sys::path::append (resourceDirPath, " usr" );
78
+ CompilerInvocation::appendSwiftLibDir (resourceDirPath,
79
+ frontendOpts.UseSharedResourceFolder );
80
+ } else {
81
+ CompilerInvocation::computeRuntimeResourcePathFromExecutablePath (frontendOpts.MainExecutablePath ,
82
+ frontendOpts.UseSharedResourceFolder ,
83
+ resourceDirPath);
84
+ }
85
+ setRuntimeResourcePath (resourceDirPath.str ().str ());
86
+ }
87
+
66
88
void CompilerInvocation::computeRuntimeResourcePathFromExecutablePath (
67
89
StringRef mainExecutablePath, bool shared,
68
90
llvm::SmallVectorImpl<char > &runtimeResourcePath) {
@@ -84,7 +106,9 @@ void CompilerInvocation::setMainExecutablePath(StringRef Path) {
84
106
llvm::SmallString<128 > LibPath;
85
107
computeRuntimeResourcePathFromExecutablePath (
86
108
Path, FrontendOpts.UseSharedResourceFolder , LibPath);
87
- setRuntimeResourcePath (LibPath.str ());
109
+ // Target info query computes the resource path wholesale
110
+ if (!FrontendOpts.PrintTargetInfo )
111
+ setRuntimeResourcePath (LibPath.str ());
88
112
89
113
llvm::SmallString<128 > clangPath (Path);
90
114
llvm::sys::path::remove_filename (clangPath);
@@ -3552,6 +3576,9 @@ bool CompilerInvocation::parseArgs(
3552
3576
return true ;
3553
3577
}
3554
3578
3579
+ if (FrontendOpts.PrintTargetInfo )
3580
+ computeRuntimeResourcePathForTargetInfo ();
3581
+
3555
3582
updateRuntimeLibraryPaths (SearchPathOpts, FrontendOpts, LangOpts);
3556
3583
setDefaultPrebuiltCacheIfNecessary ();
3557
3584
setDefaultBlocklistsIfNecessary ();
0 commit comments