From 2c8ee686d8e626c4ccc54fd0534d5b4740d114ba Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 19 Jun 2005 21:46:44 +0500 Subject: [PATCH] WL#2286 - Compile MySQL w/YASSL support Fix for yaSSL link failures with Forte Developer 7, MIPSpro Compilers, Compaq C++. These compilers have problem with implicit template instantiation in archives (libyassl.a, libtaocrypt.a). Instantiate templates explicitly. Fix for yaSSL link failure on powermacg5 (gcc 3.3). When -O3 is specified gcc inlines __cxa_pure_virtual. This is wrong behavior, __cxa_pure_virtual must never be inlined. configure.in: Better CXX_VERSION guessing. EXPLICIT_TEMPLATE_INSTANTIATION macro indicates whether to instantiate templates explicitly. Instantiate templates explicitly on MIPSpro, Compaq, Forte. extra/yassl/src/crypto_wrapper.cpp: Replace __GNUC__ by EXPLICIT_TEMPLATE_INSTANTIATION. extra/yassl/src/template_instnt.cpp: Replace __GNUC__ by EXPLICIT_TEMPLATE_INSTANTIATION. More portable templates instantiation. extra/yassl/src/yassl_int.cpp: Replace __GNUC__ by EXPLICIT_TEMPLATE_INSTANTIATION. More portable templates instantiation. extra/yassl/taocrypt/include/runtime.hpp: Fix for link failure on powermacg5 (gcc 3.3). __cxa_pure_virtual must never be inlined. extra/yassl/taocrypt/src/algebra.cpp: Replace __GNUC__ by EXPLICIT_TEMPLATE_INSTANTIATION. extra/yassl/taocrypt/src/integer.cpp: Replace __GNUC__ by EXPLICIT_TEMPLATE_INSTANTIATION. extra/yassl/taocrypt/src/template_instnt.cpp: Replace __GNUC__ by EXPLICIT_TEMPLATE_INSTANTIATION. sql/field.cc: Replace __GNUC__ by EXPLICIT_TEMPLATE_INSTANTIATION. sql/item.cc: Replace __GNUC__ by EXPLICIT_TEMPLATE_INSTANTIATION. sql/item_buff.cc: Replace __GNUC__ by EXPLICIT_TEMPLATE_INSTANTIATION. sql/mysqld.cc: Replace __GNUC__ by EXPLICIT_TEMPLATE_INSTANTIATION. sql/opt_range.cc: Replace __GNUC__ by EXPLICIT_TEMPLATE_INSTANTIATION. sql/set_var.cc: Replace __GNUC__ by EXPLICIT_TEMPLATE_INSTANTIATION. sql/slave.cc: Replace __GNUC__ by EXPLICIT_TEMPLATE_INSTANTIATION. sql/sql_acl.cc: Replace __GNUC__ by EXPLICIT_TEMPLATE_INSTANTIATION. sql/sql_class.cc: Replace __GNUC__ by EXPLICIT_TEMPLATE_INSTANTIATION. sql/sql_insert.cc: Replace __GNUC__ by EXPLICIT_TEMPLATE_INSTANTIATION. sql/sql_map.cc: Replace __GNUC__ by EXPLICIT_TEMPLATE_INSTANTIATION. sql/sql_select.cc: Replace __GNUC__ by EXPLICIT_TEMPLATE_INSTANTIATION. sql/sql_show.cc: Replace __GNUC__ by EXPLICIT_TEMPLATE_INSTANTIATION. sql/table.cc: Replace __GNUC__ by EXPLICIT_TEMPLATE_INSTANTIATION. --- configure.in | 14 +++++++ extra/yassl/src/crypto_wrapper.cpp | 4 +- extra/yassl/src/template_instnt.cpp | 42 ++++++++++---------- extra/yassl/src/yassl_int.cpp | 8 ++-- extra/yassl/taocrypt/include/runtime.hpp | 2 + extra/yassl/taocrypt/src/algebra.cpp | 2 +- extra/yassl/taocrypt/src/integer.cpp | 2 +- extra/yassl/taocrypt/src/template_instnt.cpp | 2 +- sql/field.cc | 2 +- sql/item.cc | 2 +- sql/item_buff.cc | 2 +- sql/mysqld.cc | 2 +- sql/opt_range.cc | 2 +- sql/set_var.cc | 2 +- sql/slave.cc | 2 +- sql/sql_acl.cc | 2 +- sql/sql_class.cc | 2 +- sql/sql_insert.cc | 4 +- sql/sql_map.cc | 2 +- sql/sql_select.cc | 2 +- sql/sql_show.cc | 4 +- sql/table.cc | 2 +- 22 files changed, 62 insertions(+), 46 deletions(-) diff --git a/configure.in b/configure.in index d7a081ed6c5..90b9300cfd4 100644 --- a/configure.in +++ b/configure.in @@ -201,6 +201,8 @@ CXX_VERSION=`$CXX -version | grep -i version` ;; *) CXX_VERSION=`$CXX --version | sed 1q` +CXX_VERSION=${CXX_VERSION:-`$CXX -V|sed 1q`} # trying harder for Sun and SGI +CXX_VERSION=${CXX_VERSION:-`$CXX -V 2>&1|sed 1q`} # even harder for Alpha ;; esac if test $? -eq "0" @@ -365,8 +367,20 @@ then # Disable exceptions as they seams to create problems with gcc and threads. # mysqld doesn't use run-time-type-checking, so we disable it. CXXFLAGS="$CXXFLAGS -fno-implicit-templates -fno-exceptions -fno-rtti" + CXXFLAGS="$CXXFLAGS -DEXPLICIT_TEMPLATE_INSTANTIATION" fi +case $CXX_VERSION in + MIPSpro*) + CXXFLAGS="$CXXFLAGS -no_prelink -DEXPLICIT_TEMPLATE_INSTANTIATION" + ;; + Compaq*) + CXXFLAGS="$CXXFLAGS -nopt -DEXPLICIT_TEMPLATE_INSTANTIATION" + ;; + Forte*) + CXXFLAGS="$CXXFLAGS -instance=explicit -DEXPLICIT_TEMPLATE_INSTANTIATION" +esac + # Avoid bug in fcntl on some versions of linux AC_MSG_CHECKING("if we should use 'skip-locking' as default for $target_os") # Any variation of Linux diff --git a/extra/yassl/src/crypto_wrapper.cpp b/extra/yassl/src/crypto_wrapper.cpp index ff1b4b630c2..976518ace91 100644 --- a/extra/yassl/src/crypto_wrapper.cpp +++ b/extra/yassl/src/crypto_wrapper.cpp @@ -971,7 +971,7 @@ x509* PemToDer(const char* fname, CertType type) } // namespace -#ifdef __GNUC__ +#ifdef EXPLICIT_TEMPLATE_INSTANTIATION namespace yaSSL { template void ysDelete(DiffieHellman::DHImpl*); template void ysDelete(Integer::IntegerImpl*); @@ -989,6 +989,6 @@ template void ysDelete(RMD::RMDImpl*); template void ysDelete(SHA::SHAImpl*); template void ysDelete(MD5::MD5Impl*); } -#endif // __GNUC__ +#endif // EXPLICIT_TEMPLATE_INSTANTIATION #endif // !USE_CRYPTOPP_LIB diff --git a/extra/yassl/src/template_instnt.cpp b/extra/yassl/src/template_instnt.cpp index 4ad1ec29249..43f3d551b7a 100644 --- a/extra/yassl/src/template_instnt.cpp +++ b/extra/yassl/src/template_instnt.cpp @@ -8,7 +8,7 @@ #include "ripemd.hpp" #include "openssl/ssl.h" -#ifdef __GNUC__ +#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #if !defined(USE_CRYPTOPP_LIB) namespace TaoCrypt { template class HMAC; @@ -18,26 +18,26 @@ template class HMAC; #endif namespace mySTL { -template class mySTL::list; -template yaSSL::del_ptr_zero mySTL::for_each(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); -template mySTL::pair* mySTL::uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); -template mySTL::pair* mySTL::uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); -template void mySTL::destroy*>(mySTL::pair*, mySTL::pair*); -template void mySTL::destroy*>(mySTL::pair*, mySTL::pair*); -template mySTL::pair* mySTL::uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); -template void mySTL::destroy*>(mySTL::pair*, mySTL::pair*); -template mySTL::pair* mySTL::uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); -template class mySTL::list; -template class mySTL::list; -template class mySTL::list; -template class mySTL::list; -template class mySTL::list; -template void mySTL::destroy*>(mySTL::pair*, mySTL::pair*); -template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); -template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); -template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); -template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); -template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); +template class list; +template yaSSL::del_ptr_zero for_each(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); +template pair* uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); +template pair* uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); +template void destroy*>(mySTL::pair*, mySTL::pair*); +template void destroy*>(mySTL::pair*, mySTL::pair*); +template pair* uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); +template void destroy*>(mySTL::pair*, mySTL::pair*); +template pair* uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); +template class list; +template class list; +template class list; +template class list; +template class list; +template void destroy*>(mySTL::pair*, mySTL::pair*); +template yaSSL::del_ptr_zero for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); +template yaSSL::del_ptr_zero for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); +template yaSSL::del_ptr_zero for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); +template yaSSL::del_ptr_zero for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); +template yaSSL::del_ptr_zero for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); } namespace yaSSL { diff --git a/extra/yassl/src/yassl_int.cpp b/extra/yassl/src/yassl_int.cpp index 06be7a15503..ab9188a5d61 100644 --- a/extra/yassl/src/yassl_int.cpp +++ b/extra/yassl/src/yassl_int.cpp @@ -1975,10 +1975,10 @@ X509_NAME* X509::GetSubject() } // namespace -#ifdef __GNUC__ +#ifdef EXPLICIT_TEMPLATE_INSTANTIATION namespace mySTL { -template yaSSL::yassl_int_cpp_local1::SumData mySTL::for_each::iterator, yaSSL::yassl_int_cpp_local1::SumData>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::yassl_int_cpp_local1::SumData); -template yaSSL::yassl_int_cpp_local1::SumBuffer mySTL::for_each::iterator, yaSSL::yassl_int_cpp_local1::SumBuffer>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::yassl_int_cpp_local1::SumBuffer); -template mySTL::list::iterator mySTL::find_if::iterator, yaSSL::yassl_int_cpp_local2::sess_match>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::yassl_int_cpp_local2::sess_match); +template yaSSL::yassl_int_cpp_local1::SumData for_each::iterator, yaSSL::yassl_int_cpp_local1::SumData>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::yassl_int_cpp_local1::SumData); +template yaSSL::yassl_int_cpp_local1::SumBuffer for_each::iterator, yaSSL::yassl_int_cpp_local1::SumBuffer>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::yassl_int_cpp_local1::SumBuffer); +template mySTL::list::iterator find_if::iterator, yaSSL::yassl_int_cpp_local2::sess_match>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::yassl_int_cpp_local2::sess_match); } #endif diff --git a/extra/yassl/taocrypt/include/runtime.hpp b/extra/yassl/taocrypt/include/runtime.hpp index 01106b6f960..1b364049452 100644 --- a/extra/yassl/taocrypt/include/runtime.hpp +++ b/extra/yassl/taocrypt/include/runtime.hpp @@ -34,6 +34,8 @@ extern "C" { #include +/* Disallow inline __cxa_pure_virtual() */ +static int __cxa_pure_virtual() __attribute__((noinline)); static int __cxa_pure_virtual() { // oops, pure virtual called! diff --git a/extra/yassl/taocrypt/src/algebra.cpp b/extra/yassl/taocrypt/src/algebra.cpp index 7608e78b0ed..d274b262497 100644 --- a/extra/yassl/taocrypt/src/algebra.cpp +++ b/extra/yassl/taocrypt/src/algebra.cpp @@ -319,7 +319,7 @@ void AbstractRing::SimultaneousExponentiate(Integer *results, } // namespace -#ifdef __GNUC__ +#ifdef EXPLICIT_TEMPLATE_INSTANTIATION namespace mySTL { template TaoCrypt::WindowSlider* uninit_copy(TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*); template void destroy(TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*); diff --git a/extra/yassl/taocrypt/src/integer.cpp b/extra/yassl/taocrypt/src/integer.cpp index ebfefb027b3..5c5dd59fde0 100644 --- a/extra/yassl/taocrypt/src/integer.cpp +++ b/extra/yassl/taocrypt/src/integer.cpp @@ -3956,7 +3956,7 @@ Integer CRT(const Integer &xp, const Integer &p, const Integer &xq, return p * (u * (xq-xp) % q) + xp; } -#ifdef __GNUC__ +#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #ifndef TAOCRYPT_NATIVE_DWORD_AVAILABLE template hword DivideThreeWordsByTwo(hword*, hword, hword, Word*); #endif diff --git a/extra/yassl/taocrypt/src/template_instnt.cpp b/extra/yassl/taocrypt/src/template_instnt.cpp index 81a8273c5c3..c643bd6d73a 100644 --- a/extra/yassl/taocrypt/src/template_instnt.cpp +++ b/extra/yassl/taocrypt/src/template_instnt.cpp @@ -4,7 +4,7 @@ #include "vector.hpp" #include "hash.hpp" -#ifdef __GNUC__ +#ifdef EXPLICIT_TEMPLATE_INSTANTIATION namespace TaoCrypt { #if defined(SSE2_INTRINSICS_AVAILABLE) template AlignedAllocator::pointer StdReallocate >(AlignedAllocator&, unsigned int*, AlignedAllocator::size_type, AlignedAllocator::size_type, bool); diff --git a/sql/field.cc b/sql/field.cc index 6e63dad41bb..8324d4eb725 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -38,7 +38,7 @@ Instansiate templates and static variables *****************************************************************************/ -#ifdef __GNUC__ +#ifdef EXPLICIT_TEMPLATE_INSTANTIATION template class List; template class List_iterator; #endif diff --git a/sql/item.cc b/sql/item.cc index e7feeaa4289..8a7d00e2841 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5387,7 +5387,7 @@ void Item_result_field::cleanup() ** Instantiate templates *****************************************************************************/ -#ifdef __GNUC__ +#ifdef EXPLICIT_TEMPLATE_INSTANTIATION template class List; template class List_iterator; template class List_iterator_fast; diff --git a/sql/item_buff.cc b/sql/item_buff.cc index 688e4cca846..e62a93f694e 100644 --- a/sql/item_buff.cc +++ b/sql/item_buff.cc @@ -146,7 +146,7 @@ bool Item_decimal_buff::cmp() ** Instansiate templates *****************************************************************************/ -#ifdef __GNUC__ +#ifdef EXPLICIT_TEMPLATE_INSTANTIATION template class List; template class List_iterator; #endif diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 9c5f33f849d..a27171e7891 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -7072,7 +7072,7 @@ static void create_pid_file() Instantiate templates *****************************************************************************/ -#ifdef __GNUC__ +#ifdef EXPLICIT_TEMPLATE_INSTANTIATION /* Used templates */ template class I_List; template class I_List_iterator; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 5732e156a7c..7d8bfe61692 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -8918,7 +8918,7 @@ void QUICK_GROUP_MIN_MAX_SELECT::dbug_dump(int indent, bool verbose) ** Instantiate templates *****************************************************************************/ -#ifdef __GNUC__ +#ifdef EXPLICIT_TEMPLATE_INSTANTIATION template class List; template class List_iterator; #endif diff --git a/sql/set_var.cc b/sql/set_var.cc index b22c0924de1..71b0cad06da 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -3406,7 +3406,7 @@ bool process_key_caches(int (* func) (const char *name, KEY_CACHE *)) Used templates ****************************************************************************/ -#ifdef __GNUC__ +#ifdef EXPLICIT_TEMPLATE_INSTANTIATION template class List; template class List_iterator_fast; template class I_List_iterator; diff --git a/sql/slave.cc b/sql/slave.cc index 60812469671..3094276cfaf 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -5002,7 +5002,7 @@ end: } -#ifdef __GNUC__ +#ifdef EXPLICIT_TEMPLATE_INSTANTIATION template class I_List_iterator; template class I_List_iterator; #endif diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 04da0dd5eb5..14aaab03682 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -5325,7 +5325,7 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name, Instantiate used templates *****************************************************************************/ -#ifdef __GNUC__ +#ifdef EXPLICIT_TEMPLATE_INSTANTIATION template class List_iterator; template class List_iterator; template class List; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 165ce61d5d1..eeac69aad6f 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -49,7 +49,7 @@ char internal_table_name[2]= "*"; ** Instansiate templates *****************************************************************************/ -#ifdef __GNUC__ +#ifdef EXPLICIT_TEMPLATE_INSTANTIATION /* Used templates */ template class List; template class List_iterator; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 5ca75554c6f..a963af4c6e3 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2362,11 +2362,11 @@ void select_create::abort() Instansiate templates *****************************************************************************/ -#ifdef __GNUC__ +#ifdef EXPLICIT_TEMPLATE_INSTANTIATION template class List_iterator_fast; #ifndef EMBEDDED_LIBRARY template class I_List; template class I_List_iterator; template class I_List; #endif /* EMBEDDED_LIBRARY */ -#endif /* __GNUC__ */ +#endif /* EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/sql/sql_map.cc b/sql/sql_map.cc index 9346f3df305..726bd48ab19 100644 --- a/sql/sql_map.cc +++ b/sql/sql_map.cc @@ -138,7 +138,7 @@ void unmap_file(mapped_files *map) ** Instansiate templates *****************************************************************************/ -#ifdef __GNUC__ +#ifdef EXPLICIT_TEMPLATE_INSTANTIATION /* Used templates */ template class I_List; template class I_List_iterator; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 80597aff3ac..bd646471133 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -6275,7 +6275,7 @@ public: COND_CMP(Item *a,Item_func *b) :and_level(a),cmp_func(b) {} }; -#ifdef __GNUC__ +#ifdef EXPLICIT_TEMPLATE_INSTANTIATION template class I_List; template class I_List_iterator; template class List; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index aaa34dc4cb7..9503bc9ec89 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1102,7 +1102,7 @@ public: char *query; }; -#ifdef __GNUC__ +#ifdef EXPLICIT_TEMPLATE_INSTANTIATION template class I_List; #endif @@ -3879,7 +3879,7 @@ ST_SCHEMA_TABLE schema_tables[]= }; -#ifdef __GNUC__ +#ifdef EXPLICIT_TEMPLATE_INSTANTIATION template class List_iterator_fast; template class List; #endif diff --git a/sql/table.cc b/sql/table.cc index 33cee79eb61..7b558b22e08 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2236,7 +2236,7 @@ const char *Field_iterator_view::name() ** Instansiate templates *****************************************************************************/ -#ifdef __GNUC__ +#ifdef EXPLICIT_TEMPLATE_INSTANTIATION template class List; template class List_iterator; #endif