mirror of
https://github.com/ceph/ceph
synced 2025-03-11 02:39:05 +00:00
librados/librados_c: check .symver support using cmake
the __asm__(".asmver ..") is a support provided by the compiler, so would be better to detect it by either checking the compiler identifer or just try it out. in this change, instead of checking the building platform, we check this feature using check_c_source_compiles(). in future, we could support versioned symbols using function attriubte or symbol tables or version-script. on platform where symbol versioning is not supported, we might need to go with a different approach. Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
parent
7c0ed157d7
commit
d0858dbfb4
@ -145,6 +145,21 @@ else(NOT CMAKE_CROSSCOMPILING)
|
||||
message(STATUS "Assuming unaligned access is supported")
|
||||
endif(NOT CMAKE_CROSSCOMPILING)
|
||||
|
||||
set(version_script_source "v1 { }; v2 { } v1;")
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/version_script.txt "${version_script_source}")
|
||||
cmake_push_check_state(RESET)
|
||||
set(CMAKE_REQUIRED_FLAGS -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/version_script.txt)
|
||||
check_c_source_compiles("
|
||||
void func_v1() {}
|
||||
__asm__(\".symver func_v1, func@v1\");
|
||||
void func_v2() {}
|
||||
__asm__(\".symver func_v2, func@v2\");
|
||||
|
||||
int main() {}"
|
||||
HAVE_ASM_SYMVER)
|
||||
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/version_script.txt)
|
||||
cmake_pop_check_state()
|
||||
|
||||
# should use LINK_OPTIONS instead of LINK_LIBRARIES, if we can use cmake v3.14+
|
||||
try_compile(HAVE_LINK_VERSION_SCRIPT
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
|
@ -277,6 +277,9 @@
|
||||
/* Define if the C compiler supports __PRETTY_FUNCTION__ */
|
||||
#cmakedefine HAVE_PRETTY_FUNC
|
||||
|
||||
/* Define if the C compiler supports __asm__(".symver ..") */
|
||||
#cmakedefine HAVE_ASM_SYMVER
|
||||
|
||||
/* Have eventfd extension. */
|
||||
#cmakedefine HAVE_EVENTFD
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include "acconfig.h"
|
||||
#include "common/config.h"
|
||||
#include "common/errno.h"
|
||||
#include "common/ceph_argparse.h"
|
||||
@ -42,7 +43,7 @@
|
||||
#define tracepoint(...)
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
#ifdef HAVE_ASM_SYMVER
|
||||
#define LIBRADOS_C_API_BASE(fn) \
|
||||
asm(".symver _" #fn "_base, " #fn "@")
|
||||
#define LIBRADOS_C_API_BASE_DEFAULT(fn) \
|
||||
@ -53,9 +54,6 @@
|
||||
#define LIBRADOS_C_API_BASE_F(fn) _ ## fn ## _base
|
||||
#define LIBRADOS_C_API_DEFAULT_F(fn) _ ## fn
|
||||
#else
|
||||
// symver cannot be used on Windows. We'll only be able
|
||||
// to support one version, unless we use a different
|
||||
// versioning approach.
|
||||
#define LIBRADOS_C_API_BASE(fn)
|
||||
#define LIBRADOS_C_API_BASE_DEFAULT(fn)
|
||||
#define LIBRADOS_C_API_DEFAULT(fn, ver)
|
||||
|
Loading…
Reference in New Issue
Block a user