diff --git a/aclocal.m4 b/aclocal.m4 index 86ab83daa0b0..eed798ee2d2e 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -10,7 +10,6 @@ builtin(include, build/autoconf/altoptions.m4)dnl builtin(include, build/autoconf/mozprog.m4)dnl builtin(include, build/autoconf/mozheader.m4)dnl builtin(include, build/autoconf/compiler-opts.m4)dnl -builtin(include, build/autoconf/expandlibs.m4)dnl builtin(include, build/autoconf/arch.m4)dnl builtin(include, build/autoconf/android.m4)dnl builtin(include, build/autoconf/clang-plugin.m4)dnl diff --git a/build/autoconf/expandlibs.m4 b/build/autoconf/expandlibs.m4 deleted file mode 100644 index b0fc6caf9537..000000000000 --- a/build/autoconf/expandlibs.m4 +++ /dev/null @@ -1,46 +0,0 @@ -dnl This Source Code Form is subject to the terms of the Mozilla Public -dnl License, v. 2.0. If a copy of the MPL was not distributed with this -dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. - -AC_DEFUN([MOZ_EXPAND_LIBS], -[ -dnl ======================================================== -dnl = -dnl = Check what kind of list files are supported by the -dnl = linker -dnl = -dnl ======================================================== - -AC_CACHE_CHECK(what kind of list files are supported by the linker, - moz_cv_expand_libs_list_style, - [echo "int main() {return 0;}" > conftest.${ac_ext} - if AC_TRY_COMMAND(${CC-cc} -o conftest.${OBJ_SUFFIX} -c $CFLAGS $CPPFLAGS conftest.${ac_ext} 1>&5) && test -s conftest.${OBJ_SUFFIX}; then - if test "$CC_TYPE" = "clang-cl"; then - link="$LINKER -OUT:conftest${ac_exeext}" - else - link="${CC-cc} -o conftest${ac_exeext}" - fi - echo "conftest.${OBJ_SUFFIX}" > conftest.list - if AC_TRY_COMMAND($link $LDFLAGS [-Wl,@conftest.list] $LIBS 1>&5) && test -s conftest${ac_exeext}; then - moz_cv_expand_libs_list_style=linkerlist - - dnl -filelist is for the OS X linker. We need to try -filelist first - dnl because clang understands @file, but may pass an oversized argument - dnl list to the linker depending on the contents of @file. - elif AC_TRY_COMMAND($link $LDFLAGS [-Wl,-filelist,conftest.list] $LIBS 1>&5) && test -s conftest${ac_exeext}; then - moz_cv_expand_libs_list_style=filelist - elif AC_TRY_COMMAND($link $LDFLAGS [@conftest.list] $LIBS 1>&5) && test -s conftest${ac_exeext}; then - moz_cv_expand_libs_list_style=list - else - AC_ERROR([Couldn't find one that works]) - fi - else - dnl We really don't expect to get here, but just in case - AC_ERROR([couldn't compile a simple C file]) - fi - rm -rf conftest*]) - -EXPAND_LIBS_LIST_STYLE=$moz_cv_expand_libs_list_style -AC_SUBST(EXPAND_LIBS_LIST_STYLE) - -]) diff --git a/build/moz.configure/flags.configure b/build/moz.configure/flags.configure index 9951e2ff1c32..b362948a215b 100644 --- a/build/moz.configure/flags.configure +++ b/build/moz.configure/flags.configure @@ -223,6 +223,73 @@ def check_Bsymbolic(enable_asan, building_with_gnu_cc): # Using -Wl,-Bsymbolic ensures no exported symbol can be interposed. check_and_add_linker_flag("-Wl,-Bsymbolic", when=check_Bsymbolic) + +# Check what kind of list files are supported by the linker +@depends(c_compiler, link, linker_ldflags, extra_toolchain_flags) +@checking("what kind of list files are supported by the linker") +@imports("os") +@imports(_from="__builtin__", _import="open") +@imports(_from="tempfile", _import="mkstemp") +def expand_libs_list_style(c_compiler, link, linker_flags, extra_flags): + objfd, objname = mkstemp(prefix="conftest.", suffix=".o") + os.close(objfd) + + listfd, listname = mkstemp(prefix="conftest.", suffix=".list") + os.write(listfd, objname.encode()) + os.close(listfd) + + outfd, outname = mkstemp(prefix="conftest.", suffix=".out") + os.close(outfd) + + try: + cflags = c_compiler.flags + + if ( + try_invoke_compiler( + # No configure_cache because it would not create the + # expected output file. + None, + [c_compiler.compiler] + cflags, + c_compiler.language, + "int main() {}", + ["-c", "-o", objname], + wrapper=c_compiler.wrapper, + onerror=lambda: None, + ) + is None + ): + die("couldn't compile a simple C file") + + ldflags = linker_flags + (extra_flags or []) + + if c_compiler.type == "clang-cl": + base_linker_cmd = [link] + ldflags + [f"-OUT:{outname}"] + else: + base_linker_cmd = [c_compiler.compiler] + cflags + ldflags + ["-o", outname] + + # -filelist is for the OS X linker. We need to try -filelist + # first because clang understands @file, but may pass an + # oversized argument list to the linker depending on the + # contents of @file. + options = [ + ("linkerlist", f"-Wl,@{listname}"), + ("filelist", f"-Wl,@{listname}"), + ("list", f"@{listname}"), + ] + for kind, option in options: + linker_cmd = base_linker_cmd + [option] + if check_cmd_output(*linker_cmd, onerror=lambda: None) is not None: + return kind + die("Couldn't find one that works") + + finally: + os.remove(objname) + os.remove(listname) + os.remove(outname) + + +set_config("EXPAND_LIBS_LIST_STYLE", expand_libs_list_style) + # Please keep these last in this file. add_old_configure_assignment("_COMPILATION_ASFLAGS", asm_flags.asflags) add_old_configure_assignment("_COMPILATION_HOST_ASFLAGS", asm_flags.host_asflags) diff --git a/js/src/aclocal.m4 b/js/src/aclocal.m4 index c9ad56b61ea4..336323ef3393 100644 --- a/js/src/aclocal.m4 +++ b/js/src/aclocal.m4 @@ -10,7 +10,6 @@ builtin(include, ../../build/autoconf/altoptions.m4)dnl builtin(include, ../../build/autoconf/mozprog.m4)dnl builtin(include, ../../build/autoconf/mozheader.m4)dnl builtin(include, ../../build/autoconf/compiler-opts.m4)dnl -builtin(include, ../../build/autoconf/expandlibs.m4)dnl builtin(include, ../../build/autoconf/arch.m4)dnl builtin(include, ../../build/autoconf/android.m4)dnl builtin(include, ../../build/autoconf/clang-plugin.m4)dnl diff --git a/js/src/old-configure.in b/js/src/old-configure.in index 8a301d556e2b..4b1329479a9c 100644 --- a/js/src/old-configure.in +++ b/js/src/old-configure.in @@ -563,8 +563,6 @@ if test -n "$COMPILE_ENVIRONMENT"; then MOZ_CONFIG_CLANG_PLUGIN fi # COMPILE_ENVIRONMENT -MOZ_EXPAND_LIBS - dnl ======================================================== dnl = dnl = Maintainer debug option (no --enable equivalent) diff --git a/old-configure.in b/old-configure.in index a998d6ca66a7..de4b6aec24aa 100644 --- a/old-configure.in +++ b/old-configure.in @@ -652,10 +652,6 @@ fi # COMPILE_ENVIRONMENT AC_LANG_C -if test "$COMPILE_ENVIRONMENT"; then -MOZ_EXPAND_LIBS -fi # COMPILE_ENVIRONMENT - dnl ======================================================== dnl = dnl = Maintainer debug option (no --enable equivalent)