summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2021-06-10 13:29:59 -0700
committerGravatar Andy Getz <durandal@google.com>2021-06-10 17:13:58 -0400
commit311bbd2e50ea35e921a08186840d3b6ca279e880 (patch)
tree99861ddf8b8e4e6ee519121807ebd9e50646bd42
parent8f92175783c9685045c50f227e7c10f1cddb4d58 (diff)
Export of internal Abseil changes
-- ca5ce10fa5286f2bfb51890a37b547308b8d6d93 by Benjamin Barenblat <bbaren@google.com>: 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 <absl-team@google.com>: Build without -Wl,-no-undefined. PiperOrigin-RevId: 378690619 -- 3587685a2c932405e401546ec383abcfbf8495c8 by Derek Mauro <dmauro@google.com>: Update CCTZ BUILD file. PiperOrigin-RevId: 378688996 -- 06c7841b2bf8851410b716823b7ff9b42d86085e by Derek Mauro <dmauro@google.com>: Change the CMake install test to use installed version of GoogleTest PiperOrigin-RevId: 378537383 -- eaa8122a7062c56bed80e806344cca0c8325bf6f by Derek Mauro <dmauro@google.com>: Internal change PiperOrigin-RevId: 378525523 -- 381f505cce894b8eec031a541855650c4aa46e64 by Abseil Team <absl-team@google.com>: 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
-rwxr-xr-xCMake/install_test_project/test.sh24
-rw-r--r--absl/base/BUILD.bazel5
-rw-r--r--absl/container/BUILD.bazel1
-rw-r--r--absl/container/internal/btree_container.h3
-rw-r--r--absl/flags/BUILD.bazel10
-rw-r--r--absl/hash/BUILD.bazel1
-rw-r--r--absl/numeric/BUILD.bazel1
-rw-r--r--absl/random/beta_distribution_test.cc9
-rw-r--r--absl/random/distributions_test.cc10
-rw-r--r--absl/random/exponential_distribution_test.cc10
-rw-r--r--absl/random/uniform_real_distribution_test.cc9
-rw-r--r--absl/status/BUILD.bazel2
-rw-r--r--absl/strings/BUILD.bazel7
-rw-r--r--absl/synchronization/BUILD.bazel2
-rw-r--r--absl/time/BUILD.bazel1
-rw-r--r--absl/time/duration_test.cc9
-rw-r--r--absl/time/internal/cctz/BUILD.bazel2
-rwxr-xr-xci/cmake_install_test.sh3
18 files changed, 104 insertions, 5 deletions
diff --git a/CMake/install_test_project/test.sh b/CMake/install_test_project/test.sh
index a3d39773..5a78c92c 100755
--- a/CMake/install_test_project/test.sh
+++ b/CMake/install_test_project/test.sh
@@ -19,10 +19,9 @@
# Fail on any error. Treat unset variables an error. Print commands as executed.
set -euox pipefail
-source ci/cmake_common.sh
-
absl_dir=/abseil-cpp
absl_build_dir=/buildfs
+googletest_builddir=/googletest_builddir
project_dir="${absl_dir}"/CMake/install_test_project
project_build_dir=/buildfs/project-build
@@ -31,13 +30,30 @@ if [ "${LINK_TYPE:-}" = "DYNAMIC" ]; then
build_shared_libs="ON"
fi
+# Build and install GoogleTest
+mkdir "${googletest_builddir}"
+pushd "${googletest_builddir}"
+curl -L "${ABSL_GOOGLETEST_DOWNLOAD_URL}" --output "${ABSL_GOOGLETEST_COMMIT}".zip
+unzip "${ABSL_GOOGLETEST_COMMIT}".zip
+pushd "googletest-${ABSL_GOOGLETEST_COMMIT}"
+mkdir build
+pushd build
+cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS="${build_shared_libs}" ..
+make -j $(nproc)
+make install
+ldconfig
+popd
+popd
+popd
+
# Run the LTS transformations
./create_lts.py 99998877
-# Install Abseil
+# Build and install Abseil
pushd "${absl_build_dir}"
cmake "${absl_dir}" \
- -DABSL_GOOGLETEST_DOWNLOAD_URL="${ABSL_GOOGLETEST_DOWNLOAD_URL}" \
+ -DABSL_USE_EXTERNAL_GOOGLETEST=ON \
+ -DABSL_FIND_GOOGLETEST=ON \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=ON \
-DBUILD_SHARED_LIBS="${build_shared_libs}"
diff --git a/absl/base/BUILD.bazel b/absl/base/BUILD.bazel
index 65ff0dde..16b0e2fb 100644
--- a/absl/base/BUILD.bazel
+++ b/absl/base/BUILD.bazel
@@ -56,6 +56,7 @@ cc_library(
srcs = ["log_severity.cc"],
hdrs = ["log_severity.h"],
copts = ABSL_DEFAULT_COPTS,
+ features = ["-no_undefined"],
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":config",
@@ -159,6 +160,7 @@ cc_library(
"internal/low_level_alloc.h",
],
copts = ABSL_DEFAULT_COPTS,
+ features = ["-no_undefined"],
linkopts = select({
"//absl:msvc_compiler": [],
"//absl:clang-cl_compiler": [],
@@ -220,6 +222,7 @@ cc_library(
"internal/unscaledcycleclock.h",
],
copts = ABSL_DEFAULT_COPTS,
+ features = ["-no_undefined"],
linkopts = select({
"//absl:msvc_compiler": [
"-DEFAULTLIB:advapi32.lib",
@@ -290,6 +293,7 @@ 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__",
@@ -709,6 +713,7 @@ 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/container/BUILD.bazel b/absl/container/BUILD.bazel
index f22fdc60..96510541 100644
--- a/absl/container/BUILD.bazel
+++ b/absl/container/BUILD.bazel
@@ -505,6 +505,7 @@ 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/container/internal/btree_container.h b/absl/container/internal/btree_container.h
index 4f5d56dd..a99668c7 100644
--- a/absl/container/internal/btree_container.h
+++ b/absl/container/internal/btree_container.h
@@ -20,6 +20,7 @@
#include <iterator>
#include <utility>
+#include "absl/base/attributes.h"
#include "absl/base/internal/throw_delegate.h"
#include "absl/container/internal/btree.h" // IWYU pragma: export
#include "absl/container/internal/common.h"
@@ -176,7 +177,7 @@ class btree_container {
}
// Utility routines.
- void clear() { tree_.clear(); }
+ ABSL_ATTRIBUTE_REINITIALIZES void clear() { tree_.clear(); }
void swap(btree_container &other) { tree_.swap(other.tree_); }
void verify() const { tree_.verify(); }
diff --git a/absl/flags/BUILD.bazel b/absl/flags/BUILD.bazel
index c178b86b..940e3561 100644
--- a/absl/flags/BUILD.bazel
+++ b/absl/flags/BUILD.bazel
@@ -51,6 +51,7 @@ cc_library(
"internal/program_name.h",
],
copts = ABSL_DEFAULT_COPTS,
+ features = ["-no_undefined"],
linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = [
"//absl/flags:__pkg__",
@@ -74,6 +75,7 @@ cc_library(
"usage_config.h",
],
copts = ABSL_DEFAULT_COPTS,
+ features = ["-no_undefined"],
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":path_util",
@@ -94,6 +96,7 @@ cc_library(
"marshalling.h",
],
copts = ABSL_DEFAULT_COPTS,
+ features = ["-no_undefined"],
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/base:config",
@@ -113,6 +116,7 @@ cc_library(
"internal/commandlineflag.h",
],
copts = ABSL_DEFAULT_COPTS,
+ features = ["-no_undefined"],
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/base:config",
@@ -129,6 +133,7 @@ cc_library(
"commandlineflag.h",
],
copts = ABSL_DEFAULT_COPTS,
+ features = ["-no_undefined"],
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":commandlineflag_internal",
@@ -170,6 +175,7 @@ cc_library(
"reflection.h",
],
copts = ABSL_DEFAULT_COPTS,
+ features = ["-no_undefined"],
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":commandlineflag",
@@ -194,6 +200,7 @@ cc_library(
"internal/sequence_lock.h",
],
copts = ABSL_DEFAULT_COPTS,
+ features = ["-no_undefined"],
linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = ["//absl/base:__subpackages__"],
deps = [
@@ -244,6 +251,7 @@ cc_library(
"internal/usage.h",
],
copts = ABSL_DEFAULT_COPTS,
+ features = ["-no_undefined"],
linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = [
"//absl/flags:__pkg__",
@@ -273,6 +281,7 @@ cc_library(
"usage.h",
],
copts = ABSL_DEFAULT_COPTS,
+ features = ["-no_undefined"],
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":usage_internal",
@@ -291,6 +300,7 @@ 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 4b2c220f..f5005a04 100644
--- a/absl/hash/BUILD.bazel
+++ b/absl/hash/BUILD.bazel
@@ -34,6 +34,7 @@ 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 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",
diff --git a/absl/random/beta_distribution_test.cc b/absl/random/beta_distribution_test.cc
index 44cdfdd0..d980c969 100644
--- a/absl/random/beta_distribution_test.cc
+++ b/absl/random/beta_distribution_test.cc
@@ -15,6 +15,7 @@
#include "absl/random/beta_distribution.h"
#include <algorithm>
+#include <cfloat>
#include <cstddef>
#include <cstdint>
#include <iterator>
@@ -558,6 +559,14 @@ TEST(BetaDistributionTest, StabilityTest) {
// dependencies of the distribution change, such as RandU64ToDouble, then this
// is also likely to change.
TEST(BetaDistributionTest, AlgorithmBounds) {
+#if (defined(__i386__) || defined(_M_IX86)) && FLT_EVAL_METHOD != 0
+ // We're using an x87-compatible FPU, and intermediate operations are
+ // performed with 80-bit floats. This produces slightly different results from
+ // what we expect below.
+ GTEST_SKIP()
+ << "Skipping the test because we detected x87 floating-point semantics";
+#endif
+
{
absl::random_internal::sequence_urbg urbg(
{0x7fbe76c8b4395800ull, 0x8000000000000000ull});
diff --git a/absl/random/distributions_test.cc b/absl/random/distributions_test.cc
index 5866a072..d3a5dd75 100644
--- a/absl/random/distributions_test.cc
+++ b/absl/random/distributions_test.cc
@@ -14,6 +14,7 @@
#include "absl/random/distributions.h"
+#include <cfloat>
#include <cmath>
#include <cstdint>
#include <random>
@@ -224,6 +225,15 @@ TEST_F(RandomDistributionsTest, UniformNoBounds) {
TEST_F(RandomDistributionsTest, UniformNonsenseRanges) {
// The ranges used in this test are undefined behavior.
// The results are arbitrary and subject to future changes.
+
+#if (defined(__i386__) || defined(_M_IX86)) && FLT_EVAL_METHOD != 0
+ // We're using an x87-compatible FPU, and intermediate operations can be
+ // performed with 80-bit floats. This produces slightly different results from
+ // what we expect below.
+ GTEST_SKIP()
+ << "Skipping the test because we detected x87 floating-point semantics";
+#endif
+
absl::InsecureBitGen gen;
// <uint>
diff --git a/absl/random/exponential_distribution_test.cc b/absl/random/exponential_distribution_test.cc
index af11d61c..81a5d17b 100644
--- a/absl/random/exponential_distribution_test.cc
+++ b/absl/random/exponential_distribution_test.cc
@@ -15,6 +15,7 @@
#include "absl/random/exponential_distribution.h"
#include <algorithm>
+#include <cfloat>
#include <cmath>
#include <cstddef>
#include <cstdint>
@@ -384,6 +385,15 @@ TEST(ExponentialDistributionTest, StabilityTest) {
TEST(ExponentialDistributionTest, AlgorithmBounds) {
// Relies on absl::uniform_real_distribution, so some of these comments
// reference that.
+
+#if (defined(__i386__) || defined(_M_IX86)) && FLT_EVAL_METHOD != 0
+ // We're using an x87-compatible FPU, and intermediate operations can be
+ // performed with 80-bit floats. This produces slightly different results from
+ // what we expect below.
+ GTEST_SKIP()
+ << "Skipping the test because we detected x87 floating-point semantics";
+#endif
+
absl::exponential_distribution<double> dist;
{
diff --git a/absl/random/uniform_real_distribution_test.cc b/absl/random/uniform_real_distribution_test.cc
index 18bcd3bc..035bd284 100644
--- a/absl/random/uniform_real_distribution_test.cc
+++ b/absl/random/uniform_real_distribution_test.cc
@@ -14,6 +14,7 @@
#include "absl/random/uniform_real_distribution.h"
+#include <cfloat>
#include <cmath>
#include <cstdint>
#include <iterator>
@@ -70,6 +71,14 @@ using RealTypes =
TYPED_TEST_SUITE(UniformRealDistributionTest, RealTypes);
TYPED_TEST(UniformRealDistributionTest, ParamSerializeTest) {
+#if (defined(__i386__) || defined(_M_IX86)) && FLT_EVAL_METHOD != 0
+ // We're using an x87-compatible FPU, and intermediate operations are
+ // performed with 80-bit floats. This produces slightly different results from
+ // what we expect below.
+ GTEST_SKIP()
+ << "Skipping the test because we detected x87 floating-point semantics";
+#endif
+
using param_type =
typename absl::uniform_real_distribution<TypeParam>::param_type;
diff --git a/absl/status/BUILD.bazel b/absl/status/BUILD.bazel
index 189bd73d..4db72c0d 100644
--- a/absl/status/BUILD.bazel
+++ b/absl/status/BUILD.bazel
@@ -40,6 +40,7 @@ cc_library(
"status_payload_printer.h",
],
copts = ABSL_DEFAULT_COPTS,
+ features = ["-no_undefined"],
deps = [
"//absl/base:atomic_hook",
"//absl/base:config",
@@ -76,6 +77,7 @@ 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 1cb5b3e5..a02ee395 100644
--- a/absl/strings/BUILD.bazel
+++ b/absl/strings/BUILD.bazel
@@ -66,6 +66,7 @@ cc_library(
"substitute.h",
],
copts = ABSL_DEFAULT_COPTS,
+ features = ["-no_undefined"],
deps = [
":internal",
"//absl/base",
@@ -96,6 +97,7 @@ cc_library(
"internal/utf8.h",
],
copts = ABSL_DEFAULT_COPTS,
+ features = ["-no_undefined"],
deps = [
"//absl/base:config",
"//absl/base:core_headers",
@@ -278,6 +280,7 @@ cc_library(
"internal/cord_rep_ring_reader.h",
],
copts = ABSL_DEFAULT_COPTS,
+ features = ["-no_undefined"],
visibility = [
"//visibility:private",
],
@@ -327,6 +330,7 @@ cc_library(
"cord.h",
],
copts = ABSL_DEFAULT_COPTS,
+ features = ["-no_undefined"],
deps = [
":cord_internal",
":cordz_functions",
@@ -355,6 +359,7 @@ cc_library(
srcs = ["internal/cordz_handle.cc"],
hdrs = ["internal/cordz_handle.h"],
copts = ABSL_DEFAULT_COPTS,
+ features = ["-no_undefined"],
visibility = [
"//absl:__subpackages__",
],
@@ -371,6 +376,7 @@ cc_library(
srcs = ["internal/cordz_info.cc"],
hdrs = ["internal/cordz_info.h"],
copts = ABSL_DEFAULT_COPTS,
+ features = ["-no_undefined"],
visibility = [
"//absl:__subpackages__",
],
@@ -995,6 +1001,7 @@ 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 92e2448d..46c4b917 100644
--- a/absl/synchronization/BUILD.bazel
+++ b/absl/synchronization/BUILD.bazel
@@ -36,6 +36,7 @@ cc_library(
"internal/graphcycles.h",
],
copts = ABSL_DEFAULT_COPTS,
+ features = ["-no_undefined"],
linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = [
"//absl:__subpackages__",
@@ -87,6 +88,7 @@ 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 3e25ca26..4700616d 100644
--- a/absl/time/BUILD.bazel
+++ b/absl/time/BUILD.bazel
@@ -43,6 +43,7 @@ cc_library(
"time.h",
],
copts = ABSL_DEFAULT_COPTS,
+ features = ["-no_undefined"],
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/base",
diff --git a/absl/time/duration_test.cc b/absl/time/duration_test.cc
index a3617e74..b7209e1c 100644
--- a/absl/time/duration_test.cc
+++ b/absl/time/duration_test.cc
@@ -17,6 +17,7 @@
#endif
#include <chrono> // NOLINT(build/c++11)
+#include <cfloat>
#include <cmath>
#include <cstdint>
#include <ctime>
@@ -1390,6 +1391,14 @@ void VerifyApproxSameAsMul(double time_as_seconds, int* const misses) {
// Seconds(point) returns a duration near point * Seconds(1.0). (They may
// not be exactly equal due to fused multiply/add contraction.)
TEST(Duration, ToDoubleSecondsCheckEdgeCases) {
+#if (defined(__i386__) || defined(_M_IX86)) && FLT_EVAL_METHOD != 0
+ // We're using an x87-compatible FPU, and intermediate operations can be
+ // performed with 80-bit floats. This means the edge cases are different than
+ // what we expect here, so just skip this test.
+ GTEST_SKIP()
+ << "Skipping the test because we detected x87 floating-point semantics";
+#endif
+
constexpr uint32_t kTicksPerSecond = absl::time_internal::kTicksPerSecond;
constexpr auto duration_tick = absl::time_internal::MakeDuration(0, 1u);
int misses = 0;
diff --git a/absl/time/internal/cctz/BUILD.bazel b/absl/time/internal/cctz/BUILD.bazel
index 45a95292..35747e57 100644
--- a/absl/time/internal/cctz/BUILD.bazel
+++ b/absl/time/internal/cctz/BUILD.bazel
@@ -45,6 +45,7 @@ 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"],
@@ -74,6 +75,7 @@ cc_library(
"include/cctz/time_zone.h",
"include/cctz/zone_info_source.h",
],
+ features = ["-no_undefined"],
linkopts = select({
":osx": [
"-framework Foundation",
diff --git a/ci/cmake_install_test.sh b/ci/cmake_install_test.sh
index ffc6b516..97ed8478 100755
--- a/ci/cmake_install_test.sh
+++ b/ci/cmake_install_test.sh
@@ -36,8 +36,11 @@ for link_type in ${LINK_TYPE}; do
--tmpfs=/abseil-cpp:exec \
--workdir=/abseil-cpp \
--cap-add=SYS_PTRACE \
+ -e "ABSL_GOOGLETEST_COMMIT=${ABSL_GOOGLETEST_COMMIT}" \
+ -e "ABSL_GOOGLETEST_DOWNLOAD_URL=${ABSL_GOOGLETEST_DOWNLOAD_URL}" \
-e "LINK_TYPE=${link_type}" \
--rm \
+ ${DOCKER_EXTRA_ARGS:-} \
${DOCKER_CONTAINER} \
/bin/bash -c "cp -r /abseil-cpp-ro/* . && CMake/install_test_project/test.sh"
done