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

[P4Testgen] Unify compiler options and tool options. Ensure options context is always initialized correctly. #4787

Merged
merged 3 commits into from
Sep 30, 2024

Conversation

fruffy
Copy link
Collaborator

@fruffy fruffy commented Jul 8, 2024

This is a larger rewrite of the core parts of P4Testgen's target initialization. The goal is to fix several problems when trying to use P4Testgen and other tools as a library. We need to make sure that the CompileContext we are accessing is the correct one.

  • We decouple initialization of the options and the initialization of the target. This way we can initialize a target before we even know which options we need. This means we can make the options target-dependent (e.g., different options for BMv2, Tofino, etc). This can be really nice for usability since we can create bespoke options per target.

  • To reduce the amount of random static objects floating around we fold P4ToolsOptions and the CompilerOptions together. There is no reason why need two classes here.

  • Options are only accessed by passing them along or retrieving them from the context stack. Ideally, we get rid of the context stack entirely but this requires a lot more work.

@fruffy fruffy added the p4tools Topics related to the P4Tools back end label Jul 8, 2024
@fruffy fruffy force-pushed the fruffy/testgen_options_cleanup branch 2 times, most recently from 0bb6a4b to c478a18 Compare July 17, 2024 14:11
@fruffy fruffy force-pushed the fruffy/testgen_options_cleanup branch 2 times, most recently from cf25391 to 167fe11 Compare July 31, 2024 17:29
@fruffy fruffy force-pushed the fruffy/testgen_options_cleanup branch from 167fe11 to ba435db Compare August 1, 2024 08:17
@fruffy fruffy force-pushed the fruffy/testgen_options_cleanup branch 2 times, most recently from 269d0d3 to 093029b Compare August 28, 2024 17:57
@fruffy fruffy marked this pull request as ready for review August 28, 2024 19:27
@fruffy fruffy force-pushed the fruffy/testgen_options_cleanup branch from 093029b to b683f0d Compare September 13, 2024 11:15
@fruffy fruffy requested a review from vlstill September 13, 2024 11:16
@fruffy
Copy link
Collaborator Author

fruffy commented Sep 19, 2024

@vlstill Could you give this a review? This is a rather major change to the way options work for P4Testgen but is required to fix issues with using the tool as a library.

Copy link
Contributor

@vlstill vlstill left a comment

Choose a reason for hiding this comment

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

Sorry for the late review, somehow I did not see this.

backends/p4tools/common/core/target.cpp Show resolved Hide resolved
backends/p4tools/common/core/target.cpp Show resolved Hide resolved
backends/p4tools/common/core/target.cpp Show resolved Hide resolved
backends/p4tools/common/core/target.cpp Show resolved Hide resolved
backends/p4tools/common/core/target.cpp Outdated Show resolved Hide resolved
backends/p4tools/common/core/target.cpp Outdated Show resolved Hide resolved
backends/p4tools/common/core/target.cpp Outdated Show resolved Hide resolved
backends/p4tools/common/p4ctool.h Outdated Show resolved Hide resolved
backends/p4tools/modules/testgen/test/gtest_utils.h Outdated Show resolved Hide resolved
@fruffy fruffy force-pushed the fruffy/testgen_options_cleanup branch from b683f0d to 24e929c Compare September 27, 2024 21:08
lib/stringify.h Outdated Show resolved Hide resolved
@fruffy fruffy force-pushed the fruffy/testgen_options_cleanup branch from 33f9b7d to 083f552 Compare September 30, 2024 17:49
@fruffy fruffy added this pull request to the merge queue Sep 30, 2024
Merged via the queue into main with commit 6b5e688 Sep 30, 2024
18 checks passed
@fruffy fruffy deleted the fruffy/testgen_options_cleanup branch September 30, 2024 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p4tools Topics related to the P4Tools back end
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants