Bug 203219

Summary: databases/memcached Builds on i386, fails on amd64 with assert tautology error
Product: Ports & Packages Reporter: Phil <phil>
Component: Individual Port(s)Assignee: Steve Wills <swills>
Status: Closed FIXED    
Severity: Affects Some People CC: c.kworr
Priority: --- Flags: bugzilla: maintainer-feedback? (swills)
Version: Latest   
Hardware: Any   
OS: Any   

Description Phil 2015-09-20 03:02:48 UTC
(In reply to Steve Wills from comment #9 Bug 202590 which was "Fixed" and closed)

I've built memcached successfully on FreeBSD10.2Stable i386, but not on amd64. Both using ccache. With the exception of -march the settings and scripts are  identical. Compiler used is clang 3.4.1 
# cc -v
FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512


The kernel,world,distribution were rebuilt/installed yesterday, ports today.  Updated /usr/ports and commenced a FULL ports rebuild.

After the amd64 failure, the ccache was cleared as a precaution.  Retry resulted in:

make -DBATCH -DUSE_CORE2 package
===>  Building for memcached-1.4.24_2
/usr/bin/make  all-recursive
Making all in doc
/usr/bin/make  all-am
/usr/local/libexec/ccache/cc -DHAVE_CONFIG_H -I.   -I/usr/local/include -O2 -pipe -g0 -ggdb0 -DSTRIP_FBSDID -march=core-avx-i  -I/usr/local/include -fno-strict-aliasing -std=c99  -m64 -O2 -pipe -g0 -ggdb0 -DSTRIP_FBSDID -march=core-avx-i  -I/usr/local/include -fno-strict-aliasing -std=c99 -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached_debug-items.o -MD -MP -MF .deps/memcached_debug-items.Tpo -c -o memcached_debug-items.o `test -f 'items.c' || echo './'`items.c
items.c:1141:28: error: comparison of constant 256 with expression of type 'uint8_t' (aka 'unsigned char') is always true [-Werror,-Wtautological-constant-out-of-range-compare]
    assert(it->slabs_clsid < LARGEST_ID);
           ~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~
/usr/include/assert.h:54:21: note: expanded from macro 'assert'
#define assert(e)       ((e) ? (void)0 : __assert(__func__, __FILE__, \
                          ^
1 error generated.
*** Error code 1

FYI: 717 packages are successfully built on i386, and memcached-1.4.24.txz
 was last successfully built on Jul 22 23:32
Comment 1 Steve Wills freebsd_committer freebsd_triage 2015-09-20 12:01:16 UTC
Either disable ccache or set the CCACHE_CPP2 environment variable during your build.
Comment 2 c.kworr 2015-10-27 09:48:07 UTC
Turning ccache off only transforms that into:

items.c:1141:28: warning: comparison of constant 256 with expression of type 'uint8_t' (aka 'unsigned char') is always true [-Wtautological-constant-out-of-range-compare]
    assert(it->slabs_clsid < LARGEST_ID);
           ~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~
/usr/include/assert.h:54:21: note: expanded from macro 'assert'
#define assert(e)       ((e) ? (void)0 : __assert(__func__, __FILE__, \
                          ^
1 warning generated.

Already should be fixed upstream though, yet the highlighted line was probably forgotten:

https://github.com/memcached/memcached/commit/f0358c023e79d0ffc320222afe8a978f528e52a3
Comment 3 Steve Wills freebsd_committer freebsd_triage 2015-10-27 15:32:11 UTC
(In reply to c.kworr from comment #2)
I see the assert and agree that the fix is probably to simply remove it, but what I don't understand is why the issue is an error for you and only a warning in my build. Any ideas?
Comment 4 Steve Wills freebsd_committer freebsd_triage 2015-10-27 15:34:12 UTC
(In reply to c.kworr from comment #2)
I noticed too that in the initial bug report it was an error, but in comment 2 it shows as only a warning.
Comment 5 c.kworr 2015-10-27 17:31:26 UTC
ccache it is:

# without CCACHE_CPP2

clang37 -DHAVE_CONFIG_H -I.   -I/usr/local/include  -m64 -O3 -pipe -march=native  -fstack-protector -fno-strict-aliasing -std=c99 -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached_debug-slabs.o -MD -MP -MF .deps/memcached_debug-slabs.Tpo -c -o memcached_debug-slabs.o `test -f 'slabs.c' || echo './'`slabs.c
mv -f .deps/memcached_debug-slabs.Tpo .deps/memcached_debug-slabs.Po
clang37 -DHAVE_CONFIG_H -I.   -I/usr/local/include  -m64 -O3 -pipe -march=native  -fstack-protector -fno-strict-aliasing -std=c99 -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached_debug-items.o -MD -MP -MF .deps/memcached_debug-items.Tpo -c -o memcached_debug-items.o `test -f 'items.c' || echo './'`items.c
items.c:1141:28: error: comparison of constant 256 with expression of type 'uint8_t' (aka 'unsigned char') is always true [-Werror,-Wtautological-constant-out-of-range-compare]
    assert(it->slabs_clsid < LARGEST_ID);
           ~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~
/usr/include/assert.h:54:21: note: expanded from macro 'assert'
#define assert(e)       ((e) ? (void)0 : __assert(__func__, __FILE__, \
                          ^
1 error generated.
*** Error code 1

# with CCACHE_CPP2

clang37 -DHAVE_CONFIG_H -I.   -I/usr/local/include  -m64 -O3 -pipe -march=native  -fstack-protector -fno-strict-aliasing -std=c99 -Wall -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached_debug-slabs.o -MD -MP -MF .deps/memcached_debug-slabs.Tpo -c -o memcached_debug-slabs.o `test -f 'slabs.c' || echo './'`slabs.c
mv -f .deps/memcached_debug-slabs.Tpo .deps/memcached_debug-slabs.Po
clang37 -DHAVE_CONFIG_H -I.   -I/usr/local/include  -m64 -O3 -pipe -march=native  -fstack-protector -fno-strict-aliasing -std=c99 -Wall -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached_debug-items.o -MD -MP -MF .deps/memcached_debug-items.Tpo -c -o memcached_debug-items.o `test -f 'items.c' || echo './'`items.c
items.c:1141:28: warning: comparison of constant 256 with expression of type 'uint8_t' (aka 'unsigned char') is always true [-Wtautological-constant-out-of-range-compare]
    assert(it->slabs_clsid < LARGEST_ID);
           ~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~
/usr/include/assert.h:54:21: note: expanded from macro 'assert'
#define assert(e)       ((e) ? (void)0 : __assert(__func__, __FILE__, \
                          ^
1 warning generated.

It ends up adding -Werror from somewhere.
Comment 6 commit-hook freebsd_committer freebsd_triage 2015-10-27 18:01:44 UTC
A commit references this bug:

Author: swills
Date: Tue Oct 27 18:01:29 UTC 2015
New revision: 400333
URL: https://svnweb.freebsd.org/changeset/ports/400333

Log:
  databases/memcached: fix build with ccache on 64bit systems

  PR:		203219

Changes:
  head/databases/memcached/files/patch-items.c
Comment 7 Steve Wills freebsd_committer freebsd_triage 2015-10-27 18:02:28 UTC
Fixed, please let me know if you are still experiencing issues.