summaryrefslogtreecommitdiff
path: root/waterfox/mozilla-1336978.patch
blob: 136eb83c1a8b1d35170d3a705650da3ec669ef8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99

# HG changeset patch
# User Sylvestre Ledru <sledru@mozilla.com>
# Date 1501074847 -7200
# Node ID 342812d23eb995a19b391f7bcd48d03db092709a
# Parent  2980183d98fb2513d41209c5a9e08bfc519b68fa
Bug 1336978 - Add support of lld by adding a configure option --enable-linker='bfd', 'gold', 'lld', 'other' r=glandium

MozReview-Commit-ID: 7LI2lMXO2lG

diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -1136,23 +1136,23 @@ def build_not_win_mac(target):
         return True
 
 
 option('--enable-gold',
        env='MOZ_FORCE_GOLD',
        help='Enable GNU Gold Linker when it is not already the default',
        when=build_not_win_mac)
 
+imply_option('--enable-linker',
+             depends_if('--enable-gold', when=build_not_win_mac)(lambda x: 'gold'),
+             when=build_not_win_mac)
 
-@depends('--enable-gold', c_compiler, developer_options, check_build_environment, when=build_not_win_mac)
-@checking('for ld', lambda x: x.KIND)
 @imports('os')
 @imports('shutil')
-def enable_gold(enable_gold_option, c_compiler, developer_options, build_env):
-    linker = None
+def enable_gnu_linker(enable_gold_option, c_compiler, developer_options, build_env, linker_name):
     # Used to check the kind of linker
     version_check = ['-Wl,--version']
     cmd_base = c_compiler.wrapper + [c_compiler.compiler] + c_compiler.flags
 
     def resolve_gold():
         # Try to force the usage of gold
         targetDir = os.path.join(build_env.topobjdir, 'build', 'unix', 'gold')
 
@@ -1177,17 +1177,17 @@ def enable_gold(enable_gold_option, c_co
             return namespace(
                 KIND='gold',
                 LINKER_FLAG=linker,
             )
         else:
             # The -B trick didn't work, removing the directory
             shutil.rmtree(targetDir)
 
-    if enable_gold_option or developer_options:
+    if (enable_gold_option or developer_options) and linker_name != 'bfd':
         result = resolve_gold()
 
         if result:
             return result
         # gold is only required if --enable-gold is used.
         elif enable_gold_option:
             die('Could not find gold')
         # Else fallthrough.
@@ -1208,10 +1208,35 @@ def enable_gold(enable_gold_option, c_co
             KIND='gold'
         )
 
     # For other platforms without gold or the GNU linker
     return namespace(
         KIND='other'
     )
 
-set_config('LD_IS_BFD', depends(enable_gold.KIND)(lambda x: x == 'bfd' or None))
-set_config('LINKER_LDFLAGS', enable_gold.LINKER_FLAG)
+js_option('--enable-linker', nargs=1,
+          choices=('bfd', 'gold', 'lld', 'other'),
+          help='Select the linker',
+          when=build_not_win_mac)
+
+@depends('--enable-linker', c_compiler, developer_options, check_build_environment, when=build_not_win_mac)
+@checking('for linker', lambda x: x.KIND)
+def select_linker(linker, c_compiler, developer_options, build_env):
+    linker = linker[0] if linker else 'other'
+    if linker in ('gold', 'bfd', 'other'):
+        return enable_gnu_linker(linker == 'gold', c_compiler, developer_options, build_env, linker)
+    if linker == 'lld':
+        version_check = ['-Wl,--version']
+        cmd_base = c_compiler.wrapper + [c_compiler.compiler] + c_compiler.flags
+        lld = "-fuse-ld=" + linker
+        cmd = cmd_base + [lld] + version_check
+        if 'LLD' in check_cmd_output(*cmd).decode('utf-8'):
+            return namespace(
+                KIND='lld',
+                LINKER_FLAG=lld,
+            )
+        else:
+            die("Could not use lld as linker")
+
+
+set_config('LD_IS_BFD', depends(select_linker.KIND)(lambda x: x == 'bfd' or None))
+set_config('LINKER_LDFLAGS', select_linker.LINKER_FLAG)

bgstack15