summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMake/AbseilHelpers.cmake21
-rw-r--r--CMake/AbseilInstallDirs.cmake20
-rwxr-xr-xCMake/install_test_project/test.sh92
-rw-r--r--CMakeLists.txt66
-rw-r--r--absl/algorithm/BUILD.bazel6
-rw-r--r--absl/base/BUILD.bazel50
-rw-r--r--absl/container/BUILD.bazel60
-rw-r--r--absl/container/inlined_vector.h19
-rw-r--r--absl/container/internal/raw_hash_set_test.cc4
-rw-r--r--absl/copts/AbseilConfigureCopts.cmake3
-rw-r--r--absl/copts/GENERATED_AbseilCopts.cmake4
-rw-r--r--absl/copts/GENERATED_copts.bzl4
-rw-r--r--absl/copts/configure_copts.bzl6
-rw-r--r--absl/copts/copts.py45
-rw-r--r--absl/debugging/BUILD.bazel21
-rw-r--r--absl/hash/BUILD.bazel7
-rw-r--r--absl/memory/BUILD.bazel5
-rw-r--r--absl/meta/BUILD.bazel3
-rw-r--r--absl/numeric/BUILD.bazel4
-rw-r--r--absl/synchronization/BUILD.bazel23
-rw-r--r--absl/time/BUILD.bazel5
-rw-r--r--absl/time/internal/cctz/BUILD.bazel2
-rw-r--r--absl/types/BUILD.bazel31
-rw-r--r--absl/types/CMakeLists.txt6
-rw-r--r--absl/types/optional.cc24
-rw-r--r--absl/types/optional.h27
-rw-r--r--absl/types/optional_test.cc8
-rw-r--r--absl/types/span.h97
-rw-r--r--absl/utility/BUILD.bazel3
-rwxr-xr-xci/cmake_install_test.sh2
-rwxr-xr-xci/linux_clang-latest_libcxx_bazel.sh20
-rwxr-xr-xci/linux_clang-latest_libstdcxx_bazel.sh20
-rwxr-xr-xci/linux_gcc-latest_libstdcxx_bazel.sh20
33 files changed, 494 insertions, 234 deletions
diff --git a/CMake/AbseilHelpers.cmake b/CMake/AbseilHelpers.cmake
index 6d26169d..be9a0e9c 100644
--- a/CMake/AbseilHelpers.cmake
+++ b/CMake/AbseilHelpers.cmake
@@ -16,7 +16,7 @@
include(CMakeParseArguments)
include(AbseilConfigureCopts)
-include(GNUInstallDirs)
+include(AbseilInstallDirs)
# The IDE folder for Abseil that will be used if Abseil is included in a CMake
# project that sets
@@ -105,13 +105,15 @@ function(absl_cc_library)
target_include_directories(${_NAME}
PUBLIC
$<BUILD_INTERFACE:${ABSL_COMMON_INCLUDE_DIRS}>
- $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+ $<INSTALL_INTERFACE:${ABSL_INSTALL_INCLUDEDIR}>
)
target_compile_options(${_NAME}
PRIVATE ${ABSL_CC_LIB_COPTS})
target_link_libraries(${_NAME}
PUBLIC ${ABSL_CC_LIB_DEPS}
- PRIVATE ${ABSL_CC_LIB_LINKOPTS}
+ PRIVATE
+ ${ABSL_CC_LIB_LINKOPTS}
+ ${ABSL_DEFAULT_LINKOPTS}
)
target_compile_definitions(${_NAME} PUBLIC ${ABSL_CC_LIB_DEFINES})
@@ -140,10 +142,13 @@ function(absl_cc_library)
target_include_directories(${_NAME}
INTERFACE
$<BUILD_INTERFACE:${ABSL_COMMON_INCLUDE_DIRS}>
- $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+ $<INSTALL_INTERFACE:${ABSL_INSTALL_INCLUDEDIR}>
)
target_link_libraries(${_NAME}
- INTERFACE ${ABSL_CC_LIB_DEPS} ${ABSL_CC_LIB_LINKOPTS}
+ INTERFACE
+ ${ABSL_CC_LIB_DEPS}
+ ${ABSL_CC_LIB_LINKOPTS}
+ ${ABSL_DEFAULT_LINKOPTS}
)
target_compile_definitions(${_NAME} INTERFACE ${ABSL_CC_LIB_DEFINES})
endif()
@@ -152,9 +157,9 @@ function(absl_cc_library)
# installed abseil can't be tested.
if (NOT ABSL_CC_LIB_TESTONLY)
install(TARGETS ${_NAME} EXPORT ${PROJECT_NAME}Targets
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${ABSL_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${ABSL_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${ABSL_INSTALL_LIBDIR}
)
endif()
diff --git a/CMake/AbseilInstallDirs.cmake b/CMake/AbseilInstallDirs.cmake
new file mode 100644
index 00000000..5b67008b
--- /dev/null
+++ b/CMake/AbseilInstallDirs.cmake
@@ -0,0 +1,20 @@
+include(GNUInstallDirs)
+
+# absl_VERSION is only set if we are an LTS release being installed, in which
+# case it may be into a system directory and so we need to make subdirectories
+# for each installed version of Abseil. This mechanism is implemented in
+# Abseil's internal Copybara (https://github.com/google/copybara) workflows and
+# isn't visible in the CMake buildsystem itself.
+
+if (absl_VERSION)
+ set(ABSL_SUBDIR "${PROJECT_NAME}_${PROJECT_VERSION}")
+ set(ABSL_INSTALL_BINDIR "${CMAKE_INSTALL_BINDIR}/${ABSL_SUBDIR}")
+ set(ABSL_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${ABSL_SUBDIR}")
+ set(ABSL_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/{ABSL_SUBDIR}")
+ set(ABSL_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${ABSL_SUBDIR}")
+else()
+ set(ABSL_INSTALL_BINDIR "${CMAKE_INSTALL_BINDIR}")
+ set(ABSL_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
+ set(ABSL_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
+ set(ABSL_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
+endif() \ No newline at end of file
diff --git a/CMake/install_test_project/test.sh b/CMake/install_test_project/test.sh
index 3e77e79a..99989b03 100755
--- a/CMake/install_test_project/test.sh
+++ b/CMake/install_test_project/test.sh
@@ -24,15 +24,6 @@
# Fail on any error. Treat unset variables an error. Print commands as executed.
set -euox pipefail
-absl_dir=/abseil-cpp
-absl_build_dir=/buildfs/absl-build
-project_dir="${absl_dir}"/CMake/install_test_project
-project_build_dir=/buildfs/project-build
-install_dir="${project_build_dir}"/install
-
-mkdir -p "${absl_build_dir}"
-mkdir -p "${project_build_dir}"
-mkdir -p "${install_dir}"
install_absl() {
pushd "${absl_build_dir}"
@@ -51,10 +42,41 @@ uninstall_absl() {
mkdir -p "${absl_build_dir}"
}
+lts_install=""
+
+while getopts ":l" lts; do
+ case "${lts}" in
+ l )
+ lts_install="true"
+ ;;
+ esac
+done
+
+absl_dir=/abseil-cpp
+absl_build_dir=/buildfs/absl-build
+project_dir="${absl_dir}"/CMake/install_test_project
+project_build_dir=/buildfs/project-build
+
+mkdir -p "${absl_build_dir}"
+mkdir -p "${project_build_dir}"
+
+if [[ "${lts_install}" ]]; then
+ install_dir="/usr/local"
+else
+ install_dir="${project_build_dir}"/install
+fi
+mkdir -p "${install_dir}"
+
# Test build, install, and link against installed abseil
-install_absl "${install_dir}"
pushd "${project_build_dir}"
-cmake "${project_dir}" -DCMAKE_PREFIX_PATH="${install_dir}"
+if [[ "${lts_install}" ]]; then
+ install_absl
+ cmake "${project_dir}"
+else
+ install_absl "${install_dir}"
+ cmake "${project_dir}" -DCMAKE_PREFIX_PATH="${install_dir}"
+fi
+
cmake --build . --target simple
output="$(${project_build_dir}/simple "printme" 2>&1)"
@@ -64,14 +86,16 @@ if [[ "${output}" != *"Arg 1: printme"* ]]; then
exit 1
fi
+popd
+
# Test that we haven't accidentally made absl::abslblah
pushd "${install_dir}"
# Starting in CMake 3.12 the default install dir is lib$bit_width
-if [[ -d lib ]]; then
- libdir="lib"
-elif [[ -d lib64 ]]; then
+if [[ -d lib64 ]]; then
libdir="lib64"
+elif [[ -d lib ]]; then
+ libdir="lib"
else
echo "ls *, */*, */*/*:"
ls *
@@ -80,7 +104,15 @@ else
echo "unknown lib dir"
fi
-if ! grep absl::strings "${libdir}"/cmake/absl/abslTargets.cmake; then
+if [[ "${lts_install}" ]]; then
+ # LTS versions append the date of the release to the subdir.
+ # 9999/99/99 is the dummy date used in the local_lts workflow.
+ absl_subdir="absl_99999999"
+else
+ absl_subdir="absl"
+fi
+
+if ! grep absl::strings "${libdir}/cmake/${absl_subdir}/abslTargets.cmake"; then
cat "${libdir}"/cmake/absl/abslTargets.cmake
echo "CMake targets named incorrectly"
exit 1
@@ -89,22 +121,24 @@ fi
uninstall_absl
popd
-# Test that we warn if installed without a prefix or a system prefix
-output="$(install_absl 2>&1)"
-if [[ "${output}" != *"Please set CMAKE_INSTALL_PREFIX"* ]]; then
- echo "Install without prefix didn't warn as expected. Output:"
- echo "${output}"
- exit 1
-fi
-uninstall_absl
+if [[ ! "${lts_install}" ]]; then
+ # Test that we warn if installed without a prefix or a system prefix
+ output="$(install_absl 2>&1)"
+ if [[ "${output}" != *"Please set CMAKE_INSTALL_PREFIX"* ]]; then
+ echo "Install without prefix didn't warn as expected. Output:"
+ echo "${output}"
+ exit 1
+ fi
+ uninstall_absl
-output="$(install_absl /usr 2>&1)"
-if [[ "${output}" != *"Please set CMAKE_INSTALL_PREFIX"* ]]; then
- echo "Install with /usr didn't warn as expected. Output:"
- echo "${output}"
- exit 1
+ output="$(install_absl /usr 2>&1)"
+ if [[ "${output}" != *"Please set CMAKE_INSTALL_PREFIX"* ]]; then
+ echo "Install with /usr didn't warn as expected. Output:"
+ echo "${output}"
+ exit 1
+ fi
+ uninstall_absl
fi
-uninstall_absl
echo "Install test complete!"
exit 0
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3f4fbdcf..ad55fa47 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,13 +22,14 @@
cmake_minimum_required(VERSION 3.5)
# Compiler id for Apple Clang is now AppleClang.
-if (POLICY CMP0025)
- cmake_policy(SET CMP0025 NEW)
-endif()
+cmake_policy(SET CMP0025 NEW)
# if command can use IN_LIST
cmake_policy(SET CMP0057 NEW)
+# Project version variables are the empty std::string if version is unspecified
+cmake_policy(SET CMP0048 NEW)
+
project(absl)
# when absl is included as subproject (i.e. using add_subdirectory(abseil-cpp))
@@ -44,7 +45,7 @@ list(APPEND CMAKE_MODULE_PATH
${CMAKE_CURRENT_LIST_DIR}/absl/copts
)
-include(GNUInstallDirs)
+include(AbseilInstallDirs)
include(CMakePackageConfigHelpers)
include(AbseilHelpers)
@@ -85,6 +86,7 @@ if(${ABSL_RUN_TESTS})
enable_testing()
endif()
+# absl:lts-remove-begin(system installation is supported for LTS releases)
# We don't support system-wide installation
list(APPEND SYSTEM_INSTALL_DIRS "/usr/local" "/usr" "/opt/" "/opt/local" "c:/Program Files/${PROJECT_NAME}")
if(NOT DEFINED CMAKE_INSTALL_PREFIX OR CMAKE_INSTALL_PREFIX IN_LIST SYSTEM_INSTALL_DIRS)
@@ -94,6 +96,7 @@ releases of Abseil. Please set CMAKE_INSTALL_PREFIX to install Abseil in your \
source or build tree directly.\
")
endif()
+# absl:lts-remove-end
## check targets
if(BUILD_TESTING)
@@ -118,25 +121,40 @@ endif()
add_subdirectory(absl)
-# install as a subdirectory only
-install(EXPORT ${PROJECT_NAME}Targets
- NAMESPACE absl::
- DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
-)
-
-configure_package_config_file(
- CMake/abslConfig.cmake.in
- "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
- INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
-)
+if (ABSL_ENABLE_INSTALL)
+ # install as a subdirectory only
+ install(EXPORT ${PROJECT_NAME}Targets
+ NAMESPACE absl::
+ DESTINATION "${ABSL_INSTALL_CONFIGDIR}"
+ )
-install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
- DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
-)
+ configure_package_config_file(
+ CMake/abslConfig.cmake.in
+ "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
+ INSTALL_DESTINATION "${ABSL_INSTALL_CONFIGDIR}"
+ )
+ install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
+ DESTINATION "${ABSL_INSTALL_CONFIGDIR}"
+ )
-install(DIRECTORY absl
- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
- FILES_MATCHING
- PATTERN "*.inc"
- PATTERN "*.h"
-)
+ # Abseil only has a version in LTS releases. This mechanism is accomplished
+ # Abseil's internal Copybara (https://github.com/google/copybara) workflows and
+ # isn't visible in the CMake buildsystem itself.
+ if (absl_VERSION)
+ write_basic_package_version_file(
+ "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
+ COMPATIBILITY ExactVersion
+ )
+
+ install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
+ DESTINATION ${ABSL_INSTALL_CONFIGDIR}
+ )
+ endif() # absl_VERSION
+
+ install(DIRECTORY absl
+ DESTINATION ${ABSL_INSTALL_INCLUDEDIR}
+ FILES_MATCHING
+ PATTERN "*.inc"
+ PATTERN "*.h"
+ )
+endif() # ABSL_ENABLE_INSTALL
diff --git a/absl/algorithm/BUILD.bazel b/absl/algorithm/BUILD.bazel
index 8d266db5..c506f3b9 100644
--- a/absl/algorithm/BUILD.bazel
+++ b/absl/algorithm/BUILD.bazel
@@ -17,6 +17,7 @@
load(
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
+ "ABSL_DEFAULT_LINKOPTS",
"ABSL_TEST_COPTS",
)
@@ -28,6 +29,7 @@ cc_library(
name = "algorithm",
hdrs = ["algorithm.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
)
cc_test(
@@ -35,6 +37,7 @@ cc_test(
size = "small",
srcs = ["algorithm_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":algorithm",
"@com_google_googletest//:gtest_main",
@@ -45,6 +48,7 @@ cc_test(
name = "algorithm_benchmark",
srcs = ["equal_benchmark.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
tags = ["benchmark"],
deps = [
":algorithm",
@@ -59,6 +63,7 @@ cc_library(
"container.h",
],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":algorithm",
"//absl/base:core_headers",
@@ -70,6 +75,7 @@ cc_test(
name = "container_test",
srcs = ["container_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":container",
"//absl/base",
diff --git a/absl/base/BUILD.bazel b/absl/base/BUILD.bazel
index 804f62a0..8133a462 100644
--- a/absl/base/BUILD.bazel
+++ b/absl/base/BUILD.bazel
@@ -17,6 +17,7 @@
load(
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
+ "ABSL_DEFAULT_LINKOPTS",
"ABSL_TEST_COPTS",
"ABSL_EXCEPTIONS_FLAG",
"ABSL_EXCEPTIONS_FLAG_LINKOPTS",
@@ -40,6 +41,7 @@ cc_library(
"internal/spinlock_wait.h",
],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = [
"//absl/base:__pkg__",
],
@@ -53,6 +55,7 @@ cc_library(
"policy_checks.h",
],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
)
cc_library(
@@ -61,6 +64,7 @@ cc_library(
hdrs = ["dynamic_annotations.h"],
copts = ABSL_DEFAULT_COPTS,
defines = ["__CLANG_SUPPORT_DYN_ANNOTATION__"],
+ linkopts = ABSL_DEFAULT_LINKOPTS,
)
cc_library(
@@ -74,6 +78,7 @@ cc_library(
"thread_annotations.h",
],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":config",
],
@@ -92,7 +97,7 @@ cc_library(
linkopts = select({
"//absl:windows": [],
"//conditions:default": ["-pthread"],
- }),
+ }) + ABSL_DEFAULT_LINKOPTS,
visibility = [
"//absl:__subpackages__",
],
@@ -115,6 +120,7 @@ cc_library(
"internal/scheduling_mode.h",
],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = [
"//absl:__subpackages__",
],
@@ -149,7 +155,7 @@ cc_library(
linkopts = select({
"//absl:windows": [],
"//conditions:default": ["-pthread"],
- }),
+ }) + ABSL_DEFAULT_LINKOPTS,
deps = [
":base_internal",
":config",
@@ -164,6 +170,7 @@ cc_test(
size = "small",
srcs = ["internal/atomic_hook_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":base",
":core_headers",
@@ -178,6 +185,7 @@ cc_test(
"bit_cast_test.cc",
],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":base",
":core_headers",
@@ -190,7 +198,7 @@ cc_library(
srcs = ["internal/throw_delegate.cc"],
hdrs = ["internal/throw_delegate.h"],
copts = ABSL_DEFAULT_COPTS + ABSL_EXCEPTIONS_FLAG,
- linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS,
+ linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS,
visibility = [
"//absl:__subpackages__",
],
@@ -204,7 +212,7 @@ cc_test(
name = "throw_delegate_test",
srcs = ["throw_delegate_test.cc"],
copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG,
- linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS,
+ linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS,
deps = [
":throw_delegate",
"@com_google_googletest//:gtest_main",
@@ -216,6 +224,7 @@ cc_library(
testonly = 1,
hdrs = ["internal/exception_testing.h"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = [
"//absl:__subpackages__",
],
@@ -228,6 +237,7 @@ cc_library(
cc_library(
name = "pretty_function",
hdrs = ["internal/pretty_function.h"],
+ linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = ["//absl:__subpackages__"],
)
@@ -237,7 +247,7 @@ cc_library(
srcs = ["internal/exception_safety_testing.cc"],
hdrs = ["internal/exception_safety_testing.h"],
copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG,
- linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS,
+ linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS,
deps = [
":config",
":pretty_function",
@@ -253,7 +263,7 @@ cc_test(
name = "exception_safety_testing_test",
srcs = ["exception_safety_testing_test.cc"],
copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG,
- linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS,
+ linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS,
deps = [
":exception_safety_testing",
"//absl/memory",
@@ -271,6 +281,7 @@ cc_test(
"internal/inline_variable_testing.h",
],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":base_internal",
"@com_google_googletest//:gtest_main",
@@ -282,6 +293,7 @@ cc_test(
size = "small",
srcs = ["invoke_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":base_internal",
"//absl/memory",
@@ -297,6 +309,7 @@ cc_library(
testonly = 1,
srcs = ["spinlock_test_common.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":base",
":core_headers",
@@ -312,7 +325,7 @@ cc_test(
size = "medium",
srcs = ["spinlock_test_common.cc"],
copts = ABSL_TEST_COPTS,
- tags = ["no_test_wasm"],
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":base",
":core_headers",
@@ -327,6 +340,7 @@ cc_library(
testonly = 1,
srcs = ["internal/spinlock_benchmark.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = [
"//absl/base:__pkg__",
],
@@ -343,6 +357,7 @@ cc_binary(
name = "spinlock_benchmark",
testonly = 1,
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = ["//visibility:private"],
deps = [
":spinlock_benchmark_common",
@@ -356,6 +371,7 @@ cc_library(
"internal/unaligned_access.h",
],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":config",
":core_headers",
@@ -378,9 +394,7 @@ cc_test(
name = "config_test",
srcs = ["config_test.cc"],
copts = ABSL_TEST_COPTS,
- tags = [
- "no_test_wasm",
- ],
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":config",
"//absl/synchronization:thread_pool",
@@ -392,9 +406,7 @@ cc_test(
name = "call_once_test",
srcs = ["call_once_test.cc"],
copts = ABSL_TEST_COPTS,
- tags = [
- "no_test_wasm",
- ],
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":base",
":core_headers",
@@ -407,6 +419,7 @@ cc_test(
name = "raw_logging_test",
srcs = ["raw_logging_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":base",
"//absl/strings",
@@ -419,6 +432,7 @@ cc_test(
size = "small",
srcs = ["internal/sysinfo_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":base",
"//absl/synchronization",
@@ -431,6 +445,7 @@ cc_test(
size = "small",
srcs = ["internal/low_level_alloc_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
tags = ["no_test_ios_x86_64"],
deps = [":malloc_internal"],
)
@@ -440,9 +455,7 @@ cc_test(
size = "small",
srcs = ["internal/thread_identity_test.cc"],
copts = ABSL_TEST_COPTS,
- tags = [
- "no_test_wasm",
- ],
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":base",
":core_headers",
@@ -455,6 +468,7 @@ cc_test(
name = "thread_identity_benchmark",
srcs = ["internal/thread_identity_benchmark.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
tags = ["benchmark"],
visibility = ["//visibility:private"],
deps = [
@@ -467,6 +481,7 @@ cc_test(
cc_library(
name = "bits",
hdrs = ["internal/bits.h"],
+ linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = [
"//absl:__subpackages__",
],
@@ -478,6 +493,7 @@ cc_test(
size = "small",
srcs = ["internal/bits_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":bits",
"@com_google_googletest//:gtest_main",
@@ -489,6 +505,7 @@ cc_library(
testonly = 1,
srcs = ["internal/scoped_set_env.cc"],
hdrs = ["internal/scoped_set_env.h"],
+ linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = [
"//absl:__subpackages__",
],
@@ -500,6 +517,7 @@ cc_test(
size = "small",
srcs = ["internal/scoped_set_env_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":scoped_set_env",
"@com_google_googletest//:gtest_main",
diff --git a/absl/container/BUILD.bazel b/absl/container/BUILD.bazel
index cd914baf..066a9886 100644
--- a/absl/container/BUILD.bazel
+++ b/absl/container/BUILD.bazel
@@ -17,6 +17,7 @@
load(
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
+ "ABSL_DEFAULT_LINKOPTS",
"ABSL_EXCEPTIONS_FLAG",
"ABSL_EXCEPTIONS_FLAG_LINKOPTS",
"ABSL_TEST_COPTS",
@@ -30,6 +31,7 @@ cc_library(
name = "compressed_tuple",
hdrs = ["internal/compressed_tuple.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/utility",
],
@@ -39,6 +41,7 @@ cc_test(
name = "compressed_tuple_test",
srcs = ["internal/compressed_tuple_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":compressed_tuple",
"//absl/memory",
@@ -51,6 +54,7 @@ cc_library(
name = "fixed_array",
hdrs = ["fixed_array.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":compressed_tuple",
"//absl/algorithm",
@@ -65,7 +69,7 @@ cc_test(
name = "fixed_array_test",
srcs = ["fixed_array_test.cc"],
copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG,
- linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS,
+ linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS,
deps = [
":fixed_array",
"//absl/base:exception_testing",
@@ -79,6 +83,7 @@ cc_test(
name = "fixed_array_test_noexceptions",
srcs = ["fixed_array_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":fixed_array",
"//absl/base:exception_testing",
@@ -92,7 +97,7 @@ cc_test(
name = "fixed_array_exception_safety_test",
srcs = ["fixed_array_exception_safety_test.cc"],
copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG,
- linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS,
+ linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS,
deps = [
":fixed_array",
"//absl/base:exception_safety_testing",
@@ -104,6 +109,7 @@ cc_test(
name = "fixed_array_benchmark",
srcs = ["fixed_array_benchmark.cc"],
copts = ABSL_TEST_COPTS + ["$(STACK_FRAME_UNLIMITED)"],
+ linkopts = ABSL_DEFAULT_LINKOPTS,
tags = ["benchmark"],
deps = [
":fixed_array",
@@ -115,6 +121,7 @@ cc_library(
name = "inlined_vector_internal",
hdrs = ["internal/inlined_vector.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/meta:type_traits",
],
@@ -124,6 +131,7 @@ cc_library(
name = "inlined_vector",
hdrs = ["inlined_vector.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":inlined_vector_internal",
"//absl/algorithm",
@@ -138,6 +146,7 @@ cc_library(
testonly = 1,
hdrs = ["internal/counting_allocator.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = ["//visibility:private"],
)
@@ -145,7 +154,7 @@ cc_test(
name = "inlined_vector_test",
srcs = ["inlined_vector_test.cc"],
copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG,
- linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS,
+ linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS,
deps = [
":counting_allocator",
":inlined_vector",
@@ -164,6 +173,7 @@ cc_test(
name = "inlined_vector_test_noexceptions",
srcs = ["inlined_vector_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":counting_allocator",
":inlined_vector",
@@ -182,6 +192,7 @@ cc_test(
name = "inlined_vector_benchmark",
srcs = ["inlined_vector_benchmark.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
tags = ["benchmark"],
deps = [
":inlined_vector",
@@ -197,6 +208,7 @@ cc_library(
srcs = ["internal/test_instance_tracker.cc"],
hdrs = ["internal/test_instance_tracker.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = [
"//absl:__subpackages__",
],
@@ -206,6 +218,7 @@ cc_test(
name = "test_instance_tracker_test",
srcs = ["internal/test_instance_tracker_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":test_instance_tracker",
"@com_google_googletest//:gtest_main",
@@ -230,6 +243,7 @@ cc_library(
name = "flat_hash_map",
hdrs = ["flat_hash_map.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":container_memory",
":hash_function_defaults",
@@ -243,6 +257,7 @@ cc_test(
name = "flat_hash_map_test",
srcs = ["flat_hash_map_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
tags = NOTEST_TAGS_NONMOBILE,
deps = [
":flat_hash_map",
@@ -260,6 +275,7 @@ cc_library(
name = "flat_hash_set",
hdrs = ["flat_hash_set.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":container_memory",
":hash_function_defaults",
@@ -274,6 +290,7 @@ cc_test(
name = "flat_hash_set_test",
srcs = ["flat_hash_set_test.cc"],
copts = ABSL_TEST_COPTS + ["-DUNORDERED_SET_CXX17"],
+ linkopts = ABSL_DEFAULT_LINKOPTS,
tags = NOTEST_TAGS_NONMOBILE,
deps = [
":flat_hash_set",
@@ -292,6 +309,7 @@ cc_library(
name = "node_hash_map",
hdrs = ["node_hash_map.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":container_memory",
":hash_function_defaults",
@@ -306,6 +324,7 @@ cc_test(
name = "node_hash_map_test",
srcs = ["node_hash_map_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
tags = NOTEST_TAGS_NONMOBILE,
deps = [
":hash_generator_testing",
@@ -323,6 +342,7 @@ cc_library(
name = "node_hash_set",
hdrs = ["node_hash_set.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":hash_function_defaults",
":node_hash_policy",
@@ -336,6 +356,7 @@ cc_test(
name = "node_hash_set_test",
srcs = ["node_hash_set_test.cc"],
copts = ABSL_TEST_COPTS + ["-DUNORDERED_SET_CXX17"],
+ linkopts = ABSL_DEFAULT_LINKOPTS,
tags = NOTEST_TAGS_NONMOBILE,
deps = [
":node_hash_set",
@@ -351,6 +372,7 @@ cc_library(
name = "container_memory",
hdrs = ["internal/container_memory.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/memory",
"//absl/utility",
@@ -361,6 +383,7 @@ cc_test(
name = "container_memory_test",
srcs = ["internal/container_memory_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
tags = NOTEST_TAGS_NONMOBILE,
deps = [
":container_memory",
@@ -373,6 +396,7 @@ cc_library(
name = "hash_function_defaults",
hdrs = ["internal/hash_function_defaults.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/base:config",
"//absl/hash",
@@ -384,6 +408,7 @@ cc_test(
name = "hash_function_defaults_test",
srcs = ["internal/hash_function_defaults_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
tags = NOTEST_TAGS,
deps = [
":hash_function_defaults",
@@ -399,6 +424,7 @@ cc_library(
srcs = ["internal/hash_generator_testing.cc"],
hdrs = ["internal/hash_generator_testing.h"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":hash_policy_testing",
"//absl/meta:type_traits",
@@ -411,6 +437,7 @@ cc_library(
testonly = 1,
hdrs = ["internal/hash_policy_testing.h"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/hash",
"//absl/strings",
@@ -421,6 +448,7 @@ cc_test(
name = "hash_policy_testing_test",
srcs = ["internal/hash_policy_testing_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":hash_policy_testing",
"@com_google_googletest//:gtest_main",
@@ -431,6 +459,7 @@ cc_library(
name = "hash_policy_traits",
hdrs = ["internal/hash_policy_traits.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = ["//absl/meta:type_traits"],
)
@@ -438,6 +467,7 @@ cc_test(
name = "hash_policy_traits_test",
srcs = ["internal/hash_policy_traits_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":hash_policy_traits",
"@com_google_googletest//:gtest_main",
@@ -448,6 +478,7 @@ cc_library(
name = "hashtable_debug",
hdrs = ["internal/hashtable_debug.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":hashtable_debug_hooks",
],
@@ -457,6 +488,7 @@ cc_library(
name = "hashtable_debug_hooks",
hdrs = ["internal/hashtable_debug_hooks.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
)
cc_library(
@@ -467,6 +499,7 @@ cc_library(
],
hdrs = ["internal/hashtablez_sampler.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":have_sse",
"//absl/base",
@@ -481,6 +514,7 @@ cc_library(
cc_test(
name = "hashtablez_sampler_test",
srcs = ["internal/hashtablez_sampler_test.cc"],
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":hashtablez_sampler",
":have_sse",
@@ -496,12 +530,14 @@ cc_library(
name = "node_hash_policy",
hdrs = ["internal/node_hash_policy.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
)
cc_test(
name = "node_hash_policy_test",
srcs = ["internal/node_hash_policy_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":hash_policy_traits",
":node_hash_policy",
@@ -513,6 +549,7 @@ cc_library(
name = "raw_hash_map",
hdrs = ["internal/raw_hash_map.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":container_memory",
":raw_hash_set",
@@ -523,6 +560,7 @@ cc_library(
name = "have_sse",
hdrs = ["internal/have_sse.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = ["//visibility:private"],
)
@@ -530,6 +568,7 @@ cc_library(
name = "common",
hdrs = ["internal/common.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/meta:type_traits",
"//absl/types:optional",
@@ -541,6 +580,7 @@ cc_library(
srcs = ["internal/raw_hash_set.cc"],
hdrs = ["internal/raw_hash_set.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":common",
":compressed_tuple",
@@ -584,6 +624,7 @@ cc_test(
size = "small",
srcs = ["internal/raw_hash_set_allocator_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":raw_hash_set",
":tracked",
@@ -596,6 +637,7 @@ cc_library(
name = "layout",
hdrs = ["internal/layout.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/base:core_headers",
"//absl/meta:type_traits",
@@ -610,6 +652,7 @@ cc_test(
size = "small",
srcs = ["internal/layout_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
tags = NOTEST_TAGS,
visibility = ["//visibility:private"],
deps = [
@@ -626,6 +669,7 @@ cc_library(
testonly = 1,
hdrs = ["internal/tracked.h"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
)
cc_library(
@@ -633,6 +677,7 @@ cc_library(
testonly = 1,
hdrs = ["internal/unordered_map_constructor_test.h"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":hash_generator_testing",
":hash_policy_testing",
@@ -645,6 +690,7 @@ cc_library(
testonly = 1,
hdrs = ["internal/unordered_map_lookup_test.h"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":hash_generator_testing",
":hash_policy_testing",
@@ -657,6 +703,7 @@ cc_library(
testonly = 1,
hdrs = ["internal/unordered_map_modifiers_test.h"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":hash_generator_testing",
":hash_policy_testing",
@@ -669,6 +716,7 @@ cc_library(
testonly = 1,
hdrs = ["internal/unordered_set_constructor_test.h"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":hash_generator_testing",
":hash_policy_testing",
@@ -682,6 +730,7 @@ cc_library(
testonly = 1,
hdrs = ["internal/unordered_set_members_test.h"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/meta:type_traits",
"@com_google_googletest//:gtest",
@@ -693,6 +742,7 @@ cc_library(
testonly = 1,
hdrs = ["internal/unordered_map_members_test.h"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/meta:type_traits",
"@com_google_googletest//:gtest",
@@ -704,6 +754,7 @@ cc_library(
testonly = 1,
hdrs = ["internal/unordered_set_lookup_test.h"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":hash_generator_testing",
":hash_policy_testing",
@@ -716,6 +767,7 @@ cc_library(
testonly = 1,
hdrs = ["internal/unordered_set_modifiers_test.h"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":hash_generator_testing",
":hash_policy_testing",
@@ -727,6 +779,7 @@ cc_test(
name = "unordered_set_test",
srcs = ["internal/unordered_set_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
tags = NOTEST_TAGS_NONMOBILE,
deps = [
":unordered_set_constructor_test",
@@ -741,6 +794,7 @@ cc_test(
name = "unordered_map_test",
srcs = ["internal/unordered_map_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
tags = NOTEST_TAGS_NONMOBILE,
deps = [
":unordered_map_constructor_test",
diff --git a/absl/container/inlined_vector.h b/absl/container/inlined_vector.h
index 77988058..bd4ed666 100644
--- a/absl/container/inlined_vector.h
+++ b/absl/container/inlined_vector.h
@@ -454,7 +454,7 @@ class InlinedVector {
// Overload of `InlinedVector::operator=()` to replace the contents of the
// inlined vector with the contents of `other`.
InlinedVector& operator=(const InlinedVector& other) {
- if (ABSL_PREDICT_FALSE(this == &other)) return *this;
+ if (ABSL_PREDICT_FALSE(this == std::addressof(other))) return *this;
// Optimized to avoid reallocation.
// Prefer reassignment to copy construction for elements.
@@ -475,7 +475,7 @@ class InlinedVector {
// NOTE: As a result of calling this overload, `other` may be empty or it's
// contents may be left in a moved-from state.
InlinedVector& operator=(InlinedVector&& other) {
- if (ABSL_PREDICT_FALSE(this == &other)) return *this;
+ if (ABSL_PREDICT_FALSE(this == std::addressof(other))) return *this;
if (other.allocated()) {
clear();
@@ -840,7 +840,7 @@ class InlinedVector {
//
// Swaps the contents of this inlined vector with the contents of `other`.
void swap(InlinedVector& other) {
- if (ABSL_PREDICT_FALSE(this == &other)) return;
+ if (ABSL_PREDICT_FALSE(this == std::addressof(other))) return;
SwapImpl(other);
}
@@ -864,7 +864,8 @@ class InlinedVector {
}
void init_allocation(const Allocation& allocation) {
- new (&storage_.rep_.allocation_storage.allocation) Allocation(allocation);
+ new (static_cast<void*>(std::addressof(
+ storage_.rep_.allocation_storage.allocation))) Allocation(allocation);
}
// TODO(absl-team): investigate whether the reinterpret_cast is appropriate.
@@ -1154,7 +1155,7 @@ class InlinedVector {
if (!allocated() && !other.allocated()) {
// Both inlined: swap up to smaller size, then move remaining elements.
InlinedVector* a = this;
- InlinedVector* b = &other;
+ InlinedVector* b = std::addressof(other);
if (size() < other.size()) {
swap(a, b);
}
@@ -1186,7 +1187,7 @@ class InlinedVector {
// pointer/capacity into the originally inlined vector and swap
// the tags.
InlinedVector* a = this;
- InlinedVector* b = &other;
+ InlinedVector* b = std::addressof(other);
if (a->allocated()) {
swap(a, b);
}
@@ -1305,10 +1306,4 @@ auto AbslHashValue(H h, const InlinedVector<TheT, TheN, TheA>& v) -> H {
}
} // namespace absl
-// -----------------------------------------------------------------------------
-// Implementation of InlinedVector
-//
-// Do not depend on any below implementation details!
-// -----------------------------------------------------------------------------
-
#endif // ABSL_CONTAINER_INLINED_VECTOR_H_
diff --git a/absl/container/internal/raw_hash_set_test.cc b/absl/container/internal/raw_hash_set_test.cc
index 02fd0bfa..4d94f785 100644
--- a/absl/container/internal/raw_hash_set_test.cc
+++ b/absl/container/internal/raw_hash_set_test.cc
@@ -1785,7 +1785,7 @@ TEST(Table, IterationOrderChangesByInstance) {
std::vector<IntTable> tables;
bool found_difference = false;
- for (int i = 0; !found_difference && i < 500; ++i) {
+ for (int i = 0; !found_difference && i < 5000; ++i) {
tables.push_back(MakeSimpleTable(size));
found_difference = OrderOfIteration(tables.back()) != reference;
}
@@ -1799,7 +1799,7 @@ TEST(Table, IterationOrderChangesByInstance) {
TEST(Table, IterationOrderChangesOnRehash) {
std::vector<IntTable> garbage;
- for (int i = 0; i < 500; ++i) {
+ for (int i = 0; i < 5000; ++i) {
auto t = MakeSimpleTable(20);
const auto reference = OrderOfIteration(t);
// Force rehash to the same size.
diff --git a/absl/copts/AbseilConfigureCopts.cmake b/absl/copts/AbseilConfigureCopts.cmake
index 5084958c..b2b3f88d 100644
--- a/absl/copts/AbseilConfigureCopts.cmake
+++ b/absl/copts/AbseilConfigureCopts.cmake
@@ -3,6 +3,7 @@ include(GENERATED_AbseilCopts)
set(ABSL_LSAN_LINKOPTS "")
set(ABSL_HAVE_LSAN OFF)
+set(ABSL_DEFAULT_LINKOPTS "")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(ABSL_DEFAULT_COPTS "${ABSL_GCC_FLAGS}")
@@ -19,6 +20,7 @@ elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(ABSL_DEFAULT_COPTS "${ABSL_LLVM_FLAGS}")
set(ABSL_TEST_COPTS "${ABSL_LLVM_FLAGS};${ABSL_LLVM_TEST_FLAGS}")
set(ABSL_EXCEPTIONS_FLAG "${ABSL_LLVM_EXCEPTIONS_FLAGS}")
+ set(ABSL_DEFAULT_LINKOPTS "${ABSL_MSVC_LINKOPTS}")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# AppleClang doesn't have lsan
# https://developer.apple.com/documentation/code_diagnostics
@@ -32,6 +34,7 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(ABSL_DEFAULT_COPTS "${ABSL_MSVC_FLAGS}")
set(ABSL_TEST_COPTS "${ABSL_MSVC_FLAGS};${ABSL_MSVC_TEST_FLAGS}")
set(ABSL_EXCEPTIONS_FLAG "${ABSL_MSVC_EXCEPTIONS_FLAGS}")
+ set(ABSL_DEFAULT_LINKOPTS "${ABSL_MSVC_LINKOPTS}")
else()
message(WARNING "Unknown compiler: ${CMAKE_CXX_COMPILER}. Building with no default flags")
set(ABSL_DEFAULT_COPTS "")
diff --git a/absl/copts/GENERATED_AbseilCopts.cmake b/absl/copts/GENERATED_AbseilCopts.cmake
index 9031bfa5..043c88a2 100644
--- a/absl/copts/GENERATED_AbseilCopts.cmake
+++ b/absl/copts/GENERATED_AbseilCopts.cmake
@@ -201,6 +201,10 @@ list(APPEND ABSL_MSVC_FLAGS
"/wd4800"
)
+list(APPEND ABSL_MSVC_LINKOPTS
+ "-ignore:4221"
+)
+
list(APPEND ABSL_MSVC_TEST_FLAGS
"/wd4018"
"/wd4101"
diff --git a/absl/copts/GENERATED_copts.bzl b/absl/copts/GENERATED_copts.bzl
index e05a58e3..d40380b8 100644
--- a/absl/copts/GENERATED_copts.bzl
+++ b/absl/copts/GENERATED_copts.bzl
@@ -202,6 +202,10 @@ ABSL_MSVC_FLAGS = [
"/wd4800",
]
+ABSL_MSVC_LINKOPTS = [
+ "-ignore:4221",
+]
+
ABSL_MSVC_TEST_FLAGS = [
"/wd4018",
"/wd4101",
diff --git a/absl/copts/configure_copts.bzl b/absl/copts/configure_copts.bzl
index 1655addd..00159317 100644
--- a/absl/copts/configure_copts.bzl
+++ b/absl/copts/configure_copts.bzl
@@ -14,6 +14,7 @@ load(
"ABSL_LLVM_TEST_FLAGS",
"ABSL_MSVC_EXCEPTIONS_FLAGS",
"ABSL_MSVC_FLAGS",
+ "ABSL_MSVC_LINKOPTS",
"ABSL_MSVC_TEST_FLAGS",
)
@@ -40,3 +41,8 @@ ABSL_EXCEPTIONS_FLAG = select({
ABSL_EXCEPTIONS_FLAG_LINKOPTS = select({
"//conditions:default": [],
})
+
+ABSL_DEFAULT_LINKOPTS = select({
+ "//absl:windows": ABSL_MSVC_LINKOPTS,
+ "//conditions:default": [],
+})
diff --git a/absl/copts/copts.py b/absl/copts/copts.py
index 3c9d4294..608d7c0e 100644
--- a/absl/copts/copts.py
+++ b/absl/copts/copts.py
@@ -153,26 +153,39 @@ COPT_VARS = {
"-Wno-unused-private-field",
],
"ABSL_GCC_EXCEPTIONS_FLAGS": ["-fexceptions"],
- "ABSL_LLVM_FLAGS": LLVM_BIG_WARNING_FLAGS + LLVM_DISABLE_WARNINGS_FLAGS,
- "ABSL_LLVM_TEST_FLAGS": LLVM_TEST_DISABLE_WARNINGS_FLAGS,
+ "ABSL_LLVM_FLAGS":
+ LLVM_BIG_WARNING_FLAGS + LLVM_DISABLE_WARNINGS_FLAGS,
+ "ABSL_LLVM_TEST_FLAGS":
+ LLVM_TEST_DISABLE_WARNINGS_FLAGS,
"ABSL_LLVM_EXCEPTIONS_FLAGS": ["-fexceptions"],
- "ABSL_CLANG_CL_FLAGS": (MSVC_BIG_WARNING_FLAGS +
- LLVM_DISABLE_WARNINGS_FLAGS + MSVC_DEFINES),
- "ABSL_CLANG_CL_TEST_FLAGS": LLVM_TEST_DISABLE_WARNINGS_FLAGS,
- "ABSL_CLANG_CL_EXCEPTIONS_FLAGS": MSVC_STYLE_EXCEPTIONS_FLAGS,
- "ABSL_MSVC_FLAGS": MSVC_BIG_WARNING_FLAGS + MSVC_DEFINES + [
- "/wd4005", # macro-redefinition
- "/wd4068", # unknown pragma
- "/wd4180", # qualifier applied to function type has no meaning; ignored
- "/wd4244", # conversion from 'type1' to 'type2', possible loss of data
- "/wd4267", # conversion from 'size_t' to 'type', possible loss of data
- # forcing value to bool 'true' or 'false' (performance warning)
- "/wd4800",
- ],
+ "ABSL_CLANG_CL_FLAGS": (
+ MSVC_BIG_WARNING_FLAGS + LLVM_DISABLE_WARNINGS_FLAGS + MSVC_DEFINES),
+ "ABSL_CLANG_CL_TEST_FLAGS":
+ LLVM_TEST_DISABLE_WARNINGS_FLAGS,
+ "ABSL_CLANG_CL_EXCEPTIONS_FLAGS":
+ MSVC_STYLE_EXCEPTIONS_FLAGS,
+ "ABSL_MSVC_FLAGS":
+ MSVC_BIG_WARNING_FLAGS + MSVC_DEFINES + [
+ "/wd4005", # macro-redefinition
+ "/wd4068", # unknown pragma
+ # qualifier applied to function type has no meaning; ignored
+ "/wd4180",
+ # conversion from 'type1' to 'type2', possible loss of data
+ "/wd4244",
+ # conversion from 'size_t' to 'type', possible loss of data
+ "/wd4267",
+ # forcing value to bool 'true' or 'false' (performance warning)
+ "/wd4800",
+ ],
"ABSL_MSVC_TEST_FLAGS": [
"/wd4018", # signed/unsigned mismatch
"/wd4101", # unreferenced local variable
"/wd4503", # decorated name length exceeded, name was truncated
],
- "ABSL_MSVC_EXCEPTIONS_FLAGS": MSVC_STYLE_EXCEPTIONS_FLAGS,
+ "ABSL_MSVC_EXCEPTIONS_FLAGS":
+ MSVC_STYLE_EXCEPTIONS_FLAGS,
+ "ABSL_MSVC_LINKOPTS": [
+ # Object file doesn't export any previously undefined symbols
+ "/ignore:4221",
+ ],
}
diff --git a/absl/debugging/BUILD.bazel b/absl/debugging/BUILD.bazel
index c9184f92..0854314e 100644
--- a/absl/debugging/BUILD.bazel
+++ b/absl/debugging/BUILD.bazel
@@ -17,6 +17,7 @@
load(
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
+ "ABSL_DEFAULT_LINKOPTS",
"ABSL_TEST_COPTS",
)
@@ -33,6 +34,7 @@ cc_library(
],
hdrs = ["stacktrace.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":debugging_internal",
"//absl/base",
@@ -53,6 +55,7 @@ cc_library(
"symbolize.h",
],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":debugging_internal",
":demangle_internal",
@@ -66,6 +69,7 @@ cc_test(
name = "symbolize_test",
srcs = ["symbolize_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":stack_consumption",
":symbolize",
@@ -85,6 +89,7 @@ cc_library(
"internal/examine_stack.h",
],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = ["//visibility:private"],
deps = [
":stacktrace",
@@ -99,6 +104,7 @@ cc_library(
srcs = ["failure_signal_handler.cc"],
hdrs = ["failure_signal_handler.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":examine_stack",
":stacktrace",
@@ -115,7 +121,7 @@ cc_test(
linkopts = select({
"//absl:windows": [],
"//conditions:default": ["-pthread"],
- }),
+ }) + ABSL_DEFAULT_LINKOPTS,
deps = [
":failure_signal_handler",
":stacktrace",
@@ -147,6 +153,7 @@ cc_library(
"internal/vdso_support.h",
],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/base",
"//absl/base:core_headers",
@@ -169,6 +176,7 @@ cc_test(
name = "demangle_test",
srcs = ["internal/demangle_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":demangle_internal",
":stack_consumption",
@@ -183,6 +191,7 @@ cc_library(
name = "leak_check",
srcs = ["leak_check.cc"],
hdrs = ["leak_check.h"],
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = ["//absl/base:core_headers"],
)
@@ -192,6 +201,7 @@ cc_library(
cc_library(
name = "leak_check_disable",
srcs = ["leak_check_disable.cc"],
+ linkopts = ABSL_DEFAULT_LINKOPTS,
linkstatic = 1,
alwayslink = 1,
)
@@ -212,6 +222,7 @@ cc_library(
"//absl:llvm_compiler": ["-DLEAK_SANITIZER"],
"//conditions:default": [],
}),
+ linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = ["//visibility:private"],
)
@@ -221,6 +232,7 @@ cc_library(
srcs = ["leak_check.cc"],
hdrs = ["leak_check.h"],
copts = ["-ULEAK_SANITIZER"],
+ linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = ["//visibility:private"],
)
@@ -231,7 +243,7 @@ cc_test(
"//absl:llvm_compiler": ["-DABSL_EXPECT_LEAK_SANITIZER"],
"//conditions:default": [],
}),
- linkopts = ABSL_LSAN_LINKOPTS,
+ linkopts = ABSL_LSAN_LINKOPTS + ABSL_DEFAULT_LINKOPTS,
deps = [
":leak_check_api_enabled_for_testing",
"//absl/base",
@@ -243,6 +255,7 @@ cc_test(
name = "leak_check_no_lsan_test",
srcs = ["leak_check_test.cc"],
copts = ["-UABSL_EXPECT_LEAK_SANITIZER"],
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":leak_check_api_disabled_for_testing",
"//absl/base", # for raw_logging
@@ -257,7 +270,7 @@ cc_test(
cc_test(
name = "disabled_leak_check_test",
srcs = ["leak_check_fail_test.cc"],
- linkopts = ABSL_LSAN_LINKOPTS,
+ linkopts = ABSL_LSAN_LINKOPTS + ABSL_DEFAULT_LINKOPTS,
deps = [
":leak_check_api_enabled_for_testing",
":leak_check_disable",
@@ -272,6 +285,7 @@ cc_library(
srcs = ["internal/stack_consumption.cc"],
hdrs = ["internal/stack_consumption.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = ["//visibility:private"],
deps = [
"//absl/base",
@@ -283,6 +297,7 @@ cc_test(
name = "stack_consumption_test",
srcs = ["internal/stack_consumption_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":stack_consumption",
"//absl/base",
diff --git a/absl/hash/BUILD.bazel b/absl/hash/BUILD.bazel
index 69860d98..8c2daf70 100644
--- a/absl/hash/BUILD.bazel
+++ b/absl/hash/BUILD.bazel
@@ -17,6 +17,7 @@
load(
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
+ "ABSL_DEFAULT_LINKOPTS",
"ABSL_TEST_COPTS",
)
@@ -32,6 +33,7 @@ cc_library(
],
hdrs = ["hash.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":city",
"//absl/base:core_headers",
@@ -50,6 +52,7 @@ cc_library(
name = "hash_testing",
testonly = 1,
hdrs = ["hash_testing.h"],
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":spy_hash_state",
"//absl/meta:type_traits",
@@ -63,6 +66,7 @@ cc_test(
name = "hash_test",
srcs = ["hash_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":hash",
":hash_testing",
@@ -80,6 +84,7 @@ cc_library(
testonly = 1,
hdrs = ["internal/spy_hash_state.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = ["//visibility:private"],
deps = [
":hash",
@@ -95,6 +100,7 @@ cc_library(
"internal/city.h",
],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/base:config",
"//absl/base:core_headers",
@@ -106,6 +112,7 @@ cc_test(
name = "city_test",
srcs = ["internal/city_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":city",
"@com_google_googletest//:gtest_main",
diff --git a/absl/memory/BUILD.bazel b/absl/memory/BUILD.bazel
index 7c6366fe..f815ef94 100644
--- a/absl/memory/BUILD.bazel
+++ b/absl/memory/BUILD.bazel
@@ -17,6 +17,7 @@
load(
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
+ "ABSL_DEFAULT_LINKOPTS",
"ABSL_TEST_COPTS",
"ABSL_EXCEPTIONS_FLAG",
"ABSL_EXCEPTIONS_FLAG_LINKOPTS",
@@ -30,6 +31,7 @@ cc_library(
name = "memory",
hdrs = ["memory.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/base:core_headers",
"//absl/meta:type_traits",
@@ -40,6 +42,7 @@ cc_test(
name = "memory_test",
srcs = ["memory_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":memory",
"//absl/base",
@@ -54,7 +57,7 @@ cc_test(
"memory_exception_safety_test.cc",
],
copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG,
- linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS,
+ linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS,
deps = [
":memory",
"//absl/base:exception_safety_testing",
diff --git a/absl/meta/BUILD.bazel b/absl/meta/BUILD.bazel
index 1c39fa98..c2435f4f 100644
--- a/absl/meta/BUILD.bazel
+++ b/absl/meta/BUILD.bazel
@@ -1,6 +1,7 @@
load(
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
+ "ABSL_DEFAULT_LINKOPTS",
"ABSL_TEST_COPTS",
)
@@ -12,6 +13,7 @@ cc_library(
name = "type_traits",
hdrs = ["type_traits.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/base:config",
],
@@ -21,6 +23,7 @@ cc_test(
name = "type_traits_test",
srcs = ["type_traits_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":type_traits",
"//absl/base:core_headers",
diff --git a/absl/numeric/BUILD.bazel b/absl/numeric/BUILD.bazel
index 7cd7ee19..d9b561df 100644
--- a/absl/numeric/BUILD.bazel
+++ b/absl/numeric/BUILD.bazel
@@ -15,6 +15,7 @@
load(
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
+ "ABSL_DEFAULT_LINKOPTS",
"ABSL_TEST_COPTS",
)
@@ -31,6 +32,7 @@ cc_library(
],
hdrs = ["int128.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/base:config",
"//absl/base:core_headers",
@@ -45,6 +47,7 @@ cc_test(
"int128_test.cc",
],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":int128",
"//absl/base",
@@ -59,6 +62,7 @@ cc_test(
name = "int128_benchmark",
srcs = ["int128_benchmark.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
tags = ["benchmark"],
deps = [
":int128",
diff --git a/absl/synchronization/BUILD.bazel b/absl/synchronization/BUILD.bazel
index 5e69847e..67da9d46 100644
--- a/absl/synchronization/BUILD.bazel
+++ b/absl/synchronization/BUILD.bazel
@@ -17,6 +17,7 @@
load(
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
+ "ABSL_DEFAULT_LINKOPTS",
"ABSL_TEST_COPTS",
)
@@ -34,6 +35,7 @@ cc_library(
"internal/graphcycles.h",
],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = [
"//absl:__subpackages__",
],
@@ -72,7 +74,7 @@ cc_library(
linkopts = select({
"//absl:windows": [],
"//conditions:default": ["-pthread"],
- }),
+ }) + ABSL_DEFAULT_LINKOPTS,
deps = [
":graphcycles_internal",
"//absl/base",
@@ -92,9 +94,7 @@ cc_test(
size = "small",
srcs = ["barrier_test.cc"],
copts = ABSL_TEST_COPTS,
- tags = [
- "no_test_wasm",
- ],
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":synchronization",
"//absl/time",
@@ -107,9 +107,7 @@ cc_test(
size = "small",
srcs = ["blocking_counter_test.cc"],
copts = ABSL_TEST_COPTS,
- tags = [
- "no_test_wasm",
- ],
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":synchronization",
"//absl/time",
@@ -122,6 +120,7 @@ cc_test(
size = "medium",
srcs = ["internal/graphcycles_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":graphcycles_internal",
"//absl/base",
@@ -134,6 +133,7 @@ cc_test(
name = "graphcycles_benchmark",
srcs = ["internal/graphcycles_benchmark.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
tags = [
"benchmark",
],
@@ -148,6 +148,7 @@ cc_library(
name = "thread_pool",
testonly = 1,
hdrs = ["internal/thread_pool.h"],
+ linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = [
"//absl:__subpackages__",
],
@@ -162,6 +163,7 @@ cc_test(
size = "large",
srcs = ["mutex_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
shard_count = 25,
deps = [
":synchronization",
@@ -179,6 +181,7 @@ cc_library(
testonly = 1,
srcs = ["mutex_benchmark.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = [
"//absl/synchronization:__pkg__",
],
@@ -195,6 +198,7 @@ cc_binary(
name = "mutex_benchmark",
testonly = 1,
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = ["//visibility:private"],
deps = [
":mutex_benchmark_common",
@@ -206,6 +210,7 @@ cc_test(
size = "small",
srcs = ["notification_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":synchronization",
"//absl/time",
@@ -218,6 +223,7 @@ cc_library(
testonly = 1,
srcs = ["internal/per_thread_sem_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":synchronization",
"//absl/base",
@@ -232,7 +238,7 @@ cc_test(
name = "per_thread_sem_test",
size = "medium",
copts = ABSL_TEST_COPTS,
- tags = ["no_test_wasm"],
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":per_thread_sem_test_common",
":synchronization",
@@ -249,6 +255,7 @@ cc_test(
"lifetime_test.cc",
],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
tags = ["no_test_ios_x86_64"],
deps = [
":synchronization",
diff --git a/absl/time/BUILD.bazel b/absl/time/BUILD.bazel
index a94be655..55e83a8c 100644
--- a/absl/time/BUILD.bazel
+++ b/absl/time/BUILD.bazel
@@ -17,6 +17,7 @@
load(
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
+ "ABSL_DEFAULT_LINKOPTS",
"ABSL_TEST_COPTS",
)
@@ -41,6 +42,7 @@ cc_library(
"time.h",
],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/base",
"//absl/base:core_headers",
@@ -60,6 +62,7 @@ cc_library(
],
hdrs = ["internal/test_util.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
visibility = [
"//absl/time:__pkg__",
],
@@ -82,6 +85,7 @@ cc_test(
"time_zone_test.cc",
],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":test_util",
":time",
@@ -103,6 +107,7 @@ cc_test(
"time_benchmark.cc",
],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
tags = [
"benchmark",
],
diff --git a/absl/time/internal/cctz/BUILD.bazel b/absl/time/internal/cctz/BUILD.bazel
index 903499be..05f56bca 100644
--- a/absl/time/internal/cctz/BUILD.bazel
+++ b/absl/time/internal/cctz/BUILD.bazel
@@ -87,7 +87,6 @@ cc_test(
"no_test_android_arm",
"no_test_android_arm64",
"no_test_android_x86",
- "no_test_wasm",
],
deps = [
":civil_time",
@@ -106,7 +105,6 @@ cc_test(
"no_test_android_arm",
"no_test_android_arm64",
"no_test_android_x86",
- "no_test_wasm",
],
deps = [
":civil_time",
diff --git a/absl/types/BUILD.bazel b/absl/types/BUILD.bazel
index 7da00030..a62522e4 100644
--- a/absl/types/BUILD.bazel
+++ b/absl/types/BUILD.bazel
@@ -17,6 +17,7 @@
load(
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
+ "ABSL_DEFAULT_LINKOPTS",
"ABSL_TEST_COPTS",
"ABSL_EXCEPTIONS_FLAG",
"ABSL_EXCEPTIONS_FLAG_LINKOPTS",
@@ -30,6 +31,7 @@ cc_library(
name = "any",
hdrs = ["any.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":bad_any_cast",
"//absl/base:config",
@@ -43,6 +45,7 @@ cc_library(
name = "bad_any_cast",
hdrs = ["bad_any_cast.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":bad_any_cast_impl",
"//absl/base:config",
@@ -56,7 +59,7 @@ cc_library(
"bad_any_cast.h",
],
copts = ABSL_EXCEPTIONS_FLAG + ABSL_DEFAULT_COPTS,
- linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS,
+ linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS,
visibility = ["//visibility:private"],
deps = [
"//absl/base",
@@ -71,7 +74,7 @@ cc_test(
"any_test.cc",
],
copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG,
- linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS,
+ linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS,
deps = [
":any",
"//absl/base",
@@ -89,6 +92,7 @@ cc_test(
"any_test.cc",
],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":any",
"//absl/base",
@@ -103,7 +107,7 @@ cc_test(
name = "any_exception_safety_test",
srcs = ["any_exception_safety_test.cc"],
copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG,
- linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS,
+ linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS,
deps = [
":any",
"//absl/base:exception_safety_testing",
@@ -115,6 +119,7 @@ cc_library(
name = "span",
hdrs = ["span.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/algorithm",
"//absl/base:core_headers",
@@ -128,7 +133,7 @@ cc_test(
size = "small",
srcs = ["span_test.cc"],
copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG,
- linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS,
+ linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS,
deps = [
":span",
"//absl/base:config",
@@ -147,6 +152,7 @@ cc_test(
size = "small",
srcs = ["span_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":span",
"//absl/base:config",
@@ -162,11 +168,12 @@ cc_test(
cc_library(
name = "optional",
- srcs = ["optional.cc"],
hdrs = ["optional.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":bad_optional_access",
+ "//absl/base:base_internal",
"//absl/base:config",
"//absl/base:core_headers",
"//absl/memory",
@@ -180,7 +187,7 @@ cc_library(
srcs = ["bad_optional_access.cc"],
hdrs = ["bad_optional_access.h"],
copts = ABSL_DEFAULT_COPTS + ABSL_EXCEPTIONS_FLAG,
- linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS,
+ linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/base",
"//absl/base:config",
@@ -192,7 +199,7 @@ cc_library(
srcs = ["bad_variant_access.cc"],
hdrs = ["bad_variant_access.h"],
copts = ABSL_EXCEPTIONS_FLAG + ABSL_DEFAULT_COPTS,
- linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS,
+ linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/base",
"//absl/base:config",
@@ -206,7 +213,7 @@ cc_test(
"optional_test.cc",
],
copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG,
- linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS,
+ linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS,
deps = [
":optional",
"//absl/base",
@@ -223,7 +230,7 @@ cc_test(
"optional_exception_safety_test.cc",
],
copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG,
- linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS,
+ linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS,
deps = [
":optional",
"//absl/base:exception_safety_testing",
@@ -236,6 +243,7 @@ cc_library(
srcs = ["internal/variant.h"],
hdrs = ["variant.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":bad_variant_access",
"//absl/base:base_internal",
@@ -251,7 +259,7 @@ cc_test(
size = "small",
srcs = ["variant_test.cc"],
copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG,
- linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS,
+ linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS,
deps = [
":variant",
"//absl/base:config",
@@ -269,6 +277,7 @@ cc_test(
"variant_benchmark.cc",
],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
tags = ["benchmark"],
deps = [
":variant",
@@ -284,7 +293,7 @@ cc_test(
"variant_exception_safety_test.cc",
],
copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG,
- linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS,
+ linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS,
deps = [
":variant",
"//absl/base:config",
diff --git a/absl/types/CMakeLists.txt b/absl/types/CMakeLists.txt
index 8afde466..910c099a 100644
--- a/absl/types/CMakeLists.txt
+++ b/absl/types/CMakeLists.txt
@@ -172,12 +172,11 @@ absl_cc_library(
optional
HDRS
"optional.h"
- SRCS
- "optional.cc"
COPTS
${ABSL_DEFAULT_COPTS}
DEPS
absl::bad_optional_access
+ absl::base_internal
absl::config
absl::core_headers
absl::memory
@@ -297,7 +296,8 @@ absl_cc_test(
)
# TODO(cohenjon,zhangxy) Figure out why this test is failing on gcc 4.8
-if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9)
+if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
+else()
absl_cc_test(
NAME
variant_exception_safety_test
diff --git a/absl/types/optional.cc b/absl/types/optional.cc
deleted file mode 100644
index 44ff8294..00000000
--- a/absl/types/optional.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2017 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 "absl/types/optional.h"
-
-#ifndef ABSL_HAVE_STD_OPTIONAL
-namespace absl {
-
-nullopt_t::init_t nullopt_t::init;
-extern const nullopt_t nullopt{nullopt_t::init};
-
-} // namespace absl
-#endif // ABSL_HAVE_STD_OPTIONAL
diff --git a/absl/types/optional.h b/absl/types/optional.h
index f0ae9a17..6806160d 100644
--- a/absl/types/optional.h
+++ b/absl/types/optional.h
@@ -61,6 +61,7 @@ using std::nullopt;
#include <utility>
#include "absl/base/attributes.h"
+#include "absl/base/internal/inline_variable.h"
#include "absl/meta/type_traits.h"
#include "absl/types/bad_optional_access.h"
@@ -126,32 +127,30 @@ namespace absl {
template <typename T>
class optional;
+namespace optional_internal {
+
+// This tag type is used as a constructor parameter type for `nullopt_t`.
+struct init_t {
+ explicit init_t() = default;
+};
+
+} // namespace optional_internal
+
// nullopt_t
//
// Class type for `absl::nullopt` used to indicate an `absl::optional<T>` type
// that does not contain a value.
struct nullopt_t {
- struct init_t {};
- static init_t init;
-
// It must not be default-constructible to avoid ambiguity for opt = {}.
- // Note the non-const reference, which is to eliminate ambiguity for code
- // like:
- //
- // struct S { int value; };
- //
- // void Test() {
- // optional<S> opt;
- // opt = {{}};
- // }
- explicit constexpr nullopt_t(init_t& /*unused*/) {}
+ explicit constexpr nullopt_t(optional_internal::init_t) noexcept {}
};
// nullopt
//
// A tag constant of type `absl::nullopt_t` used to indicate an empty
// `absl::optional` in certain functions, such as construction or assignment.
-extern const nullopt_t nullopt;
+ABSL_INTERNAL_INLINE_CONSTEXPR(nullopt_t, nullopt,
+ nullopt_t(optional_internal::init_t()));
namespace optional_internal {
diff --git a/absl/types/optional_test.cc b/absl/types/optional_test.cc
index 0665488e..897c183a 100644
--- a/absl/types/optional_test.cc
+++ b/absl/types/optional_test.cc
@@ -179,15 +179,7 @@ TEST(optionalTest, DefaultConstructor) {
TEST(optionalTest, nulloptConstructor) {
absl::optional<int> empty(absl::nullopt);
EXPECT_FALSE(empty);
-
-#ifdef ABSL_HAVE_STD_OPTIONAL
constexpr absl::optional<int> cempty{absl::nullopt};
-#else
- // Creating a temporary absl::nullopt_t object instead of using absl::nullopt
- // because absl::nullopt cannot be constexpr and have external linkage at the
- // same time.
- constexpr absl::optional<int> cempty{absl::nullopt_t(absl::nullopt_t::init)};
-#endif
static_assert(!cempty.has_value(), "");
EXPECT_TRUE((std::is_nothrow_constructible<absl::optional<int>,
absl::nullopt_t>::value));
diff --git a/absl/types/span.h b/absl/types/span.h
index d7f48d9f..e5c4fe1e 100644
--- a/absl/types/span.h
+++ b/absl/types/span.h
@@ -73,9 +73,6 @@
namespace absl {
-template <typename T>
-class Span;
-
namespace span_internal {
// A constexpr min function
constexpr size_t Min(size_t a, size_t b) noexcept { return a < b ? a : b; }
@@ -133,14 +130,16 @@ template <typename T>
using EnableIfMutable =
typename std::enable_if<!std::is_const<T>::value, int>::type;
-template <typename T>
-bool EqualImpl(Span<T> a, Span<T> b) {
+template <template <typename> class SpanT, typename T>
+bool EqualImpl(SpanT<T> a, SpanT<T> b) {
static_assert(std::is_const<T>::value, "");
return absl::equal(a.begin(), a.end(), b.begin(), b.end());
}
-template <typename T>
-bool LessThanImpl(Span<T> a, Span<T> b) {
+template <template <typename> class SpanT, typename T>
+bool LessThanImpl(SpanT<T> a, SpanT<T> b) {
+ // We can't use value_type since that is remove_cv_t<T>, so we go the long way
+ // around.
static_assert(std::is_const<T>::value, "");
return std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end());
}
@@ -165,8 +164,8 @@ struct IsConvertible : IsConvertibleHelper<From, To>::type {};
// TODO(zhangxy): replace `IsConvertible` with `std::is_convertible` once the
// older version of libcxx is not supported.
template <typename From, typename To>
-using EnableIfConvertibleToSpanConst =
- typename std::enable_if<IsConvertible<From, Span<const To>>::value>::type;
+using EnableIfConvertibleTo =
+ typename std::enable_if<IsConvertible<From, To>::value>::type;
} // namespace span_internal
//------------------------------------------------------------------------------
@@ -551,25 +550,27 @@ const typename Span<T>::size_type Span<T>::npos;
// operator==
template <typename T>
bool operator==(Span<T> a, Span<T> b) {
- return span_internal::EqualImpl<const T>(a, b);
+ return span_internal::EqualImpl<Span, const T>(a, b);
}
template <typename T>
bool operator==(Span<const T> a, Span<T> b) {
- return span_internal::EqualImpl<const T>(a, b);
+ return span_internal::EqualImpl<Span, const T>(a, b);
}
template <typename T>
bool operator==(Span<T> a, Span<const T> b) {
- return span_internal::EqualImpl<const T>(a, b);
+ return span_internal::EqualImpl<Span, const T>(a, b);
}
-template <typename T, typename U,
- typename = span_internal::EnableIfConvertibleToSpanConst<U, T>>
+template <
+ typename T, typename U,
+ typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
bool operator==(const U& a, Span<T> b) {
- return span_internal::EqualImpl<const T>(a, b);
+ return span_internal::EqualImpl<Span, const T>(a, b);
}
-template <typename T, typename U,
- typename = span_internal::EnableIfConvertibleToSpanConst<U, T>>
+template <
+ typename T, typename U,
+ typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
bool operator==(Span<T> a, const U& b) {
- return span_internal::EqualImpl<const T>(a, b);
+ return span_internal::EqualImpl<Span, const T>(a, b);
}
// operator!=
@@ -585,13 +586,15 @@ template <typename T>
bool operator!=(Span<T> a, Span<const T> b) {
return !(a == b);
}
-template <typename T, typename U,
- typename = span_internal::EnableIfConvertibleToSpanConst<U, T>>
+template <
+ typename T, typename U,
+ typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
bool operator!=(const U& a, Span<T> b) {
return !(a == b);
}
-template <typename T, typename U,
- typename = span_internal::EnableIfConvertibleToSpanConst<U, T>>
+template <
+ typename T, typename U,
+ typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
bool operator!=(Span<T> a, const U& b) {
return !(a == b);
}
@@ -599,25 +602,27 @@ bool operator!=(Span<T> a, const U& b) {
// operator<
template <typename T>
bool operator<(Span<T> a, Span<T> b) {
- return span_internal::LessThanImpl<const T>(a, b);
+ return span_internal::LessThanImpl<Span, const T>(a, b);
}
template <typename T>
bool operator<(Span<const T> a, Span<T> b) {
- return span_internal::LessThanImpl<const T>(a, b);
+ return span_internal::LessThanImpl<Span, const T>(a, b);
}
template <typename T>
bool operator<(Span<T> a, Span<const T> b) {
- return span_internal::LessThanImpl<const T>(a, b);
+ return span_internal::LessThanImpl<Span, const T>(a, b);
}
-template <typename T, typename U,
- typename = span_internal::EnableIfConvertibleToSpanConst<U, T>>
+template <
+ typename T, typename U,
+ typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
bool operator<(const U& a, Span<T> b) {
- return span_internal::LessThanImpl<const T>(a, b);
+ return span_internal::LessThanImpl<Span, const T>(a, b);
}
-template <typename T, typename U,
- typename = span_internal::EnableIfConvertibleToSpanConst<U, T>>
+template <
+ typename T, typename U,
+ typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
bool operator<(Span<T> a, const U& b) {
- return span_internal::LessThanImpl<const T>(a, b);
+ return span_internal::LessThanImpl<Span, const T>(a, b);
}
// operator>
@@ -633,13 +638,15 @@ template <typename T>
bool operator>(Span<T> a, Span<const T> b) {
return b < a;
}
-template <typename T, typename U,
- typename = span_internal::EnableIfConvertibleToSpanConst<U, T>>
+template <
+ typename T, typename U,
+ typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
bool operator>(const U& a, Span<T> b) {
return b < a;
}
-template <typename T, typename U,
- typename = span_internal::EnableIfConvertibleToSpanConst<U, T>>
+template <
+ typename T, typename U,
+ typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
bool operator>(Span<T> a, const U& b) {
return b < a;
}
@@ -657,13 +664,15 @@ template <typename T>
bool operator<=(Span<T> a, Span<const T> b) {
return !(b < a);
}
-template <typename T, typename U,
- typename = span_internal::EnableIfConvertibleToSpanConst<U, T>>
+template <
+ typename T, typename U,
+ typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
bool operator<=(const U& a, Span<T> b) {
return !(b < a);
}
-template <typename T, typename U,
- typename = span_internal::EnableIfConvertibleToSpanConst<U, T>>
+template <
+ typename T, typename U,
+ typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
bool operator<=(Span<T> a, const U& b) {
return !(b < a);
}
@@ -681,13 +690,15 @@ template <typename T>
bool operator>=(Span<T> a, Span<const T> b) {
return !(a < b);
}
-template <typename T, typename U,
- typename = span_internal::EnableIfConvertibleToSpanConst<U, T>>
+template <
+ typename T, typename U,
+ typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
bool operator>=(const U& a, Span<T> b) {
return !(a < b);
}
-template <typename T, typename U,
- typename = span_internal::EnableIfConvertibleToSpanConst<U, T>>
+template <
+ typename T, typename U,
+ typename = span_internal::EnableIfConvertibleTo<U, absl::Span<const T>>>
bool operator>=(Span<T> a, const U& b) {
return !(a < b);
}
diff --git a/absl/utility/BUILD.bazel b/absl/utility/BUILD.bazel
index 5185ccd8..d41317e3 100644
--- a/absl/utility/BUILD.bazel
+++ b/absl/utility/BUILD.bazel
@@ -1,6 +1,7 @@
load(
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
+ "ABSL_DEFAULT_LINKOPTS",
"ABSL_TEST_COPTS",
)
@@ -12,6 +13,7 @@ cc_library(
name = "utility",
hdrs = ["utility.h"],
copts = ABSL_DEFAULT_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
"//absl/base:base_internal",
"//absl/base:config",
@@ -23,6 +25,7 @@ cc_test(
name = "utility_test",
srcs = ["utility_test.cc"],
copts = ABSL_TEST_COPTS,
+ linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":utility",
"//absl/base:core_headers",
diff --git a/ci/cmake_install_test.sh b/ci/cmake_install_test.sh
index e54b7837..7195d180 100755
--- a/ci/cmake_install_test.sh
+++ b/ci/cmake_install_test.sh
@@ -29,5 +29,5 @@ time docker run \
-e CFLAGS="-Werror" \
-e CXXFLAGS="-Werror" \
gcr.io/google.com/absl-177019/linux_gcc-4.8:20190316 \
- /bin/bash CMake/install_test_project/test.sh
+ /bin/bash CMake/install_test_project/test.sh $@
diff --git a/ci/linux_clang-latest_libcxx_bazel.sh b/ci/linux_clang-latest_libcxx_bazel.sh
index 741e48c4..eec6c26f 100755
--- a/ci/linux_clang-latest_libcxx_bazel.sh
+++ b/ci/linux_clang-latest_libcxx_bazel.sh
@@ -32,6 +32,20 @@ if [ -z ${COMPILATION_MODE:-} ]; then
COMPILATION_MODE="fastbuild opt"
fi
+readonly DOCKER_CONTAINER="gcr.io/google.com/absl-177019/linux_clang-latest:20190313"
+
+# USE_BAZEL_CACHE=1 only works on Kokoro.
+# Without access to the credentials this won't work.
+if [ ${USE_BAZEL_CACHE:-0} -ne 0 ]; then
+ DOCKER_EXTRA_ARGS="--volume=${KOKORO_KEYSTORE_DIR}:/keystore:ro ${DOCKER_EXTRA_ARGS:-}"
+ # Bazel doesn't track changes to tools outside of the workspace
+ # (e.g. /usr/bin/gcc), so by appending the docker container to the
+ # remote_http_cache url, we make changes to the container part of
+ # the cache key. Hashing the key is to make it shorter and url-safe.
+ container_key=$(echo ${DOCKER_CONTAINER} | sha256sum | head -c 16)
+ BAZEL_EXTRA_ARGS="--remote_http_cache=https://storage.googleapis.com/absl-bazel-remote-cache/${container_key} --google_credentials=/keystore/73103_absl-bazel-remote-cache ${BAZEL_EXTRA_ARGS:-}"
+fi
+
for std in ${STD}; do
for compilation_mode in ${COMPILATION_MODE}; do
echo "--------------------------------------------------------------------"
@@ -47,7 +61,8 @@ for std in ${STD}; do
-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" \
- gcr.io/google.com/absl-177019/linux_clang-latest:20190313 \
+ ${DOCKER_EXTRA_ARGS:-} \
+ ${DOCKER_CONTAINER} \
/usr/local/bin/bazel test ... \
--compilation_mode=${compilation_mode} \
--copt=-Werror \
@@ -57,6 +72,7 @@ for std in ${STD}; do
--test_env="GTEST_INSTALL_FAILURE_SIGNAL_HANDLER=1" \
--test_env="TZDIR=/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo" \
--test_output=errors \
- --test_tag_filters=-benchmark
+ --test_tag_filters=-benchmark \
+ ${BAZEL_EXTRA_ARGS:-}
done
done
diff --git a/ci/linux_clang-latest_libstdcxx_bazel.sh b/ci/linux_clang-latest_libstdcxx_bazel.sh
index d703a776..14723235 100755
--- a/ci/linux_clang-latest_libstdcxx_bazel.sh
+++ b/ci/linux_clang-latest_libstdcxx_bazel.sh
@@ -32,6 +32,20 @@ if [ -z ${COMPILATION_MODE:-} ]; then
COMPILATION_MODE="fastbuild opt"
fi
+readonly DOCKER_CONTAINER="gcr.io/google.com/absl-177019/linux_clang-latest:20190313"
+
+# USE_BAZEL_CACHE=1 only works on Kokoro.
+# Without access to the credentials this won't work.
+if [ ${USE_BAZEL_CACHE:-0} -ne 0 ]; then
+ DOCKER_EXTRA_ARGS="--volume=${KOKORO_KEYSTORE_DIR}:/keystore:ro ${DOCKER_EXTRA_ARGS:-}"
+ # Bazel doesn't track changes to tools outside of the workspace
+ # (e.g. /usr/bin/gcc), so by appending the docker container to the
+ # remote_http_cache url, we make changes to the container part of
+ # the cache key. Hashing the key is to make it shorter and url-safe.
+ container_key=$(echo ${DOCKER_CONTAINER} | sha256sum | head -c 16)
+ BAZEL_EXTRA_ARGS="--remote_http_cache=https://storage.googleapis.com/absl-bazel-remote-cache/${container_key} --google_credentials=/keystore/73103_absl-bazel-remote-cache ${BAZEL_EXTRA_ARGS:-}"
+fi
+
for std in ${STD}; do
for compilation_mode in ${COMPILATION_MODE}; do
echo "--------------------------------------------------------------------"
@@ -46,7 +60,8 @@ for std in ${STD}; do
-e BAZEL_COMPILER="llvm" \
-e BAZEL_CXXOPTS="-std=${std}" \
-e CPLUS_INCLUDE_PATH="/usr/include/c++/6" \
- gcr.io/google.com/absl-177019/linux_clang-latest:20190313 \
+ ${DOCKER_EXTRA_ARGS:-} \
+ ${DOCKER_CONTAINER} \
/usr/local/bin/bazel test ... \
--compilation_mode=${compilation_mode} \
--copt=-Werror \
@@ -56,6 +71,7 @@ for std in ${STD}; do
--test_env="GTEST_INSTALL_FAILURE_SIGNAL_HANDLER=1" \
--test_env="TZDIR=/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo" \
--test_output=errors \
- --test_tag_filters=-benchmark
+ --test_tag_filters=-benchmark \
+ ${BAZEL_EXTRA_ARGS:-}
done
done
diff --git a/ci/linux_gcc-latest_libstdcxx_bazel.sh b/ci/linux_gcc-latest_libstdcxx_bazel.sh
index e14a019c..24469628 100755
--- a/ci/linux_gcc-latest_libstdcxx_bazel.sh
+++ b/ci/linux_gcc-latest_libstdcxx_bazel.sh
@@ -32,6 +32,20 @@ if [ -z ${COMPILATION_MODE:-} ]; then
COMPILATION_MODE="fastbuild opt"
fi
+readonly DOCKER_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-latest:20190318"
+
+# USE_BAZEL_CACHE=1 only works on Kokoro.
+# Without access to the credentials this won't work.
+if [ ${USE_BAZEL_CACHE:-0} -ne 0 ]; then
+ DOCKER_EXTRA_ARGS="--volume=${KOKORO_KEYSTORE_DIR}:/keystore:ro ${DOCKER_EXTRA_ARGS:-}"
+ # Bazel doesn't track changes to tools outside of the workspace
+ # (e.g. /usr/bin/gcc), so by appending the docker container to the
+ # remote_http_cache url, we make changes to the container part of
+ # the cache key. Hashing the key is to make it shorter and url-safe.
+ container_key=$(echo ${DOCKER_CONTAINER} | sha256sum | head -c 16)
+ BAZEL_EXTRA_ARGS="--remote_http_cache=https://storage.googleapis.com/absl-bazel-remote-cache/${container_key} --google_credentials=/keystore/73103_absl-bazel-remote-cache ${BAZEL_EXTRA_ARGS:-}"
+fi
+
for std in ${STD}; do
for compilation_mode in ${COMPILATION_MODE}; do
echo "--------------------------------------------------------------------"
@@ -44,7 +58,8 @@ for std in ${STD}; do
--rm \
-e CC="/usr/local/bin/gcc" \
-e BAZEL_CXXOPTS="-std=${std}" \
- gcr.io/google.com/absl-177019/linux_gcc-latest:20190318 \
+ ${DOCKER_EXTRA_ARGS:-} \
+ ${DOCKER_CONTAINER} \
/usr/local/bin/bazel test ... \
--compilation_mode=${compilation_mode} \
--copt=-Werror \
@@ -54,6 +69,7 @@ for std in ${STD}; do
--test_env="GTEST_INSTALL_FAILURE_SIGNAL_HANDLER=1" \
--test_env="TZDIR=/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo" \
--test_output=errors \
- --test_tag_filters=-benchmark
+ --test_tag_filters=-benchmark \
+ ${BAZEL_EXTRA_ARGS:-}
done
done