]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Remove a template instantiation optimization when building modules. 18500/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Sun, 25 May 2025 23:52:12 +0000 (17:52 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Sun, 25 May 2025 23:52:32 +0000 (17:52 -0600)
include/deal.II/dofs/dof_handler.h
include/deal.II/grid/tria.h
include/deal.II/hp/mapping_collection.h

index a4173a090ec1238b697ff14702516f552717714d..0d46cddea92b8544056150c6113b0aec22efaca5 100644 (file)
@@ -2147,13 +2147,24 @@ inline types::global_dof_index
 
 
 
+// Declare the existence of explicit instantiations of the class
+// above. This is not strictly necessary, but tells the compiler to
+// avoid instantiating templates that we know are instantiated in
+// .cc files and so can be referenced without implicit
+// instantiations.
+//
+// Unfortunately, this does not seem to work when building modules
+// because the compiler (well, Clang at least) then just doesn't
+// instantiate these classes at all, even though their members are
+// defined and explicitly instantiated in a .cc file.
+#  ifndef DEAL_II_BUILDING_CXX20_MODULE
 extern template class DoFHandler<1, 1>;
 extern template class DoFHandler<1, 2>;
 extern template class DoFHandler<1, 3>;
 extern template class DoFHandler<2, 2>;
 extern template class DoFHandler<2, 3>;
 extern template class DoFHandler<3, 3>;
-
+#  endif
 
 #endif // DOXYGEN
 
index 8701067fcbc6c72199087d17723fbd258bb32c08..7cf46b6066ec31915f4b88ebdaca87859636d18e 100644 (file)
@@ -4937,12 +4937,24 @@ bool
 Triangulation<1, 3>::prepare_coarsening_and_refinement();
 
 
+// Declare the existence of explicit instantiations of the class
+// above. This is not strictly necessary, but tells the compiler to
+// avoid instantiating templates that we know are instantiated in
+// .cc files and so can be referenced without implicit
+// instantiations.
+//
+// Unfortunately, this does not seem to work when building modules
+// because the compiler (well, Clang at least) then just doesn't
+// instantiate these classes at all, even though their members are
+// defined and explicitly instantiated in a .cc file.
+#  ifndef DEAL_II_BUILDING_CXX20_MODULE
 extern template class Triangulation<1, 1>;
 extern template class Triangulation<1, 2>;
 extern template class Triangulation<1, 3>;
 extern template class Triangulation<2, 2>;
 extern template class Triangulation<2, 3>;
 extern template class Triangulation<3, 3>;
+#  endif
 
 #endif // DOXYGEN
 
index af4acc9906e4c564b1d9747a8950831c6ede9643..b645c89a2e8cb9aa828cb7b94b7a6ffe95f2bf4b 100644 (file)
@@ -182,9 +182,18 @@ namespace hp
 
 
 #ifndef DOXYGEN
-  // Declare the existence of explicit instantiations of the class
-  // above to avoid certain warnings issues by clang and
-  // newer (LLVM-based) Intel compilers:
+// Declare the existence of explicit instantiations of the class
+// above. This is not strictly necessary, but tells the compiler to
+// avoid instantiating templates that we know are instantiated in
+// .cc files and so can be referenced without implicit
+// instantiations. In the current case, this also avoids certain
+// warnings issues by clang and newer (LLVM-based) Intel compilers.
+//
+// Unfortunately, this does not seem to work when building modules
+// because the compiler (well, Clang at least) then just doesn't
+// instantiate these classes at all, even though their members are
+// defined and explicitly instantiated in a .cc file.
+#  ifndef DEAL_II_BUILDING_CXX20_MODULE
   extern template struct StaticMappingQ1<1, 1>;
   extern template struct StaticMappingQ1<1, 2>;
   extern template struct StaticMappingQ1<1, 3>;
@@ -192,7 +201,7 @@ namespace hp
   extern template struct StaticMappingQ1<2, 3>;
   extern template struct StaticMappingQ1<3, 3>;
 
-#  ifndef _MSC_VER
+#    ifndef _MSC_VER
   extern template MappingCollection<1, 1>
     StaticMappingQ1<1, 1>::mapping_collection;
   extern template MappingCollection<1, 2>
@@ -205,6 +214,7 @@ namespace hp
     StaticMappingQ1<2, 3>::mapping_collection;
   extern template MappingCollection<3, 3>
     StaticMappingQ1<3, 3>::mapping_collection;
+#    endif
 #  endif
 #endif
 

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.