return "o";
}
+std::string getMainExecutable(const char *Name) {
+ void *Ptr = (void *)(intptr_t)&getMainExecutable;
+ auto COWPath = sys::fs::getMainExecutable(Name, Ptr);
+ return sys::path::parent_path(COWPath).str();
+}
+
/// Extract the device file from the string '<triple>-<arch>=<library>.bc'.
DeviceFile getBitcodeLibrary(StringRef LibraryStr) {
auto DeviceAndPath = StringRef(LibraryStr).split('=');
// We will use llvm-strip to remove the now unneeded section containing the
// offloading code.
- void *P = (void *)(intptr_t)&Help;
- StringRef COWDir = "";
- auto COWPath = sys::fs::getMainExecutable("llvm-strip", P);
- if (!COWPath.empty())
- COWDir = sys::path::parent_path(COWPath);
ErrorOr<std::string> StripPath =
- sys::findProgramByName("llvm-strip", {COWDir});
+ sys::findProgramByName("llvm-strip", {getMainExecutable("llvm-strip")});
if (!StripPath)
- return createStringError(StripPath.getError(),
- "Unable to find 'llvm-strip' in path");
+ StripPath = sys::findProgramByName("llvm-strip");
+ if (!StripPath)
+ return None;
SmallString<128> TempFile;
if (Error Err = createOutputFile(Prefix + "-host", Extension, TempFile))
namespace amdgcn {
Expected<std::string> link(ArrayRef<std::string> InputFiles, Triple TheTriple,
StringRef Arch) {
- // AMDGPU uses the lld binary to link device object files.
+ // AMDGPU uses lld to link device object files.
ErrorOr<std::string> LLDPath =
- sys::findProgramByName("lld", sys::path::parent_path(LinkerExecutable));
+ sys::findProgramByName("lld", {getMainExecutable("lld")});
if (!LLDPath)
LLDPath = sys::findProgramByName("lld");
if (!LLDPath)