-
Notifications
You must be signed in to change notification settings - Fork 950
Backport 28259 to master #29152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backport 28259 to master #29152
Conversation
4a1ec76 to
128ee8c
Compare
marnovandermaas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some comments from an initial read through.
128ee8c to
444fe63
Compare
|
Any idea why CI is complaining about? |
2150a5a to
99e9194
Compare
Replace some heavily-nested Makefile target code with a dedicated python script that invokes Bazel to build the needed software collateral for a simulation. This script does not fundamentally change any of logic for building software, but repackages it in a form that allows proper documentation and modularity. Signed-off-by: Harry Callahan <[email protected]> (cherry picked from commit 9989803)
Signed-off-by: Harry Callahan <[email protected]> (cherry picked from commit 6437f96)
This creates a new run_mode 'sw_test_mode_base', which currently only provides the following run opts: +sw_build_device and +sw_images Signed-off-by: Harry Callahan <[email protected]> (cherry picked from commit 85b1517)
This commit replicate the changes made to the sim.mk file in the commit 4790641 Signed-off-by: Douglas Reis <[email protected]>
2ef8be7 to
eea84dd
Compare
|
There were some problems with darjeeling that @hcallahan-lowrisc helped me to investigate and fix. |
marnovandermaas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, @hcallahan-lowrisc would review this code.
| # If build_seed is provided, feed this value into bazel when building the OTP pre-load images. | ||
| # This overrides the default seed value and is needed for reproducibility to match the | ||
| # synthesized hardware from the 'build' stage. (sw build happens in the 'run' stage) | ||
| if args.build_seed != "None": | ||
| bazel_runner.build_opts += [ | ||
| f"--//hw/ip/otp_ctrl/data:lc_seed={args.build_seed}", | ||
| f"--//hw/ip/otp_ctrl/data:otp_seed={args.build_seed}", | ||
| ] | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you removing the build seed here? The commit message says you're making changes to sim.mk but this is a different file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original PR extracted the shell script inside the sim.mk to a python script build_sw_collateral_for_sim.py. So in order to backport this PR to master, all the changes made to sim.mk after the earlgrey_1.0.0 forked must be replicated in build_sw_collateral_for_sim.py.
|
As a backport it looks okay, but I don't know enough about this flow to give a good review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the backport, this is definitely a big improvement over the original Makefile logic. I've primarily focused on reviewing the new Python script, but have briefly looked over other changes. The majority of the comments are about the original PR, not this backport specifically. As this is a backport (and a big improvement), I'm okay for it to go in without most the comments being addressed and we can defer these to an issue / separate PR.
Generally most of the comments should be quick fixes or suggestions, but there are a couple that ideally I would like to be resolved before approving this PR - specifically, the comments about the docs on the sw_type enum and about the de-duplication in the last commit that passes the sw build opt to cquery.
| // SPDX-License-Identifier: Apache-2.0 | ||
| { | ||
| sw_build_cmd: "bazel" | ||
| sw_build_cmd: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nit: maybe this should be called sw_build.hjson, or even bazel_sw.hjson instead? At the moment it's slightly confusing to just have it named bazel.hjson when its purpose is actually just to build the sw collateral (via Bazel) - "Bazel" should not be synonymous with "SW collateral". I think the naming issue here just becomes more pronounced with the change to a python script that uses Bazel.
| type=_space_sep_str, | ||
| default=[], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit (repeated for --sw-build-opts): the idiomatic way would be to have nargs="*" with no specified type and then just have your shell and argparse handle splitting on whitespace for you, and then give the args like e.g.
./util/py/scripts/build_sw_collateral_for_sim.py --sw-images img_one img_two img_threeetc., but that might require some small changes to the HJSON to support. At the moment this works well for the makefile flow but won't play particularly nice with manual invocations.
| dev = args.sw_build_device | ||
|
|
||
| def _f_endswith_dev(f: Path) -> bool: | ||
| f_stem = str(f).split(".")[0] | ||
| return f_stem.endswith(dev) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this --sw-build-device argument should be marked as required=True in the argparse parser? Or this code should handle the None case.
The same is true with args.run_dir later on in the copy_files_to_run_dir call, which doesn't handle the None case for its run_dir arg.
| if logger.level <= logging.INFO: | ||
| location_query = bazel_runner.query(iq.label, ["--output=location"]) | ||
| location = location_query[0].split(" ")[0] | ||
| logger.info(f"bazel target location: {location}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this script should default to logging.WARNING and take a -v/--verbose option? As right now _main always configures to logging.INFO which means that we are making these additional expensive Bazel queries per image for any SW collateral build we do (despite good logging practice here!) This could add up over lots of SW images.
This is needed on master branch only because of darjeeling, otherwise cquery would not find darjeeling artefacts. Signed-off-by: Douglas Reis <[email protected]>
6776896 to
800d7f1
Compare
800d7f1 to
1ca7e87
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK to me modulo a couple of quick comments on your fixes 😅
As already mentioned, I'm happy to defer my remaining comments to an issue or future PR in the interest of making the backporting easier. If you haven't already, it would probably be a good idea to check the DV flow with the latest changes before merging.
Signed-off-by: Douglas Reis <[email protected]>
Signed-off-by: Douglas Reis <[email protected]>
1ca7e87 to
13ff019
Compare
AlexJones0
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes! As before, I am happy for the rest of the comments to be deferred so we can get this backported.
This PR is a manual Backport of #28259.
The conflict was caused by commit 4790641, which also modified sim.mk. I have resolved the conflict in an additional commit within this PR, which can be squashed after the review if preferred.