From c28d3c668776e06b05d67ff37817ef987f798e5a Mon Sep 17 00:00:00 2001 From: Justin Turner Arthur Date: Tue, 16 Dec 2025 05:25:50 -0600 Subject: [PATCH 1/3] Make BestSourceException and derivatives visible to linked modules. Fixes vapoursynth/bestsource#114. --- meson.build | 2 ++ src/bsshared.h | 24 ++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 3bbe6c2..46c4006 100644 --- a/meson.build +++ b/meson.build @@ -27,6 +27,7 @@ plugin_sources = files( ) libs = [] +api_args = ['-DBSSHARED_API_BUILDING'] p2p_args = [] if host_machine.cpu_family().startswith('x86') @@ -71,6 +72,7 @@ endif libbestsource = library('libbestsource', api_sources, dependencies: deps, install: true, + cpp_args: api_args, link_args: link_args, link_with: libs, name_prefix: '', diff --git a/src/bsshared.h b/src/bsshared.h index 0959268..bc4be3c 100644 --- a/src/bsshared.h +++ b/src/bsshared.h @@ -28,13 +28,33 @@ #include #include +#if (defined(_WIN32) || defined(__CYGWIN__)) +# define BSSHARED_API_EXPORT __declspec(dllexport) +# define BSSHARED_API_IMPORT __declspec(dllimport) +#elif defined(__OS2__) +# define BSSHARED_API_EXPORT __declspec(dllexport) +# define BSSHARED_API_IMPORT +#elif __GNUC__ >= 4 +# define BSSHARED_API_EXPORT __attribute__((visibility("default"))) +# define BSSHARED_API_IMPORT __attribute__((visibility("default"))) +#else +# define BSSHARED_API_EXPORT +# define BSSHARED_API_IMPORT +#endif + +#ifdef BSSHARED_API_BUILDING +# define BSSHARED_API BSSHARED_API_EXPORT +#else +# define BSSHARED_API BSSHARED_API_IMPORT +#endif + constexpr size_t HashSize = 8; -class BestSourceException : public std::runtime_error { +class BSSHARED_API BestSourceException : public std::runtime_error { using std::runtime_error::runtime_error; }; -class BestSourceHWDecoderException : public BestSourceException { +class BSSHARED_API BestSourceHWDecoderException : public BestSourceException { using BestSourceException::BestSourceException; }; From c374e5728402adc3129b45019c72f7dd4310820c Mon Sep 17 00:00:00 2001 From: Justin Turner Arthur Date: Wed, 17 Dec 2025 00:48:22 -0600 Subject: [PATCH 2/3] Hide exception symbols in a static build. --- meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 46c4006..ef6d443 100644 --- a/meson.build +++ b/meson.build @@ -27,7 +27,7 @@ plugin_sources = files( ) libs = [] -api_args = ['-DBSSHARED_API_BUILDING'] +api_args = [] p2p_args = [] if host_machine.cpu_family().startswith('x86') @@ -69,6 +69,10 @@ if meson.get_compiler('cpp').get_linker_id() in ['ld.bfd', 'ld.gold', 'ld.mold'] link_args += ['-Wl,-Bsymbolic'] endif +if get_option('default_library') != 'static' + api_args += ['-DBSSHARED_API_BUILDING'] +endif + libbestsource = library('libbestsource', api_sources, dependencies: deps, install: true, From 0937d52348766eba0f9e0adcee4000fd2bab54c6 Mon Sep 17 00:00:00 2001 From: Justin Turner Arthur Date: Wed, 17 Dec 2025 01:50:25 -0600 Subject: [PATCH 3/3] Avoid import/export of symbols altogether in Windows and OS2 static builds. --- meson.build | 4 +++- src/bsshared.h | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index ef6d443..04de5c3 100644 --- a/meson.build +++ b/meson.build @@ -69,7 +69,9 @@ if meson.get_compiler('cpp').get_linker_id() in ['ld.bfd', 'ld.gold', 'ld.mold'] link_args += ['-Wl,-Bsymbolic'] endif -if get_option('default_library') != 'static' +if get_option('default_library') == 'static' + api_args += ['-DBSSHARED_API_STATIC'] +else api_args += ['-DBSSHARED_API_BUILDING'] endif diff --git a/src/bsshared.h b/src/bsshared.h index bc4be3c..b894f2a 100644 --- a/src/bsshared.h +++ b/src/bsshared.h @@ -28,10 +28,10 @@ #include #include -#if (defined(_WIN32) || defined(__CYGWIN__)) +#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(BSSHARED_API_STATIC) # define BSSHARED_API_EXPORT __declspec(dllexport) # define BSSHARED_API_IMPORT __declspec(dllimport) -#elif defined(__OS2__) +#elif defined(__OS2__) && !defined(BSSHARED_API_STATIC) # define BSSHARED_API_EXPORT __declspec(dllexport) # define BSSHARED_API_IMPORT #elif __GNUC__ >= 4