tomato/cmake/StrictAbi.cmake
Green Sky 9ddeea3d06 Squashed 'external/toxcore/c-toxcore/' changes from d4b06edc2a..adbd5b32d8
adbd5b32d8 feat: add ngc events
15ee46d431 add simple test for max sized lossy custom group packet
01e7950c67 increase lossy custom packet size in ngc to the toxcore common max of 1373
9b3c1089f1 Make group saving/loading more forgiving with data errors
55a76003b0 Replace memset(int32_t*, -1, _) with a for-loop
66453439ac fix: also Install header for private/experimental API functions with autotools
3983369103 fix: Enable debug flag for ubsan.
4d1db21102 Update tox-boostrapd hash
e700c31b70 Fix memory leak in group connection
2994441d9c Fix memory leak in save-generator
d0400df13d Fix memory leak in tox-bootstrapd
7a6d50ebe3 Install header for private/experimental API functions
d89677fb5f Remove defunct IRC channel from README.md
26d41fc604 Replace DEFAULT_TCP_RELAY_PORTS_COUNT with a compile-time calculation
63fb2941ca Clarify disabling of static assert checks
65b3375b98 refactor: Use Bin_Pack for packing Node_format.
84ba154f6a group connection queries now return our own connection type
a4df2862ed Replace tabs with spaces
1b6dee7594 Update tox-bootstrapd's base Docker images
a030cdee5c Fix Docker tox-bootstrapd hash update failing when using BuildKit
7cfe35dff2 cleanup: Remove explicit layering_check feature.
d390947245 chore: Upgrade sonar-scan jvm to java 17.
d1e850c56c fix: Add missing `htons` call when adding configured TCP relay.
814090f2b8 chore: Cancel old PR builds on docker and sonar-scan workflows.
83efb17367 perf: Add a KVM FreeBSD build on cirrus ci.
a927183233 test: Add a test for encrypting 100MB of data.
28f39049f6 chore: Retry freebsd tests 2 times.
47e77d1bb0 chore: Use C99 on MSVC instead of C11.
7155f7f60e test: Add an s390x build (on alpine) for CI.
6c35cef63f chore: Add a compcert docker run script.
41e6ea865e cleanup: Use tcc docker image for CI.
e726b197b0 refactor: Store time in Mono_Time in milliseconds.
REVERT: d4b06edc2a feat: add ngc events

git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: adbd5b32d85d9c13800f5ece17c0a9dce99faacd
2023-12-15 15:21:40 +01:00

77 lines
2.3 KiB
CMake

################################################################################
#
# :: Strict ABI
#
# Enabling the STRICT_ABI flag will generate and use an LD version script.
# It ensures that the dynamic libraries (libtoxcore.so, libtoxav.so) only
# export the symbols that are defined in their public API (tox.h and toxav.h,
# respectively).
#
################################################################################
find_program(SHELL NAMES sh dash bash zsh fish)
macro(make_version_script)
if(STRICT_ABI AND SHELL AND ENABLE_SHARED)
_make_version_script(${ARGN})
endif()
endmacro()
function(_make_version_script target)
set(${target}_VERSION_SCRIPT "${CMAKE_BINARY_DIR}/${target}.ld")
file(WRITE ${${target}_VERSION_SCRIPT}
"{ global:\n")
foreach(sublib ${ARGN})
string(REPLACE "^" ";" sublib ${sublib})
list(GET sublib 0 header)
list(GET sublib 1 ns)
execute_process(
COMMAND ${SHELL} -c "egrep '^\\w' ${header} | grep '${ns}_[a-z0-9_]*(' | grep -v '^typedef' | grep -o '${ns}_[a-z0-9_]*(' | egrep -o '[a-z0-9_]+' | sort -u"
OUTPUT_VARIABLE sublib_SYMS
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REPLACE "\n" ";" sublib_SYMS ${sublib_SYMS})
foreach(sym ${sublib_SYMS})
file(APPEND ${${target}_VERSION_SCRIPT}
"${sym};\n")
endforeach(sym)
endforeach(sublib)
file(APPEND ${${target}_VERSION_SCRIPT}
"local: *; };\n")
set_target_properties(${target}_shared PROPERTIES
LINK_FLAGS -Wl,--version-script,${${target}_VERSION_SCRIPT})
endfunction()
option(STRICT_ABI "Enforce strict ABI export in dynamic libraries" OFF)
if(WIN32 OR APPLE)
# Windows and OSX don't have this linker functionality.
set(STRICT_ABI OFF)
endif()
if(STRICT_ABI AND NOT ENABLE_STATIC)
if(AUTOTEST)
message("AUTOTEST option is incompatible with STRICT_ABI. Disabling AUTOTEST.")
endif()
set(AUTOTEST OFF)
if(BUILD_MISC_TESTS)
message("BUILD_MISC_TESTS option is incompatible with STRICT_ABI. Disabling BUILD_MISC_TESTS.")
endif()
set(BUILD_MISC_TESTS OFF)
if(BOOTSTRAP_DAEMON)
message("BOOTSTRAP_DAEMON option is incompatible with STRICT_ABI. Disabling BOOTSTRAP_DAEMON.")
endif()
set(BOOTSTRAP_DAEMON OFF)
if(DHT_BOOTSTRAP)
message("DHT_BOOTSTRAP option is incompatible with STRICT_ABI. Disabling DHT_BOOTSTRAP.")
endif()
set(DHT_BOOTSTRAP OFF)
endif()