lovell / farmhash

Node.js implementation of FarmHash, Google's family of high performance hash functions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Error on Windows: '__builtin_expect' identifier not found

jhermsmeier opened this issue · comments

Error

..\src\upstream\farmhash.cc(1378): error C3861: '__builtin_expect': identifier not found [C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash\build\farmhash.vcxproj]

Versions

OS: Windows 10 Tech Preview
node 0.10.35
npm 1.4.28
node-gyp 1.0.1

Output

C:\Users\Jonas\Code\node-hexadb>npm i --save farmhash
npm http GET https://registry.npmjs.org/farmhash
npm http 200 https://registry.npmjs.org/farmhash
npm http GET https://registry.npmjs.org/farmhash/-/farmhash-0.1.0.tgz
npm http 200 https://registry.npmjs.org/farmhash/-/farmhash-0.1.0.tgz
npm http GET https://registry.npmjs.org/nan
npm http 200 https://registry.npmjs.org/nan
npm http GET https://registry.npmjs.org/nan/-/nan-1.4.1.tgz
npm http 200 https://registry.npmjs.org/nan/-/nan-1.4.1.tgz

> farmhash@0.1.0 install C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash
> node-gyp rebuild


C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash>node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(942,5): warning MSB8027: Two or more files with the name of farmhash.cc will produce outputs to the same location. This can lead to an incorrect build result.  The files involved are ..\src\upstream\farmhash.cc, ..\src\farmhash.cc. [C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash\build\farmhash.vcxproj]
  farmhash.cc
  farmhash.cc
..\src\upstream\farmhash.cc(407): warning C4267: 'initializing' : conversion from 'size_t' to 'uint32_t', possible loss of data [C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash\build\farmhash.vcxproj]
..\src\upstream\farmhash.cc(481): warning C4307: '*' : integral constant overflow [C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash\build\farmhash.vcxproj]
..\src\upstream\farmhash.cc(548): warning C4267: 'initializing' : conversion from 'size_t' to 'uint32_t', possible loss of data [C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash\build\farmhash.vcxproj]
..\src\upstream\farmhash.cc(566): warning C4267: 'argument' : conversion from 'size_t' to 'uint32_t', possible loss of data [C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash\build\farmhash.vcxproj]
..\src\upstream\farmhash.cc(570): warning C4267: 'initializing' : conversion from 'size_t' to 'uint32_t', possible loss of data [C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash\build\farmhash.vcxproj]
..\src\upstream\farmhash.cc(585): warning C4267: 'initializing' : conversion from 'size_t' to 'uint32_t', possible loss of data [C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash\build\farmhash.vcxproj]
..\src\upstream\farmhash.cc(641): warning C4267: 'argument' : conversion from 'size_t' to 'uint32_t', possible loss of data [C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash\build\farmhash.vcxproj]
..\src\upstream\farmhash.cc(650): warning C4267: 'return' : conversion from 'size_t' to 'uint32_t', possible loss of data [C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash\build\farmhash.vcxproj]
..\src\upstream\farmhash.cc(873): warning C4267: 'return' : conversion from 'size_t' to 'uint32_t', possible loss of data [C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash\build\farmhash.vcxproj]
..\src\upstream\farmhash.cc(902): warning C4267: 'return' : conversion from 'size_t' to 'uint32_t', possible loss of data [C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash\build\farmhash.vcxproj]
..\src\upstream\farmhash.cc(1128): warning C4267: 'initializing' : conversion from 'size_t' to 'uint32_t', possible loss of data [C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash\build\farmhash.vcxproj]
..\src\upstream\farmhash.cc(1141): warning C4267: 'argument' : conversion from 'size_t' to 'uint32_t', possible loss of data [C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash\build\farmhash.vcxproj]
..\src\upstream\farmhash.cc(1145): warning C4267: 'initializing' : conversion from 'size_t' to 'uint32_t', possible loss of data [C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash\build\farmhash.vcxproj]
..\src\upstream\farmhash.cc(1160): warning C4267: 'initializing' : conversion from 'size_t' to 'uint32_t', possible loss of data [C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash\build\farmhash.vcxproj]
..\src\upstream\farmhash.cc(1227): warning C4267: 'argument' : conversion from 'size_t' to 'uint32_t', possible loss of data [C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash\build\farmhash.vcxproj]
..\src\upstream\farmhash.cc(1277): warning C4267: 'initializing' : conversion from 'size_t' to 'uint32_t', possible loss of data [C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash\build\farmhash.vcxproj]
..\src\upstream\farmhash.cc(1316): warning C4267: 'initializing' : conversion from 'size_t' to 'long', possible loss of data [C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash\build\farmhash.vcxproj]
..\src\upstream\farmhash.cc(1378): error C3861: '__builtin_expect': identifier not found [C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash\build\farmhash.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xlocale(337): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc (..\src\farmhash.cc) [C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash\build\farmhash.vcxproj]
C:\Users\Jonas\.node-gyp\0.10.35\deps\v8\include\v8.h(179): warning C4506: no definition for inline function 'v8::Persistent<v8::Object> v8::Persistent<v8::Object>::New(v8::Handle<v8::Object>)' (..\src\farmhash.cc) [C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash\build\farmhash.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:820:12)
gyp ERR! System Windows_NT 6.2.9200
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Jonas\Code\node-hexadb\node_modules\farmhash
gyp ERR! node -v v0.10.35
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok

npm ERR! farmhash@0.1.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the farmhash@0.1.0 install script.
npm ERR! This is most likely a problem with the farmhash package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls farmhash
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "i" "--save" "farmhash"
npm ERR! cwd C:\Users\Jonas\Code\node-hexadb
npm ERR! node -v v0.10.35
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0

There's some discussion about this problem on the FarmHash Google Group at https://groups.google.com/forum/#!msg/farmhash-discuss/xTkB3uv62pw/wAusRsWMeaAJ (requires registration).

The summary seems to be manually set the FARMHASH_OPTIONAL_BUILTIN_EXPECT macro for compilers that don't provide __builtin_expect, which includes VS.

Are you able to add -DFARMHASH_OPTIONAL_BUILTIN_EXPECT to the list of compiler directives in the cflags_cc section of binding.gyp to see if this works? If so, we can probably make this addition to binding.gyp a Windows-specific conditional.

Thanks! I just tried the fix mentioned in the thread (patching farmhash.cc around line 66), with -DFARMHASH_OPTIONAL_BUILTIN_EXPECT added to the compiler directives, and rebuilt - which leads to more errors:

Creating library C:\Users\Jonas\Code\farmhash\build\Release\farmhash.lib and object C:\Users\Jonas\Code\farmhash\build\Release\farmhash.exp
farmhash.obj : error LNK2001: unresolved external symbol "unsigned __int64 __cdecl util::Fingerprint64(char const*,unsigned __int64)" (?Fingerprint64@util@@YA_KPEBD_K@Z) [C:\Users\Jonas\Code\farmhash\build\farmhash.vcxproj]
farmhash.obj : error LNK2001: unresolved external symbol "unsigned int __cdecl util::Hash32WithSeed(char const*,unsigned __int64,unsigned int)" (?Hash32WithSeed@util@@YAIPEBD_KI@Z) [C:\Users\Jonas\Code\farmhash\build\farmhash.vcxproj]
farmhash.obj : error LNK2001: unresolved external symbol "unsigned __int64 __cdecl util::Hash64WithSeed(char const*,unsigned __int64,unsigned __int64)" (?Hash64WithSeed@util@@YA_KPEBD_K1@Z) [C:\Users\Jonas\Code\farmhash\build\farmhash.vcxproj]
farmhash.obj : error LNK2001: unresolved external symbol "unsigned int __cdecl util::Fingerprint32(char const *,unsigned __int64)" (?Fingerprint32@util@@YAIPEBD_K@Z) [C:\Users\Jonas\Code\farmhash\build\farmhash.vcxproj]
farmhash.obj : error LNK2001: unresolved external symbol "unsigned __int64 __cdecl util::Hash64(char const *,unsigned __int64)" (?Hash64@util@@YA_KPEBD_K@Z) [C:\Users\Jonas\Code\farmhash\build\farmhash.vcxproj]
farmhash.obj : error LNK2001: unresolved external symbol "unsigned __int64 __cdecl util::Hash64WithSeeds(char const *,unsigned __int64,unsigned __int64,unsigned __int64)" (?Hash64WithSeeds@util@@YA_KPEBD_K11@Z) [C:\Users\Jonas\Code\farmhash\build\farmhash.vcxproj]
farmhash.obj : error LNK2001: unresolved external symbol "unsigned int __cdecl util::Hash32(char const *,unsigned __int64)" (?Hash32@util@@YAIPEBD_K@Z) [C:\Users\Jonas\Code\farmhash\build\farmhash.vcxproj]
C:\Users\Jonas\Code\farmhash\build\Release\farmhash.node : fatal error LNK1120: 7 unresolved externals [C:\Users\Jonas\Code\farmhash\build\farmhash.vcxproj]

So now the linker is crapping out. Not entirely sure how probable it is, that this has something to do with me running Win 10.

I wonder if this is due to having two source files and therefore two obj files with the same "farmhash" file name. http://stackoverflow.com/questions/9130803/classes-with-same-file-name-in-different-libs-inheritance-issue seems to suggest there are known problems relating to this in VS.

Ah ha, your PR and my comment crossed each other. Great minds etc.

Hehe, yeah taking the time to read the entire output also pays off; right on the first line of the build output it is mentioned that identical file names create conflicts.