Skip to content
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

[bazel] Pass copt and features through the OT transition #20388

Merged
merged 1 commit into from
Jan 13, 2024

Conversation

cfrantz
Copy link
Contributor

@cfrantz cfrantz commented Nov 17, 2023

  1. Pass the copt and features values through the OT platform transition.
  2. Convert the aes_smoketest to the opentitan_test rule.

@cfrantz cfrantz requested a review from moidx November 17, 2023 18:45
@cfrantz cfrantz force-pushed the bazel-rules branch 3 times, most recently from cc37e04 to acb6382 Compare November 20, 2023 17:27
@a-will
Copy link
Contributor

a-will commented Jan 8, 2024

Shouldn't we keep the transition-supplied configuration separate from the target platform's? In the case where the host is the target platform, there may be parameters that only apply to the host software and actually cause errors for the opentitan platform. Perhaps some build settings could be used to supply those instead?

The compilation_mode is one part that has given me trouble in the past, for example. If I just want to debug host tools, I sometimes can't use the dbg mode, as it causes the firmware builds to fail.

@cfrantz
Copy link
Contributor Author

cfrantz commented Jan 8, 2024

Shouldn't we keep the transition-supplied configuration separate from the target platform's? In the case where the host is the target platform, there may be parameters that only apply to the host software and actually cause errors for the opentitan platform. Perhaps some build settings could be used to supply those instead?

The compilation_mode is one part that has given me trouble in the past, for example. If I just want to debug host tools, I sometimes can't use the dbg mode, as it causes the firmware builds to fail.

This is specifically to be able to build englishbreakfast programs using the new rules. The opentitan plaform transition is discarding the --copt and --feature flags needed to build englishbreakfast programs. IMHO, the proper way to do this is to either supply these flags via an englishbreakfast exec_env or by having the platform transition recognize englishbreakfast as a separate (or sub-) platform and supply the flags.

This change is concerned with getting the englishbreakfast programs to build with the new rules, thus allowing us to eliminate any of the old opentitan_functest type rules. Once we've gotten the programs migrated to the new rules, we can look into making englishbreakfast into its own top with its own exec_envs.

@cfrantz cfrantz force-pushed the bazel-rules branch 5 times, most recently from afa4f4b to 7ec84f4 Compare January 10, 2024 17:29
@cfrantz cfrantz marked this pull request as ready for review January 10, 2024 17:30
@cfrantz cfrantz requested review from rswarbrick and a team as code owners January 10, 2024 17:30
- bash: |
. util/build_consts.sh
mkdir -p "$BIN_DIR/hw/top_earlgrey/"
cp $(ci/scripts/target-location.sh //hw:verilator) \
cp $(./bazelisk.sh outquery-build.verilator //sw/device/tests:uart_smoketest_sim_verilator) \
"$BIN_DIR/hw/top_earlgrey/Vchip_earlgrey_verilator"
displayName: Copy //hw:verilator to $BIN_DIR
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the displayName to reflect line 350?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still is //hw:verilator, but indirectly by way of a test rule :)

It has to be done that way because //hw:verilator is built under the platform transition of the test rule (it transitions back to the host, but that causes the somewhat confusing bindir name of k8-opt-exec-${host}-ST-${target}.

As a compromise, I've changed the text to read "Copy verilated binary to $BIN_DIR".

@@ -1220,14 +1220,14 @@
{
name: chip_sw_aes_enc
uvm_test_seq: chip_sw_base_vseq
sw_images: ["//sw/device/tests:aes_smoketest:1"]
sw_images: ["//sw/device/tests:aes_smoketest:1:new_rules"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, it seems there are some other "sw_images" missing the new_rules suffix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you point out where I've missed them? I can't seem to find any with grep.

Comment on lines 183 to 184
'--features=-rv32_bitmanip',
'--copt=-DOT_IS_ENGLISH_BREAKFAST_REDUCED_SUPPORT_FOR_INTERNAL_USE_ONLY_',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And these are the --features and --copt you intended to pass for the risc V code generation. Along the line of @a-will's concern, is it safe to assume no other --copt flags will sneak in via some other kind of command? For example, the regular test rules will build both harness and device code, so if --copt was given in the bazel test invocation intended for the harness it may sneak through.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --copt and --features serve two purposes:

  • The copts identify the platform as englishbreakfast and cause the preprocessor symbol OT_IS_ENGLISH_BREAKFAST to get defined (in macros.h).
  • The features identify CPU code generation options for the specific rv32imc implementation in englishbreakfast. Most notably, it disables the bitmanip and crc32 extensions.

Unfortunately, the copts currently have to be passed through to host code generation to make sure the correct enumerations/defines are available for DIFs (e.g. rstmgr reasons) and for bindgen'ing the constants in to Rust opentitanlib/tool.

The feature flags matter less, but they also have no meaning to the host compiler - the bazel compiler configuration for the host doesn't have a feature called rv32_bitmanip and ignores it.

I don't particularly like this situation with copt leaking into other configurations, but until we change the overall hacky way englishbreakfast is handled in the codebase, we need it. Eliminating all legacy usage of opentitan_functest in favor of the new rules will help us get to a configuration where englishbreakfast is a true separate top supported by exec_envs rather than by the current tree-dirtying operation.

1. Pass the `copt` and `features` values through the OT platform
   transition.
2. Convert the aes_smoketest to the `opentitan_test` rule.
3. Refine the verilator binary query for the englishbreakfast model.

Signed-off-by: Chris Frantz <[email protected]>

Signed-off-by: Chris Frantz <[email protected]>
@moidx moidx merged commit 3735400 into lowRISC:master Jan 13, 2024
32 checks passed
@jwnrt
Copy link
Contributor

jwnrt commented Jan 15, 2024

This incidentally seems to have reduced Fast Earl Grey Verilated Tests runtime by ~10 minutes in CI. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants