Make internal symbols hidden.
Only the malloc/free/... interface is exported. This allows all of C++'s weak ODR symbols to be resolved at compile-time, rather than staying weak and resolved at load-time. Since internal calls don't need to go through the PLT anymore, we get a nice speedup, at least on small objects.
This commit is contained in:
@@ -54,16 +54,18 @@ if(USE_SBRK)
|
||||
add_definitions(-DUSE_SBRK)
|
||||
endif()
|
||||
|
||||
if(NOT MSVC)
|
||||
add_library(snmallocshim SHARED src/override/malloc.cc)
|
||||
target_link_libraries(snmallocshim -pthread)
|
||||
target_include_directories(snmallocshim PRIVATE src)
|
||||
endif()
|
||||
macro(add_shim name)
|
||||
add_library(${name} SHARED src/override/malloc.cc)
|
||||
target_link_libraries(${name} -pthread)
|
||||
target_include_directories(${name} PRIVATE src)
|
||||
target_compile_definitions(${name} PRIVATE "SNMALLOC_EXPORT=__attribute__((visibility(\"default\")))")
|
||||
set_target_properties(${name} PROPERTIES CXX_VISIBILITY_PRESET hidden)
|
||||
endmacro()
|
||||
|
||||
if(NOT MSVC)
|
||||
add_library(snmallocshim-1mib SHARED src/override/malloc.cc)
|
||||
target_link_libraries(snmallocshim-1mib -pthread)
|
||||
target_include_directories(snmallocshim-1mib PRIVATE src)
|
||||
add_shim(snmallocshim)
|
||||
|
||||
add_shim(snmallocshim-1mib)
|
||||
target_compile_definitions(snmallocshim-1mib PRIVATE IS_ADDRESS_SPACE_CONSTRAINED)
|
||||
endif()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user