google / tcmalloc

Apache License 2.0
4.41k stars 480 forks source link

Compilation Error with tcmalloc: ‘static constexpr bool absl::lts_20230125::base_internal::SpinLock::IsCooperative’ is private within this context #235

Closed eholmes-see closed 5 months ago

eholmes-see commented 6 months ago

I’m encountering a compilation error when trying to build tcmalloc in a Bazel workspace. I’m using the latest versions of tcmalloc, absl, and rules_fuzzing.

Here’s the command I’m running:

bazel build --cxxopt='-std=c++17' //subprojects:tcmalloc

And here’s the error message I’m receiving:

ERROR:

In file included from external/com_google_tcmalloc/tcmalloc/internal/allocation_guard.cc:15:
external/com_google_tcmalloc/tcmalloc/internal/allocation_guard.h: In constructor 'tcmalloc::tcmalloc_internal::AllocationGuardSpinLockHolder::AllocationGuardSpinLockHolder(absl::lts_20230125::base_internal::SpinLock*)':
external/com_google_tcmalloc/tcmalloc/internal/allocation_guard.h:39:12: error: 'static constexpr bool absl::lts_20230125::base_internal::SpinLock::IsCooperative(absl::lts_20230125::base_internal::SchedulingMode)' is private within this context
   39 |     if (l->IsCooperative()) {
      |            ^~~~~~~~~~~~~
In file included from external/com_google_tcmalloc/tcmalloc/internal/allocation_guard.h:19,
                 from external/com_google_tcmalloc/tcmalloc/internal/allocation_guard.cc:15:
external/com_google_absl/absl/base/internal/spinlock.h:169:25: note: declared private here
  169 |   static constexpr bool IsCooperative(
      |                         ^~~~~~~~~~~~~
In file included from external/com_google_tcmalloc/tcmalloc/internal/allocation_guard.cc:15:
external/com_google_tcmalloc/tcmalloc/internal/allocation_guard.h:39:26: error: no matching function for call to 'absl::lts_20230125::base_internal::SpinLock::IsCooperative()'
   39 |     if (l->IsCooperative()) {
      |                          ^
In file included from external/com_google_tcmalloc/tcmalloc/internal/allocation_guard.h:19,
                 from external/com_google_tcmalloc/tcmalloc/internal/allocation_guard.cc:15:
external/com_google_absl/absl/base/internal/spinlock.h:169:25: note: candidate: 'static constexpr bool absl::lts_20230125::base_internal::SpinLock::IsCooperative(absl::lts_20230125::base_internal::SchedulingMode)'
  169 |   static constexpr bool IsCooperative(
      |                         ^~~~~~~~~~~~~
external/com_google_absl/absl/base/internal/spinlock.h:169:25: note:   candidate expects 1 argument, 0 provided
Target @@com_google_tcmalloc//tcmalloc:tcmalloc failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.910s, Critical Path: 0.41s
INFO: 14 processes: 14 internal.
ERROR: Build did NOT complete successfully

Any help would be greatly appreciated!

ckennelly commented 6 months ago

You might need a later release of Abseil, which contains https://github.com/abseil/abseil-cpp/commit/133360ca449bb2a44899e71f253856dca8443bdb.

It looks like it is in 20240116.2, but based on your build failure, you're using the 20230125 release which is nearly a year older.