animetosho / node-yencode

SIMD accelerated yEnc encoder/decoder and CRC32 calculator for node.js
37 stars 5 forks source link

macOS: llvm: yencode 1.1.0: build error: use of undeclared identifier 'aligned_alloc' #8

Closed bgeet closed 4 years ago

bgeet commented 4 years ago

Versions sw_vers

ProductName: Mac OS X ProductVersion: 10.14.6 BuildVersion: 18G3020

clang++ --version (homebrew)

clang version 9.0.1 Target: x86_64-apple-darwin18.7.0 Thread model: posix InstalledDir: /usr/local/opt/llvm/bin

node --version

v10.19.0

Problem Despite yencode 1.0.8 building, 1.1.0 doesn't:

CC="/usr/local/opt/llvm/bin/clang" CXX="/usr/local/opt/llvm/bin/clang++" LDFLAGS="-L/usr/local/opt/llvm/lib" CPPFLAGS="-I/usr/local/opt/llvm/include" npm install -g yencode@1.1.0

yencode@1.1.0 install /usr/local/lib/node_modules/yencode node-gyp rebuild

CXX(target) Release/obj.target/crcutil/crcutil-1.0/code/crc32c_sse4.o CXX(target) Release/obj.target/crcutil/crcutil-1.0/code/multiword_64_64_cl_i386_mmx.o CXX(target) Release/obj.target/crcutil/crcutil-1.0/code/multiword_64_64_gcc_amd64_asm.o CXX(target) Release/obj.target/crcutil/crcutil-1.0/code/multiword_64_64_gcc_i386_mmx.o CXX(target) Release/obj.target/crcutil/crcutil-1.0/code/multiword_64_64_intrinsic_i386_mmx.o CXX(target) Release/obj.target/crcutil/crcutil-1.0/code/multiword_128_64_gcc_amd64_sse2.o CXX(target) Release/obj.target/crcutil/crcutil-1.0/examples/interface.o LIBTOOL-STATIC Release/crcutil.a CXX(target) Release/obj.target/yencode_sse2/src/encoder_sse2.o In file included from ../src/encoder_sse2.cc:4: ../src/encoder_sse_base.h:31:2: error: use of undeclared identifier 'aligned_alloc' ALIGN_ALLOC(lookups, sizeof(*lookups), 16); ^ ../src/common.h:42:57: note: expanded from macro 'ALIGN_ALLOC'

define ALIGN_ALLOC(buf, len, align) *(void**)&(buf) = aligned_a...

^ 1 error generated. make: *** [Release/obj.target/yencode_sse2/src/encoder_sse2.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:194:23) gyp ERR! stack at ChildProcess.emit (events.js:198:13) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12) gyp ERR! System Darwin 18.7.0 gyp ERR! command "/usr/local/Cellar/node@10/10.19.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /usr/local/lib/node_modules/yencode gyp ERR! node -v v10.19.0 gyp ERR! node-gyp -v v5.0.7 gyp ERR! not ok npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! yencode@1.1.0 install: node-gyp rebuild npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the yencode@1.1.0 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/test/.npm/_logs/2020-02-06T01_00_00_000Z-debug.log

Node v12 gives the same error.

animetosho commented 4 years ago

Thanks for reporting! I happened to notice something similar but wasn't sure if it was just my hacked version of OSX - looks like actual OSX has the same (weird) issue.

Could you give the following a try?

In src/common.h, find

#if defined(__cplusplus) && __cplusplus > 201100 && !(defined(_MSC_VER) && defined(__clang__))

replace with

#if defined(__cplusplus) && __cplusplus > 201100 && !(defined(_MSC_VER) && defined(__clang__)) && !defined(__APPLE__)

See if that works for you.

I got another issue with _lzcnt_u32 not being found. I added the following to the same file, just before the last line (#endif /* __YENC_COMMON */):

// weird thing with Apple's Clang
#if defined(__clang__) && defined(__APPLE__)
# define _lzcnt_u32 __lzcnt32
#endif
bgeet commented 4 years ago

In src/common.h, find

#if defined(__cplusplus) && __cplusplus > 201100 && !(defined(_MSC_VER) && defined(__clang__))

replace with

#if defined(__cplusplus) && __cplusplus > 201100 && !(defined(_MSC_VER) && defined(__clang__)) && !defined(__APPLE__)

See if that works for you.

Builds. Thanks a lot.

I got another issue with _lzcnt_u32 not being found. I added the following to the same file, just before the last line (#endif /* __YENC_COMMON */):

// weird thing with Apple's Clang
#if defined(__clang__) && defined(__APPLE__)
# define _lzcnt_u32 __lzcnt32
#endif

Did not encounter. Adding it (combined with the previous suggestion) does still compile.

animetosho commented 4 years ago

Thanks a lot for confirming and testing the second edit!

bgeet commented 4 years ago

Could you please cut a new release with this fixed. That way macOS users can simply get it from NPM and automatically stay updated (instead of manually checking our manual builds).

animetosho commented 4 years ago

Yes definitely. Sorry for the delay.

NPM module should now be at v1.1.1