Extract C++ files, rather than C, when working around Bazel bugs
To work around Bazel's bugs around mixed C/C++ targets
(https://github.com/bazelbuild/bazel/issues/22041), we automatically
split all of our targets in two.
When we did this, we originally pulled the C files into their own
target. This had the side effect of building assembly files with the C
files instead of with the C++ files. In principle, this does not matter,
but Bazel likes to turn targets into shared libraries, and our assembly
files still contain a couple references to OPENSSL_ia32cap_P (see
https://crbug.com/42290548). Those references rely on OPENSSL_ia32cap_P
being a hidden symbol, and statically linked with the assembly files.
Pull the C++ out instead, to avoid this. Once
https://crbug.com/42290548 is done, either will work, but this is
needed for now.
Bug: 362664827
Change-Id: Icb929d194ee2311707fe1a0bb27ea0ccaf96a510
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/70690
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/util/util.bzl b/util/util.bzl
index 8de6afb..83ddff6 100644
--- a/util/util.bzl
+++ b/util/util.bzl
@@ -107,12 +107,13 @@
# If a target has both C and C++, we need to split it in two.
if has_c and has_cxx:
- srcs_c = [src for src in srcs if src.endswith(".c") or src.endswith(".h")]
- name_c = name + "_c"
+ # Pull the C++ files out.
+ srcs_cxx = [src for src in srcs if src.endswith(".cc") or src.endswith(".h")]
+ name_cxx = name + "_cxx"
cc_library(
- name = name_c,
- srcs = srcs_c + internal_hdrs,
- copts = copts + boringssl_copts_c,
+ name = name_cxx,
+ srcs = srcs_cxx + internal_hdrs,
+ copts = copts + boringssl_copts_cxx,
includes = includes,
# This target only exists to be linked into the main library, so
# always link it statically.
@@ -122,10 +123,10 @@
testonly = testonly,
)
- # Build the remainder as a C++-only target.
- deps = deps + [":" + name_c]
- srcs = [src for src in srcs if not src.endswith(".c")]
- has_c = False
+ # Build the remainder as a C-only target.
+ deps = deps + [":" + name_cxx]
+ srcs = [src for src in srcs if not src.endswith(".cc")]
+ has_cxx = False
if has_c:
copts = copts + boringssl_copts_c