Bug 1861365 - Detect statically linking with libstdc++ r=glandium

Do this by scanning for lib(std)c++ in the dynamic section.

Differential Revision: https://phabricator.services.mozilla.com/D194744
This commit is contained in:
serge-sans-paille 2024-01-13 18:00:25 +00:00
Родитель 627cc80def
Коммит c29e1211c3
1 изменённых файлов: 35 добавлений и 0 удалений

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

@ -102,6 +102,41 @@ if test "$GNU_CC" -a "$GCC_USE_GNU_LD" -a -z "$MOZ_DISABLE_ICF" -a -z "$DEVELOPE
fi
fi
dnl ========================================================
dnl = Detect static linkage of libstdc++
dnl ========================================================
if test "$OS_TARGET" = Linux; then
AC_CACHE_CHECK([whether we're trying to statically link with libstdc++],
moz_cv_opt_static_libstdcxx,
[moz_cv_opt_static_libstdcxx=no
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
cat > conftest.$ac_ext <<EOF
#include <iostream>
int main() { std::cout << 1; }
EOF
dnl This test is quite conservative: it assumes dynamic linkage if the compilation step fails or if
dnl the binary format is not supported. But it still detects basic issues.
if AC_TRY_EVAL([ac_link]) && test -s conftest${ac_exeext} && $LLVM_OBJDUMP --private-headers conftest${ac_exeext} 2> conftest.err 1> conftest.out
then
if test -s conftest.err
then :
elif grep -q -E 'NEEDED.*lib(std)?c\+\+' conftest.out
then :
else moz_cv_opt_static_libstdcxx=yes
fi
fi
AC_LANG_RESTORE
rm -f conftest*
])
if test "$moz_cv_opt_static_libstdcxx" = "yes"; then
AC_MSG_ERROR([Firefox does not support linking statically with libstdc++])
fi
fi
dnl ========================================================
dnl = Automatically remove dead symbols
dnl ========================================================