Skip to content

Commit 9f4d369

Browse files
author
Tor Didriksen
committed
Bug#11929733 - 59607: REMOVE THE FNO-IMPLICIT-TEMPLATES COMPILATION FLAG
Explicit template instantiations introduces extra code maintenance, and actually yields code bloat with modern gcc compilers/linkers: - we instantiate code which is un-used - we disable optimization of common code for pointer-based templates The mysqld executable size shrinks with about 200Kb with this patch.
1 parent 6b561e5 commit 9f4d369

28 files changed

Lines changed: 23 additions & 482 deletions

cmake/ssl.cmake

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2009 Sun Microsystems, Inc
1+
# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -27,16 +27,8 @@ MACRO (MYSQL_USE_BUNDLED_SSL)
2727
SET(SSL_INTERNAL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL)
2828
SET(SSL_DEFINES "-DHAVE_YASSL -DYASSL_PURE_C -DYASSL_PREFIX -DHAVE_OPENSSL -DYASSL_THREAD_SAFE")
2929
CHANGE_SSL_SETTINGS("bundled")
30-
#Remove -fno-implicit-templates
31-
#(yassl sources cannot be compiled with it)
32-
SET(SAVE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
33-
IF(CMAKE_CXX_FLAGS)
34-
STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS
35-
${CMAKE_CXX_FLAGS})
36-
ENDIF()
3730
ADD_SUBDIRECTORY(extra/yassl)
3831
ADD_SUBDIRECTORY(extra/yassl/taocrypt)
39-
SET(CMAKE_CXX_FLAGS ${SAVE_CXX_FLAGS})
4032
GET_TARGET_PROPERTY(src yassl SOURCES)
4133
FOREACH(file ${src})
4234
SET(SSL_SOURCES ${SSL_SOURCES} ${CMAKE_SOURCE_DIR}/extra/yassl/${file})

config.h.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#cmakedefine HAVE_FNMATCH_H 1
4141
#cmakedefine HAVE_FPU_CONTROL_H 1
4242
#cmakedefine HAVE_GRP_H 1
43-
#cmakedefine HAVE_EXPLICIT_TEMPLATE_INSTANTIATION 1
4443
#cmakedefine HAVE_IA64INTRIN_H 1
4544
#cmakedefine HAVE_IEEEFP_H 1
4645
#cmakedefine HAVE_INTTYPES_H 1

configure.cmake

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
# Copyright (C) 2009 Sun Microsystems,Inc
1+
# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
32
#
43
# This program is free software; you can redistribute it and/or modify
54
# it under the terms of the GNU General Public License as published by
@@ -67,15 +66,7 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
6766
# MySQL "canonical" GCC flags. At least -fno-rtti flag affects
6867
# ABI and cannot be simply removed.
6968
SET(CMAKE_CXX_FLAGS
70-
"${CMAKE_CXX_FLAGS} -fno-implicit-templates -fno-exceptions -fno-rtti")
71-
IF(CMAKE_CXX_FLAGS)
72-
STRING(REGEX MATCH "fno-implicit-templates" NO_IMPLICIT_TEMPLATES
73-
${CMAKE_CXX_FLAGS})
74-
IF (NO_IMPLICIT_TEMPLATES)
75-
SET(HAVE_EXPLICIT_TEMPLATE_INSTANTIATION TRUE)
76-
ENDIF()
77-
ENDIF()
78-
69+
"${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")
7970
IF (CMAKE_EXE_LINKER_FLAGS MATCHES " -static "
8071
OR CMAKE_EXE_LINKER_FLAGS MATCHES " -static$")
8172
SET(HAVE_DLOPEN FALSE CACHE "Disable dlopen due to -static flag" FORCE)

extra/yassl/CMakeLists.txt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -20,20 +20,11 @@ INCLUDE_DIRECTORIES(
2020
${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL)
2121

2222
ADD_DEFINITIONS(${SSL_DEFINES})
23-
IF(CMAKE_COMPILER_IS_GNUXX)
24-
#Remove -fno-implicit-templates
25-
#(yassl sources cannot be compiled with it)
26-
STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS
27-
${CMAKE_CXX_FLAGS})
28-
ENDIF()
23+
2924
SET(YASSL_SOURCES src/buffer.cpp src/cert_wrapper.cpp src/crypto_wrapper.cpp src/handshake.cpp src/lock.cpp
3025
src/log.cpp src/socket_wrapper.cpp src/ssl.cpp src/timer.cpp src/yassl_error.cpp
3126
src/yassl_imp.cpp src/yassl_int.cpp)
3227

33-
IF(HAVE_EXPLICIT_TEMPLATE_INSTANTIATION)
34-
SET(YASSL_SOURCES ${YASSL_SOURCES} src/template_instnt.cpp)
35-
ENDIF()
36-
3728
ADD_CONVENIENCE_LIBRARY(yassl ${YASSL_SOURCES})
3829
RESTRICT_SYMBOL_EXPORTS(yassl)
3930

extra/yassl/src/crypto_wrapper.cpp

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
/*
2-
Copyright (C) 2000-2007 MySQL AB
1+
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
32
43
This program is free software; you can redistribute it and/or modify
54
it under the terms of the GNU General Public License as published by
@@ -11,10 +10,8 @@
1110
GNU General Public License for more details.
1211
1312
You should have received a copy of the GNU General Public License
14-
along with this program; see the file COPYING. If not, write to the
15-
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
16-
MA 02110-1301 USA.
17-
*/
13+
along with this program; if not, write to the Free Software
14+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
1815

1916
/* The crypto wrapper source implements the policies for the cipher
2017
* components used by SSL.
@@ -991,24 +988,4 @@ x509* PemToDer(FILE* file, CertType type, EncryptedInfo* info)
991988
} // namespace
992989

993990

994-
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
995-
namespace yaSSL {
996-
template void ysDelete<DiffieHellman::DHImpl>(DiffieHellman::DHImpl*);
997-
template void ysDelete<Integer::IntegerImpl>(Integer::IntegerImpl*);
998-
template void ysDelete<RSA::RSAImpl>(RSA::RSAImpl*);
999-
template void ysDelete<DSS::DSSImpl>(DSS::DSSImpl*);
1000-
template void ysDelete<RandomPool::RandomImpl>(RandomPool::RandomImpl*);
1001-
template void ysDelete<AES::AESImpl>(AES::AESImpl*);
1002-
template void ysDelete<RC4::RC4Impl>(RC4::RC4Impl*);
1003-
template void ysDelete<DES_EDE::DES_EDEImpl>(DES_EDE::DES_EDEImpl*);
1004-
template void ysDelete<DES::DESImpl>(DES::DESImpl*);
1005-
template void ysDelete<HMAC_RMD::HMAC_RMDImpl>(HMAC_RMD::HMAC_RMDImpl*);
1006-
template void ysDelete<HMAC_SHA::HMAC_SHAImpl>(HMAC_SHA::HMAC_SHAImpl*);
1007-
template void ysDelete<HMAC_MD5::HMAC_MD5Impl>(HMAC_MD5::HMAC_MD5Impl*);
1008-
template void ysDelete<RMD::RMDImpl>(RMD::RMDImpl*);
1009-
template void ysDelete<SHA::SHAImpl>(SHA::SHAImpl*);
1010-
template void ysDelete<MD5::MD5Impl>(MD5::MD5Impl*);
1011-
}
1012-
#endif // HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
1013-
1014991
#endif // !USE_CRYPTOPP_LIB

extra/yassl/src/template_instnt.cpp

Lines changed: 0 additions & 110 deletions
This file was deleted.

extra/yassl/src/yassl_int.cpp

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
/*
2-
Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
1+
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
32
43
This program is free software; you can redistribute it and/or modify
54
it under the terms of the GNU General Public License as published by
@@ -11,11 +10,8 @@
1110
GNU General Public License for more details.
1211
1312
You should have received a copy of the GNU General Public License
14-
along with this program; see the file COPYING. If not, write to the
15-
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
16-
MA 02110-1301 USA.
17-
*/
18-
13+
along with this program; if not, write to the Free Software
14+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
1915

2016
/* yaSSL internal source implements SSL supporting types not specified in the
2117
* draft along with type conversion functions.
@@ -2568,14 +2564,3 @@ extern "C" void yaSSL_CleanUp()
25682564
yaSSL::sessionsInstance = 0;
25692565
yaSSL::errorsInstance = 0;
25702566
}
2571-
2572-
2573-
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
2574-
namespace mySTL {
2575-
template yaSSL::yassl_int_cpp_local1::SumData for_each<mySTL::list<yaSSL::input_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumData>(mySTL::list<yaSSL::input_buffer*>::iterator, mySTL::list<yaSSL::input_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumData);
2576-
template yaSSL::yassl_int_cpp_local1::SumBuffer for_each<mySTL::list<yaSSL::output_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumBuffer>(mySTL::list<yaSSL::output_buffer*>::iterator, mySTL::list<yaSSL::output_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumBuffer);
2577-
template mySTL::list<yaSSL::SSL_SESSION*>::iterator find_if<mySTL::list<yaSSL::SSL_SESSION*>::iterator, yaSSL::yassl_int_cpp_local2::sess_match>(mySTL::list<yaSSL::SSL_SESSION*>::iterator, mySTL::list<yaSSL::SSL_SESSION*>::iterator, yaSSL::yassl_int_cpp_local2::sess_match);
2578-
template mySTL::list<yaSSL::ThreadError>::iterator find_if<mySTL::list<yaSSL::ThreadError>::iterator, yaSSL::yassl_int_cpp_local2::thr_match>(mySTL::list<yaSSL::ThreadError>::iterator, mySTL::list<yaSSL::ThreadError>::iterator, yaSSL::yassl_int_cpp_local2::thr_match);
2579-
}
2580-
#endif
2581-

extra/yassl/taocrypt/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -27,10 +27,6 @@ SET(TAOCRYPT_SOURCES src/aes.cpp src/aestables.cpp src/algebra.cpp src/arc4.cpp
2727
include/md2.hpp include/md5.hpp include/misc.hpp include/modarith.hpp include/modes.hpp
2828
include/random.hpp include/ripemd.hpp include/rsa.hpp include/sha.hpp)
2929

30-
IF(HAVE_EXPLICIT_TEMPLATE_INSTANTIATION)
31-
SET(TAOCRYPT_SOURCES ${TAOCRYPT_SOURCES} src/template_instnt.cpp)
32-
ENDIF()
33-
3430
ADD_CONVENIENCE_LIBRARY(taocrypt ${TAOCRYPT_SOURCES})
3531
RESTRICT_SYMBOL_EXPORTS(taocrypt)
3632

extra/yassl/taocrypt/src/algebra.cpp

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
/*
2-
Copyright (C) 2000-2007 MySQL AB
1+
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
32
43
This program is free software; you can redistribute it and/or modify
54
it under the terms of the GNU General Public License as published by
@@ -11,10 +10,8 @@
1110
GNU General Public License for more details.
1211
1312
You should have received a copy of the GNU General Public License
14-
along with this program; see the file COPYING. If not, write to the
15-
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
16-
MA 02110-1301 USA.
17-
*/
13+
along with this program; if not, write to the Free Software
14+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
1815

1916
/* based on Wei Dai's algebra.cpp from CryptoPP */
2017
#undef NDEBUG
@@ -326,14 +323,3 @@ void AbstractRing::SimultaneousExponentiate(Integer *results,
326323

327324

328325
} // namespace
329-
330-
331-
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
332-
namespace mySTL {
333-
template TaoCrypt::WindowSlider* uninit_copy<TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*>(TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*);
334-
template void destroy<TaoCrypt::WindowSlider*>(TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*);
335-
template TaoCrypt::WindowSlider* GetArrayMemory<TaoCrypt::WindowSlider>(size_t);
336-
template void FreeArrayMemory<TaoCrypt::WindowSlider>(TaoCrypt::WindowSlider*);
337-
}
338-
#endif
339-

extra/yassl/taocrypt/src/integer.cpp

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
/*
2-
Copyright (C) 2000-2007 MySQL AB
1+
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
32
43
This program is free software; you can redistribute it and/or modify
54
it under the terms of the GNU General Public License as published by
@@ -11,12 +10,8 @@
1110
GNU General Public License for more details.
1211
1312
You should have received a copy of the GNU General Public License
14-
along with this program; see the file COPYING. If not, write to the
15-
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
16-
MA 02110-1301 USA.
17-
*/
18-
19-
13+
along with this program; if not, write to the Free Software
14+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
2015

2116
/* based on Wei Dai's integer.cpp from CryptoPP */
2217

@@ -3953,18 +3948,5 @@ Integer CRT(const Integer &xp, const Integer &p, const Integer &xq,
39533948
// isn't operator overloading great?
39543949
return p * (u * (xq-xp) % q) + xp;
39553950
}
3956-
3957-
3958-
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
3959-
#ifndef TAOCRYPT_NATIVE_DWORD_AVAILABLE
3960-
template hword DivideThreeWordsByTwo<hword, Word>(hword*, hword, hword, Word*);
3961-
#endif
3962-
template word DivideThreeWordsByTwo<word, DWord>(word*, word, word, DWord*);
3963-
#ifdef SSE2_INTRINSICS_AVAILABLE
3964-
template class AlignedAllocator<word>;
3965-
#endif
3966-
#endif
3967-
3968-
39693951
} // namespace
39703952

0 commit comments

Comments
 (0)