diff --git a/indra/llcommon/llstl.h b/indra/llcommon/llstl.h
index 6109b215468ae262de46296317652c45aacb0b91..d3941e1bc92c30502b0a05989ab4da896d776db5 100644
--- a/indra/llcommon/llstl.h
+++ b/indra/llcommon/llstl.h
@@ -471,6 +471,27 @@ llbind2nd(const _Operation& __oper, const _Tp& __x)
   return llbinder2nd<_Operation>(__oper, _Arg2_type(__x));
 }
 
+/**
+ * Compare std::type_info* pointers a la std::less. We break this out as a
+ * separate function for use in two different std::less specializations.
+ */
+inline
+bool before(const std::type_info* lhs, const std::type_info* rhs)
+{
+#if LL_LINUX && defined(__GNUC__) && ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 4))
+    // If we're building on Linux with gcc, and it's either gcc 3.x or
+    // 4.{0,1,2,3}, then we have to use a workaround. Note that we use gcc on
+    // Mac too, and some people build with gcc on Windows (cygwin or mingw).
+    // On Linux, different load modules may produce different type_info*
+    // pointers for the same type. Have to compare name strings to get good
+    // results.
+    return strcmp(lhs->name(), rhs->name()) < 0;
+#else  // not Linux, or gcc 4.4+
+    // Just use before(), as we normally would
+    return lhs->before(*rhs);
+#endif
+}
+
 /**
  * Specialize std::less<std::type_info*> to use std::type_info::before().
  * See MAINT-1175. It is NEVER a good idea to directly compare std::type_info*
@@ -479,25 +500,25 @@ llbind2nd(const _Operation& __oper, const _Tp& __x)
  */
 namespace std
 {
-    template <>
-    struct less<const std::type_info*>:
-        public std::binary_function<const std::type_info*, const std::type_info*, bool>
-    {
-        bool operator()(const std::type_info* lhs, const std::type_info* rhs) const
-        {
-            return lhs->before(*rhs);
-        }
-    };
-
-    template <>
-    struct less<std::type_info*>:
-        public std::binary_function<std::type_info*, std::type_info*, bool>
-    {
-        bool operator()(std::type_info* lhs, std::type_info* rhs) const
-        {
-            return lhs->before(*rhs);
-        }
-    };
+	template <>
+	struct less<const std::type_info*>:
+		public std::binary_function<const std::type_info*, const std::type_info*, bool>
+	{
+		bool operator()(const std::type_info* lhs, const std::type_info* rhs) const
+		{
+			return before(lhs, rhs);
+		}
+	};
+
+	template <>
+	struct less<std::type_info*>:
+		public std::binary_function<std::type_info*, std::type_info*, bool>
+	{
+		bool operator()(std::type_info* lhs, std::type_info* rhs) const
+		{
+			return before(lhs, rhs);
+		}
+	};
 } // std
 
 #endif // LL_LLSTL_H