14
14
#include " clang/Driver/DriverDiagnostic.h"
15
15
#include " clang/Driver/Options.h"
16
16
#include " llvm/Option/ArgList.h"
17
+ #include " clang/Basic/VirtualFileSystem.h"
17
18
18
19
using namespace llvm ::opt;
19
20
@@ -31,16 +32,22 @@ void DPURTE::AddClangSystemIncludeArgs(
31
32
addSystemInclude (DriverArgs, CC1Args, StringRef (PathToSyslibIncludes));
32
33
}
33
34
34
- char *DPURTE::GetUpmemSdkPath (const char *Path) const {
35
- char *UpmemHome = getenv (" UPMEM_HOME" );
36
- if (UpmemHome == nullptr ) {
37
- // Assume that the toolchain is installed at system root
38
- return strdup (Path);
39
- } else {
40
- char *result;
41
- asprintf (&result, " %s%s" , UpmemHome, Path);
35
+ char *DPURTE::GetUpmemSdkPath (const char *Path) {
36
+ char *result;
37
+ if (PathToSDK != NULL ) {
38
+ asprintf (&result, " %s%s" , PathToSDK, Path);
42
39
return result;
43
40
}
41
+ const std::string InstalledDir (getDriver ().getInstalledDir ());
42
+ const std::string UpmemDir (InstalledDir + " /../share/upmem" );
43
+ if (getVFS ().exists (UpmemDir)) {
44
+ PathToSDK = strdup ((InstalledDir + " /../.." ).c_str ());
45
+ asprintf (&result, " %s%s" , PathToSDK, Path);
46
+ return result;
47
+ }
48
+ PathToSDK = strdup (getenv (" UPMEM_HOME" ));
49
+ asprintf (&result, " %s%s" , PathToSDK, Path);
50
+ return result;
44
51
}
45
52
46
53
Tool *DPURTE::buildLinker () const {
0 commit comments