Skip to content

Commit e07940e

Browse files
authored
Simplify detail::xilinx_xrt() to always return compiled prefix (#9511)
When XILINX_XRT is not set, use compile time constant XRT_INSTALL_PREFIX. There was a bug in the upstream binaries that used parent_path()*2 relative to sopath, but upstream lib path can contain any number of components, e.g. lib/x86_64-linux-gnu/libfoo.so so hardwiring parent_path() * n is not right. Always used compile time CMAKE_INSTALL_PREFIX for detail::xilinx_xrt(), for relocatable builds XILINX_XRT should be set, e.g. do not ever rely on sopath. Signed-off-by: Soren Soe <2106410+stsoe@users.noreply.github.com>
1 parent 933856c commit e07940e

1 file changed

Lines changed: 5 additions & 15 deletions

File tree

src/runtime_src/core/common/detail/linux/xilinx_xrt.h

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,11 @@ namespace sfs = std::filesystem;
3131
sfs::path
3232
xilinx_xrt()
3333
{
34-
Dl_info info {};
35-
if (dladdr(reinterpret_cast<void*>(&xilinx_xrt), &info) == 0 || !info.dli_fname)
36-
return sfs::path(XRT_INSTALL_PREFIX);
37-
38-
if (std::string(info.dli_fname).find("libxrt_coreutil") == std::string::npos)
39-
return sfs::path(XRT_INSTALL_PREFIX);
40-
41-
try {
42-
// Relocatable path based on install location of this DSO
43-
sfs::path so_path(sfs::canonical(info.dli_fname)); // /.../lib/libxrt_coreutil.so
44-
return so_path.parent_path().parent_path();
45-
}
46-
catch (const std::exception&) {
47-
return sfs::path(XRT_INSTALL_PREFIX);
48-
}
34+
// This returns CMAKE_INSTALL_PREFIX. The internal default cmake
35+
// install path is /opt/xilinx/xrt, for upstreaming most likely /usr.
36+
// In relocatable installs XILINX_XRT should be set and this function
37+
// will not be called.
38+
return sfs::path(XRT_INSTALL_PREFIX);
4939
}
5040

5141
// platform_repo_path() - Get candidate paths for platform repository data

0 commit comments

Comments
 (0)