Skip to content

Commit

Permalink
Normalize rpath entries to guard against missing default solib dir
Browse files Browse the repository at this point in the history
When all dynamic deps in a build are built in transitioned
configurations, the default solib dir is not created. However, while
resolving paths, the dynamic linker stops at the first directory that
does not exist, even when followed by "../".

Before this commit, all rpath entries would consist of the relative
path to the default solib dir followed by the relative path to the
particular library's solib dir. Thus, if the default solib dir was
missing, the dynamic linker wouldn't resolve any of these paths.

This commit ensures that the relative path entries are normalized and
thus contain no references to non-existing directories assuming the
normalized path itself exists.

Work towards #13819.
  • Loading branch information
fmeum committed Jan 28, 2022
1 parent 3fb43f1 commit b459cfe
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,13 @@ private void addDynamicInputLinkOptions(
commonParent = commonParent.getParentDirectory();
}

rpathRootsForExplicitSoDeps.add(
rpathRoot + dotdots + libDir.relativeTo(commonParent).getPathString());
// When all dynamic deps are built in transitioned configurations, the default solib dir is
// not created. While resolving paths, the dynamic linker stops at the first directory that
// does not exist, even when followed by "../". We thus have to normalize the relative path.
String relativePathToRoot =
rpathRoot + dotdots + libDir.relativeTo(commonParent).getPathString();
String normalizedPathToRoot = PathFragment.create(relativePathToRoot).getPathString();
rpathRootsForExplicitSoDeps.add(normalizedPathToRoot);
}

librarySearchDirectories.add(inputArtifact.getExecPath().getParentDirectory().getPathString());
Expand Down

0 comments on commit b459cfe

Please sign in to comment.