diff --git a/GeoModelCore/GeoModelKernel/CMakeLists.txt b/GeoModelCore/GeoModelKernel/CMakeLists.txt
index d0bbfb56521da288e08e92440ca7b04c3e47b4d9..5f01934699c73582b9fd4178f0a3c988b225ff65 100644
--- a/GeoModelCore/GeoModelKernel/CMakeLists.txt
+++ b/GeoModelCore/GeoModelKernel/CMakeLists.txt
@@ -28,6 +28,7 @@ set_target_properties( GeoModelKernel PROPERTIES
 if ( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" )
   set_source_files_properties(
      ${CMAKE_CURRENT_SOURCE_DIR}/src/GeoXF.cxx
+     ${CMAKE_CURRENT_SOURCE_DIR}/src/GeoAlignableTransform.cxx
      PROPERTIES
      COMPILE_FLAGS "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}"
      COMPILE_DEFINITIONS "FLATTEN" )
diff --git a/GeoModelCore/GeoModelKernel/src/GeoAlignableTransform.cxx b/GeoModelCore/GeoModelKernel/src/GeoAlignableTransform.cxx
index 834a28da954d54a6b2259de67c878d5beb0babe3..9542340bbe9d10bde31de88b14d769fd8bf9bb0f 100755
--- a/GeoModelCore/GeoModelKernel/src/GeoAlignableTransform.cxx
+++ b/GeoModelCore/GeoModelKernel/src/GeoAlignableTransform.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "GeoModelKernel/GeoAlignableTransform.h"
@@ -19,6 +19,14 @@ GeoAlignableTransform::~GeoAlignableTransform()
   delete m_delta;
 }
 
+#if defined(FLATTEN) && defined(__GNUC__)
+// We compile this package with optimization, even in debug builds; otherwise,
+// the heavy use of Eigen makes it too slow.  However, from here we may call
+// to out-of-line Eigen code that is linked from other DSOs; in that case,
+// it would not be optimized.  Avoid this by forcing all Eigen code
+// to be inlined here if possible.
+__attribute__ ((flatten))
+#endif
 GeoTrf::Transform3D GeoAlignableTransform::getTransform(const GeoVAlignmentStore* store) const
 {
   const GeoTrf::Transform3D* delta = (store==nullptr ? m_delta : store->getDelta(this));