google / tcmalloc

Apache License 2.0
4.42k stars 480 forks source link

build tcmalloc failed #258

Closed 396848385 closed 2 months ago

396848385 commented 3 months ago

Compared to tcmalloc in gperftools, Google/tcmalloc is really difficult to compile.This issue can also be seen in the Issues from different people. Can you help me solve the compilation problem in the picture. Bazel version 6.1.0. gcc/g++ version 9.3.1.

396848385 commented 3 months ago

tcmalloc

lano1106 commented 3 months ago

you need a compiler supporting C++17... Unless you provide an env variable that adds its own switches to the compiler,

bazel build files sets the switch -std=c++17

in your setup, you can see that you have 'std=c++0x' this is what is causing the error.

yes, there is a big learning curve coming with bazel but once you have a working setup, it is pretty cool...

try to add a copt switch to your bazel build cmdline: bazel build --copt "-std=c++17" your_target

https://github.com/google/tcmalloc/blob/master/docs/platforms.md

396848385 commented 3 months ago

I still get the same error when compiling with gcc11.2.1 and g++11.2.1

------------------ 原始邮件 ------------------ 发件人: "google/tcmalloc" @.>; 发送时间: 2024年8月22日(星期四) 晚上9:34 @.>; @.**@.>; 主题: Re: [google/tcmalloc] build tcmalloc failed (Issue #258)

you need a compiler supporting C++14... Unless you provide an env variable that adds its own switches to the compiler,

bazel build files sets the switch -std=c++14

in your setup, you can see that you have 'std=c++0x' this is what is causing the error.

yes, there is a big learning curve coming with bazel but once you have a working setup, it is pretty cool...

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

396848385 commented 3 months ago

I enabled gcc11 and g++11 in this way(scl enable devtoolset-11 bash), but it seems that absl did not perceive gcc11 and g++11 when compiling 

------------------ 原始邮件 ------------------ 发件人: "google/tcmalloc" @.>; 发送时间: 2024年8月22日(星期四) 晚上9:34 @.>; @.**@.>; 主题: Re: [google/tcmalloc] build tcmalloc failed (Issue #258)

you need a compiler supporting C++14... Unless you provide an env variable that adds its own switches to the compiler,

bazel build files sets the switch -std=c++14

in your setup, you can see that you have 'std=c++0x' this is what is causing the error.

yes, there is a big learning curve coming with bazel but once you have a working setup, it is pretty cool...

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

396848385 commented 3 months ago

I have specified the CC as the version path for gcc10, but the compilation still reports the same error. I feel that __cplusplus is still incorrect tcmalloc

396848385 commented 3 months ago

@lano1106

ckennelly commented 2 months ago

This isn't strictly a problem of compiler version, it's just that the code needs to be compiled for C++17 or newer (for TCMalloc). Abseil, one of our dependencies, requires C++14 or newer, which is where the error is coming from.