mirror of
https://github.com/protobuf-c/protobuf-c.git
synced 2024-12-26 12:41:01 +08:00
version the libprotobuf-c symbols on compatible linkers (Issue #116)
this is conditional on whether the linker supports version scripts, for which we use the gl_LD_VERSION_SCRIPT macro from the gnulib project. on platforms without version scripts, we fall back to libtool's -export-symbols-regex.
This commit is contained in:
parent
4da97eeaa3
commit
daad5868cf
10
Makefile.am
10
Makefile.am
@ -39,9 +39,17 @@ protobuf_c_libprotobuf_c_la_SOURCES = \
|
||||
|
||||
protobuf_c_libprotobuf_c_la_LDFLAGS = $(AM_LDFLAGS) \
|
||||
-version-info $(LIBPROTOBUF_C_CURRENT):$(LIBPROTOBUF_C_REVISION):$(LIBPROTOBUF_C_AGE) \
|
||||
-export-symbols-regex "^(protobuf_c_[a-z].*)" \
|
||||
-no-undefined
|
||||
|
||||
if HAVE_LD_VERSION_SCRIPT
|
||||
protobuf_c_libprotobuf_c_la_LDFLAGS += \
|
||||
-Wl,--version-script=$(top_srcdir)/protobuf-c/libprotobuf-c.sym
|
||||
else
|
||||
protobuf_c_libprotobuf_c_la_LDFLAGS += \
|
||||
-export-symbols-regex "^(protobuf_c_[a-z].*)"
|
||||
endif
|
||||
EXTRA_DIST += protobuf-c/libprotobuf-c.sym
|
||||
|
||||
pkgconfig_DATA += protobuf-c/libprotobuf-c.pc
|
||||
CLEANFILES += protobuf-c/libprotobuf-c.pc
|
||||
EXTRA_DIST += protobuf-c/libprotobuf-c.pc.in
|
||||
|
@ -54,6 +54,8 @@ else
|
||||
fi
|
||||
AM_CONDITIONAL([BUILD_COMPILER], [test "x$enable_protoc" != "xno"])
|
||||
|
||||
gl_LD_VERSION_SCRIPT
|
||||
|
||||
gl_VALGRIND_TESTS
|
||||
|
||||
AC_C_BIGENDIAN
|
||||
|
53
m4/ld-version-script.m4
Normal file
53
m4/ld-version-script.m4
Normal file
@ -0,0 +1,53 @@
|
||||
# ld-version-script.m4 serial 3
|
||||
dnl Copyright (C) 2008-2014 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl From Simon Josefsson
|
||||
|
||||
# FIXME: The test below returns a false positive for mingw
|
||||
# cross-compiles, 'local:' statements does not reduce number of
|
||||
# exported symbols in a DLL. Use --disable-ld-version-script to work
|
||||
# around the problem.
|
||||
|
||||
# gl_LD_VERSION_SCRIPT
|
||||
# --------------------
|
||||
# Check if LD supports linker scripts, and define automake conditional
|
||||
# HAVE_LD_VERSION_SCRIPT if so.
|
||||
AC_DEFUN([gl_LD_VERSION_SCRIPT],
|
||||
[
|
||||
AC_ARG_ENABLE([ld-version-script],
|
||||
AS_HELP_STRING([--enable-ld-version-script],
|
||||
[enable linker version script (default is enabled when possible)]),
|
||||
[have_ld_version_script=$enableval], [])
|
||||
if test -z "$have_ld_version_script"; then
|
||||
AC_MSG_CHECKING([if LD -Wl,--version-script works])
|
||||
save_LDFLAGS="$LDFLAGS"
|
||||
LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
|
||||
cat > conftest.map <<EOF
|
||||
foo
|
||||
EOF
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
|
||||
[accepts_syntax_errors=yes], [accepts_syntax_errors=no])
|
||||
if test "$accepts_syntax_errors" = no; then
|
||||
cat > conftest.map <<EOF
|
||||
VERS_1 {
|
||||
global: sym;
|
||||
};
|
||||
|
||||
VERS_2 {
|
||||
global: sym;
|
||||
} VERS_1;
|
||||
EOF
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
|
||||
[have_ld_version_script=yes], [have_ld_version_script=no])
|
||||
else
|
||||
have_ld_version_script=no
|
||||
fi
|
||||
rm -f conftest.map
|
||||
LDFLAGS="$save_LDFLAGS"
|
||||
AC_MSG_RESULT($have_ld_version_script)
|
||||
fi
|
||||
AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
|
||||
])
|
24
protobuf-c/libprotobuf-c.sym
Normal file
24
protobuf-c/libprotobuf-c.sym
Normal file
@ -0,0 +1,24 @@
|
||||
LIBPROTOBUF_C_1.0.0 {
|
||||
global:
|
||||
protobuf_c_buffer_simple_append;
|
||||
protobuf_c_default_allocator;
|
||||
protobuf_c_enum_descriptor_get_value;
|
||||
protobuf_c_enum_descriptor_get_value_by_name;
|
||||
protobuf_c_major;
|
||||
protobuf_c_message_check;
|
||||
protobuf_c_message_descriptor_get_field;
|
||||
protobuf_c_message_descriptor_get_field_by_name;
|
||||
protobuf_c_message_free_unpacked;
|
||||
protobuf_c_message_get_packed_size;
|
||||
protobuf_c_message_init;
|
||||
protobuf_c_message_pack;
|
||||
protobuf_c_message_pack_to_buffer;
|
||||
protobuf_c_message_unpack;
|
||||
protobuf_c_minor;
|
||||
protobuf_c_service_descriptor_get_method_by_name;
|
||||
protobuf_c_service_destroy;
|
||||
protobuf_c_service_generated_init;
|
||||
protobuf_c_service_invoke_internal;
|
||||
local:
|
||||
*;
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user