Bug 1489443 - Set GCC_USE_GNU_LD based on linker kind. r=froydnj

The desired outcome of this change is that we'll set
`-Wl,--version-script` based on linker kind and not on the output of
`$LINKER -v`.

This is a cheap way to address a simple problem that has a complicated
ideal solution.  The underlying issue is that in some situations, when
targeting Android, a macOS system `ld` is interrogated to determine if
a cross-compiling linker "is GNU ld" and a particular linker feature
is set in that situation.  The macOS system `ld` doesn't pass the "is
GNU ld" test, and the linker feature isn't set; that causes link
failures, even though the actual linker has nothing to do with the
system `ld`.

The ideal solution is to test for linker capabilities dynamically.  We
do a lot of that in old-configure.in, and we don't do any of that in
toolchain.configure.  Rather than start testing in
toolchain.configure, we hard-code: a cheap solution to the immediate
problem.

Differential Revision: https://phabricator.services.mozilla.com/D8471

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nick Alexander 2018-10-12 22:38:44 +00:00
Родитель 99e17d748f
Коммит 3c83541616
6 изменённых файлов: 10 добавлений и 11 удалений

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

@ -34,12 +34,6 @@ if test "$CC_TYPE" = "clang-cl"; then
CLANG_CL=1
fi
if test "$GNU_CC"; then
if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then
GCC_USE_GNU_LD=1
fi
fi
AC_SUBST(CLANG_CXX)
AC_SUBST(CLANG_CL)
])

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

@ -1818,6 +1818,13 @@ set_config('LD_IS_BFD', depends(select_linker.KIND)
add_old_configure_assignment('LINKER_LDFLAGS', select_linker.LINKER_FLAG)
# GCC_USE_GNU_LD=1 means the linker is command line compatible with GNU ld.
set_config('GCC_USE_GNU_LD', depends(select_linker.KIND)
(lambda x: x in ('bfd', 'gold', 'lld') or None))
add_old_configure_assignment('GCC_USE_GNU_LD', depends(select_linker.KIND)
(lambda x: x in ('bfd', 'gold', 'lld') or None))
# Assembler detection
# ==============================================================

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

@ -1770,8 +1770,6 @@ AC_SUBST(HOST_BIN_SUFFIX)
AC_SUBST(TARGET_XPCOM_ABI)
AC_SUBST(GCC_USE_GNU_LD)
AC_SUBST_LIST(DSO_CFLAGS)
AC_SUBST_LIST(DSO_PIC_CFLAGS)
AC_SUBST(DSO_LDOPTS)

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

@ -4212,7 +4212,6 @@ AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSSE3)
AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSE4_1)
AC_SUBST(HAVE_X86_AVX2)
AC_SUBST(HAVE_ALTIVEC)
AC_SUBST(GCC_USE_GNU_LD)
AC_SUBST_LIST(DSO_CFLAGS)
AC_SUBST_LIST(DSO_PIC_CFLAGS)

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

@ -71,7 +71,7 @@ def generate_symbols_file(output, *args):
assert ext == '.def'
output.write('LIBRARY %s\nEXPORTS\n %s\n'
% (libname, '\n '.join(symbols)))
elif buildconfig.substs['GCC_USE_GNU_LD']:
elif buildconfig.substs.get('GCC_USE_GNU_LD'):
# A linker version script is generated for GNU LD that looks like the
# following:
# liblibrary.so {

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

@ -22,7 +22,8 @@ import buildconfig
def main(output, input):
is_darwin = buildconfig.substs['OS_ARCH'] == 'Darwin'
is_mingw = "WINNT" == buildconfig.substs['OS_ARCH'] and buildconfig.substs['GCC_USE_GNU_LD']
is_mingw = "WINNT" == buildconfig.substs['OS_ARCH'] and \
buildconfig.substs.get('GCC_USE_GNU_LD')
with open(input, 'rb') as f:
for line in f: