Skip to content

Commit dcf4899

Browse files
Abseil Teamdinord
authored andcommitted
Export of internal Abseil changes
-- 8e75347c10d85112296811be6ef35761744ad9bc by Derek Mauro <[email protected]>: Big update to LTS release process * Add create_lts.py script to to the LTS modification This is simpler than copybara since very few changes are needed * Use the default installation paths instead of a versioned path. If a versioned path is needed, this is easy to change on the commandline. * Make the integration test use the LTS transformed version * Test both static and dynamic linking (fixes pkg-config dynamic linking) PiperOrigin-RevId: 363566934 -- e00e971a2de3138861f5e1900201c9cc7788f714 by Laramie Leavitt <[email protected]>: Add a non-compile test to absl::BitGenRef for temporaries. PiperOrigin-RevId: 363437284 -- 3685644ec115d99789de32aceb76c32a00756fea by Derek Mauro <[email protected]>: Make OSS code consistent with internal code by using the forward declaration of absl::Status that contains ABSL_MUST_USE_RESULT. PiperOrigin-RevId: 363426906 -- b85fec142c3aa3f632fa985f9f8f73a253819723 by Evan Brown <[email protected]>: Move raw_hash_set::infoz_ into raw_hash_set::settings_. This reduces the size of raw_hash_sets by alignof(size_t) bytes when hashtablez is disabled. PiperOrigin-RevId: 363034264 -- c6fde3b17e5845191eb8b2bfc1760c8bfb9573ff by Mark Barolak <[email protected]>: Internal change PiperOrigin-RevId: 362990378 -- 81713cf964905b43d1cbe32ce5fed97539029625 by Abseil Team <[email protected]>: Fix typo in comment (execeptions -> exceptions). PiperOrigin-RevId: 362946191 -- 3ee92ca470feca44da417b03ee45a915c6eb5155 by Abseil Team <[email protected]>: Add absl::FindAndReportLeaks and routes it to the corresponding __lsan_do_recoverable_leak_check. PiperOrigin-RevId: 362622199 -- b95b7194b20e02c20d72289fbc79a0d35b82e256 by Abseil Team <[email protected]>: Add `kWithEverything` to StatusToStringMode PiperOrigin-RevId: 362595218 -- 0a960d96a0014eab7e1c55b479269450ed8e98d7 by Abseil Team <[email protected]>: Accept e.g. ".__uniq" as a valid clone name. Further, bring the implementation on par with libiberty's demangler grammar. Clang introduced option -funique-internal-linkage-names that adds the suffix ".__uniq.[0-9]+" to internal linkage functions to give them a globally unique identifier. The suffix was designed to work with existing demanglers which do recognize a "_" along with the alphanumeric string. This change enhances the demangler to allow "_" with the alphanumeric string. Please refer to libiberty's cp-demangle.c where function d_clone_suffix implements the demangling of clone suffixes : 1. '_' is accepted as a valid character with the alphanumeric sequence. 2. The alphanumberic sequence is optional. 3. The digit sequence is optional. PiperOrigin-RevId: 362557420 -- 2ac5ea212c150afd2f58025a5cab8c45d16949c6 by Abseil Team <[email protected]>: Change variable name 'slots' to 'slot_count' to avoid name-clash with Qt builds. PiperOrigin-RevId: 362556289 -- 934f0f409c9c548716a46363d6e243406fad4028 by Mark Barolak <[email protected]>: Clarify the comment on ABSL_CACHELINE_SIZE to indicate that the macro definition itself shouldn't change, but rather that call sites should change when possible. This addresses the request for improved documentation in #842. PiperOrigin-RevId: 362354288 GitOrigin-RevId: 8e75347c10d85112296811be6ef35761744ad9bc Change-Id: I33ec8561d8d645c3353e9d2dd447501d0e1825a7
1 parent 2e9532c commit dcf4899

File tree

20 files changed

+339
-211
lines changed

20 files changed

+339
-211
lines changed

CMake/AbseilDll.cmake

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
include(CMakeParseArguments)
2+
include(GNUInstallDirs)
23

34
set(ABSL_INTERNAL_DLL_FILES
45
"algorithm/algorithm.h"
@@ -500,7 +501,7 @@ function(absl_make_dll)
500501
abseil_dll
501502
PUBLIC
502503
"$<BUILD_INTERFACE:${ABSL_COMMON_INCLUDE_DIRS}>"
503-
$<INSTALL_INTERFACE:${ABSL_INSTALL_INCLUDEDIR}>
504+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
504505
)
505506

506507
target_compile_options(
@@ -518,8 +519,8 @@ function(absl_make_dll)
518519
${ABSL_CC_LIB_DEFINES}
519520
)
520521
install(TARGETS abseil_dll EXPORT ${PROJECT_NAME}Targets
521-
RUNTIME DESTINATION ${ABSL_INSTALL_BINDIR}
522-
LIBRARY DESTINATION ${ABSL_INSTALL_LIBDIR}
523-
ARCHIVE DESTINATION ${ABSL_INSTALL_LIBDIR}
522+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
523+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
524+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
524525
)
525526
endfunction()

CMake/AbseilHelpers.cmake

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
include(CMakeParseArguments)
1818
include(AbseilConfigureCopts)
1919
include(AbseilDll)
20-
include(AbseilInstallDirs)
2120

2221
# The IDE folder for Abseil that will be used if Abseil is included in a CMake
2322
# project that sets
@@ -151,6 +150,10 @@ function(absl_cc_library)
151150
endif()
152151
foreach(dep ${ABSL_CC_LIB_DEPS})
153152
if(${dep} MATCHES "^absl::(.*)")
153+
# Join deps with commas.
154+
if(PC_DEPS)
155+
set(PC_DEPS "${PC_DEPS},")
156+
endif()
154157
set(PC_DEPS "${PC_DEPS} absl_${CMAKE_MATCH_1} = ${PC_VERSION}")
155158
endif()
156159
endforeach()
@@ -167,14 +170,14 @@ function(absl_cc_library)
167170
FILE(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/lib/pkgconfig/absl_${_NAME}.pc" CONTENT "\
168171
prefix=${CMAKE_INSTALL_PREFIX}\n\
169172
exec_prefix=\${prefix}\n\
170-
libdir=\${prefix}/lib\n\
171-
includedir=\${prefix}/include\n\
173+
libdir=\${prefix}/${CMAKE_INSTALL_LIBDIR}\n\
174+
includedir=\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}\n\
172175
\n\
173176
Name: absl_${_NAME}\n\
174177
Description: Abseil ${_NAME} library\n\
175178
URL: https://abseil.io/\n\
176179
Version: ${PC_VERSION}\n\
177-
Requires.private:${PC_DEPS}\n\
180+
Requires:${PC_DEPS}\n\
178181
Libs: -L\${libdir} $<JOIN:${ABSL_CC_LIB_LINKOPTS}, > $<$<NOT:$<BOOL:${ABSL_CC_LIB_IS_INTERFACE}>>:-labsl_${_NAME}>\n\
179182
Cflags: -I\${includedir}${PC_CFLAGS}\n")
180183
INSTALL(FILES "${CMAKE_BINARY_DIR}/lib/pkgconfig/absl_${_NAME}.pc"
@@ -235,7 +238,7 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n")
235238
target_include_directories(${_NAME}
236239
PUBLIC
237240
"$<BUILD_INTERFACE:${ABSL_COMMON_INCLUDE_DIRS}>"
238-
$<INSTALL_INTERFACE:${ABSL_INSTALL_INCLUDEDIR}>
241+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
239242
)
240243
target_compile_options(${_NAME}
241244
PRIVATE ${ABSL_CC_LIB_COPTS})
@@ -260,7 +263,6 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n")
260263
if(ABSL_ENABLE_INSTALL)
261264
set_target_properties(${_NAME} PROPERTIES
262265
OUTPUT_NAME "absl_${_NAME}"
263-
# TODO(b/173696973): Figure out how to set SOVERSION for LTS releases.
264266
SOVERSION 0
265267
)
266268
endif()
@@ -270,7 +272,7 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n")
270272
target_include_directories(${_NAME}
271273
INTERFACE
272274
"$<BUILD_INTERFACE:${ABSL_COMMON_INCLUDE_DIRS}>"
273-
$<INSTALL_INTERFACE:${ABSL_INSTALL_INCLUDEDIR}>
275+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
274276
)
275277

276278
if (_build_type STREQUAL "dll")
@@ -290,9 +292,9 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n")
290292
# installed abseil can't be tested.
291293
if(NOT ABSL_CC_LIB_TESTONLY AND ABSL_ENABLE_INSTALL)
292294
install(TARGETS ${_NAME} EXPORT ${PROJECT_NAME}Targets
293-
RUNTIME DESTINATION ${ABSL_INSTALL_BINDIR}
294-
LIBRARY DESTINATION ${ABSL_INSTALL_LIBDIR}
295-
ARCHIVE DESTINATION ${ABSL_INSTALL_LIBDIR}
295+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
296+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
297+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
296298
)
297299
endif()
298300

CMake/AbseilInstallDirs.cmake

Lines changed: 0 additions & 20 deletions
This file was deleted.

CMake/install_test_project/test.sh

Lines changed: 36 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -13,70 +13,44 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16-
17-
# "Unit" and integration tests for Absl CMake installation
18-
19-
# TODO(absl-team): This script isn't fully hermetic because
20-
# -DABSL_USE_GOOGLETEST_HEAD=ON means that this script isn't pinned to a fixed
21-
# version of GoogleTest. This means that an upstream change to GoogleTest could
22-
# break this test. Fix this by allowing this script to pin to a known-good
23-
# version of GoogleTest.
16+
#
17+
# Unit and integration tests for Abseil LTS CMake installation
2418

2519
# Fail on any error. Treat unset variables an error. Print commands as executed.
2620
set -euox pipefail
2721

28-
install_absl() {
29-
pushd "${absl_build_dir}"
30-
if [[ "${#}" -eq 1 ]]; then
31-
cmake -DCMAKE_INSTALL_PREFIX="${1}" "${absl_dir}"
32-
else
33-
cmake "${absl_dir}"
34-
fi
35-
cmake --build . --target install -- -j
36-
popd
37-
}
38-
39-
uninstall_absl() {
40-
xargs rm < "${absl_build_dir}"/install_manifest.txt
41-
rm -rf "${absl_build_dir}"
42-
mkdir -p "${absl_build_dir}"
43-
}
44-
45-
lts_install=""
46-
47-
while getopts ":l" lts; do
48-
case "${lts}" in
49-
l )
50-
lts_install="true"
51-
;;
52-
esac
53-
done
22+
source ci/cmake_common.sh
5423

5524
absl_dir=/abseil-cpp
56-
absl_build_dir=/buildfs/absl-build
25+
absl_build_dir=/buildfs
5726
project_dir="${absl_dir}"/CMake/install_test_project
5827
project_build_dir=/buildfs/project-build
5928

60-
mkdir -p "${absl_build_dir}"
61-
mkdir -p "${project_build_dir}"
62-
63-
if [[ "${lts_install}" ]]; then
64-
install_dir="/usr/local"
65-
else
66-
install_dir="${project_build_dir}"/install
29+
build_shared_libs="OFF"
30+
if [ "${LINK_TYPE:-}" = "DYNAMIC" ]; then
31+
build_shared_libs="ON"
6732
fi
68-
mkdir -p "${install_dir}"
6933

70-
# Test build, install, and link against installed abseil
71-
pushd "${project_build_dir}"
72-
if [[ "${lts_install}" ]]; then
73-
install_absl
74-
cmake "${project_dir}"
75-
else
76-
install_absl "${install_dir}"
77-
cmake "${project_dir}" -DCMAKE_PREFIX_PATH="${install_dir}"
78-
fi
34+
# Run the LTS transformations
35+
./create_lts.py 99998877
36+
37+
# Install Abseil
38+
pushd "${absl_build_dir}"
39+
cmake "${absl_dir}" \
40+
-DABSL_GOOGLETEST_DOWNLOAD_URL="${ABSL_GOOGLETEST_DOWNLOAD_URL}" \
41+
-DCMAKE_BUILD_TYPE=Release \
42+
-DBUILD_TESTING=ON \
43+
-DBUILD_SHARED_LIBS="${build_shared_libs}"
44+
make -j $(nproc)
45+
ctest -j $(nproc)
46+
make install
47+
ldconfig
48+
popd
7949

50+
# Test the project against the installed Abseil
51+
mkdir -p "${project_build_dir}"
52+
pushd "${project_build_dir}"
53+
cmake "${project_dir}"
8054
cmake --build . --target simple
8155

8256
output="$(${project_build_dir}/simple "printme" 2>&1)"
@@ -88,32 +62,8 @@ fi
8862

8963
popd
9064

91-
# Test that we haven't accidentally made absl::abslblah
92-
pushd "${install_dir}"
93-
94-
# Starting in CMake 3.12 the default install dir is lib$bit_width
95-
if [[ -d lib64 ]]; then
96-
libdir="lib64"
97-
elif [[ -d lib ]]; then
98-
libdir="lib"
99-
else
100-
echo "ls *, */*, */*/*:"
101-
ls *
102-
ls */*
103-
ls */*/*
104-
echo "unknown lib dir"
105-
fi
106-
107-
if [[ "${lts_install}" ]]; then
108-
# LTS versions append the date of the release to the subdir.
109-
# 9999/99/99 is the dummy date used in the local_lts workflow.
110-
absl_subdir="absl_99999999"
111-
else
112-
absl_subdir="absl"
113-
fi
114-
115-
if ! grep absl::strings "${libdir}/cmake/${absl_subdir}/abslTargets.cmake"; then
116-
cat "${libdir}"/cmake/absl/abslTargets.cmake
65+
if ! grep absl::strings "/usr/local/lib/cmake/absl/abslTargets.cmake"; then
66+
cat "/usr/local/lib/cmake/absl/abslTargets.cmake"
11767
echo "CMake targets named incorrectly"
11868
exit 1
11969
fi
@@ -129,34 +79,18 @@ int main(int argc, char **argv) {
12979
return EXIT_SUCCESS;
13080
}
13181
EOF
132-
export PKG_CONFIG_PATH="${install_dir}/${libdir}/pkgconfig"
133-
pc_args=($(pkg-config --cflags --libs --static absl_str_format))
134-
g++ -static -o hello-abseil hello-abseil.cc "${pc_args[@]}"
82+
83+
if [ "${LINK_TYPE:-}" != "DYNAMIC" ]; then
84+
pc_args=($(pkg-config --cflags --libs --static absl_str_format))
85+
g++ -static -o hello-abseil hello-abseil.cc "${pc_args[@]}"
86+
else
87+
pc_args=($(pkg-config --cflags --libs absl_str_format))
88+
g++ -o hello-abseil hello-abseil.cc "${pc_args[@]}"
89+
fi
13590
hello="$(./hello-abseil)"
13691
[[ "${hello}" == "Hello Abseil!" ]]
137-
popd
13892

139-
uninstall_absl
14093
popd
14194

142-
if [[ ! "${lts_install}" ]]; then
143-
# Test that we warn if installed without a prefix or a system prefix
144-
output="$(install_absl 2>&1)"
145-
if [[ "${output}" != *"Please set CMAKE_INSTALL_PREFIX"* ]]; then
146-
echo "Install without prefix didn't warn as expected. Output:"
147-
echo "${output}"
148-
exit 1
149-
fi
150-
uninstall_absl
151-
152-
output="$(install_absl /usr 2>&1)"
153-
if [[ "${output}" != *"Please set CMAKE_INSTALL_PREFIX"* ]]; then
154-
echo "Install with /usr didn't warn as expected. Output:"
155-
echo "${output}"
156-
exit 1
157-
fi
158-
uninstall_absl
159-
fi
160-
16195
echo "Install test complete!"
16296
exit 0

CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ endif (POLICY CMP0077)
4545
# This must come before the project() and include(CTest) lines.
4646
OPTION(BUILD_TESTING "Build tests" OFF)
4747

48-
project(absl CXX)
48+
project(absl LANGUAGES CXX)
4949
include(CTest)
5050

5151
# Output directory is correct by default for most build setups. However, when
@@ -67,8 +67,8 @@ list(APPEND CMAKE_MODULE_PATH
6767
${CMAKE_CURRENT_LIST_DIR}/absl/copts
6868
)
6969

70-
include(AbseilInstallDirs)
7170
include(CMakePackageConfigHelpers)
71+
include(GNUInstallDirs)
7272
include(AbseilDll)
7373
include(AbseilHelpers)
7474

@@ -159,16 +159,16 @@ if(ABSL_ENABLE_INSTALL)
159159
# install as a subdirectory only
160160
install(EXPORT ${PROJECT_NAME}Targets
161161
NAMESPACE absl::
162-
DESTINATION "${ABSL_INSTALL_CONFIGDIR}"
162+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
163163
)
164164

165165
configure_package_config_file(
166166
CMake/abslConfig.cmake.in
167167
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
168-
INSTALL_DESTINATION "${ABSL_INSTALL_CONFIGDIR}"
168+
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
169169
)
170170
install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
171-
DESTINATION "${ABSL_INSTALL_CONFIGDIR}"
171+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
172172
)
173173

174174
# Abseil only has a version in LTS releases. This mechanism is accomplished
@@ -181,12 +181,12 @@ if(ABSL_ENABLE_INSTALL)
181181
)
182182

183183
install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
184-
DESTINATION ${ABSL_INSTALL_CONFIGDIR}
184+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
185185
)
186186
endif() # absl_VERSION
187187

188188
install(DIRECTORY absl
189-
DESTINATION ${ABSL_INSTALL_INCLUDEDIR}
189+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
190190
FILES_MATCHING
191191
PATTERN "*.inc"
192192
PATTERN "*.h"

absl/base/optimization.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@
106106
// Cacheline aligning objects properly allows constructive memory sharing and
107107
// prevents destructive (or "false") memory sharing.
108108
//
109-
// NOTE: this macro should be replaced with usage of `alignas()` using
109+
// NOTE: callers should replace uses of this macro with `alignas()` using
110110
// `std::hardware_constructive_interference_size` and/or
111-
// `std::hardware_destructive_interference_size` when available within C++17.
111+
// `std::hardware_destructive_interference_size` when C++17 becomes available to
112+
// them.
112113
//
113114
// See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0154r1.html
114115
// for more information.

absl/container/internal/btree.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -579,10 +579,10 @@ class btree_node {
579579
};
580580

581581
// Leaves can have less than kNodeSlots values.
582-
constexpr static layout_type LeafLayout(const int slots = kNodeSlots) {
582+
constexpr static layout_type LeafLayout(const int slot_count = kNodeSlots) {
583583
return layout_type(/*parent*/ 1,
584584
/*position, start, finish, max_count*/ 4,
585-
/*slots*/ slots,
585+
/*slots*/ slot_count,
586586
/*children*/ 0);
587587
}
588588
constexpr static layout_type InternalLayout() {
@@ -591,8 +591,8 @@ class btree_node {
591591
/*slots*/ kNodeSlots,
592592
/*children*/ kNodeSlots + 1);
593593
}
594-
constexpr static size_type LeafSize(const int slots = kNodeSlots) {
595-
return LeafLayout(slots).AllocSize();
594+
constexpr static size_type LeafSize(const int slot_count = kNodeSlots) {
595+
return LeafLayout(slot_count).AllocSize();
596596
}
597597
constexpr static size_type InternalSize() {
598598
return InternalLayout().AllocSize();

0 commit comments

Comments
 (0)