Skip to content

Commit a290770

Browse files
committed
[benchmark] Pull latest; disable -Werror
Pulled the latest (b000672), which adds an option to disable -Werror, which caused issues previously (see for instance https://reviews.llvm.org/D112012) Applied google/benchmark#1305 to unblock, as this issue is causing downstream buildbot failures. The only change is in llvm/CMakeLists.txt, where we set BENCHMARK_ENABLE_WERROR to have the same value as LLVM_ENABLE_WERROR. This patch also introduces a convenience script to pull benchmark from upstream. Differential Revision: https://reviews.llvm.org/D115684
1 parent 58473d8 commit a290770

File tree

101 files changed

+3523
-1901
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+3523
-1901
lines changed

llvm/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,8 @@ if (LLVM_INCLUDE_BENCHMARKS)
12091209
set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "Don't install benchmark" FORCE)
12101210
set(BENCHMARK_DOWNLOAD_DEPENDENCIES OFF CACHE BOOL "Don't download dependencies" FORCE)
12111211
set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Disable Google Test in benchmark" FORCE)
1212+
set(BENCHMARK_ENABLE_WERROR ${LLVM_ENABLE_WERROR} CACHE BOOL
1213+
"Handle -Werror for Google Benchmark based on LLVM_ENABLE_WERROR" FORCE)
12121214
# Since LLVM requires C++11 it is safe to assume that std::regex is available.
12131215
set(HAVE_STD_REGEX ON CACHE BOOL "OK" FORCE)
12141216
add_subdirectory(${LLVM_THIRD_PARTY_DIR}/benchmark

third-party/benchmark/.clang-format

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: Google
4+
PointerAlignment: Left
5+
...

third-party/benchmark/.clang-tidy

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
Checks: 'clang-analyzer-*,readability-redundant-*,performance-*'
3+
WarningsAsErrors: 'clang-analyzer-*,readability-redundant-*,performance-*'
4+
HeaderFilterRegex: '.*'
5+
AnalyzeTemporaryDtors: false
6+
FormatStyle: none
7+
User: user

third-party/benchmark/.travis.yml

+208
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
sudo: required
2+
dist: trusty
3+
language: cpp
4+
5+
matrix:
6+
include:
7+
- compiler: gcc
8+
addons:
9+
apt:
10+
packages:
11+
- lcov
12+
env: COMPILER=g++ C_COMPILER=gcc BUILD_TYPE=Coverage
13+
- compiler: gcc
14+
addons:
15+
apt:
16+
packages:
17+
- g++-multilib
18+
- libc6:i386
19+
env:
20+
- COMPILER=g++
21+
- C_COMPILER=gcc
22+
- BUILD_TYPE=Debug
23+
- BUILD_32_BITS=ON
24+
- EXTRA_FLAGS="-m32"
25+
- compiler: gcc
26+
addons:
27+
apt:
28+
packages:
29+
- g++-multilib
30+
- libc6:i386
31+
env:
32+
- COMPILER=g++
33+
- C_COMPILER=gcc
34+
- BUILD_TYPE=Release
35+
- BUILD_32_BITS=ON
36+
- EXTRA_FLAGS="-m32"
37+
- compiler: gcc
38+
env:
39+
- INSTALL_GCC6_FROM_PPA=1
40+
- COMPILER=g++-6 C_COMPILER=gcc-6 BUILD_TYPE=Debug
41+
- ENABLE_SANITIZER=1
42+
- EXTRA_FLAGS="-fno-omit-frame-pointer -g -O2 -fsanitize=undefined,address -fuse-ld=gold"
43+
# Clang w/ libc++
44+
- compiler: clang
45+
dist: xenial
46+
addons:
47+
apt:
48+
packages:
49+
clang-3.8
50+
env:
51+
- INSTALL_GCC6_FROM_PPA=1
52+
- COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Debug
53+
- LIBCXX_BUILD=1
54+
- EXTRA_CXX_FLAGS="-stdlib=libc++"
55+
- compiler: clang
56+
dist: xenial
57+
addons:
58+
apt:
59+
packages:
60+
clang-3.8
61+
env:
62+
- INSTALL_GCC6_FROM_PPA=1
63+
- COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Release
64+
- LIBCXX_BUILD=1
65+
- EXTRA_CXX_FLAGS="-stdlib=libc++"
66+
# Clang w/ 32bit libc++
67+
- compiler: clang
68+
dist: xenial
69+
addons:
70+
apt:
71+
packages:
72+
- clang-3.8
73+
- g++-multilib
74+
- libc6:i386
75+
env:
76+
- INSTALL_GCC6_FROM_PPA=1
77+
- COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Debug
78+
- LIBCXX_BUILD=1
79+
- BUILD_32_BITS=ON
80+
- EXTRA_FLAGS="-m32"
81+
- EXTRA_CXX_FLAGS="-stdlib=libc++"
82+
# Clang w/ 32bit libc++
83+
- compiler: clang
84+
dist: xenial
85+
addons:
86+
apt:
87+
packages:
88+
- clang-3.8
89+
- g++-multilib
90+
- libc6:i386
91+
env:
92+
- INSTALL_GCC6_FROM_PPA=1
93+
- COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Release
94+
- LIBCXX_BUILD=1
95+
- BUILD_32_BITS=ON
96+
- EXTRA_FLAGS="-m32"
97+
- EXTRA_CXX_FLAGS="-stdlib=libc++"
98+
# Clang w/ libc++, ASAN, UBSAN
99+
- compiler: clang
100+
dist: xenial
101+
addons:
102+
apt:
103+
packages:
104+
clang-3.8
105+
env:
106+
- INSTALL_GCC6_FROM_PPA=1
107+
- COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Debug
108+
- LIBCXX_BUILD=1 LIBCXX_SANITIZER="Undefined;Address"
109+
- ENABLE_SANITIZER=1
110+
- EXTRA_FLAGS="-g -O2 -fno-omit-frame-pointer -fsanitize=undefined,address -fno-sanitize-recover=all"
111+
- EXTRA_CXX_FLAGS="-stdlib=libc++"
112+
- UBSAN_OPTIONS=print_stacktrace=1
113+
# Clang w/ libc++ and MSAN
114+
- compiler: clang
115+
dist: xenial
116+
addons:
117+
apt:
118+
packages:
119+
clang-3.8
120+
env:
121+
- INSTALL_GCC6_FROM_PPA=1
122+
- COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Debug
123+
- LIBCXX_BUILD=1 LIBCXX_SANITIZER=MemoryWithOrigins
124+
- ENABLE_SANITIZER=1
125+
- EXTRA_FLAGS="-g -O2 -fno-omit-frame-pointer -fsanitize=memory -fsanitize-memory-track-origins"
126+
- EXTRA_CXX_FLAGS="-stdlib=libc++"
127+
# Clang w/ libc++ and MSAN
128+
- compiler: clang
129+
dist: xenial
130+
addons:
131+
apt:
132+
packages:
133+
clang-3.8
134+
env:
135+
- INSTALL_GCC6_FROM_PPA=1
136+
- COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=RelWithDebInfo
137+
- LIBCXX_BUILD=1 LIBCXX_SANITIZER=Thread
138+
- ENABLE_SANITIZER=1
139+
- EXTRA_FLAGS="-g -O2 -fno-omit-frame-pointer -fsanitize=thread -fno-sanitize-recover=all"
140+
- EXTRA_CXX_FLAGS="-stdlib=libc++"
141+
- os: osx
142+
osx_image: xcode8.3
143+
compiler: clang
144+
env:
145+
- COMPILER=clang++
146+
- BUILD_TYPE=Release
147+
- BUILD_32_BITS=ON
148+
- EXTRA_FLAGS="-m32"
149+
150+
before_script:
151+
- if [ -n "${LIBCXX_BUILD}" ]; then
152+
source .libcxx-setup.sh;
153+
fi
154+
- if [ -n "${ENABLE_SANITIZER}" ]; then
155+
export EXTRA_OPTIONS="-DBENCHMARK_ENABLE_ASSEMBLY_TESTS=OFF";
156+
else
157+
export EXTRA_OPTIONS="";
158+
fi
159+
- mkdir -p build && cd build
160+
161+
before_install:
162+
- if [ -z "$BUILD_32_BITS" ]; then
163+
export BUILD_32_BITS=OFF && echo disabling 32 bit build;
164+
fi
165+
- if [ -n "${INSTALL_GCC6_FROM_PPA}" ]; then
166+
sudo add-apt-repository -y "ppa:ubuntu-toolchain-r/test";
167+
sudo apt-get update --option Acquire::Retries=100 --option Acquire::http::Timeout="60";
168+
fi
169+
170+
install:
171+
- if [ -n "${INSTALL_GCC6_FROM_PPA}" ]; then
172+
travis_wait sudo -E apt-get -yq --no-install-suggests --no-install-recommends install g++-6;
173+
fi
174+
- if [ "${TRAVIS_OS_NAME}" == "linux" -a "${BUILD_32_BITS}" == "OFF" ]; then
175+
travis_wait sudo -E apt-get -y --no-install-suggests --no-install-recommends install llvm-3.9-tools;
176+
sudo cp /usr/lib/llvm-3.9/bin/FileCheck /usr/local/bin/;
177+
fi
178+
- if [ "${BUILD_TYPE}" == "Coverage" -a "${TRAVIS_OS_NAME}" == "linux" ]; then
179+
PATH=~/.local/bin:${PATH};
180+
pip install --user --upgrade pip;
181+
travis_wait pip install --user cpp-coveralls;
182+
fi
183+
- if [ "${C_COMPILER}" == "gcc-7" -a "${TRAVIS_OS_NAME}" == "osx" ]; then
184+
rm -f /usr/local/include/c++;
185+
brew update;
186+
travis_wait brew install gcc@7;
187+
fi
188+
- if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
189+
sudo apt-get update -qq;
190+
sudo apt-get install -qq unzip cmake3;
191+
wget https://github.com/bazelbuild/bazel/releases/download/3.2.0/bazel-3.2.0-installer-linux-x86_64.sh --output-document bazel-installer.sh;
192+
travis_wait sudo bash bazel-installer.sh;
193+
fi
194+
- if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
195+
curl -L -o bazel-installer.sh https://github.com/bazelbuild/bazel/releases/download/3.2.0/bazel-3.2.0-installer-darwin-x86_64.sh;
196+
travis_wait sudo bash bazel-installer.sh;
197+
fi
198+
199+
script:
200+
- cmake -DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${COMPILER} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_C_FLAGS="${EXTRA_FLAGS}" -DCMAKE_CXX_FLAGS="${EXTRA_FLAGS} ${EXTRA_CXX_FLAGS}" -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON -DBENCHMARK_BUILD_32_BITS=${BUILD_32_BITS} ${EXTRA_OPTIONS} ..
201+
- make
202+
- ctest -C ${BUILD_TYPE} --output-on-failure
203+
- bazel test -c dbg --define google_benchmark.have_regex=posix --announce_rc --verbose_failures --test_output=errors --keep_going //test/...
204+
205+
after_success:
206+
- if [ "${BUILD_TYPE}" == "Coverage" -a "${TRAVIS_OS_NAME}" == "linux" ]; then
207+
coveralls --include src --include include --gcov-options '\-lp' --root .. --build-root .;
208+
fi
+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import os
2+
import ycm_core
3+
4+
# These are the compilation flags that will be used in case there's no
5+
# compilation database set (by default, one is not set).
6+
# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.
7+
flags = [
8+
'-Wall',
9+
'-Werror',
10+
'-pedantic-errors',
11+
'-std=c++0x',
12+
'-fno-strict-aliasing',
13+
'-O3',
14+
'-DNDEBUG',
15+
# ...and the same thing goes for the magic -x option which specifies the
16+
# language that the files to be compiled are written in. This is mostly
17+
# relevant for c++ headers.
18+
# For a C project, you would set this to 'c' instead of 'c++'.
19+
'-x', 'c++',
20+
'-I', 'include',
21+
'-isystem', '/usr/include',
22+
'-isystem', '/usr/local/include',
23+
]
24+
25+
26+
# Set this to the absolute path to the folder (NOT the file!) containing the
27+
# compile_commands.json file to use that instead of 'flags'. See here for
28+
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
29+
#
30+
# Most projects will NOT need to set this to anything; you can just change the
31+
# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
32+
compilation_database_folder = ''
33+
34+
if os.path.exists( compilation_database_folder ):
35+
database = ycm_core.CompilationDatabase( compilation_database_folder )
36+
else:
37+
database = None
38+
39+
SOURCE_EXTENSIONS = [ '.cc' ]
40+
41+
def DirectoryOfThisScript():
42+
return os.path.dirname( os.path.abspath( __file__ ) )
43+
44+
45+
def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
46+
if not working_directory:
47+
return list( flags )
48+
new_flags = []
49+
make_next_absolute = False
50+
path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
51+
for flag in flags:
52+
new_flag = flag
53+
54+
if make_next_absolute:
55+
make_next_absolute = False
56+
if not flag.startswith( '/' ):
57+
new_flag = os.path.join( working_directory, flag )
58+
59+
for path_flag in path_flags:
60+
if flag == path_flag:
61+
make_next_absolute = True
62+
break
63+
64+
if flag.startswith( path_flag ):
65+
path = flag[ len( path_flag ): ]
66+
new_flag = path_flag + os.path.join( working_directory, path )
67+
break
68+
69+
if new_flag:
70+
new_flags.append( new_flag )
71+
return new_flags
72+
73+
74+
def IsHeaderFile( filename ):
75+
extension = os.path.splitext( filename )[ 1 ]
76+
return extension in [ '.h', '.hxx', '.hpp', '.hh' ]
77+
78+
79+
def GetCompilationInfoForFile( filename ):
80+
# The compilation_commands.json file generated by CMake does not have entries
81+
# for header files. So we do our best by asking the db for flags for a
82+
# corresponding source file, if any. If one exists, the flags for that file
83+
# should be good enough.
84+
if IsHeaderFile( filename ):
85+
basename = os.path.splitext( filename )[ 0 ]
86+
for extension in SOURCE_EXTENSIONS:
87+
replacement_file = basename + extension
88+
if os.path.exists( replacement_file ):
89+
compilation_info = database.GetCompilationInfoForFile(
90+
replacement_file )
91+
if compilation_info.compiler_flags_:
92+
return compilation_info
93+
return None
94+
return database.GetCompilationInfoForFile( filename )
95+
96+
97+
def FlagsForFile( filename, **kwargs ):
98+
if database:
99+
# Bear in mind that compilation_info.compiler_flags_ does NOT return a
100+
# python list, but a "list-like" StringVec object
101+
compilation_info = GetCompilationInfoForFile( filename )
102+
if not compilation_info:
103+
return None
104+
105+
final_flags = MakeRelativePathsInFlagsAbsolute(
106+
compilation_info.compiler_flags_,
107+
compilation_info.compiler_working_dir_ )
108+
else:
109+
relative_to = DirectoryOfThisScript()
110+
final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
111+
112+
return {
113+
'flags': final_flags,
114+
'do_cache': True
115+
}

third-party/benchmark/AUTHORS

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ David Coeurjolly <david.coeurjolly@liris.cnrs.fr>
2121
Deniz Evrenci <denizevrenci@gmail.com>
2222
Dirac Research
2323
Dominik Czarnota <dominik.b.czarnota@gmail.com>
24+
Dominik Korman <kormandominik@gmail.com>
25+
Donald Aingworth <donalds_junk_mail@yahoo.com>
2426
Eric Backus <eric_backus@alum.mit.edu>
2527
Eric Fiselier <eric@efcs.ca>
2628
Eugene Zhuk <eugene.zhuk@gmail.com>

third-party/benchmark/BUILD.bazel

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
load("@rules_cc//cc:defs.bzl", "cc_library")
2-
31
licenses(["notice"])
42

3+
config_setting(
4+
name = "qnx",
5+
constraint_values = ["@platforms//os:qnx"],
6+
values = {
7+
"cpu": "x64_qnx",
8+
},
9+
visibility = [":__subpackages__"],
10+
)
11+
512
config_setting(
613
name = "windows",
14+
constraint_values = ["@platforms//os:windows"],
715
values = {
816
"cpu": "x64_windows",
917
},

0 commit comments

Comments
 (0)