Bug 1381741 - Only fail gold detection when --enable-gold is specified; r=glandium

developer_options (!--enable-release) implies to search for and prefer
the gold linker. As part of porting gold detection to moz.configure
in d0e782180741 (bug 1351109), the logic inadvertently changed to
require gold when either --enable-gold or !--enable-release were
present.

This commit relaxes the requirement to find gold when only --enable-gold
is true.

MozReview-Commit-ID: HTBicWNUkvy

--HG--
extra : rebase_source : dd3938a7914f5db6c315fb775e7cc5ea177bf600
This commit is contained in:
Gregory Szorc 2017-07-20 08:24:36 -07:00
Родитель 78793f2a1e
Коммит 499d2ea19c
1 изменённых файлов: 14 добавлений и 3 удалений

Просмотреть файл

@ -1105,18 +1105,19 @@ def enable_gold(enable_gold_option, c_compiler, developer_options, build_env):
# Used to check the kind of linker
version_check = ['-Wl,--version']
cmd_base = c_compiler.wrapper + [c_compiler.compiler] + c_compiler.flags
if enable_gold_option or developer_options:
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:
die('Could not find gold')
return
goldFullPath = find_program(gold)
if goldFullPath is None:
die('Could not find gold')
return
if os.path.exists(targetDir):
shutil.rmtree(targetDir)
@ -1135,6 +1136,16 @@ def enable_gold(enable_gold_option, c_compiler, developer_options, build_env):
# The -B trick didn't work, removing the directory
shutil.rmtree(targetDir)
if enable_gold_option or developer_options:
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.
cmd = cmd_base + version_check
cmd_output = check_cmd_output(*cmd).decode('utf-8')
# using decode because ld can be localized and python will