Check for string COW by checking for library, not compiler

Note in particular that clang++ uses libstdc++ (GNU) by default, and not libc++.
Therefore, it suffers from the string COW bug too.
This commit is contained in:
Jean-Marc Lasgouttes 2014-12-17 12:28:25 +01:00
parent dd2be1777f
commit 385f3e8abd

View File

@ -143,7 +143,7 @@ rm -f conftest.C conftest.o conftest.obj || true
dnl Usage: LYX_PROG_CLANG: set lyx_cv_prog_clang to yes if the compiler is clang.
AC_DEFUN([LYX_PROG_CLANG],
[AC_CACHE_CHECK([for clang],
[AC_CACHE_CHECK([whether the compiler is clang],
[lyx_cv_prog_clang],
[AC_TRY_COMPILE([], [
#ifndef __clang__
@ -154,6 +154,19 @@ AC_DEFUN([LYX_PROG_CLANG],
])
dnl Usage: LYX_LIB_STDCXX: set lyx_cv_lib_stdcxx to yes if the STL library is libstdc++.
AC_DEFUN([LYX_LIB_STDCXX],
[AC_CACHE_CHECK([whether STL is libstdc++],
[lyx_cv_lib_stdcxx],
[AC_TRY_COMPILE([#include<vector>], [
#if ! defined(__GLIBCXX__) && ! defined(__GLIBCPP__)
this is not libstdc++
#endif
],
[lyx_cv_lib_stdcxx=yes], [lyx_cv_lib_stdcxx=no])])
])
AC_DEFUN([LYX_PROG_CXX],
[AC_MSG_CHECKING([for a good enough C++ compiler])
LYX_SEARCH_PROG(CXX, $CXX $CCC g++ gcc c++ CC cxx xlC cc++, [LYX_PROG_CXX_WORKS])
@ -167,8 +180,13 @@ AC_REQUIRE([AC_PROG_CXX])
AC_REQUIRE([AC_PROG_CXXCPP])
AC_LANG_PUSH(C++)
LYX_PROG_CLANG
LYX_LIB_STDCXX
AC_LANG_POP(C++)
if test $lyx_cv_lib_stdcxx = "yes" ; then
AC_DEFINE(STD_STRING_USES_COW, 1, [std::string uses copy-on-write])
fi
### We might want to get or shut warnings.
AC_ARG_ENABLE(warnings,
AC_HELP_STRING([--enable-warnings],[tell the compiler to display more warnings]),,
@ -320,8 +338,6 @@ if test x$GXX = xyes; then
;;
esac
fi
dnl FIXME: this should be conditional to the use of libstdc++
AC_DEFINE(STD_STRING_USES_COW, 1, [std::string uses copy-on-write])
fi
test "$lyx_pch_comp" = yes && lyx_flags="$lyx_flags pch"
AM_CONDITIONAL(LYX_BUILD_PCH, test "$lyx_pch_comp" = yes)