awesomized / libmemcached

Resurrection of libmemcached
https://awesomized.github.io/libmemcached/
BSD 3-Clause "New" or "Revised" License
45 stars 26 forks source link

libmemcached does not compile on Mac OS X Mavericks #28

Closed m6w6 closed 4 years ago

m6w6 commented 4 years ago

Imported from Launchpad using lp2gh.


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 Filetests/memslap' does not exist. Must remake target tests/memslap'. CXXLD tests/memerror Filetests/memdump' does not exist. Must remake target tests/memdump'. CXXLD tests/memslap CXXLD tests/memdump Fileall-am' does not exist. File tests/libmemcached-1.0/internals' does not exist. Fileall-am' does not exist. File tests/libmemcached-1.0/internals' does not exist. Fileall-am' does not exist. File tests/libmemcached-1.0/internals' does not exist. Fileall-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. Filetests/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

Greetings.

m6w6 commented 4 years ago

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.
m6w6 commented 4 years ago

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 ]

m6w6 commented 4 years ago

Just replace false with NULL

m6w6 commented 4 years ago

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!

m6w6 commented 4 years ago

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

m6w6 commented 4 years ago

Using Yosemite, applying patch is not working well with version 1.0.18:

$ patch -p1 < ~/Downloads/fix-osx.diff.txt patching file clients/memflush.cc Hunk #1 FAILED at 39. Hunk #2 FAILED at 48. 2 out of 2 hunks FAILED -- saving rejects to file clients/memflush.cc.rej 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

m6w6 commented 4 years ago

used stable (libmemcache.0.18)

2014-06-19 13:15 GMT+04:00 Maxime

Using Yosemite, applying patch is not working well with version 1.0.18:

$ patch -p1 < ~/Downloads/fix-osx.diff.txt patching file clients/memflush.cc Hunk #1 FAILED at 39. Hunk #2 FAILED at 48. 2 out of 2 hunks FAILED -- saving rejects to file clients/memflush.cc.rej 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

-- You received this bug notification because you are subscribed to a duplicate bug report (1284765). https://bugs.launchpad.net/bugs/1245562

Title: libmemcached does not compile on Mac OS X Mavericks

Status in libmemcached - A C and C++ client library for memcached: In Progress

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. Filetests/libmemcached-1.0/internals' does not exist. File all-am' does not exist. Filetests/libmemcached-1.0/internals' does not exist. File all-am' does not exist. Filetests/libmemcached-1.0/internals' does not exist. File all-am' does not exist. Filetests/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. Filetests/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.

To manage notifications about this bug go to: https://bugs.launchpad.net/libmemcached/+bug/1245562/+subscriptions

m6w6 commented 4 years ago

libmemcached-1.0.18$ patch -p1 -i ~/Downloads/fix-osx.diff (Stripping trailing CRs from patch.) patching file clients/memflush.cc (Stripping trailing CRs from patch.) patching file example/byteorder.cc (Stripping trailing CRs from patch.) patching file libmemcached-1.0/memcached.h (Stripping trailing CRs from patch.) patching file libmemcached/byteorder.cc Hunk #1 FAILED at 39. 1 out of 1 hunk FAILED -- saving rejects to file libmemcached/byteorder.cc.rej

m6w6 commented 4 years ago

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

m6w6 commented 4 years ago

Maxime (max44410), Sorry I forgot at the end of the file a new line

patch -p1 < libmemcached-1.0.18_osx-fix.diff patching file clients/memflush.cc patching file example/byteorder.cc patching file libmemcached-1.0/memcached.h patching file libmemcached/byteorder.cc

m6w6 commented 4 years ago

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

m6w6 commented 4 years ago

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:

m6w6 commented 4 years ago

m6w6 commented 4 years ago

m6w6 commented 4 years ago

Umm, not quite. I think we just want:

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

m6w6 commented 4 years ago

+# 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

       ^

1 error generated. make[1]: [libmemcached/csl/libmemcached_libmemcached_la-context.lo] Error 1 make: [install] Error 2

m6w6 commented 4 years ago

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

m6w6 commented 4 years ago

Sean, mountain lion: http://bot.brew.sh/job/Homebrew%20Pull%20Requests/18594/version=mountain_lion/testReport/junit/brew-test-bot/mountain_lion/install_libmemcached/

m6w6 commented 4 years ago

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 Mavericks - I guess that Mountain Lion requires a different fix?

m6w6 commented 4 years ago

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

m6w6 commented 4 years ago

OK, I see what the problem is with .

The fix for bug 1216521 is to configure the location of . 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.

m6w6 commented 4 years ago

I attached the log analysis libmemcached 1.0.18, can diagnose a memory leak and the decrease in performance?

$ cppcheck --enable=warning,performance,portability -j4 libmemcached-1.0.18 2> libmemcached.txt