libs: figure out right export define in configure

Add new GST_API_EXPORT in config.h and use that for GST_*_API
decorators instead of GST_EXPORT.

The right export define depends on the toolchain and whether
we're using -fvisibility=hidden or not, so it's better to set it
to the right thing directly than hard-coding a compiler whitelist
in the public header.

We put the export define into config.h instead of passing it via the
command line to the compiler because it might contain spaces and brackets
and in the autotools scenario we'd have to pass that through multiple
layers of plumbing and Makefile/shell escaping and we're just not going
to be *that* lucky.

The export define is only used if we're compiling our lib, not by external
users of the lib headers, so it's not a problem to put it into config.h

Also, this means all .c files of libs need to include config.h
to get the export marker defined, so fix up a few that didn't
include config.h.

This commit depends on a common submodule commit that makes gst-glib-gen.mak
add an #include "config.h" to generated enum/marshal .c files for the
autotools build.

https://bugzilla.gnome.org/show_bug.cgi?id=797185
This commit is contained in:
Tim-Philipp Müller 2018-08-25 23:56:01 +02:00
parent 46ed0f0489
commit 57c8e0146f
22 changed files with 66 additions and 11 deletions

2
common

@ -1 +1 @@
Subproject commit ed78bee437dcbe22e6eef0031d9a29d157c0461f
Subproject commit cd1dee06bf07f094677d0cf3eea4a2e8c2636b24

View file

@ -892,7 +892,13 @@ AC_ARG_WITH([memory-alignment],
dnl Symbol visibility
VISIBILITY_CFLAGS=""
AS_COMPILER_FLAG([-fvisibility=hidden], [VISIBILITY_CFLAGS="-fvisibility=hidden"])
AS_COMPILER_FLAG([-fvisibility=hidden], [
VISIBILITY_CFLAGS="-fvisibility=hidden"
AC_DEFINE(GST_API_EXPORT, [extern __attribute__ ((visibility ("default")))], [public symbol export define])
], [
VISIBILITY_CFLAGS=""
AC_DEFINE(GST_API_EXPORT, [extern], [public symbol export define])
])
AC_SUBST(VISIBILITY_CFLAGS)
dnl Check for -Bsymbolic-functions linker flag used to avoid

View file

@ -163,7 +163,7 @@
#ifndef GST_API
# ifdef BUILDING_GST
#define GST_API GST_EXPORT
# define GST_API GST_API_EXPORT /* from config.h */
# else
# define GST_API GST_API_IMPORT
# endif

View file

@ -26,7 +26,7 @@
#ifndef GST_BASE_API
#ifdef BUILDING_GST_BASE
#define GST_BASE_API GST_EXPORT
#define GST_BASE_API GST_API_EXPORT /* from config.h */
#else
#define GST_BASE_API GST_API_IMPORT
#endif

View file

@ -28,6 +28,9 @@
* also provides size-related functionality. This object should be used for
* any #GstElement that wishes to provide some sort of queueing functionality.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
#include "string.h"

View file

@ -60,6 +60,9 @@
*
* Since: 1.4
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
#include "gstflowcombiner.h"

View file

@ -29,7 +29,9 @@
* based on an array instead of linked lists. This reduces the overhead
* caused by memory management by a large factor.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include <gst/gst.h>

View file

@ -26,7 +26,7 @@
#ifndef GST_CHECK_API
#ifdef BUILDING_GST_CHECK
#define GST_CHECK_API GST_EXPORT
#define GST_CHECK_API GST_API_EXPORT /* from config.h */
#else
#define GST_CHECK_API GST_API_IMPORT
#endif

View file

@ -28,6 +28,9 @@
* These macros and functions are for internal use of the unit tests found
* inside the 'check' directories of various GStreamer packages.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstbufferstraw.h"

View file

@ -29,6 +29,9 @@
* These macros and functions are for internal use of the unit tests found
* inside the 'check' directories of various GStreamer packages.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstconsistencychecker.h"

View file

@ -26,7 +26,7 @@
#ifndef GST_CONTROLLER_API
#ifdef BUILDING_GST_CONTROLLER
#define GST_CONTROLLER_API GST_EXPORT
#define GST_CONTROLLER_API GST_API_EXPORT /* from config.h */
#else
#define GST_CONTROLLER_API GST_API_IMPORT
#endif

View file

@ -29,6 +29,9 @@
* gobject properties representing a color. A control value of 0.0 will turn the
* color component off and a value of 1.0 will be the color level.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <glib-object.h>
#include <gst/gst.h>

View file

@ -31,6 +31,9 @@
* will be clipped. An absolute control binding will not do any value
* transformations.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <glib-object.h>
#include <gst/gst.h>

View file

@ -36,6 +36,9 @@
* All functions are MT-safe.
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <glib-object.h>
#include <gst/gst.h>

View file

@ -35,6 +35,9 @@
*
* All functions are MT-safe.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <float.h>

View file

@ -35,6 +35,9 @@
* All functions are MT-safe.
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <glib-object.h>
#include <gst/gst.h>

View file

@ -36,6 +36,9 @@
*
* All functions are MT-safe.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <glib-object.h>
#include <gst/gst.h>

View file

@ -29,6 +29,7 @@ install_headers(gst_controller_headers, subdir : 'gstreamer-1.0/gst/controller/'
controller_enums = gnome.mkenums_simple('controller-enumtypes',
sources : controller_mkenum_headers,
header_prefix : '#include <gst/controller/controller-prelude.h>',
body_prefix : '#include "config.h"',
decorator : 'GST_CONTROLLER_API',
install_header : true,
install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/controller'))

View file

@ -26,6 +26,9 @@
* in a #GstBuffer so that it network elements can track the to and from address
* of the buffer.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>

View file

@ -28,6 +28,9 @@
* sending and receiving ancillary data such as unix credentials (See
* #GUnixCredentialsMessage) and Unix file descriptions (See #GUnixFDMessage).
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>

View file

@ -26,7 +26,7 @@
#ifndef GST_NET_API
#ifdef BUILDING_GST_NET
#define GST_NET_API GST_EXPORT
#define GST_NET_API GST_API_EXPORT /* from config.h */
#else
#define GST_NET_API GST_API_IMPORT
#endif

View file

@ -33,6 +33,8 @@ helpers_install_dir = join_paths(libexecdir, 'gstreamer-1.0')
cc = meson.get_compiler('c')
cdata = configuration_data()
# Ignore several spurious warnings for things gstreamer does very commonly
# If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
# If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
@ -51,11 +53,20 @@ elif cc.has_link_argument('-Wl,-Bsymbolic-functions')
endif
# Symbol visibility
have_visibility_hidden = cc.has_argument('-fvisibility=hidden')
if have_visibility_hidden
have_visibility_hidden = false
if cc.get_id() == 'msvc'
export_define = '__declspec(dllexport) extern'
elif cc.has_argument('-fvisibility=hidden')
add_project_arguments('-fvisibility=hidden', language: 'c')
export_define = 'extern __attribute__ ((visibility ("default")))'
have_visibility_hidden = true
else
export_define = 'extern'
endif
# Passing this through the command line would be too messy
cdata.set('GST_API_EXPORT', export_define)
# Disable strict aliasing
if cc.has_argument('-fno-strict-aliasing')
add_project_arguments('-fno-strict-aliasing', language: 'c')
@ -85,7 +96,6 @@ if glib_checks.disabled() or (glib_checks.auto() and not gst_version_is_dev)
add_project_arguments('-DG_DISABLE_CHECKS', language: 'c')
endif
cdata = configuration_data()
cdata.set_quoted('GST_API_VERSION', apiversion)
cdata.set_quoted('GST_DATADIR', join_paths(prefix, get_option('datadir')))
cdata.set_quoted('LOCALEDIR', join_paths(prefix, get_option('localedir')))