Skip to content

Commit b4d31a1

Browse files
committed
[#95311] Dynamically patch Renode.deps.json when loading portable Renode to force runtime to load native libraries
1 parent eb0d1f5 commit b4d31a1

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/pyrenode3/loader.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,18 @@ def from_net_bin(cls, path: "Union[str, pathlib.Path]"):
302302
# }}}}}
303303
SYSTEM_RUNTIME = "runtimepack.Microsoft.NETCore.App.Runtime." + get_RID()
304304
LIB_EXT = get_library_ext()
305+
native_libs_to_load = list(renode_dir.glob("*" + LIB_EXT))
306+
deps_file = binaries / "Renode.deps.json"
307+
308+
with open(deps_file, "rb") as deps_fp:
309+
deps = json.load(deps_fp)
305310

306-
deps = json.load(open(binaries / "Renode.deps.json", "rb"))
307311
target = deps["targets"][deps["runtimeTarget"]["name"]]
308312
for lib, dlls in target.items():
309313
name, version = lib.split("/")
310314
if name == SYSTEM_RUNTIME:
315+
# Patch in the libraries into deps.json so that they can be easily found, otherwise libhostfxr.so doesn't find them in newer versions of the runtime
316+
dlls["native"] = {lib.name: {} for lib in native_libs_to_load}
311317
tfm_full = version
312318
system_dlls = list(dlls["runtime"])
313319
break
@@ -317,9 +323,12 @@ def from_net_bin(cls, path: "Union[str, pathlib.Path]"):
317323
logging.warning(f"Could not find {SYSTEM_RUNTIME} in deps.json. "
318324
f"Assuming framework version {tfm_full}.")
319325

326+
with open(deps_file, "w") as deps_fp:
327+
json.dump(deps, deps_fp)
328+
320329
runtime = binaries / "shared/Microsoft.NETCore.App" / tfm_full
321330
runtime.mkdir(parents=True, exist_ok=True)
322-
for lib in renode_dir.glob("*" + LIB_EXT):
331+
for lib in native_libs_to_load:
323332
ensure_symlink(lib, runtime / lib.name)
324333

325334
for lib in system_dlls:

0 commit comments

Comments
 (0)