diff --git a/backends/p4tools/common/compiler/compiler_target.cpp b/backends/p4tools/common/compiler/compiler_target.cpp index d8c99e08b7..22bdecc6d9 100644 --- a/backends/p4tools/common/compiler/compiler_target.cpp +++ b/backends/p4tools/common/compiler/compiler_target.cpp @@ -106,6 +106,7 @@ P4::FrontEnd CompilerTarget::mkFrontEnd() const { return {}; } MidEnd CompilerTarget::mkMidEnd(const CompilerOptions &options) const { MidEnd midEnd(options); midEnd.addDefaultPasses(); + midEnd.setStopOnError(true); return midEnd; } diff --git a/backends/p4tools/modules/testgen/targets/bmv2/bmv2.cpp b/backends/p4tools/modules/testgen/targets/bmv2/bmv2.cpp index ea1f858b2c..b132781e38 100644 --- a/backends/p4tools/modules/testgen/targets/bmv2/bmv2.cpp +++ b/backends/p4tools/modules/testgen/targets/bmv2/bmv2.cpp @@ -55,6 +55,10 @@ CompilerResultOrError Bmv2V1ModelCompilerTarget::runCompilerImpl( /// After the front end, get the P4Runtime API for the V1model architecture. auto p4runtimeApi = P4::P4RuntimeSerializer::get()->generateP4Runtime(program, "v1model"); + if (::errorCount() > 0) { + return std::nullopt; + } + program = runMidEnd(program); if (program == nullptr) { return std::nullopt;