From 74e57d8bb869219a2d51a92dcce9d9394d63f2af Mon Sep 17 00:00:00 2001 From: wolf Date: Fri, 14 Nov 2003 15:32:55 +0000 Subject: [PATCH] Another check for broken handling of anonymous namespaces and weak linkage. git-svn-id: https://svn.dealii.org/trunk@8184 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/aclocal.m4 | 45 +++++++++++++++++++++++++++ deal.II/base/include/base/config.h.in | 5 +++ deal.II/configure | 28 ++++++++++++++++- deal.II/configure.in | 1 + 4 files changed, 78 insertions(+), 1 deletion(-) diff --git a/deal.II/aclocal.m4 b/deal.II/aclocal.m4 index 4a2337b0db..e4d3e9e1ed 100644 --- a/deal.II/aclocal.m4 +++ b/deal.II/aclocal.m4 @@ -2544,6 +2544,51 @@ AC_DEFUN(DEAL_II_CHECK_ANON_NAMESPACE_BUG, dnl +dnl ------------------------------------------------------------- +dnl A second test in this direction: if the name of a function is +dnl not mangled differently for each compiler invokation, then +dnl it should at least result in a weak symbol. Test this. +dnl +dnl Note that this is not a problem in itself if the name is +dnl mangled differently each time a file is compiled. +dnl +dnl Usage: DEAL_II_CHECK_ANON_NAMESPACE_BUG2 +dnl +dnl ------------------------------------------------------------- +AC_DEFUN(DEAL_II_CHECK_ANON_NAMESPACE_BUG2, dnl +[ + AC_MSG_CHECKING(for anonymous namespace and weak linkage bug) + + dnl Create the testfile + echo "namespace { int SYMBOL() {return 1;}; }" > conftest.cc + echo "static int f() { return SYMBOL(); }" >> conftest.cc + + dnl Compile it + $CXX -c conftest.cc -o conftest.$ac_objext + + dnl Then look for lines in the output of "nm" that have the name of + dnl SYMBOL in them. Then make sure that we don't find a line with + dnl " T " in it, i.e. a text symbol with strong linkage + check="`nm conftest.$ac_objext | grep SYMBOL | grep ' T '`" + + dnl Then try to link everything + if test "x$check" = "x" ; + then + AC_MSG_RESULT(no) + else + AC_MSG_RESULT(yes) + AC_DEFINE(DEAL_II_ANON_NAMESPACE_LINKAGE_BUG, 1, + [Another test if the compiler needs to see the static + keyword even for functions in anonymous namespaces, + to avoid duplicate symbol errors when linking. + For the details, look at aclocal.m4 in the + top-level directory.]) + fi + rm -f conftest.$ac_objext +]) + + + dnl ------------------------------------------------------------- dnl We have so many templates in deal.II that sometimes we need dnl to make it clear with which types a template parameter can diff --git a/deal.II/base/include/base/config.h.in b/deal.II/base/include/base/config.h.in index 89b7f9cf69..d97bb2eb5f 100644 --- a/deal.II/base/include/base/config.h.in +++ b/deal.II/base/include/base/config.h.in @@ -36,6 +36,11 @@ the details, look at aclocal.m4 in the top-level directory. */ #undef DEAL_II_ANON_NAMESPACE_BUG +/* Another test if the compiler needs to see the static keyword even for + functions in anonymous namespaces, to avoid duplicate symbol errors when + linking. For the details, look at aclocal.m4 in the top-level directory. */ +#undef DEAL_II_ANON_NAMESPACE_LINKAGE_BUG + /* Defined if the compiler has a problem with assigning arrays in conditionals */ #undef DEAL_II_ARRAY_CONDITIONAL_DECAY_BUG diff --git a/deal.II/configure b/deal.II/configure index b6e66aae03..a1655686fb 100755 --- a/deal.II/configure +++ b/deal.II/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 1.157 . +# From configure.in Revision: 1.158 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.57. # @@ -5025,6 +5025,32 @@ _ACEOF rm -f conftest.1.$ac_objext conftest.2.$ac_objext conftest + echo "$as_me:$LINENO: checking for anonymous namespace and weak linkage bug" >&5 +echo $ECHO_N "checking for anonymous namespace and weak linkage bug... $ECHO_C" >&6 + + echo "namespace { int SYMBOL() {return 1;}; }" > conftest.cc + echo "static int f() { return SYMBOL(); }" >> conftest.cc + + $CXX -c conftest.cc -o conftest.$ac_objext + + check="`nm conftest.$ac_objext | grep SYMBOL | grep ' T '`" + + if test "x$check" = "x" ; + then + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + else + echo "$as_me:$LINENO: result: yes. using workaround" >&5 +echo "${ECHO_T}yes. using workaround" >&6 + +cat >>confdefs.h <<\_ACEOF +#define DEAL_II_ANON_NAMESPACE_LINKAGE_BUG 1 +_ACEOF + + fi + rm -f conftest.$ac_objext + + echo "$as_me:$LINENO: checking for SFINAE bug" >&5 echo $ECHO_N "checking for SFINAE bug... $ECHO_C" >&6 ac_ext=cc diff --git a/deal.II/configure.in b/deal.II/configure.in index 47f5de4ad2..228fc58ad5 100644 --- a/deal.II/configure.in +++ b/deal.II/configure.in @@ -178,6 +178,7 @@ DEAL_II_CHECK_NESTED_CLASS_TEMPL_FRIEND_BUG DEAL_II_CHECK_MEMBER_VAR_SPECIALIZATION_BUG DEAL_II_CHECK_LONG_DOUBLE_LOOP_BUG DEAL_II_CHECK_ANON_NAMESPACE_BUG +DEAL_II_CHECK_ANON_NAMESPACE_BUG2 DEAL_II_CHECK_SFINAE_BUG DEAL_II_CHECK_ARRAY_CONDITIONAL_DECAY_BUG DEAL_II_CHECK_BOOST_SHARED_PTR_ASSIGNMENT -- 2.39.5