chrisa / node-dtrace-provider

Native DTrace probes for node.js apps
Other
321 stars 68 forks source link

Install fails on FreeBSD #30

Closed mcavage closed 7 years ago

mcavage commented 11 years ago

Hey Chris-

I got this report from restify - I doubt node-dtrace will work on freebsd (afaik, usdt doesn't at all) - is that something hard to blacklist in your build script?

gmake: Entering directory `/root/test/node_modules/restify/node_modules/dtrace-provider/build'
  ACTION binding_gyp_libusdt_target_build_libusdt .
Building libusdt for x86_64
gmake[1]: Entering directory `/root/test/node_modules/restify/node_modules/dtrace-provider/libusdt'
rm -f *.gch
rm -f *.o
rm -f libusdt.a
rm -f test_usdt
rm -f test_usdt32
rm -f test_usdt64
rm -f test_mem_usage
gcc -O2 -Wno-error=unknown-pragmas -I/usr/src/sys/cddl/compat/opensolaris -I/usr/src/sys/cddl/contrib/opensolaris/uts/common   -c -o usdt.o usdt.c
In file included from usdt.c:5:
usdt_internal.h:5:24: error: sys/dtrace.h: No such file or directory
In file included from usdt.c:5:
usdt_internal.h:35: error: expected specifier-qualifier-list before 'dof_secidx_t'
usdt_internal.h:48: error: expected declaration specifiers or '...' before 'dof_secidx_t'
usdt_internal.h:53: error: expected specifier-qualifier-list before 'dof_secidx_t'
usdt_internal.h:65: error: expected declaration specifiers or '...' before 'dof_secidx_t'
usdt_internal.h:66: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'usdt_strtab_add'
usdt.c: In function 'usdt_provider_enable':
usdt.c:181: error: too many arguments to function 'usdt_strtab_init'
gmake[1]: *** [usdt.o] Error 1
gmake[1]: Leaving directory `/root/test/node_modules/restify/node_modules/dtrace-provider/libusdt'
gmake: *** [.] Error 2
gmake: Leaving directory `/root/test/node_modules/restify/node_modules/dtrace-provider/build'
gyp ERR! build error 
gyp ERR! stack Error: `gmake` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:215:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:91:17)
gyp ERR! stack     at Process._handle.onexit (child_process.js:674:10)
gyp ERR! System FreeBSD 9.0-RELEASE
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /root/test/node_modules/restify/node_modules/dtrace-provider
gyp ERR! node -v v0.8.4
gyp ERR! node-gyp -v v0.6.1
gyp ERR! not ok 
npm ERR! dtrace-provider@0.2.6 install: `node-gyp rebuild`
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1

Thanks! ~Mark

chrisa commented 11 years ago

Actually last time I tried it libusdt worked on FreeBSD, with limitations - the greatest being that only the first four probe arguments will work.

The issue you have here appears to be that FreeBSD don't ship the necessary headers outside of their source, so you need a full source tree installed.

If that doesn't fix it I think it should be possible to just drop OS=="freebsd" from the binding.gyp file here.

mcavage commented 11 years ago

Hmm ok, thanks - I linked the restify ticket to this one, but I'll copy that info back over.

denisu commented 11 years ago

Hi,

I originally reported this problem in node-restify.

As you said, I checked out the FreeBSD source headers now, the building still fails, this time with a slightly different error.

gmake: Entering directory `/root/node_modules/restify/node_modules/dtrace-provider/build'
  ACTION binding_gyp_libusdt_target_build_libusdt .
Building libusdt for x86_64
gmake[1]: Entering directory `/root/node_modules/restify/node_modules/dtrace-provider/libusdt'
rm -f *.gch
rm -f *.o
rm -f libusdt.a
rm -f test_usdt
rm -f test_usdt32
rm -f test_usdt64
rm -f test_mem_usage
gcc -O2 -Wno-error=unknown-pragmas -I/usr/src/sys/cddl/compat/opensolaris -I/usr/src/sys/cddl/contrib/opensolaris/uts/common   -c -o usdt.o usdt.c
gcc -O2 -Wno-error=unknown-pragmas -I/usr/src/sys/cddl/compat/opensolaris -I/usr/src/sys/cddl/contrib/opensolaris/uts/common   -c -o usdt_dof_file.o usdt_dof_file.c
gcc -O2 -Wno-error=unknown-pragmas -I/usr/src/sys/cddl/compat/opensolaris -I/usr/src/sys/cddl/contrib/opensolaris/uts/common -o usdt_tracepoints.o -c usdt_tracepoints_x86_64.s
gcc -O2 -Wno-error=unknown-pragmas -I/usr/src/sys/cddl/compat/opensolaris -I/usr/src/sys/cddl/contrib/opensolaris/uts/common   -c -o usdt_probe.o usdt_probe.c
gcc -O2 -Wno-error=unknown-pragmas -I/usr/src/sys/cddl/compat/opensolaris -I/usr/src/sys/cddl/contrib/opensolaris/uts/common   -c -o usdt_dof.o usdt_dof.c
gcc -O2 -Wno-error=unknown-pragmas -I/usr/src/sys/cddl/compat/opensolaris -I/usr/src/sys/cddl/contrib/opensolaris/uts/common   -c -o usdt_dof_sections.o usdt_dof_sections.c
rm -f libusdt.a
ar cru libusdt.a usdt.o usdt_dof_file.o usdt_tracepoints.o usdt_probe.o usdt_dof.o usdt_dof_sections.o 
ranlib libusdt.a
gmake[1]: Leaving directory `/root/node_modules/restify/node_modules/dtrace-provider/libusdt'
  TOUCH Release/obj.target/libusdt.stamp
  CXX(target) Release/obj.target/DTraceProviderBindings/dtrace_provider.o
In file included from ../dtrace_provider.cc:1:
../dtrace_provider.h:9:24: warning: sys/dtrace.h: No such file or directory
In file included from ../dtrace_provider.h:20,
                 from ../dtrace_provider.cc:1:
/usr/include/malloc.h:3:2: error: #error "<malloc.h> has been replaced by <stdlib.h>"
gmake: *** [Release/obj.target/DTraceProviderBindings/dtrace_provider.o] Error 1
gmake: Leaving directory `/root/node_modules/restify/node_modules/dtrace-provider/build'
gyp ERR! build error 
gyp ERR! stack Error: `gmake` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:232:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:96:17)
gyp ERR! stack     at Process._handle.onexit (child_process.js:678:10)
gyp ERR! System FreeBSD 9.0-RELEASE
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /root/node_modules/restify/node_modules/dtrace-provider
gyp ERR! node -v v0.8.12
gyp ERR! node-gyp -v v0.8.1
gyp ERR! not ok 
npm ERR! dtrace-provider@0.2.6 install: `node-gyp rebuild`
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1
chrisa commented 11 years ago

Ah, sorry about that! It looks like libusdt (the underlying library) is building OK, but then the node bindings fail because they don't have the same include path special-case for FreeBSD.

I'll try adding the include paths (and fixing that error with malloc.h) and see how well it works.

chrisa commented 11 years ago

OK, newly-published dtrace-provider 0.2.7 no longer tries to build by default on FreeBSD, since releases don't (yet) have DTrace available. Once FreeBSD has DTrace included in GENERIC kernels, I'll re-enable it here.

Please let me know if this fixes the issue you're seeing - it seems to install OK for me on FreeBSD 9.1-RELEASE.

denisu commented 11 years ago

Installation now works on FreeBSD 9.0 as well. This should solve my problems with restify after its dependency has been updated to 0.2.7.

Thank you very much!

gabrielbiga commented 9 years ago

I have the same problem in FreeBSD 10

davepacheco commented 8 years ago

@gabrielbiga Are you still seeing this issue with version 0.7.0?

No9 commented 8 years ago

Hey @davepacheco to answer your last question:

On FreeBSD this module currently fails to load at runtime and the following is dumped to console

{ Error: Cannot find module './build/Release/DTraceProviderBindings'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/home/anton/code/helloworld/node_modules/dtrace-provider/dtrace-provider.js:17:23)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3) code: 'MODULE_NOT_FOUND' }
{ Error: Cannot find module './build/default/DTraceProviderBindings'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/home/anton/code/helloworld/node_modules/dtrace-provider/dtrace-provider.js:17:23)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3) code: 'MODULE_NOT_FOUND' }
{ Error: Cannot find module './build/Debug/DTraceProviderBindings'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/home/anton/code/helloworld/node_modules/dtrace-provider/dtrace-provider.js:17:23)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3) code: 'MODULE_NOT_FOUND' }

This is because the js wrapper expects the native lib to be built https://github.com/chrisa/node-dtrace-provider/blob/master/dtrace-provider.js#L25 but the build is currently turned off https://github.com/chrisa/node-dtrace-provider/blob/master/compile.py#L3

These two pull requests reinstate FreeBSD support in this library: https://github.com/chrisa/node-dtrace-provider/pull/85 https://github.com/chrisa/libusdt/pull/15

Would be great to get these to land as I currently have to go and rebuild this out of band for libraries that have bunyan included.

melloc commented 7 years ago

Now that 942e227 is in, this issue can be closed.