libmemcached does not compile on Mac OS X Mavericks

Bug #1245562 reported by Camilo Sperberg
30
This bug affects 4 people
Affects Status Importance Assigned to Milestone
libmemcached
In Progress
Undecided
Brian Aker

Bug Description

I'm trying to compile libmemcached and it doesn't go beyond one specific point. I am no C expert so I really don't know where to go further. I've tried to manually adjust some values in the Makefile but I did just mess it up more.

./configure works fine, problem comes with make (output from make --debug):

  Must remake target `tests/memerror'.
  CXXLD tests/memcat
   File `tests/memslap' does not exist.
  Must remake target `tests/memslap'.
  CXXLD tests/memerror
   File `tests/memdump' does not exist.
  Must remake target `tests/memdump'.
  CXXLD tests/memslap
  CXXLD tests/memdump
 File `all-am' does not exist.
   File `tests/libmemcached-1.0/internals' does not exist.
 File `all-am' does not exist.
   File `tests/libmemcached-1.0/internals' does not exist.
 File `all-am' does not exist.
   File `tests/libmemcached-1.0/internals' does not exist.
 File `all-am' does not exist.
   File `tests/libmemcached-1.0/internals' does not exist.
^Cmake[1]: *** [libmemcachedinternal/libmemcachedutilinternal.la] Interrupt: 2
make: *** [all] Interrupt: 2

At the point of the last:
 File `all-am' does not exist.
   File `tests/libmemcached-1.0/internals' does not exist.

It just waits and nothing happens. I've waited for over an hour and still nothing. I've downgraded all the way back to 1.0.14 and still the same error.

Maybe it is an version problem error?

Configure command gives the following information at the end, if you need any more information, please do ask for it.

---
Configuration summary for libmemcached version 1.0.14

   * Installation prefix: /usr/local
   * System type: apple-darwin13.0.0
   * Host CPU: x86_64
   * C Compiler: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
   * C Flags: -g -O2 -Wno-pragmas -Wall -Wextra -Wunknown-pragmas -std=c99 --param=ssp-buffer-size=1 -Wno-attributes -Waddress -Wbad-function-cast -Wchar-subscripts -Wcomment -Wfloat-equal -Wformat-security -Wformat=2 -Wmissing-field-initializers -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wnormalized=id -Woverride-init -Wpointer-arith -Wpointer-sign -Wredundant-decls -Wshadow -Wshorten-64-to-32 -Wsign-compare -Wstrict-overflow=1 -Wswitch-enum -Wundef -Wunused -Wunused-variable -Wwrite-strings -fwrapv -pipe
   * C++ Compiler: i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
   * C++ Flags: -g -O2 -Wno-pragmas -Wall -Wextra -Wunknown-pragmas --param=ssp-buffer-size=1 -Wno-attributes -Waddress -Wchar-subscripts -Wcomment -Wctor-dtor-privacy -Wfloat-equal -Wformat=2 -Wmissing-field-initializers -Wnon-virtual-dtor -Wnormalized=id -Woverloaded-virtual -Wpointer-arith -Wredundant-decls -Wshadow -Wshorten-64-to-32 -Wsign-compare -Wstrict-overflow=1 -Wswitch-enum -Wundef -Wunused -Wunused-variable -Wwrite-strings -Wformat-security -fwrapv
   * CPP Flags: -fvisibility=hidden
   * LIB Flags: -z -pie
   * Assertions enabled: no
   * Debug enabled: no
   * Warnings as failure: no
   * SASL support: yes
   * make -j: 5
   * VCS checkout: no

Greetings.

Tags: maverick
Brian Aker (brianaker)
Changed in libmemcached:
status: New → In Progress
assignee: nobody → Brian Aker (brianaker)
Revision history for this message
Alexandre Carmel-Veilleux (acv) wrote :

To compile the latest stable with the latest Xcode on OS X Mavericks I had to change the the file clients/memflush.cc to add an explicit cast to avoid the errors:

clients/memflush.cc:42:19: error: comparison between pointer and integer ('char *' and 'int')
  if (opt_servers == false)
      ~~~~~~~~~~~ ^ ~~~~~
clients/memflush.cc:51:21: error: comparison between pointer and integer ('char *' and 'int')
    if (opt_servers == false)
        ~~~~~~~~~~~ ^ ~~~~~

I casted false to (char *). Obviously on this platform char * is 64 bit and int is 32.

Revision history for this message
Alexandre Carmel-Veilleux (acv) wrote :

The issue originally reported here might well be that this test:

tests/libmemcached-1.0/testapp

Never terminates or gets beyond:

testapp.generate.generate_data 0:205257000 [ ok ]

Revision history for this message
chinalu (chinalu) wrote :

Just replace `false` with NULL

Revision history for this message
Camilo Sperberg (m0) wrote :

Replacing clients/memflush.cc:42:19 and clients/memflush.cc:51:21 with

if (opt_servers == NULL)

instead of

if (opt_servers == false)

 allowed me to compile without problems on the latest stable release (1.0.18).

Thanks!

Revision history for this message
Denis Denisov (denji0k) wrote :

New patch support OSX Yosemite 10.10 and make cross-platform compatibility OS

Revision history for this message
Maxime (max44410) wrote :

I'm using the stable version of libmemcached-1.0.18: https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz

Extract the archive and try to patch it but it's failing for the last file:

$ tar xvf libmemcached-1.0.18.tar.gz
$ cd libmemcached-1.0.18
$ patch -p1 -i ~/Downloads/fix-osx.diff
patching file clients/memflush.cc
patching file example/byteorder.cc
patching file libmemcached-1.0/memcached.h
patching file libmemcached/byteorder.cc
Hunk #1 FAILED at 39.
1 out of 1 hunk FAILED -- saving rejects to file libmemcached/byteorder.cc.rej

Revision history for this message
Maxime (max44410) wrote :

Thanks Denis, I could compile it with many warning, but it compiled.
I've ended up using your homebrew recipe

$ brew install https://raw.github.com/denji/homebrew/56eaf3c/Library/Formula/libmemcached.rb
$ brew link --overwrite libmemcached

And then I could install php-memcached

$ brew install php55-memcached

Revision history for this message
Sean Burke (sburke) wrote :

I am concerned about the patch at

https://bugs.launchpad.net/libmemcached/+bug/1245562/+attachment/4131691/+files/fix-osx.diff

The change to memflush.cc appears to dereference a pointer that is possibly null:

- if (opt_servers == false)
+ if (*opt_servers != NULL)

Revision history for this message
Denis Denisov (denji0k) wrote :

- if (opt_servers == false)
+ if (opt_servers != NULL)

Revision history for this message
Sean Burke (sburke) wrote :

Umm, not quite. I think we just want:

- if (opt_servers == false)
+ if (opt_servers == NULL)

Also, while I don't find fault with the patch to byteorder.cc,
there is a more straightforward fix. The compilation error
arises because HAVE_HTONLL is defined, but sys/types.h
has not been included:

diff --git a/src/libmemcached/libmemcached/byteorder.cc b/src/libmemcached/libmemcached/byteorder.cc
index 9f11aa8..cc5ff42 100644
--- a/src/libmemcached/libmemcached/byteorder.cc
+++ b/src/libmemcached/libmemcached/byteorder.cc
@@ -38,6 +38,10 @@
 #include "mem_config.h"
 #include "libmemcached/byteorder.h"

+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif

Revision history for this message
Denis Denisov (denji0k) wrote :

+# include <sys/types.h>

In file included from libmemcached/csl/context.cc:38:
In file included from ./libmemcached/csl/common.h:50:
In file included from ./libmemcached/common.h:114:
./libmemcached-1.0/memcached.h:46:12: fatal error: 'cinttypes' file not found
# include <cinttypes>
           ^
1 error generated.
make[1]: *** [libmemcached/csl/libmemcached_libmemcached_la-context.lo] Error 1
make: *** [install] Error 2

Revision history for this message
Sean Burke (sburke) wrote :

Hi Denis,

I am not seeing that error in my build, but I am building on OSX 10.10.1 with Xcode 6.1.1,
so perhaps that is the reason. Still, I am surprised that you include <sys/types.h> in
byteorder.cc, and the result is a compilation failure in context.cc.

-SEan

Revision history for this message
Denis Denisov (denji0k) wrote :
Revision history for this message
Sean Burke (sburke) wrote :

OK, but the bot.brew.sh report that you link, builds the 1.0.18 release.
You led me to believe that the "fatal error: 'cinttypes' file not found"
was an effect of my proposed patch.

The homebrew failure seems more closely related to
https://bugs.launchpad.net/libmemcached/+bug/1216521,
which fixes an issue with <cinttypes> Mavericks - I guess that Mountain Lion
requires a different fix?

Revision history for this message
Denis Denisov (denji0k) wrote :

I trust more code API platforms, rather than in broken header file.
Maybe next time will check your option.

Revision history for this message
Sean Burke (sburke) wrote :

OK, I see what the problem is with <cinttypes>.

The fix for bug 1216521 is to configure the location of <cinttypes>.
The autoconf rule is in m4/have_cinttypes.m4, and the homebrew build log
that Denis has linked, shows it being evaluated, finding it is actually in
<tr1/cinttypes>:

    checking for location of cinttypes... <tr1/cinttypes>
    <tr1/cinttypes>

This generates some autoconf macros in mem_config.h (and here I
show examples from my Yosemite build, so "tr1/" prefix is absent):

    /* the location of <cinttypes> */
    #define CINTTYPES_H <cinttypes>

    #if defined(__cplusplus)
    # include CINTTYPES_H
    #else
    # include <inttypes.h>
    #endif

So, the real problem is in libmemcached-1.0/memcached.h,
which fails to use the autoconf macro CINTTYPES_H:

    #ifdef __cplusplus
    # include <cinttypes>

Changing the line above, should fix the Mountain Lion build problem.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers