You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
6.3 KiB

  1. From 750687bf2824fcaf8976fb8b558d583f29acdfeb Mon Sep 17 00:00:00 2001
  2. From: Eli Schwartz <eschwartz@archlinux.org>
  3. Date: Tue, 7 Jun 2022 16:14:04 -0400
  4. Subject: [PATCH 1/2] meson: simplify iconv lookups using Meson's builtin
  5. dependency lookup
  6. iconv is complicated to look up. That complexity now resides in
  7. Meson, since 0.60.0, via a `dependency('iconv')` lookup, so use that
  8. instead.
  9. No effort is made to support the old option for which type of iconv to
  10. use. It was a false choice, because if only one was available, then
  11. that's the only one you can use, and if both are available, the external
  12. iconv shadows the builtin one and renders the builtin one unusable,
  13. so there is still only one you can use.
  14. This meant that when configuring glib with -Diconv=libc on systems that
  15. had an external iconv, the configure check would detect a valid libc
  16. iconv, try to use it, and then fail during the build because iconv.h
  17. belongs to the external iconv and generates machine code using the
  18. external iconv ABI, but fails to link to the iconv `find_library()`.
  19. Meson handles this transparently.
  20. ---
  21. meson.build | 20 +-------------------
  22. meson_options.txt | 8 +-------
  23. 2 files changed, 2 insertions(+), 26 deletions(-)
  24. --- a/meson.build
  25. +++ b/meson.build
  26. @@ -1958,28 +1958,10 @@ glibconfig_conf.set10('G_HAVE_GROWING_ST
  27. # We should never use the MinGW C library's iconv because it may not be
  28. # available in the actual runtime environment. On Windows, we always use
  29. # the built-in implementation
  30. -iconv_opt = get_option('iconv')
  31. if host_system == 'windows'
  32. libiconv = []
  33. - # We have a #include "win_iconv.c" in gconvert.c on Windows, so we don't need
  34. - # any external library for it
  35. - if iconv_opt != 'auto'
  36. - warning('-Diconv was set to @0@, which was ignored')
  37. - endif
  38. else
  39. - found_iconv = false
  40. - if ['auto', 'libc'].contains(iconv_opt) and cc.has_function('iconv_open')
  41. - libiconv = []
  42. - found_iconv = true
  43. - endif
  44. - if not found_iconv and ['auto', 'external'].contains(iconv_opt) and cc.has_header_symbol('iconv.h', 'iconv_open')
  45. - libiconv = [cc.find_library('iconv')]
  46. - found_iconv = true
  47. - endif
  48. -
  49. - if not found_iconv
  50. - error('iconv implementation "@0@" not found'.format(iconv_opt))
  51. - endif
  52. + libiconv = dependency('iconv')
  53. endif
  54. pcre = dependency('libpcre', version: '>= 8.31', required : false) # Should check for Unicode support, too. FIXME
  55. @@ -2046,42 +2028,37 @@ endif
  56. # FIXME: glib-gettext.m4 has much more checks to detect broken/uncompatible
  57. # implementations. This could be extended if issues are found in some platforms.
  58. libintl_deps = []
  59. -if cc.has_function('ngettext', args : osx_ldflags)
  60. - have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset')
  61. -else
  62. - # First just find the bare library.
  63. - libintl = cc.find_library('intl', required : false)
  64. - # The bare library probably won't link without help if it's static.
  65. - if libintl.found() and not cc.has_function('ngettext', args : osx_ldflags, dependencies : libintl)
  66. - libintl_iconv = cc.find_library('iconv', required : false)
  67. - # libintl supports different threading APIs, which may not
  68. - # require additional flags, but it defaults to using pthreads if
  69. - # found. Meson's "threads" dependency does not allow you to
  70. - # prefer pthreads. We may not be using pthreads for glib itself
  71. - # either so just link the library to satisfy libintl rather than
  72. - # also defining the macros with the -pthread flag.
  73. - libintl_pthread = cc.find_library('pthread', required : false)
  74. - # Try linking with just libiconv.
  75. - if libintl_iconv.found() and cc.has_function('ngettext', args : osx_ldflags, dependencies : [libintl, libintl_iconv])
  76. - libintl_deps += [libintl_iconv]
  77. - # Then also try linking with pthreads.
  78. - elif libintl_iconv.found() and libintl_pthread.found() and cc.has_function('ngettext', args : osx_ldflags, dependencies : [libintl, libintl_iconv, libintl_pthread])
  79. - libintl_deps += [libintl_iconv, libintl_pthread]
  80. - else
  81. - libintl = disabler()
  82. - endif
  83. - endif
  84. - if not libintl.found()
  85. - libintl = subproject('proxy-libintl').get_variable('intl_dep')
  86. - libintl_deps = [libintl] + libintl_deps
  87. - have_bind_textdomain_codeset = true # proxy-libintl supports it
  88. +libintl = dependency('intl', required: false)
  89. +if libintl.found()
  90. + # libintl supports different threading APIs, which may not
  91. + # require additional flags, but it defaults to using pthreads if
  92. + # found. Meson's "threads" dependency does not allow you to
  93. + # prefer pthreads. We may not be using pthreads for glib itself
  94. + # either so just link the library to satisfy libintl rather than
  95. + # also defining the macros with the -pthread flag.
  96. + #
  97. + # Meson's builtin dependency lookup as of 0.60.0 doesn't check for
  98. + # pthread, so we do this manually here.
  99. + if cc.has_function('ngettext', dependencies : libintl)
  100. + libintl_deps += [libintl]
  101. else
  102. - libintl_deps = [libintl] + libintl_deps
  103. - have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset', args : osx_ldflags,
  104. - dependencies : libintl_deps)
  105. + libintl_pthread = cc.find_library('pthread', required : false)
  106. + if libintl_pthread.found() and cc.has_function('ngettext', dependencies : [libintl, libintl_pthread])
  107. + libintl_deps += [libintl, libintl_pthread]
  108. + else
  109. + libintl = disabler()
  110. + endif
  111. endif
  112. endif
  113. +if libintl.found()
  114. + have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset', dependencies: libintl_deps)
  115. +else
  116. + libintl = subproject('proxy-libintl').get_variable('intl_dep')
  117. + libintl_deps = [libintl]
  118. + have_bind_textdomain_codeset = true # proxy-libintl supports it
  119. +endif
  120. +
  121. glib_conf.set('HAVE_BIND_TEXTDOMAIN_CODESET', have_bind_textdomain_codeset)
  122. # We require gettext to always be present
  123. --- a/meson_options.txt
  124. +++ b/meson_options.txt
  125. @@ -3,12 +3,6 @@ option('runtime_libdir',
  126. value : '',
  127. description : 'install runtime libraries relative to libdir')
  128. -option('iconv',
  129. - type : 'combo',
  130. - choices : ['auto', 'libc', 'external'],
  131. - value : 'auto',
  132. - description : 'iconv implementation to use (\'libc\' = \'Part of the C library\'; \'external\' = \'External libiconv\'; \'auto\' = \'Auto-detect which iconv is available\')')
  133. -
  134. option('charsetalias_dir',
  135. type : 'string',
  136. value : '',