summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Bostic <keith.bostic@mongodb.com>2017-04-28 00:15:24 -0400
committerAlex Gorrod <alexander.gorrod@mongodb.com>2017-06-19 17:15:11 +0000
commitcd2d31add157111bdfe4bc51ecba5ad416bafa67 (patch)
treed326d4babe79c70a2ba6bbecaf6d41f029b9ac94
parentb22f088bf30b390b1e0d6c25c099b23324e7ad2b (diff)
downloadmongo-cd2d31add157111bdfe4bc51ecba5ad416bafa67.tar.gz
WT-3297 support the gcc/clang -fvisibility=hidden flag (#3404)
-rw-r--r--dist/s_string.ok1
-rw-r--r--src/docs/programming.dox15
-rw-r--r--src/docs/spell.ok1
-rw-r--r--src/docs/tune-build-options.dox9
-rw-r--r--src/include/gcc.h2
-rw-r--r--src/include/lint.h1
-rw-r--r--src/include/msvc.h4
-rw-r--r--src/include/wiredtiger.in64
-rw-r--r--src/os_common/os_getopt.c8
9 files changed, 73 insertions, 32 deletions
diff --git a/dist/s_string.ok b/dist/s_string.ok
index 1f7f7d9fd3a..f3852d00ac8 100644
--- a/dist/s_string.ok
+++ b/dist/s_string.ok
@@ -731,6 +731,7 @@ fsyncLock
fsyncs
ftruncate
func
+fvisibility
gcc
gdb
ge
diff --git a/src/docs/programming.dox b/src/docs/programming.dox
index aa76bef4614..205e7544c6c 100644
--- a/src/docs/programming.dox
+++ b/src/docs/programming.dox
@@ -65,19 +65,20 @@ each of which is ordered by one or more columns.
- @subpage_single wtperf
- @subpage_single wtstats
<p>
-- @subpage_single tune_memory_allocator
-- @subpage_single tune_page_size_and_comp
-- @subpage_single tune_cache
+- @subpage_single tune_build_options
- @subpage_single tune_bulk_load
+- @subpage_single tune_cache
+- @subpage_single tune_checksum
+- @subpage_single tune_close
- @subpage_single tune_cursor_persist
-- @subpage_single tune_read_only
- @subpage_single tune_durability
-- @subpage_single tune_checksum
- @subpage_single tune_file_alloc
+- @subpage_single tune_memory_allocator
+- @subpage_single tune_mutex
+- @subpage_single tune_page_size_and_comp
+- @subpage_single tune_read_only
- @subpage_single tune_system_buffer_cache
- @subpage_single tune_transparent_huge_pages
-- @subpage_single tune_close
-- @subpage_single tune_mutex
- @subpage_single tune_zone_reclaim
*/
diff --git a/src/docs/spell.ok b/src/docs/spell.ok
index bc2e16b1122..5d629f4c49f 100644
--- a/src/docs/spell.ok
+++ b/src/docs/spell.ok
@@ -237,6 +237,7 @@ fput
freelist
fsync
ftruncate
+fvisibility
gcc
gdbm
ge
diff --git a/src/docs/tune-build-options.dox b/src/docs/tune-build-options.dox
new file mode 100644
index 00000000000..79cd60b1105
--- /dev/null
+++ b/src/docs/tune-build-options.dox
@@ -0,0 +1,9 @@
+/*! @page tune_build_options gcc/clang build options
+
+WiredTiger can be built using the gcc/clang \c -fvisibility=hidden flag,
+which may significantly reduce the size and load time of the WiredTiger
+library when built as a dynamic shared object, and allow the optimizer
+to produce better code (for example, by eliminating most lookups in the
+procedure linkage table).
+
+ */
diff --git a/src/include/gcc.h b/src/include/gcc.h
index 22d78fc165a..6c712813d29 100644
--- a/src/include/gcc.h
+++ b/src/include/gcc.h
@@ -9,7 +9,7 @@
#define WT_PTRDIFFT_FMT "td" /* ptrdiff_t format string */
#define WT_SIZET_FMT "zu" /* size_t format string */
-/* Add GCC-specific attributes to types and function declarations. */
+/* GCC-specific attributes. */
#define WT_PACKED_STRUCT_BEGIN(name) \
struct __attribute__ ((__packed__)) name {
#define WT_PACKED_STRUCT_END \
diff --git a/src/include/lint.h b/src/include/lint.h
index 2d0f47988b7..813b9182683 100644
--- a/src/include/lint.h
+++ b/src/include/lint.h
@@ -9,6 +9,7 @@
#define WT_PTRDIFFT_FMT "td" /* ptrdiff_t format string */
#define WT_SIZET_FMT "zu" /* size_t format string */
+/* Lint-specific attributes. */
#define WT_PACKED_STRUCT_BEGIN(name) \
struct name {
#define WT_PACKED_STRUCT_END \
diff --git a/src/include/msvc.h b/src/include/msvc.h
index 6c5c8b67647..c9399be3185 100644
--- a/src/include/msvc.h
+++ b/src/include/msvc.h
@@ -16,9 +16,7 @@
#define WT_PTRDIFFT_FMT "Id" /* ptrdiff_t format string */
#define WT_SIZET_FMT "Iu" /* size_t format string */
-/*
- * Add MSVC-specific attributes and pragmas to types and function declarations.
- */
+/* MSVC-specific attributes. */
#define WT_PACKED_STRUCT_BEGIN(name) \
__pragma(pack(push,1)) \
struct name {
diff --git a/src/include/wiredtiger.in b/src/include/wiredtiger.in
index 4f357af9c91..821efdf5fa1 100644
--- a/src/include/wiredtiger.in
+++ b/src/include/wiredtiger.in
@@ -39,6 +39,16 @@ extern "C" {
#define __F(func) (*(func))
#endif
+/*
+ * We support configuring WiredTiger with the gcc/clang -fvisibility=hidden
+ * flags, but that requires public APIs be specifically marked.
+ */
+#if defined(DOXYGEN) || defined(SWIG) || !defined(__GNUC__)
+#define WT_ATTRIBUTE_LIBRARY_VISIBLE
+#else
+#define WT_ATTRIBUTE_LIBRARY_VISIBLE __attribute__((visibility("default")))
+#endif
+
#ifdef SWIG
%{
#include <wiredtiger.h>
@@ -2553,7 +2563,7 @@ struct __wt_connection {
*/
int wiredtiger_open(const char *home,
WT_EVENT_HANDLER *errhandler, const char *config,
- WT_CONNECTION **connectionp);
+ WT_CONNECTION **connectionp) WT_ATTRIBUTE_LIBRARY_VISIBLE;
/*!
* Return information about a WiredTiger error as a string (see
@@ -2564,7 +2574,7 @@ int wiredtiger_open(const char *home,
* @param error a return value from a WiredTiger, ISO C, or POSIX standard API
* @returns a string representation of the error
*/
-const char *wiredtiger_strerror(int error);
+const char *wiredtiger_strerror(int error) WT_ATTRIBUTE_LIBRARY_VISIBLE;
#if !defined(SWIG)
/*!
@@ -2701,7 +2711,8 @@ struct __wt_event_handler {
* @errors
*/
int wiredtiger_struct_pack(WT_SESSION *session,
- void *buffer, size_t size, const char *format, ...);
+ void *buffer, size_t size, const char *format, ...)
+ WT_ATTRIBUTE_LIBRARY_VISIBLE;
/*!
* Calculate the size required to pack a structure.
@@ -2719,7 +2730,7 @@ int wiredtiger_struct_pack(WT_SESSION *session,
* @errors
*/
int wiredtiger_struct_size(WT_SESSION *session,
- size_t *sizep, const char *format, ...);
+ size_t *sizep, const char *format, ...) WT_ATTRIBUTE_LIBRARY_VISIBLE;
/*!
* Unpack a structure from a buffer.
@@ -2736,7 +2747,8 @@ int wiredtiger_struct_size(WT_SESSION *session,
* @errors
*/
int wiredtiger_struct_unpack(WT_SESSION *session,
- const void *buffer, size_t size, const char *format, ...);
+ const void *buffer, size_t size, const char *format, ...)
+ WT_ATTRIBUTE_LIBRARY_VISIBLE;
#if !defined(SWIG)
@@ -2763,7 +2775,8 @@ typedef struct __wt_pack_stream WT_PACK_STREAM;
* @errors
*/
int wiredtiger_pack_start(WT_SESSION *session,
- const char *format, void *buffer, size_t size, WT_PACK_STREAM **psp);
+ const char *format, void *buffer, size_t size, WT_PACK_STREAM **psp)
+ WT_ATTRIBUTE_LIBRARY_VISIBLE;
/*!
* Start an unpacking operation from a buffer with the given format string.
@@ -2779,7 +2792,8 @@ int wiredtiger_pack_start(WT_SESSION *session,
* @errors
*/
int wiredtiger_unpack_start(WT_SESSION *session,
- const char *format, const void *buffer, size_t size, WT_PACK_STREAM **psp);
+ const char *format, const void *buffer, size_t size, WT_PACK_STREAM **psp)
+ WT_ATTRIBUTE_LIBRARY_VISIBLE;
/*!
* Close a packing stream.
@@ -2788,7 +2802,8 @@ int wiredtiger_unpack_start(WT_SESSION *session,
* @param[out] usedp the number of bytes in the buffer used by the stream
* @errors
*/
-int wiredtiger_pack_close(WT_PACK_STREAM *ps, size_t *usedp);
+int wiredtiger_pack_close(WT_PACK_STREAM *ps, size_t *usedp)
+ WT_ATTRIBUTE_LIBRARY_VISIBLE;
/*!
* Pack an item into a packing stream.
@@ -2797,7 +2812,8 @@ int wiredtiger_pack_close(WT_PACK_STREAM *ps, size_t *usedp);
* @param item an item to pack
* @errors
*/
-int wiredtiger_pack_item(WT_PACK_STREAM *ps, WT_ITEM *item);
+int wiredtiger_pack_item(WT_PACK_STREAM *ps, WT_ITEM *item)
+ WT_ATTRIBUTE_LIBRARY_VISIBLE;
/*!
* Pack a signed integer into a packing stream.
@@ -2806,7 +2822,8 @@ int wiredtiger_pack_item(WT_PACK_STREAM *ps, WT_ITEM *item);
* @param i a signed integer to pack
* @errors
*/
-int wiredtiger_pack_int(WT_PACK_STREAM *ps, int64_t i);
+int wiredtiger_pack_int(WT_PACK_STREAM *ps, int64_t i)
+ WT_ATTRIBUTE_LIBRARY_VISIBLE;
/*!
* Pack a string into a packing stream.
@@ -2815,7 +2832,8 @@ int wiredtiger_pack_int(WT_PACK_STREAM *ps, int64_t i);
* @param s a string to pack
* @errors
*/
-int wiredtiger_pack_str(WT_PACK_STREAM *ps, const char *s);
+int wiredtiger_pack_str(WT_PACK_STREAM *ps, const char *s)
+ WT_ATTRIBUTE_LIBRARY_VISIBLE;
/*!
* Pack an unsigned integer into a packing stream.
@@ -2824,7 +2842,8 @@ int wiredtiger_pack_str(WT_PACK_STREAM *ps, const char *s);
* @param u an unsigned integer to pack
* @errors
*/
-int wiredtiger_pack_uint(WT_PACK_STREAM *ps, uint64_t u);
+int wiredtiger_pack_uint(WT_PACK_STREAM *ps, uint64_t u)
+ WT_ATTRIBUTE_LIBRARY_VISIBLE;
/*!
* Unpack an item from a packing stream.
@@ -2833,7 +2852,8 @@ int wiredtiger_pack_uint(WT_PACK_STREAM *ps, uint64_t u);
* @param item an item to unpack
* @errors
*/
-int wiredtiger_unpack_item(WT_PACK_STREAM *ps, WT_ITEM *item);
+int wiredtiger_unpack_item(WT_PACK_STREAM *ps, WT_ITEM *item)
+ WT_ATTRIBUTE_LIBRARY_VISIBLE;
/*!
* Unpack a signed integer from a packing stream.
@@ -2842,7 +2862,8 @@ int wiredtiger_unpack_item(WT_PACK_STREAM *ps, WT_ITEM *item);
* @param[out] ip the unpacked signed integer
* @errors
*/
-int wiredtiger_unpack_int(WT_PACK_STREAM *ps, int64_t *ip);
+int wiredtiger_unpack_int(WT_PACK_STREAM *ps, int64_t *ip)
+ WT_ATTRIBUTE_LIBRARY_VISIBLE;
/*!
* Unpack a string from a packing stream.
@@ -2851,7 +2872,8 @@ int wiredtiger_unpack_int(WT_PACK_STREAM *ps, int64_t *ip);
* @param[out] sp the unpacked string
* @errors
*/
-int wiredtiger_unpack_str(WT_PACK_STREAM *ps, const char **sp);
+int wiredtiger_unpack_str(WT_PACK_STREAM *ps, const char **sp)
+ WT_ATTRIBUTE_LIBRARY_VISIBLE;
/*!
* Unpack an unsigned integer from a packing stream.
@@ -2860,7 +2882,8 @@ int wiredtiger_unpack_str(WT_PACK_STREAM *ps, const char **sp);
* @param[out] up the unpacked unsigned integer
* @errors
*/
-int wiredtiger_unpack_uint(WT_PACK_STREAM *ps, uint64_t *up);
+int wiredtiger_unpack_uint(WT_PACK_STREAM *ps, uint64_t *up)
+ WT_ATTRIBUTE_LIBRARY_VISIBLE;
/*! @} */
/*!
@@ -2938,7 +2961,8 @@ struct __wt_config_item {
* @snippet ex_all.c Validate a configuration string
*/
int wiredtiger_config_validate(WT_SESSION *session,
- WT_EVENT_HANDLER *errhandler, const char *name, const char *config);
+ WT_EVENT_HANDLER *errhandler, const char *name, const char *config)
+ WT_ATTRIBUTE_LIBRARY_VISIBLE;
#endif
/*!
@@ -2958,7 +2982,8 @@ int wiredtiger_config_validate(WT_SESSION *session,
* @snippet ex_config_parse.c Create a configuration parser
*/
int wiredtiger_config_parser_open(WT_SESSION *session,
- const char *config, size_t len, WT_CONFIG_PARSER **config_parserp);
+ const char *config, size_t len, WT_CONFIG_PARSER **config_parserp)
+ WT_ATTRIBUTE_LIBRARY_VISIBLE;
/*!
* A handle that can be used to search and traverse configuration strings
@@ -3047,7 +3072,8 @@ struct __wt_config_parser {
* @param patchp a location where the patch version number is returned
* @returns a string representation of the version
*/
-const char *wiredtiger_version(int *majorp, int *minorp, int *patchp);
+const char *wiredtiger_version(int *majorp, int *minorp, int *patchp)
+ WT_ATTRIBUTE_LIBRARY_VISIBLE;
/*******************************************
* Error returns
diff --git a/src/os_common/os_getopt.c b/src/os_common/os_getopt.c
index 960776c3999..fa21123ba0e 100644
--- a/src/os_common/os_getopt.c
+++ b/src/os_common/os_getopt.c
@@ -59,13 +59,17 @@
#include "wt_internal.h"
-extern int __wt_opterr, __wt_optind, __wt_optopt, __wt_optreset;
+extern int __wt_opterr WT_ATTRIBUTE_LIBRARY_VISIBLE;
+extern int __wt_optind WT_ATTRIBUTE_LIBRARY_VISIBLE;
+extern int __wt_optopt WT_ATTRIBUTE_LIBRARY_VISIBLE;
+extern int __wt_optreset WT_ATTRIBUTE_LIBRARY_VISIBLE;
+
int __wt_opterr = 1, /* if error message should be printed */
__wt_optind = 1, /* index into parent argv vector */
__wt_optopt, /* character checked for validity */
__wt_optreset; /* reset getopt */
-extern char *__wt_optarg;
+extern char *__wt_optarg WT_ATTRIBUTE_LIBRARY_VISIBLE;
char *__wt_optarg; /* argument associated with option */
#define BADCH (int)'?'