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 794687 - inconsistent POLL* constant testing between autotools and meson
inconsistent POLL* constant testing between autotools and meson
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: win32
unspecified
Other Windows
: Normal normal
: ---
Assigned To: gtk-win32 maintainers
gtk-win32 maintainers
Depends on:
Blocks: 790954
 
 
Reported: 2018-03-26 05:45 UTC by LRN
Modified: 2018-04-25 12:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Disable W32-specific POLL* constant test, use a generic one (2.33 KB, patch)
2018-03-31 14:40 UTC, LRN
none Details | Review
Force W32-specific POLL* constant values in meson (2.32 KB, patch)
2018-04-20 19:27 UTC, LRN
none Details | Review
Force W32-specific POLL* constant values in meson v2 (2.44 KB, patch)
2018-04-25 12:40 UTC, LRN
committed Details | Review

Description LRN 2018-03-26 05:45:25 UTC
meson has special code for testing POLL* constants on Windows, configure.ac does not (the generic case falls through due to poll() test failing before that), and just defines G_IO_* to some pre-defined values.

This blows up spectacularly when you combine meson-built glib with modules that were built against autotools-built glib, since the values for G_IO_* do not match anymore (specifically, in autotools build G_IO_IN defaults to 0x1, while in meson build G_IO_IN is set to 0x300, as it is defined in winsock2.h).

I'm not sure what the "right thing"(TM) here is (i mean, autotools builds worked for years, so it seems that G_IO_* values are not fed to winsock calls directly). Most likely, configure.ac should be improved to also do correct POLL* constant tests on W32, when $ac_cv_func_poll = no.
Comment 1 LRN 2018-03-31 14:40:58 UTC
Created attachment 370385 [details] [review]
Disable W32-specific POLL* constant test, use a generic one

The winsock2-using test do works perfectly, however this is a new
thing that didn't exist in autotools-based builds of glib in the past.
Autotools builds used the generic case where values were just defined
to some agreed-upon numbers, and this is what all autotools-glib
binaries and binaries built against autotools-glib (since these
values go into public glibconfig.h header) use. At least one value,
G_POLLIN, is different, thus breaking ABI if some binaries are
built with autotools and the others are built with meson.

Disable this code for now (until an ABI break is authorized) and
implement a test that gives the same result as the old autotools
test did.
Comment 2 LRN 2018-04-20 04:49:40 UTC
bug 794898 broke this patch.
Comment 3 Philip Withnall 2018-04-20 10:22:52 UTC
Comment on attachment 370385 [details] [review]
Disable W32-specific POLL* constant test, use a generic one

(In reply to LRN from comment #2)
> bug 794898 broke this patch.

⇒ marking as needs-work
Comment 4 LRN 2018-04-20 19:27:20 UTC
Created attachment 371171 [details] [review]
Force W32-specific POLL* constant values in meson

The winsock2-using test does work perfectly, however this is a new
thing that didn't exist in autotools-based builds of glib in the past.
Autotools builds used the generic case where values were just defined
to some agreed-upon numbers, and this is what all autotools-glib
binaries and binaries built against autotools-glib (since these
values go into public glibconfig.h header) use. At least one value,
G_POLLIN, is different, thus breaking ABI if some binaries are
built with autotools and the others are built with meson.

Force meson buildscript to use the same G_POLL* constant values
for Windows builds that autotools builds use.

v2:
* Update the patch to apply against master. Since master changed
  the way the test is being done, we don't disable the test anymore.
  We let it pass, and then just override the results. Put the pre-defined
  constants in the same array as the test macros and subst variable names,
  it's more convenient that way.
Comment 5 Philip Withnall 2018-04-23 15:04:40 UTC
(In reply to LRN from comment #0)
> autotools builds
> worked for years, so it seems that G_IO_* values are not fed to winsock
> calls directly

Yeah, see network_events_for_condition() in gsocket.c.
Comment 6 Philip Withnall 2018-04-23 15:05:12 UTC
Review of attachment 371171 [details] [review]:

This seems reasonable to me, but I’d like feedback from Nirbheek or Emmanuele before it gets pushed.
Comment 7 Nirbheek Chauhan 2018-04-25 08:31:38 UTC
Review of attachment 371171 [details] [review]:

I guess we have no choice but to do this. Good thing this is undocumented stuff, so people shouldn't be assuming any meaning from the values.

::: meson.build
@@ +1395,3 @@
+  endforeach
+endif
+

Why not move this up and make the foreach d : poll_defines above conditional? It's confusing to run a compiler check and then throw away the result. Something like:

if has_syspoll and has_systypes
  foreach d : poll_defines
    ...
  endforeach
elif has_winsock2
  # Due to a bug in configure.ac ...
  foreach d : poll_defines
    ...
  endforeach
endif
Comment 8 LRN 2018-04-25 12:40:55 UTC
Created attachment 371370 [details] [review]
Force W32-specific POLL* constant values in meson v2

v2:
* Moved the code as suggested
Comment 9 Philip Withnall 2018-04-25 12:55:27 UTC
Review of attachment 371370 [details] [review]:

OK, thanks.
Comment 10 LRN 2018-04-25 12:59:11 UTC
Attachment 371370 [details] pushed as 85a32c7 - Force W32-specific POLL* constant values in meson