Skip to content

Commit 5b64d38

Browse files
Be more flexible in finding libcoredistools (#80054)
1 parent 14859bf commit 5b64d38

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

src/coreclr/scripts/superpmi.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2409,9 +2409,12 @@ def write_pivot_section(row):
24092409

24102410

24112411
def determine_coredis_tools(coreclr_args):
2412-
""" Determine the coredistools location. First, look in Core_Root. It will be there if
2413-
the setup-stress-dependencies.cmd/sh script has been run, which is typically only
2414-
if tests have been run. If unable to find coredistools, download it from a cached
2412+
""" Determine the coredistools location in one of several locations:
2413+
1. First, look in Core_Root. It will be there if the setup-stress-dependencies.cmd/sh
2414+
script has been run, which is typically only if tests have been run.
2415+
2. The build appears to restore it and put it in the R2RDump sub-directory. Look there.
2416+
Copy it to the Core_Root directory if found.
2417+
3. If unable to find coredistools, download it from a cached
24152418
copy in the CLRJIT Azure Storage. (Ideally, we would instead download the NuGet
24162419
package and extract it using the same mechanism as setup-stress-dependencies
24172420
instead of having our own copy in Azure Storage).
@@ -2440,16 +2443,22 @@ def determine_coredis_tools(coreclr_args):
24402443
if os.path.isfile(coredistools_location):
24412444
logging.info("Using coredistools found at %s", coredistools_location)
24422445
else:
2443-
# Often, Core_Root will already exist. However, you can do a product build without
2444-
# creating a Core_Root, and successfully run replay or asm diffs, if we just create Core_Root
2445-
# and copy coredistools there. Note that our replays all depend on Core_Root existing, as we
2446-
# set the current directory to Core_Root before running superpmi.
2447-
if not os.path.isdir(coreclr_args.core_root):
2448-
logging.warning("Warning: Core_Root does not exist at \"%s\"; creating it now", coreclr_args.core_root)
2449-
os.makedirs(coreclr_args.core_root)
2450-
coredistools_uri = az_blob_storage_superpmi_container_uri + "/libcoredistools/{}-{}/{}".format(coreclr_args.host_os.lower(), coreclr_args.arch.lower(), coredistools_dll_name)
2451-
skip_progress = hasattr(coreclr_args, 'no_progress') and coreclr_args.no_progress
2452-
download_one_url(coredistools_uri, coredistools_location, is_azure_storage=True, display_progress=not skip_progress)
2446+
coredistools_r2rdump_location = os.path.join(coreclr_args.core_root, "R2RDump", coredistools_dll_name)
2447+
if os.path.isfile(coredistools_r2rdump_location):
2448+
logging.info("Using coredistools found at %s (copying to %s)", coredistools_r2rdump_location, coredistools_location)
2449+
logging.debug("Copying %s -> %s", coredistools_r2rdump_location, coredistools_location)
2450+
shutil.copy2(coredistools_r2rdump_location, coredistools_location)
2451+
else:
2452+
# Often, Core_Root will already exist. However, you can do a product build without
2453+
# creating a Core_Root, and successfully run replay or asm diffs, if we just create Core_Root
2454+
# and copy coredistools there. Note that our replays all depend on Core_Root existing, as we
2455+
# set the current directory to Core_Root before running superpmi.
2456+
if not os.path.isdir(coreclr_args.core_root):
2457+
logging.warning("Warning: Core_Root does not exist at \"%s\"; creating it now", coreclr_args.core_root)
2458+
os.makedirs(coreclr_args.core_root)
2459+
coredistools_uri = az_blob_storage_superpmi_container_uri + "/libcoredistools/{}-{}/{}".format(coreclr_args.host_os.lower(), coreclr_args.arch.lower(), coredistools_dll_name)
2460+
skip_progress = hasattr(coreclr_args, 'no_progress') and coreclr_args.no_progress
2461+
download_one_url(coredistools_uri, coredistools_location, is_azure_storage=True, display_progress=not skip_progress)
24532462

24542463
assert os.path.isfile(coredistools_location)
24552464
return coredistools_location

0 commit comments

Comments
 (0)