Commit 8f1c34a7 by Abseil Team Committed by Derek Mauro

Export of internal Abseil changes

--
498800727a35cd00c199e653c2a8e34dc3322b54 by Derek Mauro <dmauro@google.com>:

Fixes CMake dependency issues and adds `-Wl,--no-undefined` to avoid
these issues in the future.

Fixes #817

PiperOrigin-RevId: 337615527

--
a14b214a50a095d0c10c9d7a9e98ab1bd3b3976b by Samuel Benzaquen <sbenza@google.com>:

Minor compatibility fix for a version of gcc 5.5

PiperOrigin-RevId: 337561733

--
89a65c211e626bd30c046f79d0df9cc4a7d7c792 by Gennadiy Rozental <rogeeff@google.com>:

Internal change

PiperOrigin-RevId: 337436891

--
d30c05c850ead352dad5ea0dc32942feb2942986 by Abseil Team <absl-team@google.com>:

Place STL exception functions underneath the ABSL_HAVE_EXCEPTIONS #ifdef.

The STL exception functions are not present in the Android NDK, so Abseil fails to build as part of ANGLE in AOSP.   This CL places the various STL exception throwing functions inside #ifdef ABSL_HAVE_EXCEPTIONS blocks so they are removed during Android builds since neither ANGLE nor the NDK support exceptions by default.

PiperOrigin-RevId: 337142938
GitOrigin-RevId: 498800727a35cd00c199e653c2a8e34dc3322b54
Change-Id: I17b02daaea145d1a8fdbfd098f0fa99e65c86d2d
parent 60d00a58
...@@ -607,6 +607,7 @@ ...@@ -607,6 +607,7 @@
// When used with unsupported compilers, the ABSL_FALLTHROUGH_INTENDED macro // When used with unsupported compilers, the ABSL_FALLTHROUGH_INTENDED macro
// has no effect on diagnostics. In any case this macro has no effect on runtime // has no effect on diagnostics. In any case this macro has no effect on runtime
// behavior and performance of code. // behavior and performance of code.
#ifdef ABSL_FALLTHROUGH_INTENDED #ifdef ABSL_FALLTHROUGH_INTENDED
#error "ABSL_FALLTHROUGH_INTENDED should not be defined." #error "ABSL_FALLTHROUGH_INTENDED should not be defined."
#endif #endif
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <functional> #include <functional>
#include <new> #include <new>
#include <stdexcept> #include <stdexcept>
#include "absl/base/config.h" #include "absl/base/config.h"
#include "absl/base/internal/raw_logging.h" #include "absl/base/internal/raw_logging.h"
...@@ -25,83 +26,186 @@ namespace absl { ...@@ -25,83 +26,186 @@ namespace absl {
ABSL_NAMESPACE_BEGIN ABSL_NAMESPACE_BEGIN
namespace base_internal { namespace base_internal {
// NOTE: The various STL exception throwing functions are placed within the
// #ifdef blocks so the symbols aren't exposed on platforms that don't support
// them, such as the Android NDK. For example, ANGLE fails to link when building
// within AOSP without them, since the STL functions don't exist.
namespace { namespace {
#ifdef ABSL_HAVE_EXCEPTIONS
template <typename T> template <typename T>
[[noreturn]] void Throw(const T& error) { [[noreturn]] void Throw(const T& error) {
#ifdef ABSL_HAVE_EXCEPTIONS
throw error; throw error;
#else
ABSL_RAW_LOG(FATAL, "%s", error.what());
std::abort();
#endif
} }
#endif
} // namespace } // namespace
void ThrowStdLogicError(const std::string& what_arg) { void ThrowStdLogicError(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::logic_error(what_arg)); Throw(std::logic_error(what_arg));
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort();
#endif
} }
void ThrowStdLogicError(const char* what_arg) { void ThrowStdLogicError(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::logic_error(what_arg)); Throw(std::logic_error(what_arg));
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort();
#endif
} }
void ThrowStdInvalidArgument(const std::string& what_arg) { void ThrowStdInvalidArgument(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::invalid_argument(what_arg)); Throw(std::invalid_argument(what_arg));
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort();
#endif
} }
void ThrowStdInvalidArgument(const char* what_arg) { void ThrowStdInvalidArgument(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::invalid_argument(what_arg)); Throw(std::invalid_argument(what_arg));
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort();
#endif
} }
void ThrowStdDomainError(const std::string& what_arg) { void ThrowStdDomainError(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::domain_error(what_arg)); Throw(std::domain_error(what_arg));
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort();
#endif
} }
void ThrowStdDomainError(const char* what_arg) { void ThrowStdDomainError(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::domain_error(what_arg)); Throw(std::domain_error(what_arg));
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort();
#endif
} }
void ThrowStdLengthError(const std::string& what_arg) { void ThrowStdLengthError(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::length_error(what_arg)); Throw(std::length_error(what_arg));
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort();
#endif
} }
void ThrowStdLengthError(const char* what_arg) { void ThrowStdLengthError(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::length_error(what_arg)); Throw(std::length_error(what_arg));
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort();
#endif
} }
void ThrowStdOutOfRange(const std::string& what_arg) { void ThrowStdOutOfRange(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::out_of_range(what_arg)); Throw(std::out_of_range(what_arg));
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort();
#endif
} }
void ThrowStdOutOfRange(const char* what_arg) { void ThrowStdOutOfRange(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::out_of_range(what_arg)); Throw(std::out_of_range(what_arg));
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort();
#endif
} }
void ThrowStdRuntimeError(const std::string& what_arg) { void ThrowStdRuntimeError(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::runtime_error(what_arg)); Throw(std::runtime_error(what_arg));
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort();
#endif
} }
void ThrowStdRuntimeError(const char* what_arg) { void ThrowStdRuntimeError(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::runtime_error(what_arg)); Throw(std::runtime_error(what_arg));
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort();
#endif
} }
void ThrowStdRangeError(const std::string& what_arg) { void ThrowStdRangeError(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::range_error(what_arg)); Throw(std::range_error(what_arg));
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort();
#endif
} }
void ThrowStdRangeError(const char* what_arg) { void ThrowStdRangeError(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::range_error(what_arg)); Throw(std::range_error(what_arg));
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort();
#endif
} }
void ThrowStdOverflowError(const std::string& what_arg) { void ThrowStdOverflowError(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::overflow_error(what_arg)); Throw(std::overflow_error(what_arg));
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort();
#endif
} }
void ThrowStdOverflowError(const char* what_arg) { void ThrowStdOverflowError(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::overflow_error(what_arg)); Throw(std::overflow_error(what_arg));
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort();
#endif
} }
void ThrowStdUnderflowError(const std::string& what_arg) { void ThrowStdUnderflowError(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::underflow_error(what_arg)); Throw(std::underflow_error(what_arg));
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort();
#endif
} }
void ThrowStdUnderflowError(const char* what_arg) { void ThrowStdUnderflowError(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::underflow_error(what_arg)); Throw(std::underflow_error(what_arg));
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort();
#endif
} }
void ThrowStdBadFunctionCall() { Throw(std::bad_function_call()); } void ThrowStdBadFunctionCall() {
#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::bad_function_call());
#else
std::abort();
#endif
}
void ThrowStdBadAlloc() { Throw(std::bad_alloc()); } void ThrowStdBadAlloc() {
#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::bad_alloc());
#else
std::abort();
#endif
}
} // namespace base_internal } // namespace base_internal
ABSL_NAMESPACE_END ABSL_NAMESPACE_END
......
...@@ -183,6 +183,7 @@ absl_cc_library( ...@@ -183,6 +183,7 @@ absl_cc_library(
DEPS DEPS
absl::base absl::base
absl::config absl::config
absl::flags_commandlineflag
absl::flags_commandlineflag_internal absl::flags_commandlineflag_internal
absl::flags_config absl::flags_config
absl::flags_marshalling absl::flags_marshalling
......
...@@ -64,6 +64,7 @@ absl_cc_library( ...@@ -64,6 +64,7 @@ absl_cc_library(
COPTS COPTS
${ABSL_DEFAULT_COPTS} ${ABSL_DEFAULT_COPTS}
DEPS DEPS
absl::status
absl::core_headers absl::core_headers
absl::raw_logging_internal absl::raw_logging_internal
absl::type_traits absl::type_traits
......
...@@ -133,10 +133,11 @@ class FormatSpecTemplate ...@@ -133,10 +133,11 @@ class FormatSpecTemplate
#endif // ABSL_INTERNAL_ENABLE_FORMAT_CHECKER #endif // ABSL_INTERNAL_ENABLE_FORMAT_CHECKER
template <FormatConversionCharSet... C, template <
typename = typename std::enable_if< FormatConversionCharSet... C,
AllOf(sizeof...(C) == sizeof...(Args), Contains(Args, typename = typename std::enable_if<sizeof...(C) == sizeof...(Args)>::type,
C)...)>::type> typename = typename std::enable_if<AllOf(Contains(Args,
C)...)>::type>
FormatSpecTemplate(const ExtendedParsedFormat<C...>& pc) // NOLINT FormatSpecTemplate(const ExtendedParsedFormat<C...>& pc) // NOLINT
: Base(&pc) {} : Base(&pc) {}
}; };
......
...@@ -34,31 +34,36 @@ if [[ -z ${ABSL_CMAKE_BUILD_TYPES:-} ]]; then ...@@ -34,31 +34,36 @@ if [[ -z ${ABSL_CMAKE_BUILD_TYPES:-} ]]; then
ABSL_CMAKE_BUILD_TYPES="Debug Release" ABSL_CMAKE_BUILD_TYPES="Debug Release"
fi fi
if [[ -z ${ABSL_CMAKE_BUILD_SHARED:-} ]]; then
ABSL_CMAKE_BUILD_SHARED="OFF ON"
fi
source "${ABSEIL_ROOT}/ci/linux_docker_containers.sh" source "${ABSEIL_ROOT}/ci/linux_docker_containers.sh"
readonly DOCKER_CONTAINER=${LINUX_GCC_LATEST_CONTAINER} readonly DOCKER_CONTAINER=${LINUX_GCC_LATEST_CONTAINER}
for std in ${ABSL_CMAKE_CXX_STANDARDS}; do for std in ${ABSL_CMAKE_CXX_STANDARDS}; do
for compilation_mode in ${ABSL_CMAKE_BUILD_TYPES}; do for compilation_mode in ${ABSL_CMAKE_BUILD_TYPES}; do
echo "--------------------------------------------------------------------" for build_shared in ${ABSL_CMAKE_BUILD_SHARED}; do
echo "Testing with CMAKE_BUILD_TYPE=${compilation_mode} and -std=c++${std}" time docker run \
--volume="${ABSEIL_ROOT}:/abseil-cpp:ro" \
time docker run \ --workdir=/abseil-cpp \
--volume="${ABSEIL_ROOT}:/abseil-cpp:ro" \ --tmpfs=/buildfs:exec \
--workdir=/abseil-cpp \ --cap-add=SYS_PTRACE \
--tmpfs=/buildfs:exec \ --rm \
--cap-add=SYS_PTRACE \ -e CFLAGS="-Werror" \
--rm \ -e CXXFLAGS="-Werror" \
-e CFLAGS="-Werror" \ ${DOCKER_CONTAINER} \
-e CXXFLAGS="-Werror" \ /bin/bash -c "
${DOCKER_CONTAINER} \ cd /buildfs && \
/bin/bash -c " cmake /abseil-cpp \
cd /buildfs && \ -DABSL_USE_GOOGLETEST_HEAD=ON \
cmake /abseil-cpp \ -DABSL_RUN_TESTS=ON \
-DABSL_USE_GOOGLETEST_HEAD=ON \ -DBUILD_SHARED_LIBS=${build_shared} \
-DABSL_RUN_TESTS=ON \ -DCMAKE_BUILD_TYPE=${compilation_mode} \
-DCMAKE_BUILD_TYPE=${compilation_mode} \ -DCMAKE_CXX_STANDARD=${std} \
-DCMAKE_CXX_STANDARD=${std} && \ -DCMAKE_MODULE_LINKER_FLAGS=\"-Wl,--no-undefined\" && \
make -j$(nproc) && \ make -j$(nproc) && \
ctest -j$(nproc) --output-on-failure" ctest -j$(nproc) --output-on-failure"
done
done done
done done
...@@ -34,31 +34,35 @@ if [[ -z ${ABSL_CMAKE_BUILD_TYPES:-} ]]; then ...@@ -34,31 +34,35 @@ if [[ -z ${ABSL_CMAKE_BUILD_TYPES:-} ]]; then
ABSL_CMAKE_BUILD_TYPES="Debug Release" ABSL_CMAKE_BUILD_TYPES="Debug Release"
fi fi
if [[ -z ${ABSL_CMAKE_BUILD_SHARED:-} ]]; then
ABSL_CMAKE_BUILD_SHARED="OFF ON"
fi
source "${ABSEIL_ROOT}/ci/linux_docker_containers.sh" source "${ABSEIL_ROOT}/ci/linux_docker_containers.sh"
readonly DOCKER_CONTAINER=${LINUX_ALPINE_CONTAINER} readonly DOCKER_CONTAINER=${LINUX_ALPINE_CONTAINER}
for std in ${ABSL_CMAKE_CXX_STANDARDS}; do for std in ${ABSL_CMAKE_CXX_STANDARDS}; do
for compilation_mode in ${ABSL_CMAKE_BUILD_TYPES}; do for compilation_mode in ${ABSL_CMAKE_BUILD_TYPES}; do
echo "--------------------------------------------------------------------" for build_shared in ${ABSL_CMAKE_BUILD_SHARED}; do
echo "Testing with CMAKE_BUILD_TYPE=${compilation_mode} and -std=c++${std}" time docker run \
--volume="${ABSEIL_ROOT}:/abseil-cpp:ro" \
time docker run \ --workdir=/abseil-cpp \
--volume="${ABSEIL_ROOT}:/abseil-cpp:ro" \ --tmpfs=/buildfs:exec \
--workdir=/abseil-cpp \ --cap-add=SYS_PTRACE \
--tmpfs=/buildfs:exec \ --rm \
--cap-add=SYS_PTRACE \ -e CFLAGS="-Werror" \
--rm \ -e CXXFLAGS="-Werror" \
-e CFLAGS="-Werror" \ "${DOCKER_CONTAINER}" \
-e CXXFLAGS="-Werror" \ /bin/sh -c "
"${DOCKER_CONTAINER}" \ cd /buildfs && \
/bin/sh -c " cmake /abseil-cpp \
cd /buildfs && \ -DABSL_USE_GOOGLETEST_HEAD=ON \
cmake /abseil-cpp \ -DABSL_RUN_TESTS=ON \
-DABSL_USE_GOOGLETEST_HEAD=ON \ -DCMAKE_BUILD_TYPE=${compilation_mode} \
-DABSL_RUN_TESTS=ON \ -DCMAKE_CXX_STANDARD=${std} \
-DCMAKE_BUILD_TYPE=${compilation_mode} \ -DCMAKE_MODULE_LINKER_FLAGS=\"-Wl,--no-undefined\" && \
-DCMAKE_CXX_STANDARD=${std} && \ make -j$(nproc) && \
make -j$(nproc) && \ ctest -j$(nproc) --output-on-failure"
ctest -j$(nproc) --output-on-failure" done
done done
done done
...@@ -28,17 +28,25 @@ if [[ -z ${ABSL_CMAKE_BUILD_TYPES:-} ]]; then ...@@ -28,17 +28,25 @@ if [[ -z ${ABSL_CMAKE_BUILD_TYPES:-} ]]; then
ABSL_CMAKE_BUILD_TYPES="Debug" ABSL_CMAKE_BUILD_TYPES="Debug"
fi fi
if [[ -z ${ABSL_CMAKE_BUILD_SHARED:-} ]]; then
ABSL_CMAKE_BUILD_SHARED="OFF ON"
fi
for compilation_mode in ${ABSL_CMAKE_BUILD_TYPES}; do for compilation_mode in ${ABSL_CMAKE_BUILD_TYPES}; do
BUILD_DIR=$(mktemp -d ${compilation_mode}.XXXXXXXX) for build_shared in ${ABSL_CMAKE_BUILD_SHARED}; do
cd ${BUILD_DIR} BUILD_DIR=$(mktemp -d ${compilation_mode}.XXXXXXXX)
cd ${BUILD_DIR}
# TODO(absl-team): Enable -Werror once all warnings are fixed. # TODO(absl-team): Enable -Werror once all warnings are fixed.
time cmake ${ABSEIL_ROOT} \ time cmake ${ABSEIL_ROOT} \
-GXcode \ -GXcode \
-DCMAKE_BUILD_TYPE=${compilation_mode} \ -DBUILD_SHARED_LIBS=${build_shared} \
-DCMAKE_CXX_STANDARD=11 \ -DCMAKE_BUILD_TYPE=${compilation_mode} \
-DABSL_USE_GOOGLETEST_HEAD=ON \ -DCMAKE_CXX_STANDARD=11 \
-DABSL_RUN_TESTS=ON -DCMAKE_MODULE_LINKER_FLAGS="-Wl,--no-undefined" \
time cmake --build . -DABSL_USE_GOOGLETEST_HEAD=ON \
time ctest -C ${compilation_mode} --output-on-failure -DABSL_RUN_TESTS=ON
time cmake --build .
time ctest -C ${compilation_mode} --output-on-failure
done
done done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment