chad3814 / node-hashtable

Native hashtable interface for when V8 objects can't take the heat
MIT License
106 stars 41 forks source link

fix issues with recent clang on macOS (tr1 removed) #31

Closed fabrice102 closed 6 years ago

fabrice102 commented 7 years ago

hashtable does not compile on recent macOS:

> hashtable@2.0.2 install /Users/fbenhamo/tmp/node-hashtable
> node-gyp configure build

  CXX(target) Release/obj.target/native/src/hashtable.o
In file included from ../src/hashtable.cpp:1:
../src/hashtable.h:7:10: fatal error: 'tr1/unordered_map' file not found
#include <tr1/unordered_map>
         ^
1 error generated.

This is a fix for this issue.

yanwsh commented 7 years ago

I have the same issue, nice fix.

fedorax commented 7 years ago

+1 nice! it's helpfull

JoeriJackers commented 7 years ago

@fabrice102 ++ Check's out on El Capitan! Thanks for this!

crazyquark commented 7 years ago

Ah, I've also made a fix for this using the MAC_OS_X_VERSION_10_12 macro: https://github.com/chad3814/node-hashtable/pull/33

randomnerd commented 7 years ago

any idea why this hasn't been merged for three months already?

igorclark commented 7 years ago

Hi folks, I found this same problem, but this PR version doesn't work for me on El Capitan 10.11.6 with clang-800.0.38, even with the < 201103L guard.

From what I could find online it seems that the tr1 package just isn't present in the latest C++11 stdlib on (at least my version of) MacOS, so I made a separate fork which just removes the whole #ifdef __APPLE__ sections, and it compiles fine for me.

Not sure what should be done about this! It obviously builds fine on Linux, so right now I'm using my fork to develop on MacOS, and including a RUN step in my Dockerfile which replaces the git+https fork reference with the latest repo version, and does npm install inside the image using that. Which works, but it's not exactly, uh, elegant.

Any thoughts on the best way to sort this out? Is it clear which versions of MacOS/clang it works with and which ones not?

Cheers!

im-kulikov commented 7 years ago

macOS 10.12.3 + nodeJS 7.8.0

31 patch work 👍

valeriansaliou commented 7 years ago

Hi! Developer of https://github.com/valeriansaliou/node-fast-ratelimit here, that relies on node-hashtable.

The fix proposed in this thread prevents older version of Node on Sierra (v6 in my case) to compile node-hashtable.

I've come up with a way to support both Node versions, fork here: https://github.com/valeriansaliou/node-hashtable — let me know if that compiles on your different environments and I can PR here.

I'm not literate in C++ so maybe there's a more elegant way than the one I propose; though it compiles fine.

EDIT: I've also fixed Travis CI tests, which now require GCC 4.9. See latest state from commit as commit log is polluted by trial-and-error for Travis.

luisw19 commented 5 years ago

Hi,

I just tired to install it on a macOS Mojave v10.14.5 and am getting a similar error to the ones described... I've tried several workarounds (including installing from valeriansaliou's fork) but none worked. Would appreciate if anyone has a solution for this.

$npm install hashtable

> hashtable@2.0.2 install /Users/luisweir/git-repos/gitlab/poc/ha-db-proxy/node_modules/hashtable
> node-gyp configure build

  CXX(target) Release/obj.target/native/src/hashtable.o
In file included from ../src/hashtable.cpp:1:
../src/hashtable.h:7:10: fatal error: 'tr1/unordered_map' file not found
#include <tr1/unordered_map>
         ^~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/native/src/hashtable.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:196:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:256:12)
gyp ERR! System Darwin 18.6.0
gyp ERR! command "/usr/local/Cellar/node/12.1.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /Users/luisweir/git-repos/gitlab/poc/ha-db-proxy/node_modules/hashtable
gyp ERR! node -v v12.1.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hashtable@2.0.2 install: `node-gyp configure build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the hashtable@2.0.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/luisweir/.npm/_logs/2019-06-13T11_09_56_503Z-debug.log