Skip to content

Commit

Permalink
Add pmi_path argument to superpmi.py script and use it in the superpm…
Browse files Browse the repository at this point in the history
…i-collect pipeline. (#63983)

* Add -pmi_path argument to superpmi.py collect command and use it to set PMIPATH environment variable in src/coreclr/scripts/superpmi.py

* Set pmi_path to $(SuperPMIDirectory)\crossgen2

* Print a warning if -pmi_path or -pmi_location is specified while --pmi is not in src/coreclr/scripts/superpmi.py

* Move setting of PMIPATH environment variable under `if self.coreclr_args.pmi is True:` in src/coreclr/scripts/superpmi.py

* Move pmi argument validation to setup_args() in src/coreclr/scripts/superpmi.py

* Clone root_env if we are going to set PMIPATH environment variable in src/coreclr/scripts/superpmi.py
  • Loading branch information
echesakov authored Jan 21, 2022
1 parent 24348f0 commit f3e4e76
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/coreclr/scripts/superpmi-collect.proj
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<OutputMchPath>%HELIX_WORKITEM_UPLOAD_ROOT%</OutputMchPath>
<!-- Workaround until https://github.com/dotnet/arcade/pull/6179 is not available -->
<HelixResultsDestinationDir>$(BUILD_SOURCESDIRECTORY)\artifacts\helixresults</HelixResultsDestinationDir>
<WorkItemCommand>$(SuperPMIDirectory)\superpmi.py collect -log_level DEBUG --$(CollectionType) -pmi_location $(SuperPMIDirectory)\pmi.dll </WorkItemCommand>
<WorkItemCommand>$(SuperPMIDirectory)\superpmi.py collect -log_level DEBUG --$(CollectionType) -pmi_location $(SuperPMIDirectory)\pmi.dll -pmi_path $(SuperPMIDirectory)\crossgen2</WorkItemCommand>
</PropertyGroup>
<PropertyGroup Condition="'$(AGENT_OS)' != 'Windows_NT'">
<Python>$HELIX_PYTHONPATH</Python>
Expand All @@ -68,7 +68,7 @@
<OutputMchPath>$HELIX_WORKITEM_UPLOAD_ROOT</OutputMchPath>
<!-- Workaround until https://github.com/dotnet/arcade/pull/6179 is not available -->
<HelixResultsDestinationDir>$(BUILD_SOURCESDIRECTORY)/artifacts/helixresults</HelixResultsDestinationDir>
<WorkItemCommand>$(SuperPMIDirectory)/superpmi.py collect -log_level DEBUG --$(CollectionType) -pmi_location $(SuperPMIDirectory)/pmi.dll </WorkItemCommand>
<WorkItemCommand>$(SuperPMIDirectory)/superpmi.py collect -log_level DEBUG --$(CollectionType) -pmi_location $(SuperPMIDirectory)/pmi.dll -pmi_path $(SuperPMIDirectory)/crossgen2</WorkItemCommand>
</PropertyGroup>

<PropertyGroup Condition="'$(WorkItemCommand)' != ''">
Expand Down
21 changes: 20 additions & 1 deletion src/coreclr/scripts/superpmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
collect_parser.add_argument("-assemblies", dest="assemblies", nargs="+", default=[], help="A list of managed dlls or directories to recursively use while collecting with PMI or crossgen2. Required if --pmi or --crossgen2 is specified.")
collect_parser.add_argument("-exclude", dest="exclude", nargs="+", default=[], help="A list of files or directories to exclude from the files and directories specified by `-assemblies`.")
collect_parser.add_argument("-pmi_location", help="Path to pmi.dll to use during PMI run. Optional; pmi.dll will be downloaded from Azure Storage if necessary.")
collect_parser.add_argument("-pmi_path", metavar="PMIPATH_DIR", nargs='*', help="Specify a \"load path\" where assemblies can be found during pmi.dll run. Optional; the argument values are translated to PMIPATH environment variable.")
collect_parser.add_argument("-output_mch_path", help="Location to place the final MCH file.")
collect_parser.add_argument("--merge_mch_files", action="store_true", help="Merge multiple MCH files. Use the -mch_files flag to pass a list of MCH files to merge.")
collect_parser.add_argument("-mch_files", metavar="MCH_FILE", nargs='+', help="Pass a sequence of MCH files which will be merged. Required by --merge_mch_files.")
Expand Down Expand Up @@ -831,7 +832,14 @@ async def run_pmi(print_prefix, assembly, self):
pmi_command_env = env_copy.copy()
pmi_complus_env = complus_env.copy()
pmi_complus_env["JitName"] = self.collection_shim_name
set_and_report_env(pmi_command_env, root_env, pmi_complus_env)

if self.coreclr_args.pmi_path is not None:
pmi_root_env = root_env.copy()
pmi_root_env["PMIPATH"] = ";".join(self.coreclr_args.pmi_path)
else:
pmi_root_env = root_env

set_and_report_env(pmi_command_env, pmi_root_env, pmi_complus_env)

old_env = os.environ.copy()
os.environ.update(pmi_command_env)
Expand Down Expand Up @@ -3105,6 +3113,11 @@ def verify_replay_common_args():
lambda unused: True,
"Unable to set tiered_compilation")

coreclr_args.verify(args,
"pmi_path",
lambda unused: True,
"Unable to set pmi_path")

if (args.collection_command is None) and (args.pmi is False) and (args.crossgen2 is False):
print("Either a collection command or `--pmi` or `--crossgen2` must be specified")
sys.exit(1)
Expand All @@ -3121,6 +3134,12 @@ def verify_replay_common_args():
print("Specify `-assemblies` if `--pmi` or `--crossgen2` is given")
sys.exit(1)

if not args.pmi:
if args.pmi_path is not None:
logging.warning("Warning: -pmi_path is set but --pmi is not.")
if args.pmi_location is not None:
logging.warning("Warning: -pmi_location is set but --pmi is not.")

if args.collection_command is None and args.merge_mch_files is not True:
assert args.collection_args is None
assert (args.pmi is True) or (args.crossgen2 is True)
Expand Down

0 comments on commit f3e4e76

Please sign in to comment.