diff --git a/backends/p4tools/modules/testgen/test/small-step/util.cpp b/backends/p4tools/modules/testgen/test/small-step/util.cpp index 3670eb819fb..4e08fe26012 100644 --- a/backends/p4tools/modules/testgen/test/small-step/util.cpp +++ b/backends/p4tools/modules/testgen/test/small-step/util.cpp @@ -1,8 +1,9 @@ #include "util.h" +#include + #include -#include "absl/strings/substitute.h" #include "test/gtest/helpers.h" #include "backends/p4tools/modules/testgen/test/gtest_utils.h" diff --git a/bazel/abseil.patch b/bazel/abseil.patch new file mode 100644 index 00000000000..2f0bb644c05 --- /dev/null +++ b/bazel/abseil.patch @@ -0,0 +1,15 @@ +diff --git a/absl/base/BUILD.bazel b/absl/base/BUILD.bazel +index 0eb735da..5dd4aa67 100644 +--- a/absl/base/BUILD.bazel ++++ b/absl/base/BUILD.bazel +@@ -137,6 +137,10 @@ cc_library( + "policy_checks.h", + ], + copts = ABSL_DEFAULT_COPTS, ++ # This library is the root of the absl dependency tree. ++ # If we add this `includes` path here, then all absl headers ++ # can be included via angle brackets in external projects. ++ includes = ["../.."], + linkopts = ABSL_DEFAULT_LINKOPTS, + ) + diff --git a/bazel/p4c_deps.bzl b/bazel/p4c_deps.bzl index af4acb74e47..a52b59b026c 100644 --- a/bazel/p4c_deps.bzl +++ b/bazel/p4c_deps.bzl @@ -77,6 +77,12 @@ filegroup( name = "com_google_absl", url = "https://github.com/abseil/abseil-cpp/releases/download/20240116.1/abseil-cpp-20240116.1.tar.gz", strip_prefix = "abseil-cpp-20240116.1", + # We patch Abseil to support bracketed system includes. + # Patch is sourced from https://github.com/abseil/abseil-cpp/pull/1637. + # Discussion around Abseil's lack of support for bracketed system includes: + # https://github.com/abseil/abseil-cpp/issues/740 + patches = ["@com_github_p4lang_p4c//:bazel/abseil.patch"], + patch_args = ["-p1"], sha256 = "3c743204df78366ad2eaf236d6631d83f6bc928d1705dd0000b872e53b73dc6a", ) if not native.existing_rule("com_google_protobuf"): diff --git a/control-plane/p4RuntimeSymbolTable.cpp b/control-plane/p4RuntimeSymbolTable.cpp index 555ca6dd305..d63c0befa50 100644 --- a/control-plane/p4RuntimeSymbolTable.cpp +++ b/control-plane/p4RuntimeSymbolTable.cpp @@ -15,7 +15,8 @@ limitations under the License. */ #include "p4RuntimeSymbolTable.h" -#include "absl/strings/str_split.h" +#include + #include "lib/cstring.h" #include "lib/iterator_range.h" #include "p4RuntimeArchHandler.h" diff --git a/frontends/common/resolveReferences/referenceMap.h b/frontends/common/resolveReferences/referenceMap.h index c07e2afeab0..e00ea126e46 100644 --- a/frontends/common/resolveReferences/referenceMap.h +++ b/frontends/common/resolveReferences/referenceMap.h @@ -17,8 +17,9 @@ limitations under the License. #ifndef COMMON_RESOLVEREFERENCES_REFERENCEMAP_H_ #define COMMON_RESOLVEREFERENCES_REFERENCEMAP_H_ -#include "absl/container/flat_hash_map.h" -#include "absl/container/flat_hash_set.h" +#include +#include + #include "frontends/common/programMap.h" #include "ir/ir.h" #include "ir/visitor.h" diff --git a/frontends/common/resolveReferences/resolveReferences.h b/frontends/common/resolveReferences/resolveReferences.h index 55ece6e5127..b1666c04406 100644 --- a/frontends/common/resolveReferences/resolveReferences.h +++ b/frontends/common/resolveReferences/resolveReferences.h @@ -17,7 +17,8 @@ limitations under the License. #ifndef COMMON_RESOLVEREFERENCES_RESOLVEREFERENCES_H_ #define COMMON_RESOLVEREFERENCES_RESOLVEREFERENCES_H_ -#include "absl/container/flat_hash_map.h" +#include + #include "ir/ir.h" #include "lib/cstring.h" #include "lib/iterator_range.h" diff --git a/frontends/p4/def_use.h b/frontends/p4/def_use.h index 8b39e4d9698..27dd475693e 100644 --- a/frontends/p4/def_use.h +++ b/frontends/p4/def_use.h @@ -17,8 +17,9 @@ limitations under the License. #ifndef FRONTENDS_P4_DEF_USE_H_ #define FRONTENDS_P4_DEF_USE_H_ -#include "absl/container/flat_hash_set.h" -#include "absl/container/inlined_vector.h" +#include +#include + #include "frontends/common/resolveReferences/referenceMap.h" #include "ir/ir.h" #include "lib/alloc_trace.h" diff --git a/frontends/p4/simplifyDefUse.cpp b/frontends/p4/simplifyDefUse.cpp index fe914dbac39..5e4313694e2 100644 --- a/frontends/p4/simplifyDefUse.cpp +++ b/frontends/p4/simplifyDefUse.cpp @@ -16,7 +16,8 @@ limitations under the License. #include "simplifyDefUse.h" -#include "absl/container/flat_hash_set.h" +#include + #include "frontends/p4/def_use.h" #include "frontends/p4/methodInstance.h" #include "frontends/p4/parserCallGraph.h" diff --git a/frontends/p4/typeChecking/typeConstraints.cpp b/frontends/p4/typeChecking/typeConstraints.cpp index 448466ec220..4ab4e2cd6e6 100644 --- a/frontends/p4/typeChecking/typeConstraints.cpp +++ b/frontends/p4/typeChecking/typeConstraints.cpp @@ -16,9 +16,10 @@ limitations under the License. #include "typeConstraints.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/str_join.h" -#include "absl/strings/str_split.h" +#include +#include +#include + #include "typeUnification.h" namespace P4 { diff --git a/frontends/p4/typeMap.h b/frontends/p4/typeMap.h index e0d636b6d30..b434e8c2841 100644 --- a/frontends/p4/typeMap.h +++ b/frontends/p4/typeMap.h @@ -17,8 +17,9 @@ limitations under the License. #ifndef FRONTENDS_P4_TYPEMAP_H_ #define FRONTENDS_P4_TYPEMAP_H_ -#include "absl/container/flat_hash_map.h" -#include "absl/container/flat_hash_set.h" +#include +#include + #include "frontends/common/programMap.h" #include "frontends/p4/typeChecking/typeSubstitution.h" diff --git a/ir/visitor.cpp b/ir/visitor.cpp index be1b116e691..1a61ca2290e 100644 --- a/ir/visitor.cpp +++ b/ir/visitor.cpp @@ -19,7 +19,8 @@ limitations under the License. #include #include -#include "absl/container/flat_hash_map.h" +#include + #include "ir/ir-generated.h" #include "lib/hash.h" diff --git a/test/gtest/complex_bitwise.cpp b/test/gtest/complex_bitwise.cpp index f0e28102d8d..0743caec6b0 100644 --- a/test/gtest/complex_bitwise.cpp +++ b/test/gtest/complex_bitwise.cpp @@ -1,8 +1,8 @@ +#include #include #include -#include "absl/strings/substitute.h" #include "frontends/common/parseInput.h" #include "frontends/common/resolveReferences/referenceMap.h" #include "frontends/p4/toP4/toP4.h" diff --git a/test/gtest/diagnostics.cpp b/test/gtest/diagnostics.cpp index 2febb2e6cf6..6d8202897d7 100644 --- a/test/gtest/diagnostics.cpp +++ b/test/gtest/diagnostics.cpp @@ -14,11 +14,11 @@ See the License for the specific language governing permissions and limitations under the License. */ +#include #include #include -#include "absl/strings/substitute.h" #include "frontends/common/applyOptionsPragmas.h" #include "test/gtest/helpers.h" diff --git a/test/gtest/p4runtime.cpp b/test/gtest/p4runtime.cpp index 381f1199516..7750073de01 100644 --- a/test/gtest/p4runtime.cpp +++ b/test/gtest/p4runtime.cpp @@ -16,6 +16,7 @@ limitations under the License. #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" +#include #include #include @@ -24,7 +25,6 @@ limitations under the License. #include #include -#include "absl/strings/substitute.h" #include "control-plane/p4/config/v1/p4types.pb.h" #include "control-plane/p4/v1/p4runtime.pb.h" #include "p4/config/v1/p4info.pb.h"