Merge pull request #226038 from SomeoneSerge/cuda_nvrtc-origin
cudaPackages: append $ORIGIN to Runpaths
This commit is contained in:
commit
46a39c48c0
3 changed files with 24 additions and 6 deletions
|
@ -167,7 +167,7 @@ class Dependency:
|
||||||
found: bool = False # Whether it was found somewhere
|
found: bool = False # Whether it was found somewhere
|
||||||
|
|
||||||
|
|
||||||
def auto_patchelf_file(path: Path, runtime_deps: list[Path]) -> list[Dependency]:
|
def auto_patchelf_file(path: Path, runtime_deps: list[Path], append_rpaths: List[Path] = []) -> list[Dependency]:
|
||||||
try:
|
try:
|
||||||
with open_elf(path) as elf:
|
with open_elf(path) as elf:
|
||||||
|
|
||||||
|
@ -235,6 +235,8 @@ def auto_patchelf_file(path: Path, runtime_deps: list[Path]) -> list[Dependency]
|
||||||
dependencies.append(Dependency(path, dep, False))
|
dependencies.append(Dependency(path, dep, False))
|
||||||
print(f" {dep} -> not found!")
|
print(f" {dep} -> not found!")
|
||||||
|
|
||||||
|
rpath.extend(append_rpaths)
|
||||||
|
|
||||||
# Dedup the rpath
|
# Dedup the rpath
|
||||||
rpath_str = ":".join(dict.fromkeys(map(Path.as_posix, rpath)))
|
rpath_str = ":".join(dict.fromkeys(map(Path.as_posix, rpath)))
|
||||||
|
|
||||||
|
@ -251,8 +253,9 @@ def auto_patchelf(
|
||||||
paths_to_patch: List[Path],
|
paths_to_patch: List[Path],
|
||||||
lib_dirs: List[Path],
|
lib_dirs: List[Path],
|
||||||
runtime_deps: List[Path],
|
runtime_deps: List[Path],
|
||||||
recursive: bool =True,
|
recursive: bool = True,
|
||||||
ignore_missing: List[str] = []) -> None:
|
ignore_missing: List[str] = [],
|
||||||
|
append_rpaths: List[Path] = []) -> None:
|
||||||
|
|
||||||
if not paths_to_patch:
|
if not paths_to_patch:
|
||||||
sys.exit("No paths to patch, stopping.")
|
sys.exit("No paths to patch, stopping.")
|
||||||
|
@ -265,7 +268,7 @@ def auto_patchelf(
|
||||||
dependencies = []
|
dependencies = []
|
||||||
for path in chain.from_iterable(glob(p, '*', recursive) for p in paths_to_patch):
|
for path in chain.from_iterable(glob(p, '*', recursive) for p in paths_to_patch):
|
||||||
if not path.is_symlink() and path.is_file():
|
if not path.is_symlink() and path.is_file():
|
||||||
dependencies += auto_patchelf_file(path, runtime_deps)
|
dependencies += auto_patchelf_file(path, runtime_deps, append_rpaths)
|
||||||
|
|
||||||
missing = [dep for dep in dependencies if not dep.found]
|
missing = [dep for dep in dependencies if not dep.found]
|
||||||
|
|
||||||
|
@ -312,6 +315,12 @@ def main() -> None:
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--runtime-dependencies", nargs="*", type=Path,
|
"--runtime-dependencies", nargs="*", type=Path,
|
||||||
help="Paths to prepend to the runtime path of executable binaries.")
|
help="Paths to prepend to the runtime path of executable binaries.")
|
||||||
|
parser.add_argument(
|
||||||
|
"--append-rpaths",
|
||||||
|
nargs="*",
|
||||||
|
type=Path,
|
||||||
|
help="Paths to append to all runtime paths unconditionally",
|
||||||
|
)
|
||||||
|
|
||||||
print("automatically fixing dependencies for ELF files")
|
print("automatically fixing dependencies for ELF files")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
@ -322,7 +331,8 @@ def main() -> None:
|
||||||
args.libs,
|
args.libs,
|
||||||
args.runtime_dependencies,
|
args.runtime_dependencies,
|
||||||
args.recursive,
|
args.recursive,
|
||||||
args.ignore_missing)
|
args.ignore_missing,
|
||||||
|
append_rpaths=args.append_rpaths)
|
||||||
|
|
||||||
|
|
||||||
interpreter_path: Path = None # type: ignore
|
interpreter_path: Path = None # type: ignore
|
||||||
|
|
|
@ -61,6 +61,7 @@ autoPatchelf() {
|
||||||
ignoreMissingDepsArray=( "*" )
|
ignoreMissingDepsArray=( "*" )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local appendRunpathsArray=($appendRunpaths)
|
||||||
local runtimeDependenciesArray=($runtimeDependencies)
|
local runtimeDependenciesArray=($runtimeDependencies)
|
||||||
@pythonInterpreter@ @autoPatchelfScript@ \
|
@pythonInterpreter@ @autoPatchelfScript@ \
|
||||||
${norecurse:+--no-recurse} \
|
${norecurse:+--no-recurse} \
|
||||||
|
@ -68,7 +69,8 @@ autoPatchelf() {
|
||||||
--paths "$@" \
|
--paths "$@" \
|
||||||
--libs "${autoPatchelfLibs[@]}" \
|
--libs "${autoPatchelfLibs[@]}" \
|
||||||
"${extraAutoPatchelfLibs[@]}" \
|
"${extraAutoPatchelfLibs[@]}" \
|
||||||
--runtime-dependencies "${runtimeDependenciesArray[@]/%//lib}"
|
--runtime-dependencies "${runtimeDependenciesArray[@]/%//lib}" \
|
||||||
|
--append-rpaths "${appendRunpathsArray[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# XXX: This should ultimately use fixupOutputHooks but we currently don't have
|
# XXX: This should ultimately use fixupOutputHooks but we currently don't have
|
||||||
|
|
|
@ -38,6 +38,12 @@ backendStdenv.mkDerivation {
|
||||||
stdenv.cc.cc.lib
|
stdenv.cc.cc.lib
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Picked up by autoPatchelf
|
||||||
|
# Needed e.g. for libnvrtc to locate (dlopen) libnvrtc-builtins
|
||||||
|
appendRunpaths = [
|
||||||
|
"$ORIGIN"
|
||||||
|
];
|
||||||
|
|
||||||
dontBuild = true;
|
dontBuild = true;
|
||||||
|
|
||||||
# TODO: choose whether to install static/dynamic libs
|
# TODO: choose whether to install static/dynamic libs
|
||||||
|
|
Loading…
Reference in a new issue