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