Fix a collection of random failures encountered when testing with Bazel.
diff --git a/Eigen/src/Core/arch/GPU/PacketMath.h b/Eigen/src/Core/arch/GPU/PacketMath.h
index 6d4230a..328b1b9 100644
--- a/Eigen/src/Core/arch/GPU/PacketMath.h
+++ b/Eigen/src/Core/arch/GPU/PacketMath.h
@@ -31,6 +31,15 @@
 #define EIGEN_GPU_HAS_FP16_ARITHMETIC 1
 #endif
 
+// We need to distinguish ‘clang as the CUDA compiler’ from ‘clang as the host compiler,
+// invoked by NVCC’ (e.g. on MacOS). The former needs to see both host and device implementation
+// of the functions, while the latter can only deal with one of them.
+#if defined(EIGEN_CUDA_ARCH) || defined(EIGEN_HIPCC) || (defined(EIGEN_CUDACC) && EIGEN_COMP_CLANG && !EIGEN_COMP_NVCC)
+#define EIGEN_HAS_GPU_DEVICE_FUNCTIONS 1
+#else
+#define EIGEN_HAS_GPU_DEVICE_FUNCTIONS 0
+#endif
+
 // Make sure this is only available when targeting a GPU: we don't want to
 // introduce conflicts between these packet_traits definitions and the ones
 // we'll use on the host side (SSE, AVX, ...)
@@ -74,7 +83,10 @@
     HasGammaSampleDerAlpha = 1,
     HasIGammac = 1,
     HasBetaInc = 1,
-    HasBlend = 0
+
+    HasBlend = 0,
+    HasFloor = 1,
+    HasCmp = EIGEN_HAS_GPU_DEVICE_FUNCTIONS
   };
 };
 
@@ -143,10 +155,7 @@
   return make_double2(from, from);
 }
 
-// We need to distinguish ‘clang as the CUDA compiler’ from ‘clang as the host compiler,
-// invoked by NVCC’ (e.g. on MacOS). The former needs to see both host and device implementation
-// of the functions, while the latter can only deal with one of them.
-#if defined(EIGEN_CUDA_ARCH) || defined(EIGEN_HIPCC) || (defined(EIGEN_CUDACC) && EIGEN_COMP_CLANG && !EIGEN_COMP_NVCC)
+#if EIGEN_HAS_GPU_DEVICE_FUNCTIONS
 
 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float bitwise_and(const float& a, const float& b) {
   return __int_as_float(__float_as_int(a) & __float_as_int(b));
@@ -259,8 +268,7 @@
 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pcmp_le<double2>(const double2& a, const double2& b) {
   return make_double2(le_mask(a.x, b.x), le_mask(a.y, b.y));
 }
-#endif  // defined(EIGEN_CUDA_ARCH) || defined(EIGEN_HIPCC) || (defined(EIGEN_CUDACC) && EIGEN_COMP_CLANG &&
-        // !EIGEN_COMP_NVCC)
+#endif  // EIGEN_HAS_GPU_DEVICE_FUNCTIONS
 
 template <>
 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 plset<float4>(const float& a) {
diff --git a/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h b/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h
index 26cd38e..3c65541 100644
--- a/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h
+++ b/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h
@@ -274,6 +274,10 @@
   }
 };
 
+// Symbol is ODR-used, so we need a definition.
+template <typename Scalar, typename StorageIndex>
+constexpr StorageIndex simpl_chol_helper<Scalar, StorageIndex>::kEmpty;
+
 }  // namespace internal
 
 template <typename Derived>
diff --git a/test/AnnoyingScalar.h b/test/AnnoyingScalar.h
index 00a20c7..9e320ea 100644
--- a/test/AnnoyingScalar.h
+++ b/test/AnnoyingScalar.h
@@ -16,7 +16,7 @@
 #pragma GCC diagnostic ignored "-Wshadow"
 #endif
 
-#ifndef EIGEN_TEST_ANNOYING_SCALAR_DONT_THROW
+#if defined(EIGEN_EXCEPTIONS) && !defined(EIGEN_TEST_ANNOYING_SCALAR_DONT_THROW)
 struct my_exception {
   my_exception() {}
   ~my_exception() {}
@@ -76,7 +76,7 @@
   }
 
   AnnoyingScalar operator+(const AnnoyingScalar& other) const {
-#ifndef EIGEN_TEST_ANNOYING_SCALAR_DONT_THROW
+#if defined(EIGEN_EXCEPTIONS) && !defined(EIGEN_TEST_ANNOYING_SCALAR_DONT_THROW)
     countdown--;
     if (countdown <= 0 && !dont_throw) throw my_exception();
 #endif
diff --git a/test/array_cwise.cpp b/test/array_cwise.cpp
index cf0e6e4..6ff8d67 100644
--- a/test/array_cwise.cpp
+++ b/test/array_cwise.cpp
@@ -1340,7 +1340,7 @@
     CALL_SUBTEST_3(array_generic(Array44d()));
     CALL_SUBTEST_4(array_generic(
         ArrayXXcf(internal::random<int>(1, EIGEN_TEST_MAX_SIZE), internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
-    CALL_SUBTEST_7(array_generic(
+    CALL_SUBTEST_5(array_generic(
         ArrayXXf(internal::random<int>(1, EIGEN_TEST_MAX_SIZE), internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
     CALL_SUBTEST_8(array_generic(
         ArrayXXi(internal::random<int>(1, EIGEN_TEST_MAX_SIZE), internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
diff --git a/test/exceptions.cpp b/test/exceptions.cpp
index e3a5893..751e291 100644
--- a/test/exceptions.cpp
+++ b/test/exceptions.cpp
@@ -8,7 +8,7 @@
 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 // Various sanity tests with exceptions and non trivially copyable scalar type.
-//  - no memory leak when a custom scalar type trow an exceptions
+//  - no memory leak when a custom scalar type throw an exceptions
 //  - todo: complete the list of tests!
 
 #define EIGEN_STACK_ALLOCATION_LIMIT 100000000
@@ -21,9 +21,8 @@
     AnnoyingScalar::countdown = 100;                                                                                  \
     int before = AnnoyingScalar::instances;                                                                           \
     bool exception_thrown = false;                                                                                    \
-    try {                                                                                                             \
-      OP;                                                                                                             \
-    } catch (my_exception) {                                                                                          \
+    EIGEN_TRY { OP; }                                                                                                 \
+    EIGEN_CATCH(my_exception) {                                                                                       \
       exception_thrown = true;                                                                                        \
       VERIFY(AnnoyingScalar::instances == before && "memory leak detected in " && EIGEN_MAKESTRING(OP));              \
     }                                                                                                                 \
@@ -35,7 +34,11 @@
   typedef Eigen::Matrix<AnnoyingScalar, Dynamic, Dynamic> MatrixType;
 
   {
+#if defined(EIGEN_EXCEPTIONS) && !defined(EIGEN_TEST_ANNOYING_SCALAR_DONT_THROW)
     AnnoyingScalar::dont_throw = false;
+#else
+    AnnoyingScalar::dont_throw = true;
+#endif
     int n = 50;
     VectorType v0(n), v1(n);
     MatrixType m0(n, n), m1(n, n), m2(n, n);
diff --git a/test/main.h b/test/main.h
index a8e951f..2288778 100644
--- a/test/main.h
+++ b/test/main.h
@@ -343,7 +343,7 @@
 #if !defined(EIGEN_TESTING_CONSTEXPR) && !defined(EIGEN_TESTING_PLAINOBJECT_CTOR)
 #define EIGEN_INTERNAL_DEBUGGING
 #endif
-#include <Eigen/QR>  // required for createRandomPIMatrixOfRank and generateRandomMatrixSvs
+#include <Eigen/Core>
 
 inline void verify_impl(bool condition, const char* testname, const char* file, int line,
                         const char* condition_as_string) {
@@ -935,3 +935,7 @@
 #endif
 
 #include "gpu_test_helper.h"
+
+#ifndef EIGEN_TEST_MAX_SIZE
+#define EIGEN_TEST_MAX_SIZE 320
+#endif
diff --git a/test/maxsizevector.cpp b/test/maxsizevector.cpp
index 7fe691a..82aa257 100644
--- a/test/maxsizevector.cpp
+++ b/test/maxsizevector.cpp
@@ -1,6 +1,8 @@
 #include "main.h"
 
+#ifdef EIGEN_EXCEPTIONS
 #include <exception>  // std::exception
+#endif
 
 #include <Eigen/src/Core/util/MaxSizeVector.h>
 
@@ -31,28 +33,27 @@
     std::cout << '~';
     --Foo::object_count;
   }
-
+#ifdef EIGEN_EXCEPTIONS
   class Fail : public std::exception {};
+#endif
 };
 
 Index Foo::object_count = 0;
 Index Foo::object_limit = 0;
 
-EIGEN_DECLARE_TEST(cxx11_maxsizevector) {
+EIGEN_DECLARE_TEST(maxsizevector) {
   typedef MaxSizeVector<Foo> VectorX;
   Foo::object_count = 0;
   for (int r = 0; r < g_repeat; r++) {
     Index rows = internal::random<Index>(3, 30);
     Foo::object_limit = internal::random<Index>(0, rows - 2);
     std::cout << "object_limit = " << Foo::object_limit << std::endl;
-    bool exception_raised = false;
 #ifdef EIGEN_EXCEPTIONS
+    bool exception_raised = false;
     try {
-#endif
       std::cout << "\nVectorX m(" << rows << ");\n";
       VectorX vect(rows);
       for (int i = 0; i < rows; ++i) vect.push_back(Foo());
-#ifdef EIGEN_EXCEPTIONS
       VERIFY(false);  // not reached if exceptions are enabled
     } catch (const Foo::Fail&) {
       exception_raised = true;
diff --git a/test/redux.cpp b/test/redux.cpp
index c9c3978..71ef535 100644
--- a/test/redux.cpp
+++ b/test/redux.cpp
@@ -182,8 +182,8 @@
     CALL_SUBTEST_5(matrixRedux(ArrayXX<int64_t>(rows, cols)));
     CALL_SUBTEST_6(matrixRedux(MatrixXcf(rows, cols)));
     CALL_SUBTEST_6(matrixRedux(ArrayXXcf(rows, cols)));
-    CALL_SUBTEST_6(matrixRedux(MatrixXcd(rows, cols)));
-    CALL_SUBTEST_6(matrixRedux(ArrayXXcd(rows, cols)));
+    CALL_SUBTEST_7(matrixRedux(MatrixXcd(rows, cols)));
+    CALL_SUBTEST_7(matrixRedux(ArrayXXcd(rows, cols)));
   }
   for (int i = 0; i < g_repeat; i++) {
     int size = internal::random<int>(1, maxsize);
diff --git a/test/sizeoverflow.cpp b/test/sizeoverflow.cpp
index 66f820f..612067f 100644
--- a/test/sizeoverflow.cpp
+++ b/test/sizeoverflow.cpp
@@ -9,6 +9,7 @@
 
 #include "main.h"
 
+#ifdef EIGEN_EXCEPTIONS
 #define VERIFY_THROWS_BADALLOC(a)                         \
   {                                                       \
     bool threw = false;                                   \
@@ -19,6 +20,10 @@
     }                                                     \
     VERIFY(threw && "should have thrown bad_alloc: " #a); \
   }
+#else
+// No way to catch a bad alloc - program terminates.
+#define VERIFY_THROWS_BADALLOC(a)
+#endif
 
 template <typename MatrixType>
 void triggerMatrixBadAlloc(Index rows, Index cols) {
diff --git a/test/svd_common.h b/test/svd_common.h
index dd520f5..5174ade 100644
--- a/test/svd_common.h
+++ b/test/svd_common.h
@@ -381,6 +381,7 @@
 
   typedef Matrix<typename MatrixType::Scalar, RowsAtCompileTime, 1> RhsType;
   RhsType rhs = RhsType::Zero(input.rows());
+  EIGEN_UNUSED_VARIABLE(rhs);  // Only used if asserts are enabled.
   MatrixType m(input.rows(), input.cols());
   svd_fill_random(m);
 
@@ -410,6 +411,7 @@
   enum { RowsAtCompileTime = MatrixType::RowsAtCompileTime };
   typedef Matrix<typename MatrixType::Scalar, RowsAtCompileTime, 1> RhsType;
   RhsType rhs = RhsType::Zero(input.rows());
+  EIGEN_UNUSED_VARIABLE(rhs);  // Only used if asserts are enabled.
   MatrixType m(input.rows(), input.cols());
   svd_fill_random(m);
 
diff --git a/test/zerosized.cpp b/test/zerosized.cpp
index 7001327..2df2f29 100644
--- a/test/zerosized.cpp
+++ b/test/zerosized.cpp
@@ -24,6 +24,8 @@
   VERIFY_RAISES_ASSERT(m.minCoeff());
   VERIFY_RAISES_ASSERT(m.maxCoeff());
   Index i, j;
+  EIGEN_UNUSED_VARIABLE(i);  // Only used if exceptions are enabled.
+  EIGEN_UNUSED_VARIABLE(j);
   VERIFY_RAISES_ASSERT(m.minCoeff(&i, &j));
   VERIFY_RAISES_ASSERT(m.maxCoeff(&i, &j));
   VERIFY_RAISES_ASSERT(m.reshaped().minCoeff(&i));
diff --git a/unsupported/Eigen/CXX11/Tensor b/unsupported/Eigen/CXX11/Tensor
index 290a0c0..7375a9b 100644
--- a/unsupported/Eigen/CXX11/Tensor
+++ b/unsupported/Eigen/CXX11/Tensor
@@ -45,7 +45,7 @@
 #include <thread>
 
 #if defined(EIGEN_USE_THREADS) || defined(EIGEN_USE_SYCL)
-#include "ThreadPool"
+#include "../../../Eigen/ThreadPool"
 #endif
 
 #ifdef EIGEN_USE_GPU