]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Invent a test to check for a weird linkage problem with functions in anonymous namesp...
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 29 Apr 2003 16:19:55 +0000 (16:19 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 29 Apr 2003 16:19:55 +0000 (16:19 +0000)
git-svn-id: https://svn.dealii.org/trunk@7491 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 866730a07e38663d175453d4289e1790d55aafcd..caadf3e7f1ba5e50f5f27eeca3b76a4978baedbc 100644 (file)
@@ -2377,6 +2377,58 @@ AC_DEFUN(DEAL_II_CHECK_FUNPTR_TEMPLATE_TEMPLATE_BUG, dnl
 
 
 
+dnl -------------------------------------------------------------
+dnl We compile all the files in the deal.II subdirectory multiple
+dnl times, for the various space dimensions. When a program
+dnl needs the libs for more than one dimension, the symbols in
+dnl these libs must be either static or weak. Unfortunately, some
+dnl compilers don't mark functions in anonymous namespaces as
+dnl static, and also mangle their names the same way each time,
+dnl so we get into trouble with duplicate symbols. Check
+dnl whether this is so.
+dnl
+dnl The check is a little more complicated than the usual one,
+dnl since we can't use AC_TRY_COMPILE (we have to compile and link
+dnl more than one file).
+dnl
+dnl Usage: DEAL_II_CHECK_ANON_NAMESPACE_BUG
+dnl
+dnl -------------------------------------------------------------
+AC_DEFUN(DEAL_II_CHECK_ANON_NAMESPACE_BUG, dnl
+[
+  AC_MSG_CHECKING(for anonymous namespace and name mangling bug)
+
+  dnl Create the testfile
+  echo "namespace { int SYMBOL() {return 1;}; }" >  conftest.cc
+  echo "static int f() { return SYMBOL(); }"     >> conftest.cc
+
+  dnl Then compile it twice...
+  $CXX -c conftest.cc -o conftest.1.$ac_objext
+  $CXX -c conftest.cc -o conftest.2.$ac_objext
+
+  dnl Create a file with main() and also compile it
+  echo "int main () {}" > conftest.cc
+  $CXX -c conftest.cc -o conftest.3.$ac_objext
+
+  dnl Then try to link everything
+  if (($CXX conftest.1.$ac_objext conftest.2.$ac_objext \
+            conftest.3.$ac_objext -o conftest  2>&1 ) > /dev/null );\
+  then
+      AC_MSG_RESULT(no)
+  else
+      AC_MSG_RESULT(yes. using workaround)
+      AC_DEFINE(DEAL_II_ANON_NAMESPACE_BUG, 1, 
+                     [Defined 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.1.$ac_objext conftest.2.$ac_objext conftest
+])
+
+
+
 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 8acd99eb5fe4340a4b0cc20ca5b780fb72821b9e..520ee6b9b138cce9361d6742322c4a0443099ae3 100644 (file)
 
 
 
+/* Defined 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_BUG
+
 /* Backward compatibility support for functions and classes that do not take
    an explicit mapping variable, but rather use a default Q1 mapping instead
    */
index 850bcbe26a08d25104c8235d9ef413a8ea1b5645..d4b9a7fab1bd98a755ca80871aad0d0384ad58d0 100755 (executable)
@@ -4906,6 +4906,35 @@ fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 
 
+  echo "$as_me:$LINENO: checking for anonymous namespace and name mangling bug" >&5
+echo $ECHO_N "checking for anonymous namespace and name mangling 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.1.$ac_objext
+  $CXX -c conftest.cc -o conftest.2.$ac_objext
+
+    echo "int main () {}" > conftest.cc
+  $CXX -c conftest.cc -o conftest.3.$ac_objext
+
+    if (($CXX conftest.1.$ac_objext conftest.2.$ac_objext \
+            conftest.3.$ac_objext -o conftest  2>&1 ) > /dev/null );\
+  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_BUG 1
+_ACEOF
+
+  fi
+  rm -f conftest.1.$ac_objext conftest.2.$ac_objext conftest
+
+
   echo "$as_me:$LINENO: checking for SFINAE bug" >&5
 echo $ECHO_N "checking for SFINAE bug... $ECHO_C" >&6
   ac_ext=cc
index 459139c42cbbb7b2bc1f214923aff0955923e78b..ab854ceafb0e3809fea91898a141d544b07c72fc 100644 (file)
@@ -175,6 +175,7 @@ DEAL_II_CHECK_FUNPTR_TEMPLATE_TEMPLATE_BUG
 DEAL_II_CHECK_NESTED_CLASS_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_SFINAE_BUG
 DEAL_II_CHECK_BOOST_SHARED_PTR_ASSIGNMENT
 DEAL_II_HAVE_PRETTY_FUNCTION

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.