2004-11-03 12:39:38 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2011-05-25 12:39:11 +02:00
|
|
|
# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
2010-12-28 19:57:23 +01:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Library General Public
|
|
|
|
# License as published by the Free Software Foundation; version 2
|
|
|
|
# of the License.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Library General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Library General Public
|
|
|
|
# License along with this library; if not, write to the Free
|
2013-03-19 15:53:48 +01:00
|
|
|
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
2019-05-11 21:29:06 +03:00
|
|
|
# MA 02110-1335 USA
|
2010-12-28 19:57:23 +01:00
|
|
|
|
2006-04-07 02:25:59 +04:00
|
|
|
########################################################################
|
|
|
|
|
|
|
|
get_key_value()
|
|
|
|
{
|
|
|
|
echo "$1" | sed 's/^--[a-zA-Z_-]*=//'
|
|
|
|
}
|
|
|
|
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat <<EOF
|
|
|
|
Usage: $0 [-h|-n] [configure-options]
|
|
|
|
-h, --help Show this help message.
|
|
|
|
-n, --just-print Don't actually run any commands; just print them.
|
|
|
|
-c, --just-configure Stop after running configure.
|
2016-01-03 12:48:55 +02:00
|
|
|
Combined with --just-print shows configure options.
|
2013-01-11 02:03:43 +02:00
|
|
|
--extra-configs=xxx Add this to configure options
|
|
|
|
--extra-flags=xxx Add this C and CXX flags
|
|
|
|
--extra-cflags=xxx Add this to C flags
|
|
|
|
--extra-cxxflags=xxx Add this to CXX flags
|
|
|
|
--verbose Print out full compile lines
|
2011-05-06 11:20:01 +02:00
|
|
|
--with-debug=full Build with full debug(no optimizations, keep call stack).
|
2010-07-24 10:31:48 -03:00
|
|
|
--warning-mode=[old|pedantic|maintainer]
|
2006-04-07 02:25:59 +04:00
|
|
|
Influences the debug flags. Old is default.
|
|
|
|
--prefix=path Build with prefix 'path'.
|
|
|
|
|
2017-01-03 15:47:17 +02:00
|
|
|
Note: this script is intended for internal use by MariaDB developers.
|
2006-04-07 02:25:59 +04:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
parse_options()
|
|
|
|
{
|
|
|
|
while test $# -gt 0
|
|
|
|
do
|
|
|
|
case "$1" in
|
|
|
|
--prefix=*)
|
|
|
|
prefix=`get_key_value "$1"`;;
|
2011-05-06 11:20:01 +02:00
|
|
|
--with-debug=full)
|
|
|
|
full_debug="=full";;
|
2006-04-07 02:25:59 +04:00
|
|
|
--warning-mode=*)
|
|
|
|
warning_mode=`get_key_value "$1"`;;
|
2009-12-06 18:34:54 +01:00
|
|
|
--extra-flags=*)
|
|
|
|
EXTRA_FLAGS=`get_key_value "$1"`;;
|
|
|
|
--extra-cflags=*)
|
|
|
|
EXTRA_CFLAGS=`get_key_value "$1"`;;
|
|
|
|
--extra-cxxflags=*)
|
|
|
|
EXTRA_CXXFLAGS=`get_key_value "$1"`;;
|
|
|
|
--extra-configs=*)
|
|
|
|
EXTRA_CONFIGS=`get_key_value "$1"`;;
|
2012-06-05 14:09:18 +03:00
|
|
|
--extra-makeflags=*)
|
|
|
|
EXTRA_MAKEFLAGS=`get_key_value "$1"`;;
|
2006-04-07 02:25:59 +04:00
|
|
|
-c | --just-configure)
|
|
|
|
just_configure=1;;
|
|
|
|
-n | --just-print | --print)
|
|
|
|
just_print=1;;
|
2013-01-11 02:03:43 +02:00
|
|
|
--verbose)
|
|
|
|
verbose_make=1;;
|
2006-04-07 02:25:59 +04:00
|
|
|
-h | --help)
|
|
|
|
usage
|
|
|
|
exit 0;;
|
|
|
|
*)
|
|
|
|
echo "Unknown option '$1'"
|
|
|
|
exit 1;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
|
2006-08-30 23:20:01 +02:00
|
|
|
if test ! -f sql/mysqld.cc
|
2001-01-30 20:43:16 -05:00
|
|
|
then
|
2000-12-18 23:24:19 +02:00
|
|
|
echo "You must run this script from the MySQL top-level directory"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2006-04-07 02:25:59 +04:00
|
|
|
prefix="/usr/local/mysql"
|
2003-10-08 21:50:05 +03:00
|
|
|
just_print=
|
2001-03-04 22:34:26 +01:00
|
|
|
just_configure=
|
2006-04-07 02:25:59 +04:00
|
|
|
warning_mode=
|
2010-07-24 10:31:48 -03:00
|
|
|
maintainer_mode=
|
2011-05-06 11:20:01 +02:00
|
|
|
full_debug=
|
2013-01-11 02:03:43 +02:00
|
|
|
verbose_make=
|
2006-04-07 02:25:59 +04:00
|
|
|
|
|
|
|
parse_options "$@"
|
|
|
|
|
2005-09-28 08:04:08 -07:00
|
|
|
if test -n "$MYSQL_BUILD_PREFIX"
|
2005-09-16 18:10:36 -07:00
|
|
|
then
|
2006-04-07 02:25:59 +04:00
|
|
|
prefix="$MYSQL_BUILD_PREFIX"
|
2005-09-16 18:10:36 -07:00
|
|
|
fi
|
|
|
|
|
2001-01-30 20:43:16 -05:00
|
|
|
set -e
|
|
|
|
|
2006-04-07 02:25:59 +04:00
|
|
|
#
|
|
|
|
# Check for the CPU and set up CPU specific flags. We may reset them
|
|
|
|
# later.
|
|
|
|
#
|
|
|
|
path=`dirname $0`
|
|
|
|
. "$path/check-cpu"
|
2010-01-07 13:02:18 +01:00
|
|
|
. "$path/util.sh"
|
2006-04-07 02:25:59 +04:00
|
|
|
|
2010-01-07 13:02:18 +01:00
|
|
|
get_make_parallel_flag
|
2000-12-18 23:24:19 +02:00
|
|
|
|
2006-05-17 13:59:37 +02:00
|
|
|
# SSL library to use.--with-ssl will select our bundled yaSSL
|
2016-12-30 11:23:45 +02:00
|
|
|
# implementation of SSL. --with-ssl=yes will first try system library
|
2022-08-07 17:07:39 -05:00
|
|
|
# then the bundled one --with-ssl=system will use the system library.
|
2018-11-19 19:52:07 +02:00
|
|
|
# We use bundled by default as this is guaranteed to work with Galera
|
|
|
|
SSL_LIBRARY=--with-ssl
|
2005-11-02 15:45:25 +02:00
|
|
|
|
2010-07-24 10:31:48 -03:00
|
|
|
if [ "x$warning_mode" = "xpedantic" ]; then
|
|
|
|
warnings="-W -Wall -ansi -pedantic -Wno-long-long -Wno-unused -D_POSIX_SOURCE"
|
|
|
|
c_warnings="$warnings"
|
|
|
|
cxx_warnings="$warnings -std=c++98"
|
|
|
|
# NOTE: warning mode should not influence optimize/debug mode.
|
|
|
|
# Please feel free to add a separate option if you don't feel it's an overkill.
|
|
|
|
debug_extra_cflags="-O0"
|
|
|
|
# Reset CPU flags (-mtune), they don't work in -pedantic mode
|
|
|
|
check_cpu_cflags=""
|
|
|
|
elif [ "x$warning_mode" = "xmaintainer" ]; then
|
|
|
|
c_warnings="-Wall -Wextra"
|
|
|
|
cxx_warnings="$c_warnings -Wno-unused-parameter"
|
|
|
|
maintainer_mode="--enable-mysql-maintainer-mode"
|
|
|
|
debug_extra_cflags="-g3"
|
|
|
|
else
|
2006-04-07 02:25:59 +04:00
|
|
|
# Both C and C++ warnings
|
Fix all warnings given by UBSAN
The easiest way to compile and test the server with UBSAN is to run:
./BUILD/compile-pentium64-ubsan
and then run mysql-test-run.
After this commit, one should be able to run this without any UBSAN
warnings. There is still a few compiler warnings that should be fixed
at some point, but these do not expose any real bugs.
The 'special' cases where we disable, suppress or circumvent UBSAN are:
- ref10 source (as here we intentionally do some shifts that UBSAN
complains about.
- x86 version of optimized int#korr() methods. UBSAN do not like unaligned
memory access of integers. Fixed by using byte_order_generic.h when
compiling with UBSAN
- We use smaller thread stack with ASAN and UBSAN, which forced me to
disable a few tests that prints the thread stack size.
- Verifying class types does not work for shared libraries. I added
suppression in mysql-test-run.pl for this case.
- Added '#ifdef WITH_UBSAN' when using integer arithmetic where it is
safe to have overflows (two cases, in item_func.cc).
Things fixed:
- Don't left shift signed values
(byte_order_generic.h, mysqltest.c, item_sum.cc and many more)
- Don't assign not non existing values to enum variables.
- Ensure that bool and enum values are properly initialized in
constructors. This was needed as UBSAN checks that these types has
correct values when one copies an object.
(gcalc_tools.h, ha_partition.cc, item_sum.cc, partition_element.h ...)
- Ensure we do not called handler functions on unallocated objects or
deleted objects.
(events.cc, sql_acl.cc).
- Fixed bugs in Item_sp::Item_sp() where we did not call constructor
on Query_arena object.
- Fixed several cast of objects to an incompatible class!
(Item.cc, Item_buff.cc, item_timefunc.cc, opt_subselect.cc, sql_acl.cc,
sql_select.cc ...)
- Ensure we do not do integer arithmetic that causes over or underflows.
This includes also ++ and -- of integers.
(Item_func.cc, Item_strfunc.cc, item_timefunc.cc, sql_base.cc ...)
- Added JSON_VALUE_UNITIALIZED to json_value_types and ensure that
value_type is initialized to this instead of to -1, which is not a valid
enum value for json_value_types.
- Ensure we do not call memcpy() when second argument could be null.
- Fixed that Item_func_str::make_empty_result() creates an empty string
instead of a null string (safer as it ensures we do not do arithmetic
on null strings).
Other things:
- Changed struct st_position to an OBJECT and added an initialization
function to it to ensure that we do not copy or use uninitialized
members. The change to a class was also motived that we used "struct
st_position" and POSITION randomly trough the code which was
confusing.
- Notably big rewrite in sql_acl.cc to avoid using deleted objects.
- Changed in sql_partition to use '^' instead of '-'. This is safe as
the operator is either 0 or 0x8000000000000000ULL.
- Added check for select_nr < INT_MAX in JOIN::build_explain() to
avoid bug when get_select() could return NULL.
- Reordered elements in POSITION for better alignment.
- Changed sql_test.cc::print_plan() to use pointers instead of objects.
- Fixed bug in find_set() where could could execute '1 << -1'.
- Added variable have_sanitizer, used by mtr. (This variable was before
only in 10.5 and up). It can now have one of two values:
ASAN or UBSAN.
- Moved ~Archive_share() from ha_archive.cc to ha_archive.h and marked
it virtual. This was an effort to get UBSAN to work with loaded storage
engines. I kept the change as the new place is better.
- Added in CONNECT engine COLBLK::SetName(), to get around a wrong cast
in tabutil.cpp.
- Added HAVE_REPLICATION around usage of rgi_slave, to get embedded
server to compile with UBSAN. (Patch from Marko).
- Added #ifdef for powerpc64 to avoid a bug in old gcc versions related
to integer arithmetic.
Changes that should not be needed but had to be done to suppress warnings
from UBSAN:
- Added static_cast<<uint16_t>> around shift to get rid of a LOT of
compiler warnings when using UBSAN.
- Had to change some '/' of 2 base integers to shift to get rid of
some compile time warnings.
Reviewed by:
- Json changes: Alexey Botchkov
- Charset changes in ctype-uca.c: Alexander Barkov
- InnoDB changes & Embedded server: Marko Mäkelä
- sql_acl.cc changes: Vicențiu Ciorbaru
- build_explain() changes: Sergey Petrunia
2021-04-18 15:29:13 +03:00
|
|
|
warnings="-Wall -Wextra -Wunused -Wwrite-strings -Wno-uninitialized -Wno-strict-aliasing -Wimplicit-fallthrough=2 -Wformat-security -Wvla"
|
2005-11-02 15:45:25 +02:00
|
|
|
|
2006-12-15 00:51:37 +02:00
|
|
|
# For more warnings, uncomment the following line
|
Bug#53445: Build with -Wall and fix warnings that it generates
Apart strict-aliasing warnings, fix the remaining warnings
generated by GCC 4.4.4 -Wall and -Wextra flags.
One major source of warnings was the in-house function my_bcmp
which (unconventionally) took pointers to unsigned characters
as the byte sequences to be compared. Since my_bcmp and bcmp
are deprecated functions whose only difference with memcmp is
the return value, every use of the function is replaced with
memcmp as the special return value wasn't actually being used
by any caller.
There were also various other warnings, mostly due to type
mismatches, missing return values, missing prototypes, dead
code (unreachable) and ignored return values.
BUILD/SETUP.sh:
Remove flags that are implied by -Wall and -Wextra.
Do not warn about unused parameters in C++.
BUILD/check-cpu:
Print only the compiler version instead of verbose banner.
Although the option is gcc specific, the check was only
being used for GCC specific checks anyway.
client/mysql.cc:
bcmp is no longer defined.
client/mysqltest.cc:
Pass a string to function expecting a format string.
Replace use of bcmp with memcmp.
cmd-line-utils/readline/Makefile.am:
Always define _GNU_SOURCE when compiling GNU readline.
Required to make certain prototypes visible.
cmd-line-utils/readline/input.c:
Condition for the code to be meaningful.
configure.in:
Remove check for bcmp.
extra/comp_err.c:
Use appropriate type.
extra/replace.c:
Replace use of bcmp with memcmp.
extra/yassl/src/crypto_wrapper.cpp:
Do not ignore the return value of fgets. Retrieve the file
position if fgets succeed -- if it fails, the function will
bail out and return a error.
extra/yassl/taocrypt/include/blowfish.hpp:
Use a single array instead of accessing positions of the sbox_
through a subscript to pbox_.
extra/yassl/taocrypt/include/runtime.hpp:
One definition of such functions is enough.
extra/yassl/taocrypt/src/aes.cpp:
Avoid potentially ambiguous conditions.
extra/yassl/taocrypt/src/algebra.cpp:
Rename arguments to avoid shadowing related warnings.
extra/yassl/taocrypt/src/blowfish.cpp:
Avoid potentially ambiguous conditions.
extra/yassl/taocrypt/src/integer.cpp:
Do not define type within a anonymous union.
Use a variable to return a value instead of
leaving the result in a register -- compiler
does not know the logic inside the asm.
extra/yassl/taocrypt/src/misc.cpp:
Define handler for pure virtual functions.
Remove unused code.
extra/yassl/taocrypt/src/twofish.cpp:
Avoid potentially ambiguous conditions.
extra/yassl/testsuite/test.hpp:
Function must have C language linkage.
include/m_string.h:
Remove check which relied on bcmp being defined -- they weren't
being used as bcmp is only visible when _BSD_SOURCE is defined.
include/my_bitmap.h:
Remove bogus helpers which were used only in a few files and
were causing warnings about dead code.
include/my_global.h:
Due to G++ bug, always silence false-positive uninitialized
variables warnings when compiling C++ code with G++.
Remove bogus helper.
libmysql/Makefile.shared:
Remove built-in implementation of bcmp.
mysql-test/lib/My/SafeProcess/safe_process.cc:
Cast pid to largest possible type for a process identifier.
mysys/mf_loadpath.c:
Leave space of the ending nul.
mysys/mf_pack.c:
Replace bcmp with memcmp.
mysys/my_bitmap.c:
Dead code removal.
mysys/my_gethwaddr.c:
Remove unused variable.
mysys/my_getopt.c:
Silence bogus uninitialized variable warning.
Do not cast away the constant qualifier.
mysys/safemalloc.c:
Cast to expected type.
mysys/thr_lock.c:
Silence bogus uninitialized variable warning.
sql/field.cc:
Replace bogus helper with a more appropriate logic which is
used throughout the code.
sql/item.cc:
Remove bogus logical condition which always evaluates to TRUE.
sql/item_create.cc:
Simplify code to avoid signedness related warnings.
sql/log_event.cc:
Replace use of bcmp with memcmp.
No need to use helpers for simple bit operations.
sql/log_event_old.cc:
Replace bmove_align with memcpy.
sql/mysqld.cc:
Move use declaration of variable to the ifdef block where it
is used. Remove now-unnecessary casts and arguments.
sql/set_var.cc:
Replace bogus helpers with simple and classic bit operations.
sql/slave.cc:
Cast to expected type and silence bogus warning.
sql/sql_class.h:
Don't use enum values as bit flags, the supposed type safety is
bogus as the combined bit flags are not a value in the enumeration.
sql/udf_example.c:
Only declare variable when necessary.
sql/unireg.h:
Replace use of bmove_align with memcpy.
storage/innobase/os/os0file.c:
Silence bogus warning.
storage/myisam/mi_open.c:
Remove bogus cast, DBUG_DUMP expects a pointer to unsigned
char.
storage/myisam/mi_page.c:
Remove bogus cast, DBUG_DUMP expects a pointer to unsigned
char.
strings/bcmp.c:
Remove built-in bcmp.
strings/ctype-ucs2.c:
Silence bogus warning.
tests/mysql_client_test.c:
Use a appropriate type as expected by simple_command().
2010-07-02 15:30:47 -03:00
|
|
|
# warnings="$warnings -Wshadow"
|
2007-01-27 03:46:45 +02:00
|
|
|
|
2006-04-07 02:25:59 +04:00
|
|
|
# C warnings
|
Bug#53445: Build with -Wall and fix warnings that it generates
Apart strict-aliasing warnings, fix the remaining warnings
generated by GCC 4.4.4 -Wall and -Wextra flags.
One major source of warnings was the in-house function my_bcmp
which (unconventionally) took pointers to unsigned characters
as the byte sequences to be compared. Since my_bcmp and bcmp
are deprecated functions whose only difference with memcmp is
the return value, every use of the function is replaced with
memcmp as the special return value wasn't actually being used
by any caller.
There were also various other warnings, mostly due to type
mismatches, missing return values, missing prototypes, dead
code (unreachable) and ignored return values.
BUILD/SETUP.sh:
Remove flags that are implied by -Wall and -Wextra.
Do not warn about unused parameters in C++.
BUILD/check-cpu:
Print only the compiler version instead of verbose banner.
Although the option is gcc specific, the check was only
being used for GCC specific checks anyway.
client/mysql.cc:
bcmp is no longer defined.
client/mysqltest.cc:
Pass a string to function expecting a format string.
Replace use of bcmp with memcmp.
cmd-line-utils/readline/Makefile.am:
Always define _GNU_SOURCE when compiling GNU readline.
Required to make certain prototypes visible.
cmd-line-utils/readline/input.c:
Condition for the code to be meaningful.
configure.in:
Remove check for bcmp.
extra/comp_err.c:
Use appropriate type.
extra/replace.c:
Replace use of bcmp with memcmp.
extra/yassl/src/crypto_wrapper.cpp:
Do not ignore the return value of fgets. Retrieve the file
position if fgets succeed -- if it fails, the function will
bail out and return a error.
extra/yassl/taocrypt/include/blowfish.hpp:
Use a single array instead of accessing positions of the sbox_
through a subscript to pbox_.
extra/yassl/taocrypt/include/runtime.hpp:
One definition of such functions is enough.
extra/yassl/taocrypt/src/aes.cpp:
Avoid potentially ambiguous conditions.
extra/yassl/taocrypt/src/algebra.cpp:
Rename arguments to avoid shadowing related warnings.
extra/yassl/taocrypt/src/blowfish.cpp:
Avoid potentially ambiguous conditions.
extra/yassl/taocrypt/src/integer.cpp:
Do not define type within a anonymous union.
Use a variable to return a value instead of
leaving the result in a register -- compiler
does not know the logic inside the asm.
extra/yassl/taocrypt/src/misc.cpp:
Define handler for pure virtual functions.
Remove unused code.
extra/yassl/taocrypt/src/twofish.cpp:
Avoid potentially ambiguous conditions.
extra/yassl/testsuite/test.hpp:
Function must have C language linkage.
include/m_string.h:
Remove check which relied on bcmp being defined -- they weren't
being used as bcmp is only visible when _BSD_SOURCE is defined.
include/my_bitmap.h:
Remove bogus helpers which were used only in a few files and
were causing warnings about dead code.
include/my_global.h:
Due to G++ bug, always silence false-positive uninitialized
variables warnings when compiling C++ code with G++.
Remove bogus helper.
libmysql/Makefile.shared:
Remove built-in implementation of bcmp.
mysql-test/lib/My/SafeProcess/safe_process.cc:
Cast pid to largest possible type for a process identifier.
mysys/mf_loadpath.c:
Leave space of the ending nul.
mysys/mf_pack.c:
Replace bcmp with memcmp.
mysys/my_bitmap.c:
Dead code removal.
mysys/my_gethwaddr.c:
Remove unused variable.
mysys/my_getopt.c:
Silence bogus uninitialized variable warning.
Do not cast away the constant qualifier.
mysys/safemalloc.c:
Cast to expected type.
mysys/thr_lock.c:
Silence bogus uninitialized variable warning.
sql/field.cc:
Replace bogus helper with a more appropriate logic which is
used throughout the code.
sql/item.cc:
Remove bogus logical condition which always evaluates to TRUE.
sql/item_create.cc:
Simplify code to avoid signedness related warnings.
sql/log_event.cc:
Replace use of bcmp with memcmp.
No need to use helpers for simple bit operations.
sql/log_event_old.cc:
Replace bmove_align with memcpy.
sql/mysqld.cc:
Move use declaration of variable to the ifdef block where it
is used. Remove now-unnecessary casts and arguments.
sql/set_var.cc:
Replace bogus helpers with simple and classic bit operations.
sql/slave.cc:
Cast to expected type and silence bogus warning.
sql/sql_class.h:
Don't use enum values as bit flags, the supposed type safety is
bogus as the combined bit flags are not a value in the enumeration.
sql/udf_example.c:
Only declare variable when necessary.
sql/unireg.h:
Replace use of bmove_align with memcpy.
storage/innobase/os/os0file.c:
Silence bogus warning.
storage/myisam/mi_open.c:
Remove bogus cast, DBUG_DUMP expects a pointer to unsigned
char.
storage/myisam/mi_page.c:
Remove bogus cast, DBUG_DUMP expects a pointer to unsigned
char.
strings/bcmp.c:
Remove built-in bcmp.
strings/ctype-ucs2.c:
Silence bogus warning.
tests/mysql_client_test.c:
Use a appropriate type as expected by simple_command().
2010-07-02 15:30:47 -03:00
|
|
|
c_warnings="$warnings"
|
2006-04-07 02:25:59 +04:00
|
|
|
# C++ warnings
|
2012-09-28 02:06:56 +03:00
|
|
|
cxx_warnings="$warnings -Wno-unused-parameter -Wno-invalid-offsetof"
|
2007-12-14 15:21:37 +02:00
|
|
|
# cxx_warnings="$cxx_warnings -Woverloaded-virtual -Wsign-promo"
|
2010-10-19 11:49:31 -02:00
|
|
|
cxx_warnings="$cxx_warnings -Wnon-virtual-dtor"
|
Bug#53445: Build with -Wall and fix warnings that it generates
Apart strict-aliasing warnings, fix the remaining warnings
generated by GCC 4.4.4 -Wall and -Wextra flags.
One major source of warnings was the in-house function my_bcmp
which (unconventionally) took pointers to unsigned characters
as the byte sequences to be compared. Since my_bcmp and bcmp
are deprecated functions whose only difference with memcmp is
the return value, every use of the function is replaced with
memcmp as the special return value wasn't actually being used
by any caller.
There were also various other warnings, mostly due to type
mismatches, missing return values, missing prototypes, dead
code (unreachable) and ignored return values.
BUILD/SETUP.sh:
Remove flags that are implied by -Wall and -Wextra.
Do not warn about unused parameters in C++.
BUILD/check-cpu:
Print only the compiler version instead of verbose banner.
Although the option is gcc specific, the check was only
being used for GCC specific checks anyway.
client/mysql.cc:
bcmp is no longer defined.
client/mysqltest.cc:
Pass a string to function expecting a format string.
Replace use of bcmp with memcmp.
cmd-line-utils/readline/Makefile.am:
Always define _GNU_SOURCE when compiling GNU readline.
Required to make certain prototypes visible.
cmd-line-utils/readline/input.c:
Condition for the code to be meaningful.
configure.in:
Remove check for bcmp.
extra/comp_err.c:
Use appropriate type.
extra/replace.c:
Replace use of bcmp with memcmp.
extra/yassl/src/crypto_wrapper.cpp:
Do not ignore the return value of fgets. Retrieve the file
position if fgets succeed -- if it fails, the function will
bail out and return a error.
extra/yassl/taocrypt/include/blowfish.hpp:
Use a single array instead of accessing positions of the sbox_
through a subscript to pbox_.
extra/yassl/taocrypt/include/runtime.hpp:
One definition of such functions is enough.
extra/yassl/taocrypt/src/aes.cpp:
Avoid potentially ambiguous conditions.
extra/yassl/taocrypt/src/algebra.cpp:
Rename arguments to avoid shadowing related warnings.
extra/yassl/taocrypt/src/blowfish.cpp:
Avoid potentially ambiguous conditions.
extra/yassl/taocrypt/src/integer.cpp:
Do not define type within a anonymous union.
Use a variable to return a value instead of
leaving the result in a register -- compiler
does not know the logic inside the asm.
extra/yassl/taocrypt/src/misc.cpp:
Define handler for pure virtual functions.
Remove unused code.
extra/yassl/taocrypt/src/twofish.cpp:
Avoid potentially ambiguous conditions.
extra/yassl/testsuite/test.hpp:
Function must have C language linkage.
include/m_string.h:
Remove check which relied on bcmp being defined -- they weren't
being used as bcmp is only visible when _BSD_SOURCE is defined.
include/my_bitmap.h:
Remove bogus helpers which were used only in a few files and
were causing warnings about dead code.
include/my_global.h:
Due to G++ bug, always silence false-positive uninitialized
variables warnings when compiling C++ code with G++.
Remove bogus helper.
libmysql/Makefile.shared:
Remove built-in implementation of bcmp.
mysql-test/lib/My/SafeProcess/safe_process.cc:
Cast pid to largest possible type for a process identifier.
mysys/mf_loadpath.c:
Leave space of the ending nul.
mysys/mf_pack.c:
Replace bcmp with memcmp.
mysys/my_bitmap.c:
Dead code removal.
mysys/my_gethwaddr.c:
Remove unused variable.
mysys/my_getopt.c:
Silence bogus uninitialized variable warning.
Do not cast away the constant qualifier.
mysys/safemalloc.c:
Cast to expected type.
mysys/thr_lock.c:
Silence bogus uninitialized variable warning.
sql/field.cc:
Replace bogus helper with a more appropriate logic which is
used throughout the code.
sql/item.cc:
Remove bogus logical condition which always evaluates to TRUE.
sql/item_create.cc:
Simplify code to avoid signedness related warnings.
sql/log_event.cc:
Replace use of bcmp with memcmp.
No need to use helpers for simple bit operations.
sql/log_event_old.cc:
Replace bmove_align with memcpy.
sql/mysqld.cc:
Move use declaration of variable to the ifdef block where it
is used. Remove now-unnecessary casts and arguments.
sql/set_var.cc:
Replace bogus helpers with simple and classic bit operations.
sql/slave.cc:
Cast to expected type and silence bogus warning.
sql/sql_class.h:
Don't use enum values as bit flags, the supposed type safety is
bogus as the combined bit flags are not a value in the enumeration.
sql/udf_example.c:
Only declare variable when necessary.
sql/unireg.h:
Replace use of bmove_align with memcpy.
storage/innobase/os/os0file.c:
Silence bogus warning.
storage/myisam/mi_open.c:
Remove bogus cast, DBUG_DUMP expects a pointer to unsigned
char.
storage/myisam/mi_page.c:
Remove bogus cast, DBUG_DUMP expects a pointer to unsigned
char.
strings/bcmp.c:
Remove built-in bcmp.
strings/ctype-ucs2.c:
Silence bogus warning.
tests/mysql_client_test.c:
Use a appropriate type as expected by simple_command().
2010-07-02 15:30:47 -03:00
|
|
|
debug_extra_cflags="-O0 -g3 -gdwarf-2"
|
2006-04-07 02:25:59 +04:00
|
|
|
fi
|
2000-12-18 23:24:19 +02:00
|
|
|
|
2006-04-07 02:25:59 +04:00
|
|
|
# Set flags for various build configurations.
|
|
|
|
# Used in -valgrind builds
|
2010-05-20 13:40:42 +03:00
|
|
|
# Override -DFORCE_INIT_OF_VARS from debug_cflags. It enables the macro
|
2015-02-10 14:05:49 +04:00
|
|
|
# UNINIT_VAR(), which is only useful for silencing spurious warnings
|
|
|
|
# of static analysis tools. We want UNINIT_VAR() to be a no-op in Valgrind.
|
2019-08-30 16:07:26 +03:00
|
|
|
# TRASH_FREE_MEMORY is enabled so that we can find wrong memory accesses
|
|
|
|
# even when running a test without valgrind
|
|
|
|
#
|
|
|
|
valgrind_flags="-DHAVE_valgrind -USAFEMALLOC -DTRASH_FREE_MEMORY"
|
2011-01-26 15:17:46 +02:00
|
|
|
valgrind_flags="$valgrind_flags -UFORCE_INIT_OF_VARS -Wno-uninitialized"
|
2006-04-07 02:25:59 +04:00
|
|
|
valgrind_flags="$valgrind_flags -DMYSQL_SERVER_SUFFIX=-valgrind-max"
|
2010-05-20 13:40:42 +03:00
|
|
|
valgrind_configs="--with-valgrind"
|
2006-04-07 02:25:59 +04:00
|
|
|
#
|
|
|
|
# Used in -debug builds
|
2013-03-26 00:03:13 +02:00
|
|
|
debug_cflags="-DEXTRA_DEBUG -DSAFE_MUTEX -DSAFEMALLOC"
|
2006-02-03 12:05:29 -05:00
|
|
|
error_inject="--with-error-inject "
|
2006-04-07 02:25:59 +04:00
|
|
|
#
|
|
|
|
# Base C++ flags for all builds
|
2019-06-13 17:53:57 +03:00
|
|
|
base_cxxflags="-felide-constructors -fexceptions"
|
2006-04-07 02:25:59 +04:00
|
|
|
#
|
|
|
|
# Flags for optimizing builds.
|
|
|
|
# Be as fast as we can be without losing our ability to backtrace.
|
2001-04-13 22:09:33 +03:00
|
|
|
fast_cflags="-O3 -fno-omit-frame-pointer"
|
2004-10-04 13:43:16 +02:00
|
|
|
|
2010-08-06 09:59:38 -03:00
|
|
|
debug_configs="--with-debug"
|
2011-05-06 11:20:01 +02:00
|
|
|
if [ -z "$full_debug" ]
|
|
|
|
then
|
|
|
|
debug_cflags="$debug_cflags $debug_extra_cflags"
|
|
|
|
fi
|
|
|
|
|
2009-10-29 02:04:56 +02:00
|
|
|
# we need local-infile in all binaries for rpl000001
|
|
|
|
# if you need to disable local-infile in the client, write a build script
|
|
|
|
# and unset local_infile_configs
|
|
|
|
local_infile_configs="--enable-local-infile"
|
|
|
|
|
2006-04-07 02:25:59 +04:00
|
|
|
#
|
|
|
|
# Configuration options.
|
|
|
|
#
|
|
|
|
base_configs="--prefix=$prefix --enable-assembler "
|
|
|
|
base_configs="$base_configs --with-extra-charsets=complex "
|
2007-01-25 09:18:10 +01:00
|
|
|
base_configs="$base_configs --enable-thread-safe-client "
|
2010-07-24 10:31:48 -03:00
|
|
|
base_configs="$base_configs --with-big-tables $maintainer_mode"
|
2011-04-25 17:22:25 +02:00
|
|
|
base_configs="$base_configs --with-plugin-aria --with-aria-tmp-tables"
|
2018-11-19 19:52:07 +02:00
|
|
|
# Following is to get tokudb to work
|
|
|
|
base_configs="$base_configs --with-jemalloc=NO"
|
2006-04-07 02:25:59 +04:00
|
|
|
|
2007-01-25 08:46:07 +01:00
|
|
|
if test -d "$path/../cmd-line-utils/readline"
|
|
|
|
then
|
|
|
|
base_configs="$base_configs --with-readline"
|
|
|
|
elif test -d "$path/../cmd-line-utils/libedit"
|
|
|
|
then
|
|
|
|
base_configs="$base_configs --with-libedit"
|
|
|
|
fi
|
|
|
|
|
2006-05-01 21:33:09 -07:00
|
|
|
max_no_embedded_configs="$SSL_LIBRARY --with-plugins=max"
|
2009-10-06 09:57:22 +03:00
|
|
|
max_no_qc_configs="$SSL_LIBRARY --with-plugins=max --without-query-cache"
|
2022-03-29 09:53:15 +03:00
|
|
|
max_configs="$SSL_LIBRARY --with-plugins=max --with-embedded-server --with-libevent --with-plugin-rocksdb=dynamic --without-plugin-tokudb --with-plugin-test_sql_discovery=DYNAMIC --with-plugin-file_key_management=DYNAMIC"
|
2014-08-21 18:11:46 +02:00
|
|
|
all_configs="$SSL_LIBRARY --with-plugins=max --with-embedded-server --with-innodb_plugin --with-libevent"
|
2006-04-07 02:25:59 +04:00
|
|
|
|
|
|
|
#
|
|
|
|
# CPU and platform specific compilation flags.
|
|
|
|
#
|
|
|
|
alpha_cflags="$check_cpu_cflags -Wa,-m$cpu_flag"
|
|
|
|
amd64_cflags="$check_cpu_cflags"
|
|
|
|
amd64_cxxflags="" # If dropping '--with-big-tables', add here "-DBIG_TABLES"
|
2014-08-06 15:39:15 +03:00
|
|
|
pentium_cflags="$check_cpu_cflags -m32"
|
2006-04-07 02:25:59 +04:00
|
|
|
pentium64_cflags="$check_cpu_cflags -m64"
|
|
|
|
ppc_cflags="$check_cpu_cflags"
|
|
|
|
sparc_cflags=""
|
2000-12-18 23:24:19 +02:00
|
|
|
|
2001-01-30 20:43:16 -05:00
|
|
|
if gmake --version > /dev/null 2>&1
|
|
|
|
then
|
2000-12-18 23:24:19 +02:00
|
|
|
make=gmake
|
|
|
|
else
|
|
|
|
make=make
|
|
|
|
fi
|
2001-10-30 16:31:35 +02:00
|
|
|
|
2005-10-06 17:54:43 +03:00
|
|
|
if test -z "$CC" ; then
|
|
|
|
CC=gcc
|
|
|
|
fi
|
|
|
|
|
2003-05-23 18:20:57 +02:00
|
|
|
if test -z "$CXX" ; then
|
2010-01-04 09:27:50 +01:00
|
|
|
CXX=g++
|
2003-04-09 14:53:20 +02:00
|
|
|
fi
|
2003-05-23 18:20:57 +02:00
|
|
|
|
2011-03-01 15:19:25 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Set -Wuninitialized to debug flags for gcc 4.4 and above
|
|
|
|
# because it is allowed there without -O
|
|
|
|
#
|
|
|
|
if test `$CC -v 2>&1 | tail -1 | sed 's/ .*$//'` = 'gcc' ; then
|
2011-03-01 16:21:27 +02:00
|
|
|
GCCVERSION=`$CC -v 2>&1 | tail -1 | \
|
|
|
|
sed 's/^[a-zA-Z][a-zA-Z]* [a-zA-Z][a-zA-Z]* //' | sed 's/ .*$//'`
|
2011-03-01 15:19:25 +02:00
|
|
|
GCCV1=`echo $GCCVERSION | sed 's/\..*$//'`
|
|
|
|
GCCV2=`echo $GCCVERSION | sed 's/[0-9][0-9]*\.//'|sed 's/\..*$//'`
|
|
|
|
if test '(' "$GCCV1" -gt '4' ')' -o \
|
|
|
|
'(' '(' "$GCCV1" -eq '4' ')' -a '(' "$GCCV2" -ge '4' ')' ')'
|
|
|
|
then
|
|
|
|
debug_cflags="$debug_cflags -DFORCE_INIT_OF_VARS -Wuninitialized"
|
|
|
|
fi
|
2019-08-30 16:07:26 +03:00
|
|
|
if (test '(' "$GCCV1" -gt '6' ')')
|
|
|
|
then
|
|
|
|
c_warnings="$c_warnings -Wimplicit-fallthrough=2"
|
|
|
|
cxx_warnings="$cxx_warnings -Wimplicit-fallthrough=2"
|
|
|
|
fi
|
2011-03-01 15:19:25 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2003-05-23 18:20:57 +02:00
|
|
|
# If ccache (a compiler cache which reduces build time)
|
|
|
|
# (http://samba.org/ccache) is installed, use it.
|
|
|
|
# We use 'grep' and hope 'grep' will work as expected
|
|
|
|
# (returns 0 if finds lines)
|
2015-12-23 13:46:32 +02:00
|
|
|
|
|
|
|
# As cmake doesn't like CC and CXX with a space, use symlinks from
|
|
|
|
# /usr/lib64/ccache if they exits.
|
|
|
|
|
2007-01-29 01:47:35 +02:00
|
|
|
if test "$USING_GCOV" != "1"
|
|
|
|
then
|
|
|
|
# Not using gcov; Safe to use ccache
|
|
|
|
CCACHE_GCOV_VERSION_ENABLED=1
|
|
|
|
fi
|
|
|
|
|
2007-01-07 12:21:42 -05:00
|
|
|
if ccache -V > /dev/null 2>&1 && test "$CCACHE_GCOV_VERSION_ENABLED" = "1"
|
2003-05-23 18:20:57 +02:00
|
|
|
then
|
2015-12-23 13:46:32 +02:00
|
|
|
if test -x /usr/lib64/ccache/gcc
|
|
|
|
then
|
|
|
|
CC=/usr/lib64/ccache/gcc
|
|
|
|
fi
|
|
|
|
if test -x /usr/lib64/ccache/g++
|
|
|
|
then
|
|
|
|
CXX=/usr/lib64/ccache/g++
|
|
|
|
fi
|
2003-05-23 18:20:57 +02:00
|
|
|
fi
|
2007-08-15 18:10:16 -06:00
|
|
|
|
|
|
|
# gcov
|
|
|
|
|
|
|
|
# The -fprofile-arcs and -ftest-coverage options cause GCC to instrument the
|
|
|
|
# code with profiling information used by gcov.
|
|
|
|
# The -DDISABLE_TAO_ASM is needed to avoid build failures in Yassl.
|
|
|
|
# The -DHAVE_gcov enables code to write out coverage info even when crashing.
|
|
|
|
|
|
|
|
gcov_compile_flags="-fprofile-arcs -ftest-coverage"
|
|
|
|
gcov_compile_flags="$gcov_compile_flags -DDISABLE_TAO_ASM"
|
|
|
|
gcov_compile_flags="$gcov_compile_flags -DMYSQL_SERVER_SUFFIX=-gcov -DHAVE_gcov"
|
|
|
|
|
2017-07-01 14:02:29 +03:00
|
|
|
#
|
|
|
|
# The following plugins doesn't work on 32 bit systems
|
|
|
|
disable_64_bit_plugins="--without-plugin-tokudb --without-plugin-rocksdb"
|
|
|
|
|
|
|
|
|
2007-08-15 18:10:16 -06:00
|
|
|
# GCC4 needs -fprofile-arcs -ftest-coverage on the linker command line (as well
|
|
|
|
# as on the compiler command line), and this requires setting LDFLAGS for BDB.
|
|
|
|
|
2016-12-06 14:05:09 +02:00
|
|
|
gcov_link_flags="-fprofile-arcs -ftest-coverage -lgcov"
|
2007-08-15 18:10:16 -06:00
|
|
|
|
2011-05-25 12:39:11 +02:00
|
|
|
gcov_configs="--with-gcov"
|
2007-08-15 18:10:16 -06:00
|
|
|
|
|
|
|
# gprof
|
|
|
|
|
|
|
|
gprof_compile_flags="-O2 -pg -g"
|
|
|
|
|
|
|
|
gprof_link_flags="--disable-shared $static_link"
|
|
|
|
|
2018-01-18 01:42:51 +02:00
|
|
|
disable_gprof_plugins="--with-zlib-dir=bundled --without-plugin-oqgraph --without-plugin-mroonga"
|
2018-01-27 14:39:33 +02:00
|
|
|
|
|
|
|
disable_asan_plugins="--without-plugin-rocksdb"
|