After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 732669 - Use visibility/dllexport to export symbols for GObject-Introspection
Use visibility/dllexport to export symbols for GObject-Introspection
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: general
2.41.x
Other All
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2014-07-03 09:40 UTC by Fan, Chun-wei
Modified: 2015-02-07 16:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add a version header to define macros to decorate public symbols (and the 2 private symbols, as needed) (38.98 KB, patch)
2014-07-04 10:22 UTC, Fan, Chun-wei
committed Details | Review
girepository: Include config.h first in all the C-sources (7.85 KB, patch)
2014-07-04 10:29 UTC, Fan, Chun-wei
committed Details | Review
Update the generation of the sources for the 'Everything' test (1.38 KB, patch)
2014-07-04 10:43 UTC, Fan, Chun-wei
needs-work Details | Review
Add to the test sources/headers macros to export the symbols (95.87 KB, patch)
2014-07-04 10:53 UTC, Fan, Chun-wei
needs-work Details | Review
Tests: Add a header for sumbol exporting (1.44 KB, patch)
2014-07-04 12:03 UTC, Fan, Chun-wei
none Details | Review
Build: determine compiler directives for symbol export at configure time and drop the .def/.symbols files (44.00 KB, patch)
2014-07-07 10:07 UTC, Fan, Chun-wei
committed Details | Review
Update the pre-defined config.h.win32(.in) for exporting the symbols for MSVC Builds (1.10 KB, patch)
2014-07-07 10:15 UTC, Fan, Chun-wei
committed Details | Review
MSVC Project: Don't try to create and use a .def file when building libgirepository (10.60 KB, patch)
2014-07-07 10:17 UTC, Fan, Chun-wei
committed Details | Review
tests/: Add a Header For Symbol Exporting (take ii) (1.66 KB, patch)
2014-08-12 05:07 UTC, Fan, Chun-wei
committed Details | Review
tests/: Annotate the gimarshallingtest for exporting symbols (42.15 KB, patch)
2014-08-12 05:11 UTC, Fan, Chun-wei
committed Details | Review
tests/scanner/: Annotate the tests headers and sources for exporting symbols (57.50 KB, patch)
2014-08-12 05:15 UTC, Fan, Chun-wei
committed Details | Review
Update MSVC NMake file used to build the tests (4.79 KB, patch)
2014-08-12 05:22 UTC, Fan, Chun-wei
committed Details | Review
Update the generation of the sources for the 'Everything' test (take ii) (1.38 KB, patch)
2014-08-15 02:33 UTC, Fan, Chun-wei
none Details | Review
Update the generation of the sources for the 'Everything' test (take iii) (2.24 KB, patch)
2014-08-22 12:16 UTC, Fan, Chun-wei
reviewed Details | Review
Export symbols using visibility for the offsets test library (3.96 KB, patch)
2014-08-22 12:19 UTC, Fan, Chun-wei
none Details | Review
Export symbols using visibility for the offsets test library (take ii) (3.94 KB, patch)
2014-08-25 03:53 UTC, Fan, Chun-wei
committed Details | Review
giscanner: Add optional options to decorate symbols and include headers in generated code (7.68 KB, patch)
2014-09-03 04:04 UTC, Fan, Chun-wei
committed Details | Review
Update tests/Makefile.am on generating everything.[c|h] (1.85 KB, patch)
2014-09-03 04:07 UTC, Fan, Chun-wei
committed Details | Review
MSVC Builds: Update Generation of everything.[c|h] (1.26 KB, patch)
2014-09-03 04:09 UTC, Fan, Chun-wei
committed Details | Review
Hide more symbols that shouldn't be exported (1.47 KB, patch)
2014-09-05 21:01 UTC, Andreas Henriksson
committed Details | Review
Export missing g_typelib_error_quark (1007 bytes, patch)
2014-09-05 21:01 UTC, Andreas Henriksson
reviewed Details | Review

Description Fan, Chun-wei 2014-07-03 09:40:45 UTC
Hi,

From Colin's comments in bug 681820 (comments 25 & 26):

----------------------
This patch will require the most ongoing maintenance; is there a way we can use
say the "dllexport" annotation on the header files instead?

...

Similar for this one...these symbol lists are going to be annoying extra work
to maintain.  If there's a way to use an attribute in the header files, or
failing that, generate these files, that'd be much preferred.

----------------------

I thought it might be a good idea, especially as GLib, GTK+, Clutter (and so) have been doing this for some time, that we export of symbols for the g-i main library, and also for the building of the test libraries, by using the visibility/dllexport method, as we wouldn't have to worry about the .symbols/.def files running out of date (and hence drop them).

I will post patches to this bug in the next few days or so.

With blessings, thank you!
Comment 1 Fan, Chun-wei 2014-07-04 10:22:51 UTC
Created attachment 279890 [details] [review]
Add a version header to define macros to decorate public symbols (and the 2 private symbols, as needed)

Hi,

This adds a version macro header that is included either directly or indirectly by girepository's headers, so that each public symbol (and the 2 symbols in gitypelib-internal.h that is used by the tools) is decorated by a version macro, which can be later used to export a symbol and possibly display compile-time warnings for the use of deprecated API in the future.

Note that as g-i follows GLib development closely, and share the same minor
version numbers, the version macros follow the GLib minor numbers, so there
are no GI_VERSION_1_xx as a result, but instead follows the GLIB_VERSION_2_xx convention in GLib.
Comment 2 Fan, Chun-wei 2014-07-04 10:29:57 UTC
Created attachment 279891 [details] [review]
girepository: Include config.h first in all the C-sources

Hi,

This updates all the C-sources for girepository so that they will include config.h first, so that the correct symbol export compiler directive can be used to export the symbols as necessary.
Comment 3 Fan, Chun-wei 2014-07-04 10:43:46 UTC
Created attachment 279892 [details] [review]
Update the generation of the sources for the 'Everything' test

Hi,

Please see the comments in this patch...
Comment 4 Fan, Chun-wei 2014-07-04 10:53:59 UTC
Created attachment 279893 [details] [review]
Add to the test sources/headers macros to export the symbols

Hi,

This adds to the tests sources and headers macros that can be used to export the symbols when the test libraries are built, and includes config.h first in the C-sources so that the correct compiler directive for symbol exporting can be used during compile time.

I will go into updating the autotools files for determing the compiler directive to export the symbols at configure time in the next few days, but by using "__declspec(dllexport) extern" in config.h.win32(.in) did work for me for the Visual C++ builds (i.e. no .def/.symbols files were used in the build), and the patches applied in their current state does pass 'make distcheck'.

With blessings, thank you!
Comment 5 Emmanuele Bassi (:ebassi) 2014-07-04 11:43:36 UTC
Review of attachment 279890 [details] [review]:

looks generally good, but everything seems to be annotated in AVAILABLE_IN_ALL, so I don't know whether we should have versioned symbols for 1.32 and later.
Comment 6 Emmanuele Bassi (:ebassi) 2014-07-04 11:44:10 UTC
Review of attachment 279891 [details] [review]:

looks good, and should be committed regardless.
Comment 7 Emmanuele Bassi (:ebassi) 2014-07-04 11:46:23 UTC
Review of attachment 279892 [details] [review]:

gitestmacros.h does not exist in the previous commits; did you forget to add it?
Comment 8 Emmanuele Bassi (:ebassi) 2014-07-04 11:46:57 UTC
Review of attachment 279893 [details] [review]:

needs gitestmacros.h.
Comment 9 Fan, Chun-wei 2014-07-04 12:02:51 UTC
Review of attachment 279890 [details] [review]:

Hello Emmanuele,

In fact there are (such as in giinterfaceinfo.h and girepository.h, for example), but they are far between-I deduced the available version by the commit dates (vs the stable version release date).  Let me know if I missed something.

With blessings, thank you!
Comment 10 Fan, Chun-wei 2014-07-04 12:03:58 UTC
Created attachment 279899 [details] [review]
Tests: Add a header for sumbol exporting

Hello Emmanuele,

Sorry, missed that part...oops.

With blessings, thank you!
Comment 11 Fan, Chun-wei 2014-07-07 01:25:46 UTC
Review of attachment 279891 [details] [review]:

Hello Emmanuele,

Thanks for the reviews, the patch was pushed as 0ad96c5a.

With blessings.
Comment 12 Fan, Chun-wei 2014-07-07 10:07:34 UTC
Created attachment 280040 [details] [review]
Build: determine compiler directives for symbol export at configure time and drop the .def/.symbols files

Hi,

Here comes the patch that updates the autotools files to:

-Determine the compiler directive for using visibility
 attributes/dllexport to export symbols for both libgirepository
 and the test libraries at configure time to be used during
 build time.

-Drop all the .symbols and .def files.

With blessings, thank you!
Comment 13 Fan, Chun-wei 2014-07-07 10:15:54 UTC
Created attachment 280041 [details] [review]
Update the pre-defined config.h.win32(.in) for exporting the symbols for MSVC Builds

.
Comment 14 Fan, Chun-wei 2014-07-07 10:17:32 UTC
Created attachment 280042 [details] [review]
MSVC Project: Don't try to create and use a .def file when building libgirepository

Hi,

This is the last proposed patch for this bug...

With blessings, and thanks for the time.
Comment 15 Fan, Chun-wei 2014-07-11 06:51:07 UTC
Hi,

Any comments with the patchset (a.k.a ping)?  Much appreciated

With blessings, thank you!
Comment 16 Fan, Chun-wei 2014-08-12 05:01:02 UTC
Hello Emmanuele,

> looks generally good, but everything seems to be annotated in AVAILABLE_IN_ALL,
> so I don't know whether we should have versioned symbols for 1.32 and later.

hmm..., I checked the g-i documentation page[1], and I think that I had the symbols in Index of new symbols in... for 1.34 and later annotated as such in attachment 279890 [details] [review], plus some newer APIs that were added in the development cycles after 1.32, but were not marked as "Since: ..." in the GTK-Doc blocks, as they seem to me (I think this would belong to another bug, though).  Please let me know if this is okay or I missed something.

With blessings, thank you!

[1]: https://developer.gnome.org/gi/unstable/
Comment 17 Fan, Chun-wei 2014-08-12 05:07:50 UTC
Created attachment 283153 [details] [review]
tests/: Add a Header For Symbol Exporting (take ii)

Hi,

This re-does the part where we add a header in tests/ so that the headers of the test programs/libs can include it, which can then be used to export the annotated symbols, and this patch is a dependency of attachment 278892 [details] [review].

This is re-done because:
-This file needs to be installed for the autotools builds,
 as the installed test sources/headers will look for it.
-Probably it is better that we don't depend on the
 girepository headers at all, as the tests that involved
 building introspection for themselves seem not to include
 them
Comment 18 Fan, Chun-wei 2014-08-12 05:11:50 UTC
Created attachment 283154 [details] [review]
tests/: Annotate the gimarshallingtest for exporting symbols

Hi,

This updates the gimarshallingtests.h to include gitestmacros.h (in attachment 283153 [details] [review]) in order to annotate the symbols for export, and includes config.h first for gimarshallingtests.c...
Comment 19 Fan, Chun-wei 2014-08-12 05:15:03 UTC
Created attachment 283155 [details] [review]
tests/scanner/: Annotate the tests headers and sources for exporting symbols

Hi,

This annotates the various test sources and headers to include gitestmacros.h and config.h so that their various symbols can be exported during the build (like what was done in in attachment 283154 [details] [review]).  This incorporates the tests that were added a few days ago or so...
Comment 20 Fan, Chun-wei 2014-08-12 05:22:44 UTC
Created attachment 283156 [details] [review]
Update MSVC NMake file used to build the tests

Hi,

This updates the NMake Makefile that is being used to build the test programs and DLLs.

(In reply to comment #17)
> Created an attachment (id=283153) [details] [review]
> tests/: Add a Header For Symbol Exporting (take ii)
> annotated symbols, and this patch is a dependency of attachment 278892 [details] [review].

Sorry, this should read "a dependency of attachment 279892 [details] [review]".

With blessings, thank you!
Comment 21 Colin Walters 2014-08-13 02:09:48 UTC
Review of attachment 280040 [details] [review]:

This looks fine to me.
Comment 22 Colin Walters 2014-08-13 02:10:27 UTC
Review of attachment 280041 [details] [review]:

Not a win32 expert, but looks reasonable.
Comment 23 Colin Walters 2014-08-13 02:10:47 UTC
Review of attachment 280042 [details] [review]:

Right.
Comment 24 Colin Walters 2014-08-13 02:12:25 UTC
Review of attachment 283153 [details] [review]:

Looks OK, though I'm curious if there's a specific reason we do the indirection - i.e. why not annotate the tests directly as GI_EXTERN?  Just a general sense of separating API and tests?
Comment 25 Colin Walters 2014-08-13 02:12:39 UTC
Review of attachment 283154 [details] [review]:

Ok.
Comment 26 Colin Walters 2014-08-13 02:12:58 UTC
Review of attachment 283155 [details] [review]:

Yep.
Comment 27 Colin Walters 2014-08-13 02:13:28 UTC
Review of attachment 283156 [details] [review]:

Ok.
Comment 28 Fan, Chun-wei 2014-08-13 06:33:36 UTC
Hello Colin,

Just wondering, as attachment 279890 [details] [review] is needed for many of the other patches, would attachment 279890 [details] [review] be alright for consumption?  Needed to know before I go ahead to commit these.  Would be nice if attachment 279892 [details] [review] gets another look, as we have attachment 283153 [details] [review], which contains the file that is needed.

(In reply to comment #24)

> - i.e. why not annotate the tests directly as GI_EXTERN?  Just a general sense
> of separating API and tests?

Yeah, that's my take at it though, and thought that I didn't want to define _GLIB_EXTERN as extern again if it is not previously defined.  I could use _GLIB_EXTERN if that is preferred though.

With blessings, thank you!
Comment 29 Colin Walters 2014-08-14 19:04:36 UTC
Review of attachment 279890 [details] [review]:

Right, I see that.  Looks good to me then, thanks!
Comment 30 Fan, Chun-wei 2014-08-15 02:33:31 UTC
Created attachment 283430 [details] [review]
Update the generation of the sources for the 'Everything' test (take ii)

Hello Colin,

Thanks for the reviews, the patches were pushed in chronological order as:

attachment 279890 [details] [review]: 94380459
attachment 282153 [details] [review]: 4bfe7f1d
attachment 283154 [details] [review]: 28b01ad7
attachment 283155 [details] [review]: eab36c00
attachment 280040 [details] [review]: d281b07c
attachment 280041 [details] [review]: d2ff2e13
attachment 280042 [details] [review]: 902cd3f9
attachment 283156 [details] [review]: fffc66a6

Sorry, I pushed attachment 279892 [details] [review] by mistake just now and reverted it, and here is an updated version of it, as everything.[c|h] seems to be installed with the autotools builds, so it needs to be updated so that gitestmacros.h can be found after it is installed.

With blessings, thank you!
Comment 31 Fan, Chun-wei 2014-08-15 02:36:27 UTC
Sorry,

"attachment 282153 [details] [review]" should have read "attachment 283153 [details] [review]"...
Comment 32 Fan, Chun-wei 2014-08-22 12:16:40 UTC
Created attachment 284186 [details] [review]
Update the generation of the sources for the 'Everything' test (take iii)

Hi,

For the generation of everything.[c|h], it also seems that as it is also installed as test data, it needs to include gitestmacros.h directly, and so the autotools build files need to have -I$(srcdir) so that gitestmacros.h can be found when builddir != srcdir.  This is the updated patch for this.

With blessings, thank you!
Comment 33 Fan, Chun-wei 2014-08-22 12:19:03 UTC
Created attachment 284187 [details] [review]
Export symbols using visibility for the offsets test library

Hi,

This adds annotation to the offset test library sources, so that symbols from it can be exported via visibility/dllexport (sorry, offsets.[c|h] was left out in the previous patches).  The autotools files are updated as well so that gitestmacros.h can be found during building.

With blessings, thank you!
Comment 34 Fan, Chun-wei 2014-08-25 03:53:21 UTC
Created attachment 284367 [details] [review]
Export symbols using visibility for the offsets test library (take ii)

Hi,

Apparently the build files for the offsets library and test program needed some more tinkering so that it can run alright on make check/distcheck, so here it is...

With blessings, thank you!
Comment 35 Fan, Chun-wei 2014-09-01 08:58:44 UTC
Hi,

(ping mode)

Is there any chance that the remaining 2 patches be reviewed so that we can say bye to this bug by this release cycle?  Greatly appreciated.

Thanks for your time, with blessings!
Comment 36 Colin Walters 2014-09-02 15:11:59 UTC
Review of attachment 284186 [details] [review]:

::: giscanner/codegen.py
@@ +52,3 @@
     def _write_prelude(self, out, func):
         out.write("""
+_GI_TEST_EXTERN

Mmmm...now we're injecting this into every use of g-ir-scanner.  I don't think that's right.

Possibly make use of the existing UNINSTALLED_INTROSPECTION_SRCDIR environment variable?

Or a more generic fix would be to add a --with-function-prelude=_GI_TEST_EXTERN environment variable.

@@ +119,3 @@
         self.out_c.write(warning)
+        self.out_c.write("""
+#include "config.h"

If we went with a command line arg, this would have to be --with-prelude='#include "config.h"' or so.
Comment 37 Colin Walters 2014-09-02 15:13:11 UTC
Review of attachment 284367 [details] [review]:

This looks fine to me.
Comment 38 Fan, Chun-wei 2014-09-03 04:04:15 UTC
Created attachment 285219 [details] [review]
giscanner: Add optional options to decorate symbols and include headers in generated code

Hello Colin,

Thanks for the reviews, attachment 284367 [details] [review] was pushed to master as 5143afb1.

(In reply to comment #36)
> Or a more generic fix would be to add a --with-function-prelude=_GI_TEST_EXTERN
> environment variable.
> --with-prelude='#include "config.h"' or so.

OK, I think it's probably better to go with the generic route too, so this is my take at updating the scripts to take additional options for doing these if needed, albeit with different names.

I will update the build files in the next 2 patches, one for autotools and the other for MSVC builds...
Comment 39 Fan, Chun-wei 2014-09-03 04:07:35 UTC
Created attachment 285220 [details] [review]
Update tests/Makefile.am on generating everything.[c|h]

Hi,

This updates the autotools builds for generating everything.[c|h] test program sources, so that the sources will include the annotation for symbol export and the headers that define those annotations...
Comment 40 Fan, Chun-wei 2014-09-03 04:09:38 UTC
Created attachment 285221 [details] [review]
MSVC Builds: Update Generation of everything.[c|h]

Hi,

This patch is like attachment 285220 [details] [review], which updates the MSVC build files that is used to build the tests for the same purpose.

With blessings, thank you!
Comment 41 Colin Walters 2014-09-03 15:25:40 UTC
Review of attachment 285219 [details] [review]:

This looks OK to me.  Though I do wonder whether it would be better to instead just not pass the visibility linker flags while scanning.  Did we try that?

Anyways, I'm fine with this approach.
Comment 42 Colin Walters 2014-09-03 15:26:06 UTC
Review of attachment 285220 [details] [review]:

Ok.
Comment 43 Colin Walters 2014-09-03 15:26:18 UTC
Review of attachment 285221 [details] [review]:

Right.
Comment 44 Fan, Chun-wei 2014-09-03 16:14:51 UTC
Hello Colin,

Thanks for the reviews.  The patches were pushed as:

attachment 285219 [details] [review]: c112e9830
attachment 285220 [details] [review]: 99423f410
attachment 285221 [details] [review]: 9b2effedf

(In reply to comment #41)
> This looks OK to me.  Though I do wonder whether it would be better to instead
> just not pass the visibility linker flags while scanning.  Did we try that?

I think I will poke into it tomorrow or so, though I will close this bug now for records, as we are getting close to a stable release.

With blessings, thank you!
Comment 45 Andreas Henriksson 2014-09-05 20:14:52 UTC
When upgrading from 1.41.4 to 1.41.91 I'm seeing these changed symbols:

http://paste.debian.net/plain/119539


Most of them go away if I do this:

http://paste.debian.net/plain/119544



Only the missing symbol left... anyone know what happened to g_typelib_error_quark ?
Comment 46 Andreas Henriksson 2014-09-05 21:01:02 UTC
Created attachment 285523 [details] [review]
Hide more symbols that shouldn't be exported

This fixes some fallouts from commit d281b07c4aba18d3
"build: Export Symbols Using Compiler Directives"
Comment 47 Andreas Henriksson 2014-09-05 21:01:08 UTC
Created attachment 285524 [details] [review]
Export missing g_typelib_error_quark

This symbol went missing in the conversion to -fvisibility=hidden
in commit d281b07c4aba18d30c4365ef
"build: Export Symbols Using Compiler Directives"

Maybe it was mistakenly exported from the start since it's
from an internal header...
Comment 48 Andreas Henriksson 2014-09-05 21:04:46 UTC
With the two above patches there are no symbol mismatches between what 1.41.4 used to export and what 1.41.91 + patches exports ....
Comment 49 Colin Walters 2014-09-05 22:52:51 UTC
Review of attachment 285523 [details] [review]:

Definitely, thanks!
Comment 50 Colin Walters 2014-09-05 22:55:07 UTC
Review of attachment 285524 [details] [review]:

We should rather move it (and the #define) to girepository.h; the error quark is intended to be public.  (Not that its super useful, but anyways)
Comment 51 Colin Walters 2014-09-05 22:55:39 UTC
Comment on attachment 285523 [details] [review]
Hide more symbols that shouldn't be exported

Attachment 285523 [details] pushed as c9195de - Hide more symbols that shouldn't be exported
Comment 52 André Klapper 2015-02-07 16:49:42 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]