Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Finish cxx version bump #1948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 17, 2025
Merged

Conversation

LebedevRI
Copy link
Collaborator

@LebedevRI LebedevRI commented Mar 13, 2025

Fixes #1947.

835365f stopped defining it,
but didn't un-conditionalize the code guarded under it...
We no longer support such an old gcc version
@LebedevRI LebedevRI force-pushed the finish-cxx-version-bump branch 6 times, most recently from 05f6cc8 to ef1d99d Compare March 13, 2025 20:24
@LebedevRI LebedevRI requested a review from dmah42 March 13, 2025 20:33
#elif defined(__GNUC__) || defined(__clang__)
#define BENCHMARK_UNUSED __attribute__((unused))
#else
#define BENCHMARK_UNUSED
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this mean we only need C++11 to use the library?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No:

FAILED: test/CMakeFiles/cxx14_test.dir/cxx14_test.cc.o 
/usr/bin/c++ -DBENCHMARK_STATIC_DEFINE -DHAVE_POSIX_REGEX -DHAVE_PTHREAD_AFFINITY -DHAVE_STD_REGEX -DHAVE_STEADY_CLOCK -DTEST_BENCHMARK_LIBRARY_HAS_NO_ASSERTIONS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I/tmp/benchmark/include -pipe  -Wall  -Wextra  -Wshadow  -Wfloat-equal  -Wold-style-cast  -Wconversion  -Werror  -pedantic  -pedantic-errors  -fstrict-aliasing  -Wno-deprecated-declarations  -Wno-deprecated  -Wstrict-aliasing  -Wno-unused-variable -std=c++11 -fvisibility=hidden -fvisibility-inlines-hidden   -UNDEBUG -MD -MT test/CMakeFiles/cxx14_test.dir/cxx14_test.cc.o -MF test/CMakeFiles/cxx14_test.dir/cxx14_test.cc.o.d -o test/CMakeFiles/cxx14_test.dir/cxx14_test.cc.o -c /tmp/benchmark/test/cxx14_test.cc
In file included from /tmp/benchmark/test/cxx14_test.cc:1:
/tmp/benchmark/include/benchmark/benchmark.h: In function ‘benchmark::internal::Benchmark* benchmark::RegisterBenchmark(const std::string&, void (*)(State&))’:
/tmp/benchmark/include/benchmark/benchmark.h:1382:12: error: ‘make_unique’ is not a member of ‘std’
 1382 |       std::make_unique<internal::FunctionBenchmark>(name, fn));
      |            ^~~~~~~~~~~
/tmp/benchmark/include/benchmark/benchmark.h:1382:12: note: ‘std::make_unique’ is only available from C++14 onwards
/tmp/benchmark/include/benchmark/benchmark.h:1382:51: error: expected primary-expression before ‘>’ token
 1382 |       std::make_unique<internal::FunctionBenchmark>(name, fn));
      |                                                   ^
/tmp/benchmark/include/benchmark/benchmark.h:1382:53: error: left operand of comma operator has no effect [-Werror=unused-value]
 1382 |       std::make_unique<internal::FunctionBenchmark>(name, fn));
      |                                                     ^~~~
/tmp/benchmark/include/benchmark/benchmark.h: In function ‘benchmark::internal::Benchmark* benchmark::RegisterBenchmark(const std::string&, Lambda&&)’:
/tmp/benchmark/include/benchmark/benchmark.h:1390:12: error: ‘make_unique’ is not a member of ‘std’
 1390 |       std::make_unique<BenchType>(name, std::forward<Lambda>(fn)));
      |            ^~~~~~~~~~~
/tmp/benchmark/include/benchmark/benchmark.h:1390:12: note: ‘std::make_unique’ is only available from C++14 onwards
/tmp/benchmark/include/benchmark/benchmark.h:1390:33: error: expected primary-expression before ‘>’ token
 1390 |       std::make_unique<BenchType>(name, std::forward<Lambda>(fn)));
      |                                 ^

Do we want to keep C++11 support?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no we don't need C++11 support any more.

dmah42
dmah42 previously approved these changes Mar 14, 2025
Copy link
Member

@dmah42 dmah42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you so much for finishing this off!

@LebedevRI LebedevRI force-pushed the finish-cxx-version-bump branch from ef1d99d to e68c05e Compare March 14, 2025 18:22
@LebedevRI LebedevRI requested a review from dmah42 March 14, 2025 18:22
@LebedevRI LebedevRI force-pushed the finish-cxx-version-bump branch 7 times, most recently from 213749b to 2ab99c8 Compare March 14, 2025 19:54
I don't think we want to support C++03 though,
but i suppose C++11 is palatable, at least right now.
@LebedevRI LebedevRI force-pushed the finish-cxx-version-bump branch from 2ab99c8 to 80673cc Compare March 16, 2025 00:45
@dmah42 dmah42 merged commit 1bc59dc into google:main Mar 17, 2025
86 checks passed
@LebedevRI LebedevRI deleted the finish-cxx-version-bump branch March 17, 2025 15:43
@LebedevRI
Copy link
Collaborator Author

@dmah42 thank you!

@pitrou
Copy link

pitrou commented Mar 26, 2025

Hello,

The ::benchmark::internal::make_unique hackery here seems to have broken the Apache Arrow benchmark suite.

We have benchmark functions with the same name as functions in our public API. For example:

static void ExportType(benchmark::State& state) {  // NOLINT non-const reference
  struct ArrowSchema c_export;
  auto type = utf8();

  for (auto _ : state) {
    ABORT_NOT_OK(ExportType(*type, &c_export));
    ArrowSchemaRelease(&c_export);
  }
  state.SetItemsProcessed(state.iterations());
}

With these changes, it appears that the make_unique invocation can't resolve the type of its argument.

/var/lib/buildkite-agent/builds/amd64-c6a-4xlarge-linux-i-07da8a39d33d00b77-1/apache-arrow/arrow-bci-benchmark-on-amd64-c6a-4xlarge-linux/arrow/cpp/src/arrow/c/bridge_benchmark.cc:149:1: error: no matching function for call to 'make_unique<benchmark::internal::FunctionBenchmark>(const char [11], <unresolved overloaded function type>)'
  149 | BENCHMARK(ExportType);
      | ^~~~~~~~~
In file included from /var/lib/buildkite-agent/.conda/envs/arrow-commit/lib/gcc/x86_64-conda-linux-gnu/13.3.0/include/c++/memory:78,
                 from /var/lib/buildkite-agent/.conda/envs/arrow-commit/include/benchmark/benchmark.h:177:
/var/lib/buildkite-agent/.conda/envs/arrow-commit/lib/gcc/x86_64-conda-linux-gnu/13.3.0/include/c++/bits/unique_ptr.h:1094:5: note: candidate: 'template<class _Tp, class ... _Args> std::__detail::__invalid_make_unique_t<_Tp> std::make_unique(_Args&& ...)' (deleted)
 1094 |     make_unique(_Args&&...) = delete;
      |     ^~~~~~~~~~~
/var/lib/buildkite-agent/.conda/envs/arrow-commit/lib/gcc/x86_64-conda-linux-gnu/13.3.0/include/c++/bits/unique_ptr.h:1094:5: note:   template argument deduction/substitution failed:
/var/lib/buildkite-agent/.conda/envs/arrow-commit/lib/gcc/x86_64-conda-linux-gnu/13.3.0/include/c++/bits/unique_ptr.h: In substitution of 'template<class _Tp> using std::__detail::__invalid_make_unique_t = typename std::__detail::_MakeUniq::__invalid_type [with _Tp = benchmark::internal::FunctionBenchmark]':
/var/lib/buildkite-agent/.conda/envs/arrow-commit/lib/gcc/x86_64-conda-linux-gnu/13.3.0/include/c++/bits/unique_ptr.h:1094:5:   required by substitution of 'template<class _Tp, class ... _Args> std::__detail::__invalid_make_unique_t<_Tp> std::make_unique(_Args&& ...) [with _Tp = benchmark::internal::FunctionBenchmark; _Args = <missing>]'
/var/lib/buildkite-agent/builds/amd64-c6a-4xlarge-linux-i-07da8a39d33d00b77-1/apache-arrow/arrow-bci-benchmark-on-amd64-c6a-4xlarge-linux/arrow/cpp/src/arrow/c/bridge_benchmark.cc:149:1:   required from here
/var/lib/buildkite-agent/.conda/envs/arrow-commit/lib/gcc/x86_64-conda-linux-gnu/13.3.0/include/c++/bits/unique_ptr.h:1055:11: error: no type named '__invalid_type' in 'struct std::__detail::_MakeUniq<benchmark::internal::FunctionBenchmark>'
 1055 |     using __invalid_make_unique_t = typename _MakeUniq<_Tp>::__invalid_type;
      |           ^~~~~~~~~~~~~~~~~~~~~~~
/var/lib/buildkite-agent/.conda/envs/arrow-commit/lib/gcc/x86_64-conda-linux-gnu/13.3.0/include/c++/bits/unique_ptr.h:1084:5: note: candidate: 'template<class _Tp> std::__detail::__unique_ptr_array_t<_Tp> std::make_unique(size_t)'
 1084 |     make_unique(size_t __num)
      |     ^~~~~~~~~~~
/var/lib/buildkite-agent/.conda/envs/arrow-commit/lib/gcc/x86_64-conda-linux-gnu/13.3.0/include/c++/bits/unique_ptr.h:1084:5: note:   candidate expects 1 argument, 2 provided
/var/lib/buildkite-agent/.conda/envs/arrow-commit/lib/gcc/x86_64-conda-linux-gnu/13.3.0/include/c++/bits/unique_ptr.h:1069:5: note: candidate: 'std::__detail::__unique_ptr_t<_Tp> std::make_unique(_Args&& ...) [with _Tp = benchmark::internal::FunctionBenchmark; _Args = {}; __detail::__unique_ptr_t<_Tp> = __detail::__unique_ptr_t<benchmark::internal::FunctionBenchmark>]'
 1069 |     make_unique(_Args&&... __args)
      |     ^~~~~~~~~~~
/var/lib/buildkite-agent/.conda/envs/arrow-commit/lib/gcc/x86_64-conda-linux-gnu/13.3.0/include/c++/bits/unique_ptr.h:1069:5: note:   candidate expects 0 arguments, 2 provided

(see full error log at https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-amd64-c6a-4xlarge-linux/builds/932#0195d16c-04e9-4bb2-9cfd-4ec078cf7570/95-1582)

@dmah42
Copy link
Member

dmah42 commented Mar 26, 2025

Hello,

The ::benchmark::internal::make_unique hackery here seems to have broken the Apache Arrow benchmark suite.

We have benchmark functions with the same name as functions in our public API. For example:

static void ExportType(benchmark::State& state) {  // NOLINT non-const reference
  struct ArrowSchema c_export;
  auto type = utf8();

  for (auto _ : state) {
    ABORT_NOT_OK(ExportType(*type, &c_export));
    ArrowSchemaRelease(&c_export);
  }
  state.SetItemsProcessed(state.iterations());
}

With these changes, it appears that the make_unique invocation can't resolve the type of its argument.

/var/lib/buildkite-agent/builds/amd64-c6a-4xlarge-linux-i-07da8a39d33d00b77-1/apache-arrow/arrow-bci-benchmark-on-amd64-c6a-4xlarge-linux/arrow/cpp/src/arrow/c/bridge_benchmark.cc:149:1: error: no matching function for call to 'make_unique<benchmark::internal::FunctionBenchmark>(const char [11], <unresolved overloaded function type>)'
  149 | BENCHMARK(ExportType);
      | ^~~~~~~~~
In file included from /var/lib/buildkite-agent/.conda/envs/arrow-commit/lib/gcc/x86_64-conda-linux-gnu/13.3.0/include/c++/memory:78,
                 from /var/lib/buildkite-agent/.conda/envs/arrow-commit/include/benchmark/benchmark.h:177:
/var/lib/buildkite-agent/.conda/envs/arrow-commit/lib/gcc/x86_64-conda-linux-gnu/13.3.0/include/c++/bits/unique_ptr.h:1094:5: note: candidate: 'template<class _Tp, class ... _Args> std::__detail::__invalid_make_unique_t<_Tp> std::make_unique(_Args&& ...)' (deleted)
 1094 |     make_unique(_Args&&...) = delete;
      |     ^~~~~~~~~~~
/var/lib/buildkite-agent/.conda/envs/arrow-commit/lib/gcc/x86_64-conda-linux-gnu/13.3.0/include/c++/bits/unique_ptr.h:1094:5: note:   template argument deduction/substitution failed:
/var/lib/buildkite-agent/.conda/envs/arrow-commit/lib/gcc/x86_64-conda-linux-gnu/13.3.0/include/c++/bits/unique_ptr.h: In substitution of 'template<class _Tp> using std::__detail::__invalid_make_unique_t = typename std::__detail::_MakeUniq::__invalid_type [with _Tp = benchmark::internal::FunctionBenchmark]':
/var/lib/buildkite-agent/.conda/envs/arrow-commit/lib/gcc/x86_64-conda-linux-gnu/13.3.0/include/c++/bits/unique_ptr.h:1094:5:   required by substitution of 'template<class _Tp, class ... _Args> std::__detail::__invalid_make_unique_t<_Tp> std::make_unique(_Args&& ...) [with _Tp = benchmark::internal::FunctionBenchmark; _Args = <missing>]'
/var/lib/buildkite-agent/builds/amd64-c6a-4xlarge-linux-i-07da8a39d33d00b77-1/apache-arrow/arrow-bci-benchmark-on-amd64-c6a-4xlarge-linux/arrow/cpp/src/arrow/c/bridge_benchmark.cc:149:1:   required from here
/var/lib/buildkite-agent/.conda/envs/arrow-commit/lib/gcc/x86_64-conda-linux-gnu/13.3.0/include/c++/bits/unique_ptr.h:1055:11: error: no type named '__invalid_type' in 'struct std::__detail::_MakeUniq<benchmark::internal::FunctionBenchmark>'
 1055 |     using __invalid_make_unique_t = typename _MakeUniq<_Tp>::__invalid_type;
      |           ^~~~~~~~~~~~~~~~~~~~~~~
/var/lib/buildkite-agent/.conda/envs/arrow-commit/lib/gcc/x86_64-conda-linux-gnu/13.3.0/include/c++/bits/unique_ptr.h:1084:5: note: candidate: 'template<class _Tp> std::__detail::__unique_ptr_array_t<_Tp> std::make_unique(size_t)'
 1084 |     make_unique(size_t __num)
      |     ^~~~~~~~~~~
/var/lib/buildkite-agent/.conda/envs/arrow-commit/lib/gcc/x86_64-conda-linux-gnu/13.3.0/include/c++/bits/unique_ptr.h:1084:5: note:   candidate expects 1 argument, 2 provided
/var/lib/buildkite-agent/.conda/envs/arrow-commit/lib/gcc/x86_64-conda-linux-gnu/13.3.0/include/c++/bits/unique_ptr.h:1069:5: note: candidate: 'std::__detail::__unique_ptr_t<_Tp> std::make_unique(_Args&& ...) [with _Tp = benchmark::internal::FunctionBenchmark; _Args = {}; __detail::__unique_ptr_t<_Tp> = __detail::__unique_ptr_t<benchmark::internal::FunctionBenchmark>]'
 1069 |     make_unique(_Args&&... __args)
      |     ^~~~~~~~~~~
/var/lib/buildkite-agent/.conda/envs/arrow-commit/lib/gcc/x86_64-conda-linux-gnu/13.3.0/include/c++/bits/unique_ptr.h:1069:5: note:   candidate expects 0 arguments, 2 provided

(see full error log at https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-amd64-c6a-4xlarge-linux/builds/932#0195d16c-04e9-4bb2-9cfd-4ec078cf7570/95-1582)

if you rename the benchmark function to something like ExportTypeBM, does the build then succeed?

@pitrou
Copy link

pitrou commented Mar 26, 2025

if you rename the benchmark function to something like ExportTypeBM, does the build then succeed?

Yes, it does, but we don't want to do that: it would break benchmark history. Instead I've opted to put the benchmark functions in a dedicated namespace.

@dmah42
Copy link
Member

dmah42 commented Mar 26, 2025

ah ok .. so it wouldn't help if we prepended something to the benchmark name within the library. adding them to a namespace, even an unnamed one, works i guess because of name resolution rules. i'm a bit surprised it didn't work anyway, given the locality of the benchmark function, but there is ambiguity.

Comment on lines 1464 to +1469
#define BENCHMARK(...) \
BENCHMARK_PRIVATE_DECLARE(_benchmark_) = \
(::benchmark::internal::RegisterBenchmarkInternal( \
std::make_unique<::benchmark::internal::FunctionBenchmark>( \
#__VA_ARGS__, __VA_ARGS__)))
benchmark::internal::make_unique< \
::benchmark::internal::FunctionBenchmark>(#__VA_ARGS__, \
__VA_ARGS__)))
Copy link

@pitrou pitrou Mar 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a bug here: the macros should call ::benchmark::internal::make_unique not benchmark::internal::make_unique.

We're now getting compilation failures because of this, example:

/var/lib/buildkite-agent/builds/amd64-c6a-4xlarge-linux-i-0a326a82268fb1cf0-1/apache-arrow/arrow-bci-benchmark-on-amd64-c6a-4xlarge-linux/arrow/cpp/src/parquet/page_index_benchmark.cc:60:1: error: 'parquet::benchmark::internal' has not been declared
   60 | BENCHMARK(BM_ReadOffsetIndex)->Apply(PageIndexSetArgs);
      | ^~~~~~~~~

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I filed #1959 for this

@pitrou
Copy link

pitrou commented Mar 26, 2025

Oh, and we're getting yet another build regression on macOS with this kind of benchmark declaration:

template <typename InListType = ListType>
static void ListSliceInt64List(benchmark::State& state) {
  ListSliceOptions opts;
  opts.start = kSliceStart;
  BenchmarkListSlice(state, opts, std::make_shared<InListType>(int64()));
}

BENCHMARK(ListSliceInt64List)->Apply(RegressionSetArgs);

Error message:

/opt/homebrew/var/buildkite-agent/builds/test-mac-arm/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/arrow/cpp/src/arrow/compute/kernels/scalar_list_benchmark.cc:136:1: error: no matching function for call to 'make_unique'
  136 | BENCHMARK(ListSliceInt64List)->Apply(RegressionSetArgs);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/voltrondata/miniconda3/envs/arrow-commit/include/benchmark/benchmark.h:1467:11: note: expanded from macro 'BENCHMARK'
 1467 |           benchmark::internal::make_unique<                           \
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1468 |               ::benchmark::internal::FunctionBenchmark>(#__VA_ARGS__, \
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/voltrondata/miniconda3/envs/arrow-commit/bin/../include/c++/v1/__memory/unique_ptr.h:596:1: note: candidate template ignored: substitution failure [with _Tp = ::benchmark::internal::FunctionBenchmark]: deduced incomplete pack <const char (&)[19], (no value)> for template parameter '_Args'
  594 | template <class _Tp, class... _Args>
      |                               ~~~~~
  595 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_single
  596 | make_unique(_Args&&... __args) {
      | ^
/Users/voltrondata/miniconda3/envs/arrow-commit/bin/../include/c++/v1/__memory/unique_ptr.h:602:1: note: candidate function not viable: requires single argument '__n', but 2 arguments were provided
  602 | make_unique(size_t __n) {
      | ^           ~~~~~~~~~~
/Users/voltrondata/miniconda3/envs/arrow-commit/bin/../include/c++/v1/__memory/unique_ptr.h:608:55: note: candidate template ignored: substitution failure [with _Tp = ::benchmark::internal::FunctionBenchmark]: no type named '__unique_array_known_bound' in 'std::__unique_if<benchmark::internal::FunctionBenchmark>'
  608 | typename __unique_if<_Tp>::__unique_array_known_bound make_unique(_Args&&...) = delete;
      | ~~~~~~~~                                              ^

Full log at https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/6691#0195d221-7885-41a8-a884-e29c3dfdb219/34-1279

pitrou added a commit to apache/arrow that referenced this pull request Mar 26, 2025
### Rationale for this change

Benchmarks fail compiling with Google Benchmark 1.9.2. The errors seem triggered by this change upstream: google/benchmark#1948

### What changes are included in this PR?

* Move some benchmark functions to a dedicated namespace so that there is no ambiguity with other functions
* Reduce reliance on templating in benchmark functions to avoid resolution ambiguities
* Other required fixes

Note that we don't rename the benchmark functions, to avoid breaking continuous benchmarking history.

### Are these changes tested?

By continuous benchmarking.

### Are there any user-facing changes?

No.
* GitHub Issue: #45939

Authored-by: Antoine Pitrou <[email protected]>
Signed-off-by: Antoine Pitrou <[email protected]>
zanmato1984 pushed a commit to zanmato1984/arrow that referenced this pull request Apr 15, 2025
…45942)

### Rationale for this change

Benchmarks fail compiling with Google Benchmark 1.9.2. The errors seem triggered by this change upstream: google/benchmark#1948

### What changes are included in this PR?

* Move some benchmark functions to a dedicated namespace so that there is no ambiguity with other functions
* Reduce reliance on templating in benchmark functions to avoid resolution ambiguities
* Other required fixes

Note that we don't rename the benchmark functions, to avoid breaking continuous benchmarking history.

### Are these changes tested?

By continuous benchmarking.

### Are there any user-facing changes?

No.
* GitHub Issue: apache#45939

Authored-by: Antoine Pitrou <[email protected]>
Signed-off-by: Antoine Pitrou <[email protected]>
zanmato1984 pushed a commit to zanmato1984/arrow that referenced this pull request Apr 15, 2025
…45942)

### Rationale for this change

Benchmarks fail compiling with Google Benchmark 1.9.2. The errors seem triggered by this change upstream: google/benchmark#1948

### What changes are included in this PR?

* Move some benchmark functions to a dedicated namespace so that there is no ambiguity with other functions
* Reduce reliance on templating in benchmark functions to avoid resolution ambiguities
* Other required fixes

Note that we don't rename the benchmark functions, to avoid breaking continuous benchmarking history.

### Are these changes tested?

By continuous benchmarking.

### Are there any user-facing changes?

No.
* GitHub Issue: apache#45939

Authored-by: Antoine Pitrou <[email protected]>
Signed-off-by: Antoine Pitrou <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] c++17 is required instead of c++14 (as in the document)
4 participants