1dnl This Source Code Form is subject to the terms of the Mozilla Public 2dnl License, v. 2.0. If a copy of the MPL was not distributed with this 3dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 5AC_DEFUN([MOZ_EXPAND_LIBS], 6[ 7dnl ======================================================== 8dnl = 9dnl = Check what kind of list files are supported by the 10dnl = linker 11dnl = 12dnl ======================================================== 13 14AC_CACHE_CHECK(what kind of list files are supported by the linker, 15 EXPAND_LIBS_LIST_STYLE, 16 [echo "int main() {return 0;}" > conftest.${ac_ext} 17 dnl Because BFD ld doesn't work with LTO + linker scripts, we 18 dnl must pass the LTO CFLAGS to the compile command, and the LTO 19 dnl LDFLAGS to all subsequent link commands. 20 dnl https://sourceware.org/bugzilla/show_bug.cgi?id=23600 21 if AC_TRY_COMMAND(${CC-cc} -o conftest.${OBJ_SUFFIX} -c $MOZ_LTO_CFLAGS $CFLAGS $CPPFLAGS conftest.${ac_ext} 1>&5) && test -s conftest.${OBJ_SUFFIX}; then 22 echo "INPUT(conftest.${OBJ_SUFFIX})" > conftest.list 23 if test "$CC_TYPE" = "clang-cl"; then 24 link="$LINKER -OUT:conftest${ac_exeext}" 25 else 26 link="${CC-cc} -o conftest${ac_exeext}" 27 fi 28 if AC_TRY_COMMAND($link $MOZ_LTO_LDFLAGS $LDFLAGS conftest.list $LIBS 1>&5) && test -s conftest${ac_exeext}; then 29 EXPAND_LIBS_LIST_STYLE=linkerscript 30 else 31 echo "conftest.${OBJ_SUFFIX}" > conftest.list 32 dnl -filelist is for the OS X linker. We need to try -filelist 33 dnl first because clang understands @file, but may pass an 34 dnl oversized argument list to the linker depending on the 35 dnl contents of @file. 36 if AC_TRY_COMMAND($link $MOZ_LTO_LDFLAGS $LDFLAGS [-Wl,-filelist,conftest.list] $LIBS 1>&5) && test -s conftest${ac_exeext}; then 37 EXPAND_LIBS_LIST_STYLE=filelist 38 elif AC_TRY_COMMAND($link $MOZ_LTO_LDFLAGS $LDFLAGS @conftest.list $LIBS 1>&5) && test -s conftest${ac_exeext}; then 39 EXPAND_LIBS_LIST_STYLE=list 40 else 41 AC_ERROR([Couldn't find one that works]) 42 fi 43 fi 44 else 45 dnl We really don't expect to get here, but just in case 46 AC_ERROR([couldn't compile a simple C file]) 47 fi 48 rm -rf conftest*]) 49 50AC_SUBST(EXPAND_LIBS_LIST_STYLE) 51 52]) 53