Skip to content

Commit e3805c3

Browse files
Romaric JODINJordi Chauzi
Romaric JODIN
authored and
Jordi Chauzi
committed
dpu: clang: makes GetUpmemSdkPath more reliable & use sysroot if specified
Fix #3
1 parent f6902c3 commit e3805c3

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

clang/lib/Driver/ToolChains/DPURTE.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "CommonArgs.h"
1212
#include "InputInfo.h"
1313
#include "clang/Driver/Compilation.h"
14+
#include "clang/Driver/Driver.h"
1415
#include "clang/Driver/DriverDiagnostic.h"
1516
#include "clang/Driver/Options.h"
1617
#include "llvm/Option/ArgList.h"
@@ -38,14 +39,16 @@ char *DPURTE::GetUpmemSdkPath(const char *Path) {
3839
asprintf(&result, "%s%s", PathToSDK, Path);
3940
return result;
4041
}
42+
const std::string SysRoot(getDriver().SysRoot);
4143
const std::string InstalledDir(getDriver().getInstalledDir());
4244
const std::string UpmemDir(InstalledDir + "/../share/upmem");
43-
if (getVFS().exists(UpmemDir)) {
45+
if (!SysRoot.empty()) {
46+
PathToSDK = strdup(SysRoot.c_str());
47+
} else if (getVFS().exists(UpmemDir)) {
4448
PathToSDK = strdup((InstalledDir + "/../..").c_str());
45-
asprintf(&result, "%s%s", PathToSDK, Path);
46-
return result;
49+
} else {
50+
PathToSDK = strdup(Path);
4751
}
48-
PathToSDK = strdup(getenv("UPMEM_HOME"));
4952
asprintf(&result, "%s%s", PathToSDK, Path);
5053
return result;
5154
}

0 commit comments

Comments
 (0)