From 512d657dd7d6429344142150843d49e0ac5f1ca3 Mon Sep 17 00:00:00 2001 From: Will Smith Date: Fri, 28 Jul 2023 01:23:31 -0700 Subject: [PATCH] Make a copy of 'clrjit' binary for use in SuperPMI collect to avoid heap errors when the same 'clrjit' binary is used (#89473) * Make a copy of 'clrjit' binary for use in SuperPMI collect to avoid heap errors when the same 'clrjit' binary is used * Feedback * Feedback --- src/coreclr/scripts/superpmi.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/coreclr/scripts/superpmi.py b/src/coreclr/scripts/superpmi.py index 78d7882..358a06c 100644 --- a/src/coreclr/scripts/superpmi.py +++ b/src/coreclr/scripts/superpmi.py @@ -649,7 +649,18 @@ class SuperPMICollect: self.collection_shim_path = os.path.join(self.core_root, self.collection_shim_name) - self.jit_path = os.path.join(coreclr_args.core_root, get_jit_name(coreclr_args)) + jit_name = get_jit_name(coreclr_args) + self.jit_path = os.path.join(coreclr_args.core_root, jit_name) + if coreclr_args.crossgen2: + # There are issues when running SuperPMI and crossgen2 when using the same JIT binary. + # Therefore, we produce a copy of the JIT binary for SuperPMI to use. + jit_name_ext = os.path.splitext(jit_name)[1] + jit_name_without_ext = os.path.splitext(jit_name)[0] + self.superpmi_jit_path = os.path.join(coreclr_args.core_root, jit_name_without_ext + "_superpmi." + jit_name_ext) + shutil.copyfile(self.jit_path, self.superpmi_jit_path) + else: + self.superpmi_jit_path = self.jit_path + self.superpmi_path = determine_superpmi_tool_path(coreclr_args) self.mcs_path = determine_mcs_tool_path(coreclr_args) @@ -774,6 +785,10 @@ class SuperPMICollect: if passed: logging.info("Generated MCH file: %s", self.final_mch_file) + # Cleanup the copy of the JIT binary. + if self.coreclr_args.crossgen2 and not self.coreclr_args.skip_cleanup: + os.remove(self.superpmi_jit_path) + return passed ############################################################################ @@ -797,7 +812,7 @@ class SuperPMICollect: root_env = {} root_env["SuperPMIShimLogPath"] = self.temp_location - root_env["SuperPMIShimPath"] = self.jit_path + root_env["SuperPMIShimPath"] = self.superpmi_jit_path dotnet_env = {} dotnet_env["EnableExtraSuperPmiQueries"] = "1" -- 2.7.4