]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Another check for broken handling of anonymous namespaces and weak linkage.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 14 Nov 2003 15:32:55 +0000 (15:32 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 14 Nov 2003 15:32:55 +0000 (15:32 +0000)
git-svn-id: https://svn.dealii.org/trunk@8184 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/aclocal.m4
deal.II/base/include/base/config.h.in
deal.II/configure
deal.II/configure.in

index 4a2337b0dbdf2af553e76579b0ae94bbbe42ec94..e4d3e9e1ed41cf8a8002fdab46ffa32223691bb1 100644 (file)
@@ -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
index 89b7f9cf697d1a402e60d38fe5a919ad848e9d3a..d97bb2eb5fd0db52d47a738b3c2263240d9c2b47 100644 (file)
    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
index b6e66aae0362b84224db4fa1c641bbef62d1f61b..a1655686fb15b14353b0f015c736052fd82e09c7 100755 (executable)
@@ -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
index 47f5de4ad2f6906db513922eba15ab69139b39d6..228fc58ad5a43072882feaad2eb1ed2426f51899 100644 (file)
@@ -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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.