0001-Prefer-ext-static-libs-when-default-library-static.patch 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. From c1359a49b61016031287d62f44a363cb76242c91 Mon Sep 17 00:00:00 2001
  2. From: Matt Weber <matthew.weber@rockwellcollins.com>
  3. Date: Sat, 26 Oct 2019 09:17:29 -0500
  4. Subject: [PATCH] Prefer ext static libs when --default-library=static
  5. This patch adds a case in the library pattern logic to prefer static
  6. libraries when the Meson Core option for "default_library" is set to
  7. solely static.
  8. The existing library search order makes sense for cases of shared and
  9. shared / static mixed. However if using a prebuilt cross-toolchain,
  10. they usually provide both a static and shared version of sysroot
  11. libraries. This presents a problem in a complete static build where
  12. there won't be shared libraries at runtime and during build time there
  13. are failures like "ld: attempted static link of dynamic object".
  14. Bug:
  15. https://github.com/mesonbuild/meson/issues/6108
  16. Fixes:
  17. http://autobuild.buildroot.net/results/db1740b4777f436324218c52bc7b08e5c21b667d/
  18. http://autobuild.buildroot.net/results/c17/c17bbb12d9deadd64a441b36e324cfbbe8aba5be/
  19. Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
  20. [Updated for 0.57.1 - get_builtin_option() vs. get_option(OptionKey())]
  21. Signed-off-by: Peter Seiderer <ps.report@gmx.net>
  22. [Bernd: rebased for 1.6.0]
  23. Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
  24. ---
  25. mesonbuild/compilers/mixins/clike.py | 3 +++
  26. 1 file changed, 3 insertions(+)
  27. diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py
  28. index 09ad837b1..b7f6b9f22 100644
  29. --- a/mesonbuild/compilers/mixins/clike.py
  30. +++ b/mesonbuild/compilers/mixins/clike.py
  31. @@ -27,6 +27,7 @@
  32. from ... import mlog
  33. from ...linkers.linkers import GnuLikeDynamicLinkerMixin, SolarisDynamicLinker, CompCertDynamicLinker
  34. from ...mesonlib import LibType
  35. +from ...options import OptionKey
  36. from .. import compilers
  37. from ..compilers import CompileCheckMode
  38. from .visualstudio import VisualStudioLikeCompiler
  39. @@ -1038,6 +1038,9 @@ class CLikeCompiler(Compiler):
  40. # TI C6000 compiler can use both extensions for static or dynamic libs.
  41. stlibext = ['a', 'lib']
  42. shlibext = ['dll', 'so']
  43. + elif env.coredata.get_option(OptionKey('default_library')) == 'static':
  44. + # Linux/BSDs
  45. + shlibext = ['a']
  46. else:
  47. # Linux/BSDs
  48. shlibext = ['so']
  49. --
  50. 2.25.1