[SERVER-47679] Silence build warnings from tcmalloc aliases Created: 21/Apr/20  Updated: 29/Oct/23  Resolved: 05/May/20

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 4.7.0

Type: Bug Priority: Minor - P4
Reporter: Billy Donahue Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Service arch 2020-05-04
Participants:

 Description   

tcmalloc is sloppy with function aliases, and it emits warnings during a normal build of mongod with the flags we give it from scons. We can specify "-Wno-attribute-alias" to shut the warnings up.

[353/3950] Compiling build/dynamic_gcc_ninja/third_party/gperftools-2.7/dist/src/tcmalloc.dyn.o
src/third_party/gperftools-2.7/dist/src/tcmalloc.cc:2128:36: warning: ‘void tc_delete_aligned_nothrow(void*, std::align_val_t, const std::nothrow_t&)’ alias between functions of incompatible types ‘void(void*, std::align_val_t, const std::nothrow_t&)’ and ‘void(void*)’ [-Wattribute-alias]
 extern "C" PERFTOOLS_DLL_DECL void tc_delete_aligned_nothrow(void* p, std::align_val_t, const std::nothrow_t&) PERFTOOLS_NOTHROW
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~
src/third_party/gperftools-2.7/dist/src/tcmalloc.cc:2014:36: note: aliased declaration here
 extern "C" PERFTOOLS_DLL_DECL void tc_delete(void* p) PERFTOOLS_NOTHROW
                                    ^~~~~~~~~
src/third_party/gperftools-2.7/dist/src/tcmalloc.cc:2119:36: warning: ‘void tc_delete_sized_aligned(void*, size_t, std::align_val_t)’ alias between functions of incompatible types ‘void(void*, size_t, std::align_val_t)’ {aka ‘void(void*, long unsigned int, std::align_val_t)’} and ‘void(void*)’ [-Wattribute-alias]
 extern "C" PERFTOOLS_DLL_DECL void tc_delete_sized_aligned(void* p, size_t size, std::align_val_t align) PERFTOOLS_NOTHROW
                                    ^~~~~~~~~~~~~~~~~~~~~~~
src/third_party/gperftools-2.7/dist/src/tcmalloc.cc:2014:36: note: aliased declaration here
 extern "C" PERFTOOLS_DLL_DECL void tc_delete(void* p) PERFTOOLS_NOTHROW
                                    ^~~~~~~~~
src/third_party/gperftools-2.7/dist/src/tcmalloc.cc:2108:36: warning: ‘void tc_delete_aligned(void*, std::align_val_t)’ alias between functions of incompatible types ‘void(void*, std::align_val_t)’ and ‘void(void*)’ [-Wattribute-alias]
 extern "C" PERFTOOLS_DLL_DECL void tc_delete_aligned(void* p, std::align_val_t) PERFTOOLS_NOTHROW
                                    ^~~~~~~~~~~~~~~~~
src/third_party/gperftools-2.7/dist/src/tcmalloc.cc:2014:36: note: aliased declaration here
 extern "C" PERFTOOLS_DLL_DECL void tc_delete(void* p) PERFTOOLS_NOTHROW
                                    ^~~~~~~~~
src/third_party/gperftools-2.7/dist/src/tcmalloc.cc:2026:36: warning: ‘void tc_delete_nothrow(void*, const std::nothrow_t&)’ alias between functions of incompatible types ‘void(void*, const std::nothrow_t&)’ and ‘void(void*)’ [-Wattribute-alias]
 extern "C" PERFTOOLS_DLL_DECL void tc_delete_nothrow(void* p, const std::nothrow_t&) PERFTOOLS_NOTHROW
                                    ^~~~~~~~~~~~~~~~~
src/third_party/gperftools-2.7/dist/src/tcmalloc.cc:1923:6: note: aliased declaration here
 void tc_free(void* ptr) PERFTOOLS_NOTHROW {
      ^~~~~~~



 Comments   
Comment by Githook User [ 05/May/20 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-47679 -Wno-attribute-alias is only supported on gcc
Branch: master
https://github.com/mongodb/mongo/commit/2e742a4fccf961395cddaeae9a4243fd487322ee

Comment by Billy Donahue [ 04/May/20 ]

I think we should just have no -Wno-attribute-alias for Clang.
The aliasing doesn't seem to be something Clang warns about.
https://gcc.godbolt.org/z/CX-HAr

Comment by Daniel Gottlieb (Inactive) [ 04/May/20 ]

Not sure if it's because I just pulled, or because I updated my toolchain, but with clang I'm getting:

warning: unknown warning option '-Wno-attribute-alias'; did you mean '-Wno-attributes'? [-Wunknown-warning-option]
1 warning generated.

I don't see the same with gcc. billy.donahue is clang's suggestion the appropriate substitute?

Comment by Githook User [ 27/Apr/20 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-47679 silence tcmalloc compiler warning
Branch: master
https://github.com/mongodb/mongo/commit/39c32e118eb6a41deee412520ae53ce60b5d2751

Comment by Billy Donahue [ 26/Apr/20 ]

http://mongodbcr.appspot.com/579160001

Generated at Thu Feb 08 05:14:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.