drop weakening from cmake build

Weakening is optional and in github issue #1392 we apparently tried to
weaken on windows and failed. So lets not even try.
This commit is contained in:
Aliaksey Kandratsenka 2023-07-03 13:02:59 -04:00
parent 44eb0ee83c
commit cc4e289a83
2 changed files with 0 additions and 77 deletions

View File

@ -59,7 +59,6 @@ include(GNUInstallDirs)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(DefineTargetVariables)
include(FindObjcopyWithWeaken)
include(PCFromUContext)
define_target_variables()
@ -156,9 +155,6 @@ endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
# Check if we have an objcopy installed that supports -W
find_objcopy_with_weaken()
# AX_C___ATTRIBUTE__
check_c_source_compiles("#include <stdlib.h>
static void foo(void) __attribute__ ((unused));
@ -762,7 +758,6 @@ endif()
set_target_properties(tcmalloc_minimal PROPERTIES
VERSION ${TCMALLOC_SO_VERSION}
SOVERSION ${TCMALLOC_SO_VERSION})
weaken_object(tcmalloc_minimal)
install(TARGETS tcmalloc_minimal)
if(GPERFTOOLS_BUILD_STATIC)
add_library(tcmalloc_minimal_static STATIC ${libtcmalloc_minimal_internal_la_SOURCES})
@ -775,7 +770,6 @@ if(GPERFTOOLS_BUILD_STATIC)
set_target_properties(tcmalloc_minimal_static PROPERTIES
OUTPUT_NAME tcmalloc_minimal)
endif()
weaken_object(tcmalloc_minimal_static)
install(TARGETS tcmalloc_minimal_static)
endif()
@ -937,7 +931,6 @@ if(GPERFTOOLS_BUILD_DEBUGALLOC)
target_compile_definitions(tcmalloc_minimal_debug PRIVATE ${libtcmalloc_minimal_la_DEFINES}
TCMALLOC_FOR_DEBUGALLOCATION)
target_link_libraries(tcmalloc_minimal_debug PRIVATE ${libtcmalloc_minimal_la_LIBADD})
weaken_object(tcmalloc_minimal_debug)
install(TARGETS tcmalloc_minimal_debug)
set_target_properties(tcmalloc_minimal_debug PROPERTIES
VERSION ${TCMALLOC_SO_VERSION}
@ -951,7 +944,6 @@ if(GPERFTOOLS_BUILD_DEBUGALLOC)
OUTPUT_NAME tcmalloc_minimal_debug)
endif()
target_link_libraries(tcmalloc_minimal_debug_static PRIVATE ${libtcmalloc_minimal_la_LIBADD})
weaken_object(tcmalloc_minimal_debug_static)
install(TARGETS tcmalloc_minimal_debug_static)
endif()
@ -1093,7 +1085,6 @@ if(GPERFTOOLS_BUILD_HEAP_CHECKER OR GPERFTOOLS_BUILD_HEAP_PROFILER)
set_target_properties(tcmalloc PROPERTIES
VERSION ${TCMALLOC_SO_VERSION}
SOVERSION ${TCMALLOC_SO_VERSION})
weaken_object(tcmalloc)
install(TARGETS tcmalloc)
if(GPERFTOOLS_BUILD_STATIC)
add_library(tcmalloc_static STATIC ${libtcmalloc_la_SOURCES})
@ -1102,7 +1093,6 @@ if(GPERFTOOLS_BUILD_HEAP_CHECKER OR GPERFTOOLS_BUILD_HEAP_PROFILER)
set_target_properties(tcmalloc_static PROPERTIES OUTPUT_NAME tcmalloc)
endif()
target_link_libraries(tcmalloc_static PRIVATE ${libtcmalloc_la_LIBADD})
weaken_object(tcmalloc_static)
install(TARGETS tcmalloc_static)
endif()
@ -1220,7 +1210,6 @@ if(GPERFTOOLS_BUILD_DEBUGALLOC)
set_target_properties(tcmalloc_debug PROPERTIES
VERSION ${TCMALLOC_SO_VERSION}
SOVERSION ${TCMALLOC_SO_VERSION})
weaken_object(tcmalloc_debug)
install(TARGETS tcmalloc_debug)
if(GPERFTOOLS_BUILD_STATIC)
add_library(tcmalloc_debug_static STATIC src/debugallocation.cc ${HEAP_CHECKER_SOURCES} ${TCMALLOC_INCLUDES})
@ -1231,7 +1220,6 @@ if(GPERFTOOLS_BUILD_DEBUGALLOC)
set_target_properties(tcmalloc_debug_static PROPERTIES
OUTPUT_NAME tcmalloc_debug)
endif()
weaken_object(tcmalloc_debug_static)
install(TARGETS tcmalloc_debug_static)
endif()
@ -1369,7 +1357,6 @@ if(GPERFTOOLS_BUILD_HEAP_PROFILER OR GPERFTOOLS_BUILD_HEAP_CHECKER)
# libstacktrace.la, which we already get via libtcmalloc. Trying to
# specify it twice causes link-time duplicate-definition errors. :-(
target_link_libraries(tcmalloc_and_profiler PRIVATE ${libtcmalloc_la_LIBADD})
weaken_object(tcmalloc_and_profiler)
install(TARGETS tcmalloc_and_profiler)
if(GPERFTOOLS_BUILD_STATIC)
add_library(tcmalloc_and_profiler_static STATIC ${libtcmalloc_la_SOURCES} ${libprofiler_la_SOURCES})
@ -1379,7 +1366,6 @@ if(GPERFTOOLS_BUILD_HEAP_PROFILER OR GPERFTOOLS_BUILD_HEAP_CHECKER)
set_target_properties(tcmalloc_and_profiler_static PROPERTIES
OUTPUT_NAME tcmalloc_and_profiler)
endif()
weaken_object(tcmalloc_and_profiler_static)
install(TARGETS tcmalloc_and_profiler_static)
endif()

View File

@ -1,63 +0,0 @@
function(find_objcopy_with_weaken)
find_program(OBJCOPY_EXECUTABLE "objcopy")
message(STATUS "Looking for objcopy that supports weaken - ${OBJCOPY_EXECUTABLE}")
if(NOT OBJCOPY_EXECUTABLE)
return()
endif()
set(objcopy_test_src "${CMAKE_CURRENT_BINARY_DIR}/objcopy_test.c")
set(objcopy_test_exe "${CMAKE_CURRENT_BINARY_DIR}/objcopy_test")
file(WRITE ${objcopy_test_src} "void foo() {} int main() { return 0; }")
try_compile(objcopy_test_compiled
${CMAKE_CURRENT_BINARY_DIR} ${objcopy_test_src}
COPY_FILE ${objcopy_test_exe})
if(objcopy_test_compiled AND EXISTS ${objcopy_test_exe})
execute_process(
COMMAND ${OBJCOPY_EXECUTABLE} -W foo ${objcopy_test_exe}
RESULT_VARIABLE objcopy_result)
file(REMOVE ${objcopy_test_exe})
endif()
if(objcopy_result EQUAL 0)
set(objcopy_weaken ON)
endif()
file(REMOVE ${objcopy_test_src})
if(objcopy_weaken)
set(objcopy_has_weaken "Success")
set(HAVE_OBJCOPY_WEAKEN TRUE PARENT_SCOPE)
set(OBJCOPY_EXECUTABLE "${OBJCOPY_EXECUTABLE}" PARENT_SCOPE)
else()
set(objcopy_has_weaken "Failed")
endif()
message(STATUS "objcopy has weaken support - ${objcopy_has_weaken}")
endfunction(find_objcopy_with_weaken)
function(weaken_object target)
if(NOT HAVE_OBJCOPY_WEAKEN)
return()
endif()
# If we have objcopy, make malloc/free/etc weak symbols. That way folks
# can override our malloc if they want to (they can still use tc_malloc).
# Note: the weird-looking symbols are the c++ memory functions:
# (in order) new, new(nothrow), new[], new[](nothrow), delete, delete[]
# In theory this will break if mangling changes, but that seems pretty
# unlikely at this point. Just in case, I throw in versions with an
# extra underscore as well, which may help on OS X.
add_custom_command(TARGET ${target} POST_BUILD
COMMAND "${OBJCOPY_EXECUTABLE}"
-W malloc -W free -W realloc -W calloc -W cfree
-W memalign -W posix_memalign -W valloc -W pvalloc
-W aligned_alloc
-W malloc_stats -W mallopt -W mallinfo -W nallocx
-W _Znwm -W _ZnwmRKSt9nothrow_t -W _Znam -W _ZnamRKSt9nothrow_t
-W _ZdlPv -W _ZdaPv
-W __Znwm -W __ZnwmRKSt9nothrow_t -W __Znam -W __ZnamRKSt9nothrow_t
-W __ZdlPv -W __ZdaPv
-W _ZdaPvRKSt9nothrow_t -W _ZdaPvSt11align_val_t
-W _ZdaPvSt11align_val_tRKSt9nothrow_t -W _ZdaPvm
-W _ZdaPvmSt11align_val_t -W _ZdlPvRKSt9nothrow_t
-W _ZdlPvSt11align_val_t -W _ZdlPvSt11align_val_tRKSt9nothrow_t
-W _ZdlPvm -W _ZdlPvmSt11align_val_t
-W _ZnamSt11align_val_t -W _ZnamSt11align_val_tRKSt9nothrow_t
-W _ZnwmSt11align_val_t -W _ZnwmSt11align_val_tRKSt9nothrow_t
-W malloc_size -W malloc_usable_size
"$<TARGET_FILE:${target}>")
endfunction()