From 311bbd2e50ea35e921a08186840d3b6ca279e880 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 10 Jun 2021 13:29:59 -0700 Subject: Export of internal Abseil changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- ca5ce10fa5286f2bfb51890a37b547308b8d6d93 by Benjamin Barenblat : Skip floating-point edge-case tests when using an x87 32-bit Intel CPUs use 80-bit floats for intermediate values, which can change the results of floating point computations from what we normally expect. Identify tests that are sensitive to the x87, and skip them when we’re on 32-bit Intel. PiperOrigin-RevId: 378722613 -- e5798bb017854e7f3b6d8721fed7dd553642b83d by Abseil Team : Build without -Wl,-no-undefined. PiperOrigin-RevId: 378690619 -- 3587685a2c932405e401546ec383abcfbf8495c8 by Derek Mauro : Update CCTZ BUILD file. PiperOrigin-RevId: 378688996 -- 06c7841b2bf8851410b716823b7ff9b42d86085e by Derek Mauro : Change the CMake install test to use installed version of GoogleTest PiperOrigin-RevId: 378537383 -- eaa8122a7062c56bed80e806344cca0c8325bf6f by Derek Mauro : Internal change PiperOrigin-RevId: 378525523 -- 381f505cce894b8eec031a541855650c4aa46e64 by Abseil Team : Mark btree_container::clear() with the ABSL_ATTRIBUTE_REINITIALIZES attribute. This prevents false positives in the clang-tidy check bugprone-use-after-move; it allows clear() to be called on a moved-from btree_container without any warnings, and the btree_container will thereafter be regarded as initialized again. PiperOrigin-RevId: 378472690 GitOrigin-RevId: ca5ce10fa5286f2bfb51890a37b547308b8d6d93 Change-Id: I4267246f418538c5baacb562d1a40213fb13f246 --- absl/numeric/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) (limited to 'absl/numeric/BUILD.bazel') diff --git a/absl/numeric/BUILD.bazel b/absl/numeric/BUILD.bazel index ea587bfa..a0ef9055 100644 --- a/absl/numeric/BUILD.bazel +++ b/absl/numeric/BUILD.bazel @@ -62,6 +62,7 @@ cc_library( ], hdrs = ["int128.h"], copts = ABSL_DEFAULT_COPTS, + features = ["-no_undefined"], linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":bits", -- cgit v1.2.3 From 9a7e447c511dae7276ab65fde4d04f6ed52b39c9 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 24 Jun 2021 09:53:14 -0700 Subject: Export of internal Abseil changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 373171b46238585c818cec37af26959f5412f813 by Abseil Team : Build with -Wl,-no-undefined. PiperOrigin-RevId: 381276748 -- da32624792d2948fe83d0ce58794d505799ab5d0 by Benjamin Barenblat : s/round/rint/ in exponential_biased `rint` differs from `round` in that it uses the current FPU rounding mode. It’s thus potentially faster, since it doesn’t have to save and restore FPU state. It also is more reflective of developer intent – most developers expect all FPU operations to use the current rounding mode, and having exponential_biased follow that rule seems ideal. PiperOrigin-RevId: 381268264 -- 8f860253a4283d2cc8230fe98d7cdf7bcb3e05f1 by Abseil Team : Internal change. PiperOrigin-RevId: 381264180 GitOrigin-RevId: 373171b46238585c818cec37af26959f5412f813 Change-Id: Iefe60b15c80318a7707e0c32159ac004bfa26d72 --- absl/base/BUILD.bazel | 5 ----- absl/base/internal/exponential_biased.cc | 2 +- absl/base/internal/exponential_biased.h | 2 +- absl/container/BUILD.bazel | 1 - absl/flags/BUILD.bazel | 10 ---------- absl/hash/BUILD.bazel | 1 - absl/numeric/BUILD.bazel | 1 - absl/status/BUILD.bazel | 2 -- absl/strings/BUILD.bazel | 7 ------- absl/synchronization/BUILD.bazel | 2 -- absl/time/BUILD.bazel | 1 - absl/time/internal/cctz/BUILD.bazel | 2 -- 12 files changed, 2 insertions(+), 34 deletions(-) (limited to 'absl/numeric/BUILD.bazel') diff --git a/absl/base/BUILD.bazel b/absl/base/BUILD.bazel index 16b0e2fb..65ff0dde 100644 --- a/absl/base/BUILD.bazel +++ b/absl/base/BUILD.bazel @@ -56,7 +56,6 @@ cc_library( srcs = ["log_severity.cc"], hdrs = ["log_severity.h"], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":config", @@ -160,7 +159,6 @@ cc_library( "internal/low_level_alloc.h", ], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], linkopts = select({ "//absl:msvc_compiler": [], "//absl:clang-cl_compiler": [], @@ -222,7 +220,6 @@ cc_library( "internal/unscaledcycleclock.h", ], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], linkopts = select({ "//absl:msvc_compiler": [ "-DEFAULTLIB:advapi32.lib", @@ -293,7 +290,6 @@ cc_library( srcs = ["internal/throw_delegate.cc"], hdrs = ["internal/throw_delegate.h"], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], linkopts = ABSL_DEFAULT_LINKOPTS, visibility = [ "//absl:__subpackages__", @@ -713,7 +709,6 @@ cc_library( srcs = ["internal/strerror.cc"], hdrs = ["internal/strerror.h"], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], linkopts = ABSL_DEFAULT_LINKOPTS, visibility = [ "//absl:__subpackages__", diff --git a/absl/base/internal/exponential_biased.cc b/absl/base/internal/exponential_biased.cc index 1b30c061..05aeea56 100644 --- a/absl/base/internal/exponential_biased.cc +++ b/absl/base/internal/exponential_biased.cc @@ -64,7 +64,7 @@ int64_t ExponentialBiased::GetSkipCount(int64_t mean) { // Assume huge values are bias neutral, retain bias for next call. return std::numeric_limits::max() / 2; } - double value = std::round(interval); + double value = std::rint(interval); bias_ = interval - value; return value; } diff --git a/absl/base/internal/exponential_biased.h b/absl/base/internal/exponential_biased.h index 94f79a33..a81f10e2 100644 --- a/absl/base/internal/exponential_biased.h +++ b/absl/base/internal/exponential_biased.h @@ -66,7 +66,7 @@ namespace base_internal { // Adjusting with rounding bias is relatively trivial: // // double value = bias_ + exponential_distribution(mean)(); -// double rounded_value = std::round(value); +// double rounded_value = std::rint(value); // bias_ = value - rounded_value; // return rounded_value; // diff --git a/absl/container/BUILD.bazel b/absl/container/BUILD.bazel index 96510541..f22fdc60 100644 --- a/absl/container/BUILD.bazel +++ b/absl/container/BUILD.bazel @@ -505,7 +505,6 @@ cc_library( ], hdrs = ["internal/hashtablez_sampler.h"], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":have_sse", diff --git a/absl/flags/BUILD.bazel b/absl/flags/BUILD.bazel index 940e3561..c178b86b 100644 --- a/absl/flags/BUILD.bazel +++ b/absl/flags/BUILD.bazel @@ -51,7 +51,6 @@ cc_library( "internal/program_name.h", ], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], linkopts = ABSL_DEFAULT_LINKOPTS, visibility = [ "//absl/flags:__pkg__", @@ -75,7 +74,6 @@ cc_library( "usage_config.h", ], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":path_util", @@ -96,7 +94,6 @@ cc_library( "marshalling.h", ], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ "//absl/base:config", @@ -116,7 +113,6 @@ cc_library( "internal/commandlineflag.h", ], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ "//absl/base:config", @@ -133,7 +129,6 @@ cc_library( "commandlineflag.h", ], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":commandlineflag_internal", @@ -175,7 +170,6 @@ cc_library( "reflection.h", ], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":commandlineflag", @@ -200,7 +194,6 @@ cc_library( "internal/sequence_lock.h", ], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], linkopts = ABSL_DEFAULT_LINKOPTS, visibility = ["//absl/base:__subpackages__"], deps = [ @@ -251,7 +244,6 @@ cc_library( "internal/usage.h", ], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], linkopts = ABSL_DEFAULT_LINKOPTS, visibility = [ "//absl/flags:__pkg__", @@ -281,7 +273,6 @@ cc_library( "usage.h", ], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":usage_internal", @@ -300,7 +291,6 @@ cc_library( "parse.h", ], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":commandlineflag", diff --git a/absl/hash/BUILD.bazel b/absl/hash/BUILD.bazel index f5005a04..4b2c220f 100644 --- a/absl/hash/BUILD.bazel +++ b/absl/hash/BUILD.bazel @@ -34,7 +34,6 @@ cc_library( ], hdrs = ["hash.h"], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":city", diff --git a/absl/numeric/BUILD.bazel b/absl/numeric/BUILD.bazel index a0ef9055..ea587bfa 100644 --- a/absl/numeric/BUILD.bazel +++ b/absl/numeric/BUILD.bazel @@ -62,7 +62,6 @@ cc_library( ], hdrs = ["int128.h"], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ ":bits", diff --git a/absl/status/BUILD.bazel b/absl/status/BUILD.bazel index 4db72c0d..189bd73d 100644 --- a/absl/status/BUILD.bazel +++ b/absl/status/BUILD.bazel @@ -40,7 +40,6 @@ cc_library( "status_payload_printer.h", ], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], deps = [ "//absl/base:atomic_hook", "//absl/base:config", @@ -77,7 +76,6 @@ cc_library( "statusor.h", ], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], deps = [ ":status", "//absl/base:core_headers", diff --git a/absl/strings/BUILD.bazel b/absl/strings/BUILD.bazel index a02ee395..1cb5b3e5 100644 --- a/absl/strings/BUILD.bazel +++ b/absl/strings/BUILD.bazel @@ -66,7 +66,6 @@ cc_library( "substitute.h", ], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], deps = [ ":internal", "//absl/base", @@ -97,7 +96,6 @@ cc_library( "internal/utf8.h", ], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], deps = [ "//absl/base:config", "//absl/base:core_headers", @@ -280,7 +278,6 @@ cc_library( "internal/cord_rep_ring_reader.h", ], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], visibility = [ "//visibility:private", ], @@ -330,7 +327,6 @@ cc_library( "cord.h", ], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], deps = [ ":cord_internal", ":cordz_functions", @@ -359,7 +355,6 @@ cc_library( srcs = ["internal/cordz_handle.cc"], hdrs = ["internal/cordz_handle.h"], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], visibility = [ "//absl:__subpackages__", ], @@ -376,7 +371,6 @@ cc_library( srcs = ["internal/cordz_info.cc"], hdrs = ["internal/cordz_info.h"], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], visibility = [ "//absl:__subpackages__", ], @@ -1001,7 +995,6 @@ cc_library( "internal/str_format/parser.h", ], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], visibility = ["//visibility:private"], deps = [ ":strings", diff --git a/absl/synchronization/BUILD.bazel b/absl/synchronization/BUILD.bazel index 46c4b917..92e2448d 100644 --- a/absl/synchronization/BUILD.bazel +++ b/absl/synchronization/BUILD.bazel @@ -36,7 +36,6 @@ cc_library( "internal/graphcycles.h", ], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], linkopts = ABSL_DEFAULT_LINKOPTS, visibility = [ "//absl:__subpackages__", @@ -88,7 +87,6 @@ cc_library( "notification.h", ], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], linkopts = select({ "//absl:msvc_compiler": [], "//absl:clang-cl_compiler": [], diff --git a/absl/time/BUILD.bazel b/absl/time/BUILD.bazel index 4700616d..3e25ca26 100644 --- a/absl/time/BUILD.bazel +++ b/absl/time/BUILD.bazel @@ -43,7 +43,6 @@ cc_library( "time.h", ], copts = ABSL_DEFAULT_COPTS, - features = ["-no_undefined"], linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ "//absl/base", diff --git a/absl/time/internal/cctz/BUILD.bazel b/absl/time/internal/cctz/BUILD.bazel index 35747e57..45a95292 100644 --- a/absl/time/internal/cctz/BUILD.bazel +++ b/absl/time/internal/cctz/BUILD.bazel @@ -45,7 +45,6 @@ cc_library( hdrs = [ "include/cctz/civil_time.h", ], - features = ["-no_undefined"], textual_hdrs = ["include/cctz/civil_time_detail.h"], visibility = ["//visibility:public"], deps = ["//absl/base:config"], @@ -75,7 +74,6 @@ cc_library( "include/cctz/time_zone.h", "include/cctz/zone_info_source.h", ], - features = ["-no_undefined"], linkopts = select({ ":osx": [ "-framework Foundation", -- cgit v1.2.3 From 22f482f0fc25825dd3783f2e8642a8226b7293d4 Mon Sep 17 00:00:00 2001 From: Vertexwahn Date: Thu, 14 Oct 2021 19:01:52 +0200 Subject: Remove bazelbuild/rules_cc dependency (#1038) --- WORKSPACE | 8 -------- absl/algorithm/BUILD.bazel | 1 - absl/base/BUILD.bazel | 1 - absl/cleanup/BUILD.bazel | 1 - absl/container/BUILD.bazel | 1 - absl/debugging/BUILD.bazel | 1 - absl/flags/BUILD.bazel | 1 - absl/functional/BUILD.bazel | 1 - absl/hash/BUILD.bazel | 1 - absl/memory/BUILD.bazel | 1 - absl/meta/BUILD.bazel | 1 - absl/numeric/BUILD.bazel | 1 - absl/random/BUILD.bazel | 1 - absl/random/internal/BUILD.bazel | 2 -- absl/status/BUILD.bazel | 1 - absl/strings/BUILD.bazel | 1 - absl/synchronization/BUILD.bazel | 1 - absl/time/BUILD.bazel | 1 - absl/time/internal/cctz/BUILD.bazel | 2 -- absl/types/BUILD.bazel | 1 - absl/utility/BUILD.bazel | 1 - 21 files changed, 30 deletions(-) (limited to 'absl/numeric/BUILD.bazel') diff --git a/WORKSPACE b/WORKSPACE index 84ab3ed4..c9aa8caf 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -35,14 +35,6 @@ http_archive( urls = ["https://github.com/google/benchmark/archive/0baacde3618ca617da95375e0af13ce1baadea47.zip"], ) -# C++ rules for Bazel. -http_archive( - name = "rules_cc", # 2021-06-07T16:41:49Z - sha256 = "b295cad8c5899e371dde175079c0a2cdc0151f5127acc92366a8c986beb95c76", - strip_prefix = "rules_cc-daf6ace7cfeacd6a83e9ff2ed659f416537b6c74", - urls = ["https://github.com/bazelbuild/rules_cc/archive/daf6ace7cfeacd6a83e9ff2ed659f416537b6c74.zip"], -) - # Bazel platform rules. http_archive( name = "platforms", diff --git a/absl/algorithm/BUILD.bazel b/absl/algorithm/BUILD.bazel index a3002b7d..afc52639 100644 --- a/absl/algorithm/BUILD.bazel +++ b/absl/algorithm/BUILD.bazel @@ -14,7 +14,6 @@ # limitations under the License. # -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", diff --git a/absl/base/BUILD.bazel b/absl/base/BUILD.bazel index 8b09b6e3..4769efda 100644 --- a/absl/base/BUILD.bazel +++ b/absl/base/BUILD.bazel @@ -14,7 +14,6 @@ # limitations under the License. # -load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", diff --git a/absl/cleanup/BUILD.bazel b/absl/cleanup/BUILD.bazel index 5cca898f..2154d9f1 100644 --- a/absl/cleanup/BUILD.bazel +++ b/absl/cleanup/BUILD.bazel @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", diff --git a/absl/container/BUILD.bazel b/absl/container/BUILD.bazel index 9e3bc06a..d1df524a 100644 --- a/absl/container/BUILD.bazel +++ b/absl/container/BUILD.bazel @@ -14,7 +14,6 @@ # limitations under the License. # -load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", diff --git a/absl/debugging/BUILD.bazel b/absl/debugging/BUILD.bazel index b503da51..3c4ea8dc 100644 --- a/absl/debugging/BUILD.bazel +++ b/absl/debugging/BUILD.bazel @@ -14,7 +14,6 @@ # limitations under the License. # -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", diff --git a/absl/flags/BUILD.bazel b/absl/flags/BUILD.bazel index 7957c6dd..d20deab4 100644 --- a/absl/flags/BUILD.bazel +++ b/absl/flags/BUILD.bazel @@ -14,7 +14,6 @@ # limitations under the License. # -load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", diff --git a/absl/functional/BUILD.bazel b/absl/functional/BUILD.bazel index 4555cd59..f9f2b9c2 100644 --- a/absl/functional/BUILD.bazel +++ b/absl/functional/BUILD.bazel @@ -14,7 +14,6 @@ # limitations under the License. # -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", diff --git a/absl/hash/BUILD.bazel b/absl/hash/BUILD.bazel index 392b68f1..f0640d34 100644 --- a/absl/hash/BUILD.bazel +++ b/absl/hash/BUILD.bazel @@ -14,7 +14,6 @@ # limitations under the License. # -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", diff --git a/absl/memory/BUILD.bazel b/absl/memory/BUILD.bazel index d2824a05..c16bf8a9 100644 --- a/absl/memory/BUILD.bazel +++ b/absl/memory/BUILD.bazel @@ -14,7 +14,6 @@ # limitations under the License. # -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", diff --git a/absl/meta/BUILD.bazel b/absl/meta/BUILD.bazel index 5585fcca..fb379251 100644 --- a/absl/meta/BUILD.bazel +++ b/absl/meta/BUILD.bazel @@ -14,7 +14,6 @@ # limitations under the License. # -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", diff --git a/absl/numeric/BUILD.bazel b/absl/numeric/BUILD.bazel index ea587bfa..1f9e0f20 100644 --- a/absl/numeric/BUILD.bazel +++ b/absl/numeric/BUILD.bazel @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", diff --git a/absl/random/BUILD.bazel b/absl/random/BUILD.bazel index 66ffcbc7..fdde78b6 100644 --- a/absl/random/BUILD.bazel +++ b/absl/random/BUILD.bazel @@ -16,7 +16,6 @@ # ABSL random-number generation libraries. -load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", diff --git a/absl/random/internal/BUILD.bazel b/absl/random/internal/BUILD.bazel index df6e42fc..e93eebb6 100644 --- a/absl/random/internal/BUILD.bazel +++ b/absl/random/internal/BUILD.bazel @@ -14,8 +14,6 @@ # limitations under the License. # -load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") - # Internal-only implementation classes for Abseil Random load( "//absl:copts/configure_copts.bzl", diff --git a/absl/status/BUILD.bazel b/absl/status/BUILD.bazel index 30df22ae..0e5b3508 100644 --- a/absl/status/BUILD.bazel +++ b/absl/status/BUILD.bazel @@ -17,7 +17,6 @@ # It will expand later to have utilities around `Status` like `StatusOr`, # `StatusBuilder` and macros. -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", diff --git a/absl/strings/BUILD.bazel b/absl/strings/BUILD.bazel index c45a671e..c046366c 100644 --- a/absl/strings/BUILD.bazel +++ b/absl/strings/BUILD.bazel @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", diff --git a/absl/synchronization/BUILD.bazel b/absl/synchronization/BUILD.bazel index 92e2448d..d7195473 100644 --- a/absl/synchronization/BUILD.bazel +++ b/absl/synchronization/BUILD.bazel @@ -14,7 +14,6 @@ # limitations under the License. # -load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", diff --git a/absl/time/BUILD.bazel b/absl/time/BUILD.bazel index 3e25ca26..e8c49660 100644 --- a/absl/time/BUILD.bazel +++ b/absl/time/BUILD.bazel @@ -14,7 +14,6 @@ # limitations under the License. # -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", diff --git a/absl/time/internal/cctz/BUILD.bazel b/absl/time/internal/cctz/BUILD.bazel index f549af66..bdc2e309 100644 --- a/absl/time/internal/cctz/BUILD.bazel +++ b/absl/time/internal/cctz/BUILD.bazel @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") - package(features = ["-parse_headers"]) licenses(["notice"]) diff --git a/absl/types/BUILD.bazel b/absl/types/BUILD.bazel index 83be9360..38ed2286 100644 --- a/absl/types/BUILD.bazel +++ b/absl/types/BUILD.bazel @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", diff --git a/absl/utility/BUILD.bazel b/absl/utility/BUILD.bazel index 02b2c407..ca4bc0a6 100644 --- a/absl/utility/BUILD.bazel +++ b/absl/utility/BUILD.bazel @@ -14,7 +14,6 @@ # limitations under the License. # -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load( "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", -- cgit v1.2.3 From c59e7e59f5d29619ddc07fcb59be3dcba9585814 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Fri, 14 Jan 2022 04:25:20 -0800 Subject: Export of internal Abseil changes -- 0db7f4046f9b59c0f8c3df2f0eb7fd88fc328439 by Abseil Team : Revise documentation of bit_cast: * Removes inappropriate examples (round-tripping pointers, serialization), for which reinterpret_cast is more appropriate. * Removes mention of "bit representation", which is not an explicit notion in C++. The best we get is "byte representation". * Removes a circular defition of "bitcast" as itself, and instead explains what it does. * Removes the mathism "for some values of", which is probably not totally accessible to a general audience, and in any case needless verbiage. * Fixes comments in the example. * Replaces some colloquialisms with simpler, more direct language. PiperOrigin-RevId: 421791786 -- e04e64df55d93c1b9a09c0483b97cc4d8763260d by Derek Mauro : Update Docker image to use GCC 11.2, Clang 14 (prerelease), CMake 3.22.1, and Bazel 4.2.2 PiperOrigin-RevId: 421658559 -- d002bb3dc5cd1fc5b4cbd79a450efc894caa567c by Chris Kennelly : Add a small microbenchmark for absl::bit_width. PiperOrigin-RevId: 421604852 -- 131b057d1b76ecd7170421b48d661bb958ff676b by Evan Brown : Adds a disabled test for EBO in nested `CompressedTuple`s. PiperOrigin-RevId: 421413134 -- e34c7876d3a1212d90c73c030ccae6169b682d43 by Jorg Brown : Show users a better error message if they pass a pointer to absl::Uniform. PiperOrigin-RevId: 421090472 GitOrigin-RevId: 0db7f4046f9b59c0f8c3df2f0eb7fd88fc328439 Change-Id: I5a004e8d17e974fa4897a09d1466ae8fc65dfdbb --- absl/base/casts.h | 57 +++++++++--------- absl/container/internal/compressed_tuple_test.cc | 10 ++++ absl/numeric/BUILD.bazel | 14 +++++ absl/numeric/bits_benchmark.cc | 73 ++++++++++++++++++++++++ absl/random/internal/distribution_caller.h | 2 + ci/linux_clang-latest_libcxx_asan_bazel.sh | 4 +- ci/linux_clang-latest_libcxx_bazel.sh | 4 +- ci/linux_clang-latest_libcxx_tsan_bazel.sh | 4 +- ci/linux_docker_containers.sh | 4 +- 9 files changed, 137 insertions(+), 35 deletions(-) create mode 100644 absl/numeric/bits_benchmark.cc (limited to 'absl/numeric/BUILD.bazel') diff --git a/absl/base/casts.h b/absl/base/casts.h index 83c69126..b16af233 100644 --- a/absl/base/casts.h +++ b/absl/base/casts.h @@ -105,47 +105,50 @@ constexpr To implicit_cast(typename absl::internal::identity_t to) { // bit_cast() // -// Performs a bitwise cast on a type without changing the underlying bit -// representation of that type's value. The two types must be of the same size -// and both types must be trivially copyable. As with most casts, use with -// caution. A `bit_cast()` might be needed when you need to temporarily treat a -// type as some other type, such as in the following cases: -// -// * Serialization (casting temporarily to `char *` for those purposes is -// always allowed by the C++ standard) -// * Managing the individual bits of a type within mathematical operations -// that are not normally accessible through that type -// * Casting non-pointer types to pointer types (casting the other way is -// allowed by `reinterpret_cast()` but round-trips cannot occur the other -// way). -// -// Example: +// Creates a value of the new type `Dest` whose representation is the same as +// that of the argument, which is of (deduced) type `Source` (a "bitwise cast"; +// every bit in the value representation of the result is equal to the +// corresponding bit in the object representation of the source). Source and +// destination types must be of the same size, and both types must be trivially +// copyable. +// +// As with most casts, use with caution. A `bit_cast()` might be needed when you +// need to treat a value as the value of some other type, for example, to access +// the individual bits of an object which are not normally accessible through +// the object's type, such as for working with the binary representation of a +// floating point value: // // float f = 3.14159265358979; // int i = bit_cast(f); // // i = 0x40490fdb // -// Casting non-pointer types to pointer types and then dereferencing them -// traditionally produces undefined behavior. +// Reinterpreting and accessing a value directly as a different type (as shown +// below) usually results in undefined behavior. // // Example: // // // WRONG -// float f = 3.14159265358979; // WRONG -// int i = * reinterpret_cast(&f); // WRONG +// float f = 3.14159265358979; +// int i = reinterpret_cast(f); // Wrong +// int j = *reinterpret_cast(&f); // Equally wrong +// int k = *bit_cast(&f); // Equally wrong +// +// Reinterpret-casting results in undefined behavior according to the ISO C++ +// specification, section [basic.lval]. Roughly, this section says: if an object +// in memory has one type, and a program accesses it with a different type, the +// result is undefined behavior for most "different type". // -// The address-casting method produces undefined behavior according to the ISO -// C++ specification section [basic.lval]. Roughly, this section says: if an -// object in memory has one type, and a program accesses it with a different -// type, the result is undefined behavior for most values of "different type". +// Using bit_cast on a pointer and then dereferencing it is no better than using +// reinterpret_cast. You should only use bit_cast on the value itself. // // Such casting results in type punning: holding an object in memory of one type // and reading its bits back using a different type. A `bit_cast()` avoids this -// issue by implementing its casts using `memcpy()`, which avoids introducing -// this undefined behavior. +// issue by copying the object representation to a new value, which avoids +// introducing this undefined behavior (since the original value is never +// accessed in the wrong way). // -// NOTE: The requirements here are more strict than the bit_cast of standard -// proposal p0476 due to the need for workarounds and lack of intrinsics. +// NOTE: The requirements here are stricter than the bit_cast of standard +// proposal P0476 due to the need for workarounds and lack of intrinsics. // Specifically, this implementation also requires `Dest` to be // default-constructible. template < diff --git a/absl/container/internal/compressed_tuple_test.cc b/absl/container/internal/compressed_tuple_test.cc index 62a7483e..74111f97 100644 --- a/absl/container/internal/compressed_tuple_test.cc +++ b/absl/container/internal/compressed_tuple_test.cc @@ -403,6 +403,16 @@ TEST(CompressedTupleTest, EmptyFinalClass) { } #endif +// TODO(b/214288561): enable this test. +TEST(CompressedTupleTest, DISABLED_NestedEbo) { + struct Empty1 {}; + struct Empty2 {}; + CompressedTuple, int> x; + CompressedTuple y; + // Currently fails with sizeof(x) == 8, sizeof(y) == 4. + EXPECT_EQ(sizeof(x), sizeof(y)); +} + } // namespace } // namespace container_internal ABSL_NAMESPACE_END diff --git a/absl/numeric/BUILD.bazel b/absl/numeric/BUILD.bazel index 1f9e0f20..eaa27dfd 100644 --- a/absl/numeric/BUILD.bazel +++ b/absl/numeric/BUILD.bazel @@ -37,6 +37,20 @@ cc_library( ], ) +cc_binary( + name = "bits_benchmark", + testonly = 1, + srcs = ["bits_benchmark.cc"], + copts = ABSL_DEFAULT_COPTS, + linkopts = ABSL_DEFAULT_LINKOPTS, + deps = [ + ":bits", + "//absl/base:core_headers", + "//absl/random", + "@com_github_google_benchmark//:benchmark_main", + ], +) + cc_test( name = "bits_test", size = "small", diff --git a/absl/numeric/bits_benchmark.cc b/absl/numeric/bits_benchmark.cc new file mode 100644 index 00000000..3de1dbfa --- /dev/null +++ b/absl/numeric/bits_benchmark.cc @@ -0,0 +1,73 @@ +// Copyright 2022 The Abseil Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include + +#include "benchmark/benchmark.h" +#include "absl/base/optimization.h" +#include "absl/numeric/bits.h" +#include "absl/random/random.h" + +namespace absl { +namespace { + +template +static void BM_bitwidth(benchmark::State& state) { + const int count = state.range(0); + + absl::BitGen rng; + std::vector values; + values.reserve(count); + for (int i = 0; i < count; ++i) { + values.push_back(absl::Uniform(rng, 0, std::numeric_limits::max())); + } + + while (state.KeepRunningBatch(count)) { + for (int i = 0; i < count; ++i) { + benchmark::DoNotOptimize(values[i]); + } + } +} +BENCHMARK_TEMPLATE(BM_bitwidth, uint8_t)->Range(1, 1 << 20); +BENCHMARK_TEMPLATE(BM_bitwidth, uint16_t)->Range(1, 1 << 20); +BENCHMARK_TEMPLATE(BM_bitwidth, uint32_t)->Range(1, 1 << 20); +BENCHMARK_TEMPLATE(BM_bitwidth, uint64_t)->Range(1, 1 << 20); + +template +static void BM_bitwidth_nonzero(benchmark::State& state) { + const int count = state.range(0); + + absl::BitGen rng; + std::vector values; + values.reserve(count); + for (int i = 0; i < count; ++i) { + values.push_back(absl::Uniform(rng, 1, std::numeric_limits::max())); + } + + while (state.KeepRunningBatch(count)) { + for (int i = 0; i < count; ++i) { + const T value = values[i]; + ABSL_INTERNAL_ASSUME(value > 0); + benchmark::DoNotOptimize(value); + } + } +} +BENCHMARK_TEMPLATE(BM_bitwidth_nonzero, uint8_t)->Range(1, 1 << 20); +BENCHMARK_TEMPLATE(BM_bitwidth_nonzero, uint16_t)->Range(1, 1 << 20); +BENCHMARK_TEMPLATE(BM_bitwidth_nonzero, uint32_t)->Range(1, 1 << 20); +BENCHMARK_TEMPLATE(BM_bitwidth_nonzero, uint64_t)->Range(1, 1 << 20); + +} // namespace +} // namespace absl diff --git a/absl/random/internal/distribution_caller.h b/absl/random/internal/distribution_caller.h index fc81b787..f1ad5ccd 100644 --- a/absl/random/internal/distribution_caller.h +++ b/absl/random/internal/distribution_caller.h @@ -32,6 +32,8 @@ namespace random_internal { // to intercept such calls. template struct DistributionCaller { + static_assert(!std::is_pointer::value, + "You must pass a reference, not a pointer."); // SFINAE to detect whether the URBG type includes a member matching // bool InvokeMock(base_internal::FastTypeIdType, void*, void*). // diff --git a/ci/linux_clang-latest_libcxx_asan_bazel.sh b/ci/linux_clang-latest_libcxx_asan_bazel.sh index 5245933a..0605e2b3 100755 --- a/ci/linux_clang-latest_libcxx_asan_bazel.sh +++ b/ci/linux_clang-latest_libcxx_asan_bazel.sh @@ -70,8 +70,8 @@ for std in ${STD}; do --rm \ -e CC="/opt/llvm/clang/bin/clang" \ -e BAZEL_CXXOPTS="-std=${std}:-nostdinc++" \ - -e BAZEL_LINKOPTS="-L/opt/llvm/libcxx/lib:-lc++:-lc++abi:-lm:-Wl,-rpath=/opt/llvm/libcxx/lib" \ - -e CPLUS_INCLUDE_PATH="/opt/llvm/libcxx/include/c++/v1" \ + -e BAZEL_LINKOPTS="-L/opt/llvm/libcxx/lib/x86_64-unknown-linux-gnu:-lc++:-lc++abi:-lm:-Wl,-rpath=/opt/llvm/libcxx/lib/x86_64-unknown-linux-gnu" \ + -e CPLUS_INCLUDE_PATH="/opt/llvm/libcxx/include/x86_64-unknown-linux-gnu/c++/v1:/opt/llvm/libcxx/include/c++/v1" \ ${DOCKER_EXTRA_ARGS:-} \ ${DOCKER_CONTAINER} \ /usr/local/bin/bazel test ... \ diff --git a/ci/linux_clang-latest_libcxx_bazel.sh b/ci/linux_clang-latest_libcxx_bazel.sh index e0fe653d..00517749 100755 --- a/ci/linux_clang-latest_libcxx_bazel.sh +++ b/ci/linux_clang-latest_libcxx_bazel.sh @@ -71,8 +71,8 @@ for std in ${STD}; do --rm \ -e CC="/opt/llvm/clang/bin/clang" \ -e BAZEL_CXXOPTS="-std=${std}:-nostdinc++" \ - -e BAZEL_LINKOPTS="-L/opt/llvm/libcxx/lib:-lc++:-lc++abi:-lm:-Wl,-rpath=/opt/llvm/libcxx/lib" \ - -e CPLUS_INCLUDE_PATH="/opt/llvm/libcxx/include/c++/v1" \ + -e BAZEL_LINKOPTS="-L/opt/llvm/libcxx/lib/x86_64-unknown-linux-gnu:-lc++:-lc++abi:-lm:-Wl,-rpath=/opt/llvm/libcxx/lib/x86_64-unknown-linux-gnu" \ + -e CPLUS_INCLUDE_PATH="/opt/llvm/libcxx/include/x86_64-unknown-linux-gnu/c++/v1:/opt/llvm/libcxx/include/c++/v1" \ ${DOCKER_EXTRA_ARGS:-} \ ${DOCKER_CONTAINER} \ /bin/sh -c " diff --git a/ci/linux_clang-latest_libcxx_tsan_bazel.sh b/ci/linux_clang-latest_libcxx_tsan_bazel.sh index 555f6b1c..da4fcd0a 100755 --- a/ci/linux_clang-latest_libcxx_tsan_bazel.sh +++ b/ci/linux_clang-latest_libcxx_tsan_bazel.sh @@ -70,8 +70,8 @@ for std in ${STD}; do --rm \ -e CC="/opt/llvm/clang/bin/clang" \ -e BAZEL_CXXOPTS="-std=${std}:-nostdinc++" \ - -e BAZEL_LINKOPTS="-L/opt/llvm/libcxx-tsan/lib:-lc++:-lc++abi:-lm:-Wl,-rpath=/opt/llvm/libcxx-tsan/lib" \ - -e CPLUS_INCLUDE_PATH="/opt/llvm/libcxx-tsan/include/c++/v1" \ + -e BAZEL_LINKOPTS="-L/opt/llvm/libcxx-tsan/lib/x86_64-unknown-linux-gnu:-lc++:-lc++abi:-lm:-Wl,-rpath=/opt/llvm/libcxx-tsan/lib/x86_64-unknown-linux-gnu" \ + -e CPLUS_INCLUDE_PATH="/opt/llvm/libcxx-tsan/include/x86_64-unknown-linux-gnu/c++/v1:/opt/llvm/libcxx-tsan/include/c++/v1" \ ${DOCKER_EXTRA_ARGS:-} \ ${DOCKER_CONTAINER} \ /usr/local/bin/bazel test ... \ diff --git a/ci/linux_docker_containers.sh b/ci/linux_docker_containers.sh index 32865b83..37be5310 100644 --- a/ci/linux_docker_containers.sh +++ b/ci/linux_docker_containers.sh @@ -16,6 +16,6 @@ # Test scripts should source this file to get the identifiers. readonly LINUX_ALPINE_CONTAINER="gcr.io/google.com/absl-177019/alpine:20201026" -readonly LINUX_CLANG_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20210617" -readonly LINUX_GCC_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20210617" +readonly LINUX_CLANG_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20220113" +readonly LINUX_GCC_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20220113" readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20210617" -- cgit v1.2.3