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 795406 - Glib fails to build for Android
Glib fails to build for Android
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: build
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on: 740791
Blocks:
 
 
Reported: 2018-04-20 16:17 UTC by Xavier Claessens
Modified: 2018-04-25 17:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Meson: Add missing link on libintl for some tests (1.24 KB, patch)
2018-04-20 16:18 UTC, Xavier Claessens
none Details | Review
Tests: gsubprocess: Do not use stdin/stdout variables (6.52 KB, patch)
2018-04-20 16:18 UTC, Xavier Claessens
committed Details | Review
Meson: Add missing link on libintl for some tests (1.39 KB, patch)
2018-04-20 19:40 UTC, Xavier Claessens
none Details | Review
Fix build when pthread_getname_np is not available (3.34 KB, patch)
2018-04-23 15:59 UTC, Xavier Claessens
none Details | Review
Fix build when pthread_getname_np is not available (3.37 KB, patch)
2018-04-23 16:02 UTC, Xavier Claessens
none Details | Review
Meson: Add missing link on libintl in tests (1.11 KB, patch)
2018-04-24 19:08 UTC, Xavier Claessens
committed Details | Review
Fix build when pthread_getname_np is not available (3.88 KB, patch)
2018-04-24 19:31 UTC, Xavier Claessens
none Details | Review
Fix build when pthread_getname_np is not available (3.85 KB, patch)
2018-04-24 19:42 UTC, Xavier Claessens
committed Details | Review

Description Xavier Claessens 2018-04-20 16:17:27 UTC
.
Comment 1 Xavier Claessens 2018-04-20 16:18:35 UTC
Created attachment 371161 [details] [review]
Meson: Add missing link on libintl for some tests
Comment 2 Xavier Claessens 2018-04-20 16:18:39 UTC
Created attachment 371162 [details] [review]
Tests: gsubprocess: Do not use stdin/stdout variables
Comment 3 Philip Withnall 2018-04-20 16:22:29 UTC
Review of attachment 371162 [details] [review]:

Yes, definitely.
Comment 4 Philip Withnall 2018-04-20 16:34:44 UTC
Review of attachment 371161 [details] [review]:

Can you please clarify in the commit message how libintl is pulled into those tests? What function calls in what files are requiring it, and why isn’t that a problem on desktop Linux?
Comment 5 Xavier Claessens 2018-04-20 19:34:26 UTC
Comment on attachment 371162 [details] [review]
Tests: gsubprocess: Do not use stdin/stdout variables

Attachment 371162 [details] pushed as 5ccd944 - Tests: gsubprocess: Do not use stdin/stdout variables
Comment 6 Xavier Claessens 2018-04-20 19:40:15 UTC
Created attachment 371172 [details] [review]
Meson: Add missing link on libintl for some tests

This fix undefined symbol link error when building for non-glibc
platform. Applications must link on libintl, it is not a public
dependency of libglib.
Comment 7 Xavier Claessens 2018-04-20 19:42:13 UTC
Philip: This is the same as bug #794556, I don't know why we fixed only gdatatime in that bug, I think LRN stopped on the first link error and didn't see there were others.
Comment 8 Xavier Claessens 2018-04-20 19:45:26 UTC
(In reply to Philip Withnall from comment #4)
> Review of attachment 371161 [details] [review] [review]:
>
> and why isn’t that a problem on desktop Linux?

It is for _("foo"), it calls function from glibc but on non-glibc platforms it calls function from a separate library (libintl).
Comment 9 Xavier Claessens 2018-04-23 15:59:57 UTC
Created attachment 371286 [details] [review]
Fix build when pthread_getname_np is not available

On Android _setname_ is always available but _getname_ is available only
with API level >= 26.
Comment 10 Xavier Claessens 2018-04-23 16:02:05 UTC
Created attachment 371287 [details] [review]
Fix build when pthread_getname_np is not available

On Android _setname_ is always available but _getname_ is available only
with API level >= 26.
Comment 11 Philip Withnall 2018-04-24 11:10:30 UTC
Review of attachment 371172 [details] [review]:

::: gio/tests/meson.build
@@ -264,3 @@
                    '-DTEST_LOCALE_PATH="@0@"'.format(test_mo_dir),
                  ],
-        dependencies : common_gio_tests_deps)

Right at the top of the file we already have:

if host_system == 'darwin'
common_gio_tests_deps += [libintl]
endif

Could you not extend that to cover Android too?
Comment 12 Philip Withnall 2018-04-24 11:14:28 UTC
Review of attachment 371287 [details] [review]:

::: configure.ac
@@ +2232,3 @@
             [AC_MSG_RESULT(no)])
+        AC_CHECK_FUNC(pthread_getname_np,
+            [AC_DEFINE(HAVE_PTHREAD_GETNAME_NP,1, [Have function pthread_getname_np])])

Do you not need to heed the comment at the top of this block?

        # This is not AC_CHECK_FUNC to also work with function
        # name mangling in header files.

::: meson.build
@@ +1489,3 @@
+  if cc.has_function('pthread_getname_np', prefix : pthread_prefix, dependencies : thread_dep)
+    glib_conf.set('HAVE_PTHREAD_GETNAME_NP', 1)
+  endif

The checks above use cc.has_header_symbol. Might we need to do that here, probably wrt the previous comment about name mangling?
Comment 13 Xavier Claessens 2018-04-24 19:08:09 UTC
Created attachment 371341 [details] [review]
Meson: Add missing link on libintl in tests

This fix undefined symbol link error when building for non-glibc
platform. Applications must link on libintl, it is not a public
dependency of libglib.

On glibc platforms libintl is a not found dependency and is just ignored
by meson, so it doesn't hurt to always have it.
Comment 14 Xavier Claessens 2018-04-24 19:31:21 UTC
Created attachment 371343 [details] [review]
Fix build when pthread_getname_np is not available

On Android _setname_ is always available but _getname_ is available only
with API level >= 26.
Comment 15 Xavier Claessens 2018-04-24 19:42:43 UTC
Created attachment 371345 [details] [review]
Fix build when pthread_getname_np is not available

On Android _setname_ is always available but _getname_ is available only
with API level >= 26.
Comment 16 Xavier Claessens 2018-04-24 19:44:35 UTC
(In reply to Philip Withnall from comment #12)
> Do you not need to heed the comment at the top of this block?
> 
>         # This is not AC_CHECK_FUNC to also work with function
>         # name mangling in header files.

I don't know why, but better copy what they do above when in doubt. Patch updated. I did the same change in meson too.

> ::: meson.build
> @@ +1489,3 @@
> +  if cc.has_function('pthread_getname_np', prefix : pthread_prefix,
> dependencies : thread_dep)
> +    glib_conf.set('HAVE_PTHREAD_GETNAME_NP', 1)
> +  endif
> 
> The checks above use cc.has_header_symbol. Might we need to do that here,
> probably wrt the previous comment about name mangling?

Indded, whatever that "name mangling" meant, meson port didn't care about it... Let's just imitate what meson already has, if it breaks on some system we probably need to replace all has_header_symbol() anyway.
Comment 17 Xavier Claessens 2018-04-24 19:46:02 UTC
I tested those patch both with autotools and meson, and both for my ubuntu and cross build for android (in cerbero).
Comment 18 Philip Withnall 2018-04-25 11:47:54 UTC
Review of attachment 371341 [details] [review]:

Sure.
Comment 19 Philip Withnall 2018-04-25 11:48:39 UTC
Review of attachment 371345 [details] [review]:

OK.
Comment 20 Xavier Claessens 2018-04-25 17:57:43 UTC
Attachment 371341 [details] pushed as d123717 - Meson: Add missing link on libintl in tests
Attachment 371345 [details] pushed as 01e8396 - Fix build when pthread_getname_np is not available
Comment 21 Xavier Claessens 2018-04-25 17:59:16 UTC
Pushed to both master and 2.56. Thanks.