Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 494332 - dev-db/mysql-5.5.32 USE=debug - .../work/mysql/strings/ctype-ucs2.c:2321:8: error: variable 'buflen' set but not used [-Werror=unused-but-set-variable]
Summary: dev-db/mysql-5.5.32 USE=debug - .../work/mysql/strings/ctype-ucs2.c:2321:8: e...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Gentoo Linux MySQL bugs team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-15 13:45 UTC by Eric Gisse
Modified: 2014-04-25 00:49 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (file_494332.txt,51.93 KB, text/plain)
2013-12-15 13:47 UTC, Eric Gisse
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Gisse 2013-12-15 13:45:34 UTC
While attempting to track down *another* unrelated issue, I needed to build a debuggable MySQL.

ATtempts end with this:

[  3%] Building C object strings/CMakeFiles/strings.dir/ctype-ucs2.c.o
cd /var/tmp/portage/dev-db/mysql-5.5.32/work/mysql-5.5.32_build/strings && /usr/bin/x86_64-pc-linux-gnu-gcc  -DDISABLE_MYSQL_THREAD_H -DHAVE_CONFIG_H  -O2 -pipe -fno-strict-aliasing  -fPIC -Wall -Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing -Werror -Wdeclaration-after-statement -O2 -g -DNDEBUG -DDBUG_OFF -I/var/tmp/portage/dev-db/mysql-5.5.32/work/mysql-5.5.32_build/include -I/var/tmp/portage/dev-db/mysql-5.5.32/work/mysql/include    -o CMakeFiles/strings.dir/ctype-ucs2.c.o -c /var/tmp/portage/dev-db/mysql-5.5.32/work/mysql/strings/ctype-ucs2.c
/var/tmp/portage/dev-db/mysql-5.5.32/work/mysql/strings/ctype-ucs2.c: In function 'my_fill_utf32':
/var/tmp/portage/dev-db/mysql-5.5.32/work/mysql/strings/ctype-ucs2.c:2321:8: error: variable 'buflen' set but not used [-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors
make[2]: *** [strings/CMakeFiles/strings.dir/ctype-ucs2.c.o] Error 1
make[2]: Leaving directory `/var/tmp/portage/dev-db/mysql-5.5.32/work/mysql-5.5.32_build'
make[1]: *** [strings/CMakeFiles/strings.dir/all] Error 2
make[1]: Leaving directory `/var/tmp/portage/dev-db/mysql-5.5.32/work/mysql-5.5.32_build'
make: *** [all] Error 2

Note that negation of make options, C and LDFLAG options don't change the answer. 

Attempts to find a documented MySQL bug haven't been very fruitful.

Reproducible: Always

Steps to Reproduce:
1. Build dev-db/mysql-5.5.32 with USE="debug"
2. watch it fail
3. cry
Actual Results:  
[  3%] Building C object strings/CMakeFiles/strings.dir/ctype-ucs2.c.o
cd /var/tmp/portage/dev-db/mysql-5.5.32/work/mysql-5.5.32_build/strings && /usr/bin/x86_64-pc-linux-gnu-gcc  -DDISABLE_MYSQL_THREAD_H -DHAVE_CONFIG_H  -O2 -pipe -fno-strict-aliasing  -fPIC -Wall -Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing -Werror -Wdeclaration-after-statement -O2 -g -DNDEBUG -DDBUG_OFF -I/var/tmp/portage/dev-db/mysql-5.5.32/work/mysql-5.5.32_build/include -I/var/tmp/portage/dev-db/mysql-5.5.32/work/mysql/include    -o CMakeFiles/strings.dir/ctype-ucs2.c.o -c /var/tmp/portage/dev-db/mysql-5.5.32/work/mysql/strings/ctype-ucs2.c
/var/tmp/portage/dev-db/mysql-5.5.32/work/mysql/strings/ctype-ucs2.c: In function 'my_fill_utf32':
/var/tmp/portage/dev-db/mysql-5.5.32/work/mysql/strings/ctype-ucs2.c:2321:8: error: variable 'buflen' set but not used [-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors
make[2]: *** [strings/CMakeFiles/strings.dir/ctype-ucs2.c.o] Error 1
make[2]: Leaving directory `/var/tmp/portage/dev-db/mysql-5.5.32/work/mysql-5.5.32_build'
make[1]: *** [strings/CMakeFiles/strings.dir/all] Error 2
make[1]: Leaving directory `/var/tmp/portage/dev-db/mysql-5.5.32/work/mysql-5.5.32_build'
make: *** [all] Error 2


Expected Results:  
not that

emerge --info 

Portage 2.1.11.55 (hardened/linux/amd64, gcc-4.6.3, glibc-2.16.0, 3.9.4-hardened-r2 x86_64)
=================================================================
System uname: Linux-3.9.4-hardened-r2-x86_64-AMD_Opteron-tm-_Processor_6128-with-gentoo-2.2
KiB Mem:    16465532 total,    361928 free
KiB Swap:    8388604 total,   8216468 free
Timestamp of tree: Wed, 11 Dec 2013 21:45:01 +0000
ld GNU ld (GNU Binutils) 2.23.1
ccache version 3.1.9 [disabled]
app-shells/bash:          4.2_p42
dev-lang/python:          2.7.3-r3, 3.2.3-r2
dev-util/ccache:          3.1.9
dev-util/cmake:           2.8.10.2-r1
dev-util/pkgconfig:       0.28
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.11.8
sys-apps/sandbox:         2.6
sys-devel/autoconf:       2.69
sys-devel/automake:       1.11.6, 1.12.6, 1.13.1
sys-devel/binutils:       2.23.1
sys-devel/gcc:            4.6.3, 4.7.2-r1
sys-devel/gcc-config:     1.8
sys-devel/libtool:        2.4.2
sys-devel/make:           3.82-r4
sys-kernel/linux-headers: 3.8 (virtual/os-headers)
sys-libs/glibc:           2.16.0
Repositories: gentoo pentoo poly-c
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=amdfam10 -O2 -pipe -fomit-frame-pointer"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /etc/pam.d/ /var/bind /var/spool/munin-async/.ssh"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.4/ext-active/ /etc/php/cgi-php5.4/ext-active/ /etc/php/cli-php5.4/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=amdfam10 -O2 -pipe -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync metadata-transfer news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://gentoo.osuosl.org"
LDFLAGS="-Wl,--hash-style=gnu,-O1 -Wl,--as-needed"
MAKEOPTS="-j8"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/pentoo /var/lib/layman/poly-c"
SYNC="rsync://rsync.gtlib.gatech.edu/gentoo-portage"
USE="3dnow amd64 cups custom-cflags custom-optimization cxx fuse hardened hvm ipv6 lm_sensors logrotate mmx mmxext multilib ncurses offensive openrc openssl pax_kernel pcre qemu readline snmp spell sse sse2 ssl threads unicode zlib" ABI_X86="64" APACHE2_MODULES="authz_host dir mime userdir vhost_alias alias rewrite log_config" CURL_SSL="openssl" ELIBC="glibc" GRUB_PLATFORMS="pc" INPUT_DEVICES="keyboard mouse synaptics" KERNEL="linux" LINGUAS="en_US en" NGINX_MODULES_HTTP="auth_basic access autoindex browser empty_gif geoip gzip memcached perl proxy realip rewrite scgi stub_status upload upload_progress fastcgi" NGINX_MODULES_MAIL="*" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7" USERLAND="GNU"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON

make.conf

CFLAGS="-march=amdfam10 -O2 -pipe -fomit-frame-pointer"# -floop-interchange -floop-strip-mine -floop-block"
CXXFLAGS="${CFLAGS}"
LDFLAGS="-Wl,--hash-style=gnu,-O1 -Wl,--as-needed"

ACCEPT_KEYWORDS=~amd64

# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="x86_64-pc-linux-gnu"
DISTDIR="/usr/portage/distfiles"
CONFIG_PROTECT="/etc/pam.d/"
# These are the USE flags that were used in addition to what is provided by the
# profile used for building.

GRUB_PLATFORMS="pc"
USE="-* openssl cups qemu hvm cxx hardened custom-cflags custom-optimization ssl fuse spell mmx sse \
     sse2 mmxext 3dnow ipv6 logrotate readline unicode threads \
     offensive ncurses lm_sensors snmp pcre zlib pax_kernel ipv6 openrc"

APACHE2_MODULES="authz_host dir mime userdir vhost_alias alias rewrite log_config"
NGINX_MODULES_HTTP="auth_basic access autoindex browser empty_gif geoip gzip memcached perl proxy realip rewrite scgi stub_status upload upload_progress fastcgi"  
NGINX_MODULES_MAIL="*"
FEATURES="parallel-fetch metadata-transfer"
MAKEOPTS="-j8"
INPUT_DEVICES="keyboard mouse synaptics"
GENTOO_MIRRORS="http://gentoo.osuosl.org"
#SYNC="rsync://rsync.us.gentoo.org/gentoo-portage"
SYNC="rsync://rsync.gtlib.gatech.edu/gentoo-portage"
LINGUAS="en_US en"
source /var/lib/layman/make.conf
PORTAGE_ECLASS_WARNING_ENABLE=0
PORTAGE_REPO_DUPLICATE_WARN=0
ACCEPT_LICENSE=*
HTTPD_USER="nginx" 
HTTPD_GROUP="nginx"
CURL_SSL="openssl"
PYTHON_SINGLE_TARGET="python2_7"
PYTHON_TARGETS="python2_7"
Comment 1 Eric Gisse 2013-12-15 13:47:02 UTC
Created attachment 365402 [details]
build.log
Comment 2 Eric Gisse 2013-12-16 06:15:14 UTC
Build failures confirmed on 5.6.15 and 5.5.35

The relevant code bloc in ctype-ucs2.c is thus:

static
void my_fill_utf32(CHARSET_INFO *cs,
                   char *s, size_t slen, int fill)
{
  char buf[10];
  uint buflen;
  char *e= s + slen;

  DBUG_ASSERT((slen % 4) == 0);

  buflen= cs->cset->wc_mb(cs, (my_wc_t) fill, (uchar*) buf,
                          (uchar*) buf + sizeof(buf));
  DBUG_ASSERT(buflen == 4);
  while (s < e)
  {
    memcpy(s, buf, 4);
    s+= 4;
  }
}

The problem appears that one of the default GCC CFLAGS (at least in GCC 4.6 and 4.7) is that -Werror=unused-but-set-variable is a default. So this unused buflen variable in the codebloc is causing the failure. 

Disabling that check with the CFLAG addition of -Wno-unused-but-set-variable allows the build to nearly complete in 5.5 and 5.6, though now build failure happens in different spots for different reasons.

Is this a pecularity of my environment, or does nobody build a debuggable MySQL?
Comment 3 Eric Gisse 2013-12-16 09:45:26 UTC
The journey continues.

It appears that the overall problem (I use the word lightly) is that the build environment defaults to -Werror.

When MySQL is built with the debug flag (manually via cmake -DWITH_DEBUG=1), certain code paths that aren't normally used spew a few warnings which are being treated as errors.

Building with -Wno-error explicitly set manually in CMakeCache.txt allowed the build to complete with no issues. 

Now that I grasp what's going on, the two things which really irk me is that this was never noticed (as far as I can tell) and that the MySQL build environment is using cflags that I never specified.

What's not clear is what has to happen to fix this. This *looks* like an upstream MySQL failure to me, so should it be reported to them? Or is this a gentoo-ism?
Comment 4 Julian Ospald 2014-01-08 16:11:00 UTC
The proper fix is to completely remove -Werror as outlined in
http://devmanual.gentoo.org/ebuild-writing/common-mistakes/index.html
under "-Werror compiler flag not removed"

--- a/cmake/maintainer.cmake
+++ b/cmake/maintainer.cmake
@@ -18,7 +18,7 @@
 # Setup GCC (GNU C compiler) warning options.
 MACRO(SET_MYSQL_MAINTAINER_GNU_C_OPTIONS)
   SET(MY_MAINTAINER_WARNINGS
-      "-Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing -Werror")
+      "-Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing")
   CHECK_C_COMPILER_FLAG("-Wdeclaration-after-statement"
                         HAVE_DECLARATION_AFTER_STATEMENT)
   IF(HAVE_DECLARATION_AFTER_STATEMENT)
Comment 5 Brian Evans (RETIRED) gentoo-dev 2014-02-26 18:43:05 UTC
Patch added to mysql-extras along with a 5.6 patch
Comment 6 Julian Ospald 2014-03-19 00:59:24 UTC
I just added the patch to src_prepare, because such build failures are not acceptable. Don't forget to remove src_prepare phase when you bump MY_EXTRAS_VER.
Comment 7 Jorge Manuel B. S. Vicetto (RETIRED) Gentoo Infrastructure gentoo-dev 2014-04-25 00:49:20 UTC
Closing this bug as we've pushed the work from the overlay into the tree.