From 2077ff0752074353c824162177da7b5b5e271604 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Sat, 19 Sep 2020 04:16:26 +0200 Subject: [PATCH] correctly enforce symbol visibility --- meson.build | 6 ++++++ ostd/argparse.hh | 14 +++++++------- ostd/channel.hh | 3 ++- ostd/concurrency.hh | 4 ++-- ostd/coroutine.hh | 6 +++--- ostd/format.hh | 2 +- ostd/generic_condvar.hh | 4 +++- ostd/path.hh | 2 +- ostd/process.hh | 4 ++-- ostd/stream.hh | 4 ++-- ostd/string.hh | 2 +- 11 files changed, 30 insertions(+), 21 deletions(-) diff --git a/meson.build b/meson.build index af40d69..4ee0557 100644 --- a/meson.build +++ b/meson.build @@ -22,6 +22,12 @@ else extra_cxxflags = [] endif +cxx = meson.get_compiler('cpp') + +if cxx.has_argument('-fvisibility=hidden') + add_global_arguments('-fvisibility=hidden', language: 'cpp') +endif + subdir('src') if get_option('build-tests') diff --git a/ostd/argparse.hh b/ostd/argparse.hh index 67ffdc4..4b9b229 100644 --- a/ostd/argparse.hh +++ b/ostd/argparse.hh @@ -41,7 +41,7 @@ namespace ostd { */ /** @brief The error thrown on parsing and other failures. */ -struct arg_error: std::runtime_error { +struct OSTD_EXPORT arg_error: std::runtime_error { using std::runtime_error::runtime_error; /* empty, for vtable placement */ @@ -98,7 +98,7 @@ enum class arg_value { * * This base class is abstract so it cannot be instantiated. */ -struct arg_description { +struct OSTD_EXPORT arg_description { friend struct arg_description_container; friend struct arg_mutually_exclusive_group; friend struct arg_group; @@ -138,7 +138,7 @@ protected: * * It's not instantiated directly. */ -struct arg_argument: arg_description { +struct OSTD_EXPORT arg_argument: arg_description { /* empty, for vtable placement */ virtual ~arg_argument(); @@ -225,7 +225,7 @@ private: * *See ostd::basic_arg_parser for more. */ -struct arg_optional: arg_argument { +struct OSTD_EXPORT arg_optional: arg_argument { template friend struct basic_arg_parser; friend struct arg_description_container; @@ -459,7 +459,7 @@ private: * *See ostd::basic_arg_parser for more. */ -struct arg_positional: arg_argument { +struct OSTD_EXPORT arg_positional: arg_argument { template friend struct basic_arg_parser; friend struct arg_description_container; @@ -603,7 +603,7 @@ private: * A mutually exclusive group can also have the `required` flag set * in which case one of the arguments must always be used. */ -struct arg_mutually_exclusive_group: arg_description { +struct OSTD_EXPORT arg_mutually_exclusive_group: arg_description { friend struct arg_description_container; /* empty, for vtable placement */ @@ -940,7 +940,7 @@ protected: * A group is named and can optionally have a title. The title is * displayed in help listing. If not set, the name is displayed. */ -struct arg_group: arg_description, arg_description_container { +struct OSTD_EXPORT arg_group: arg_description, arg_description_container { friend struct arg_description_container; /* empty, for vtable placement */ diff --git a/ostd/channel.hh b/ostd/channel.hh index e606ab9..536b0be 100644 --- a/ostd/channel.hh +++ b/ostd/channel.hh @@ -24,6 +24,7 @@ #include #include +#include #include namespace ostd { @@ -33,7 +34,7 @@ namespace ostd { */ /** @brief Thrown when manipulating a channel that has been closed. */ -struct channel_error: std::logic_error { +struct OSTD_EXPORT channel_error: std::logic_error { using std::logic_error::logic_error; /* empty, for vtable placement */ virtual ~channel_error(); diff --git a/ostd/concurrency.hh b/ostd/concurrency.hh index b9c2b30..d7b24b5 100644 --- a/ostd/concurrency.hh +++ b/ostd/concurrency.hh @@ -212,7 +212,7 @@ private: * The `start` method will also set the internal current scheduler pointer * so that APIs such as ostd::spawn() can work. */ -struct scheduler { +struct OSTD_EXPORT scheduler { private: struct stack_allocator { stack_allocator() = delete; @@ -544,7 +544,7 @@ namespace detail { OSTD_EXPORT extern thread_local csched_task *current_csched_task; - struct csched_task: coroutine_context { + struct OSTD_EXPORT csched_task: coroutine_context { friend struct coroutine_context; csched_task() = delete; diff --git a/ostd/coroutine.hh b/ostd/coroutine.hh index 60ba470..6d20a11 100644 --- a/ostd/coroutine.hh +++ b/ostd/coroutine.hh @@ -54,14 +54,14 @@ namespace ostd { * * These can include a dead coroutine/generator call/access. */ -struct coroutine_error: std::runtime_error { +struct OSTD_EXPORT coroutine_error: std::runtime_error { using std::runtime_error::runtime_error; /* empty, for vtable placement */ virtual ~coroutine_error(); }; namespace detail { - struct stack_free_iface { + struct OSTD_EXPORT stack_free_iface { stack_free_iface() {} /* empty, for vtable placement */ virtual ~stack_free_iface(); @@ -84,7 +84,7 @@ namespace detail { * managing the coroutine as well as its entry point. All coroutine types * inherit from this. */ -struct coroutine_context { +struct OSTD_EXPORT coroutine_context { /** @brief Gets the currently executing coroutine context. * * Sometimes custom coroutine types might want to bypass being able diff --git a/ostd/format.hh b/ostd/format.hh index 50c5524..90ec29b 100644 --- a/ostd/format.hh +++ b/ostd/format.hh @@ -55,7 +55,7 @@ enum format_flags { }; /** @brief Thrown when format string does not properly match the arguments. */ -struct format_error: std::runtime_error { +struct OSTD_EXPORT format_error: std::runtime_error { using std::runtime_error::runtime_error; /* empty, for vtable placement */ virtual ~format_error(); diff --git a/ostd/generic_condvar.hh b/ostd/generic_condvar.hh index 87a26ce..4b9f0f0 100644 --- a/ostd/generic_condvar.hh +++ b/ostd/generic_condvar.hh @@ -16,6 +16,8 @@ #include #include +#include + namespace ostd { /** @addtogroup Concurrency @@ -23,7 +25,7 @@ namespace ostd { */ namespace detail { - struct cond_iface { + struct OSTD_EXPORT cond_iface { cond_iface() {} virtual ~cond_iface(); virtual void notify_one() = 0; diff --git a/ostd/path.hh b/ostd/path.hh index f9c431e..7dad3a8 100644 --- a/ostd/path.hh +++ b/ostd/path.hh @@ -90,7 +90,7 @@ namespace detail { * * It inherits from std::runtime_error and has the same methods and behavior. */ -struct path_error: std::runtime_error { +struct OSTD_EXPORT path_error: std::runtime_error { using std::runtime_error::runtime_error; /* empty, for vtable placement */ diff --git a/ostd/process.hh b/ostd/process.hh index be80108..4e0fa12 100644 --- a/ostd/process.hh +++ b/ostd/process.hh @@ -32,7 +32,7 @@ namespace ostd { */ /** @brief Thrown on errors in ostd::split_args(). */ -struct word_error: std::runtime_error { +struct OSTD_EXPORT word_error: std::runtime_error { using std::runtime_error::runtime_error; /* empty, for vtable placement */ virtual ~word_error(); @@ -81,7 +81,7 @@ Sink &&split_args(Sink &&out, string_range str) { } /** @brief Thrown on errors in ostd::subprocess. */ -struct subprocess_error: std::runtime_error { +struct OSTD_EXPORT subprocess_error: std::runtime_error { using std::runtime_error::runtime_error; /* empty, for vtable placement */ virtual ~subprocess_error(); diff --git a/ostd/stream.hh b/ostd/stream.hh index 8de3a99..5a0a5f9 100644 --- a/ostd/stream.hh +++ b/ostd/stream.hh @@ -88,7 +88,7 @@ template> struct stream_range; /** @brief Thrown on stream errors. */ -struct stream_error: std::system_error { +struct OSTD_EXPORT stream_error: std::system_error { using std::system_error::system_error; /* empty, for vtable placement */ virtual ~stream_error(); @@ -102,7 +102,7 @@ struct stream_line_range; * All streams derive from this, for example ostd::file_steram. * They implement the virtual interface provided by this class. */ -struct stream { +struct OSTD_EXPORT stream { /** @brief The stream offset type. */ using offset_type = stream_off_t; diff --git a/ostd/string.hh b/ostd/string.hh index c3bcc9e..c86ef8e 100644 --- a/ostd/string.hh +++ b/ostd/string.hh @@ -790,7 +790,7 @@ namespace utf { static inline constexpr char32_t const max_unicode = 0x10FFFF; /** @brief Thrown on UTF-8 decoding failure. */ - struct utf_error: std::runtime_error { + struct OSTD_EXPORT utf_error: std::runtime_error { using std::runtime_error::runtime_error; /* empty, for vtable placement */ virtual ~utf_error();