Bug 1396882 - pass extra_toolchain_flags to linker detection invocation; r=glandium
authorNathan Froyd <froydnj@mozilla.com>
Tue, 12 Sep 2017 09:52:13 -0400
changeset 429790 cbda735f3a427ddea14cd835457c95ff73ee189d
parent 429789 9c581d290dc3dd1dc0119b60dcf688901e5b1498
child 429791 4bad774d13f21986ea327dd5836376a81f8a2334
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1396882
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1396882 - pass extra_toolchain_flags to linker detection invocation; r=glandium The linker detection essentitally invokes `$CC -Wl,--version` to determine which linker will be used. This invocation works OK for GCC from the Android NDK, which can find the linker in the same directory; it doesn't work so well for clang from the NDK, which needs additional command-line options to point at the directory containing the linker. We already have extra_toolchain_flags for communicating such options to other compiler invocations for the target; we should be using extra_toolchain_flags here as well.
build/moz.configure/toolchain.configure
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -1143,20 +1143,23 @@ option('--enable-gold',
        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)
 
 @imports('os')
 @imports('shutil')
-def enable_gnu_linker(enable_gold_option, c_compiler, developer_options, build_env, linker_name):
+def enable_gnu_linker(enable_gold_option, c_compiler, developer_options, build_env,
+                      toolchain_flags, linker_name):
     # Used to check the kind of linker
     version_check = ['-Wl,--version']
     cmd_base = c_compiler.wrapper + [c_compiler.compiler] + c_compiler.flags
+    if toolchain_flags:
+        cmd_base += toolchain_flags
 
     def resolve_gold():
         # Try to force the usage of gold
         targetDir = os.path.join(build_env.topobjdir, 'build', 'unix', 'gold')
 
         gold_detection_arg = '-print-prog-name=ld.gold'
         gold = check_cmd_output(c_compiler.compiler, gold_detection_arg).strip()
         if not gold:
@@ -1214,22 +1217,24 @@ def enable_gnu_linker(enable_gold_option
         KIND='other'
     )
 
 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)
+@depends('--enable-linker', c_compiler, developer_options, check_build_environment,
+         extra_toolchain_flags, when=build_not_win_mac)
 @checking('for linker', lambda x: x.KIND)
-def select_linker(linker, c_compiler, developer_options, build_env):
+def select_linker(linker, c_compiler, developer_options, build_env, toolchain_flags):
     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)
+        return enable_gnu_linker(linker == 'gold', c_compiler, developer_options,
+                                 build_env, toolchain_flags, 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',