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