chrisa / node-dtrace-provider

Native DTrace probes for node.js apps
Other
319 stars 70 forks source link

[FreeBSD] usdt_internal.h:14:24: fatal error: sys/dtrace.h: No such file or directory #include <sys/dtrace.h> #98

Closed SwiftSalamander closed 6 years ago

SwiftSalamander commented 7 years ago

Is it possible to compile/install dtrace-provider on: OS: FreeBSD 10.3 STABLE

$ npm -v
4.0.5
$ node -v
v4.8.2
>$ env LC_ALL=en_US.UTF-8 V=X npm install  dtrace-provider

> dtrace-provider@0.8.2 install /usr/home/salamander/dtraceprovider/node_modules/dtrace-provider
> node scripts/install.js

gmake: Entering directory '/usr/home/salamander/dtraceprovider/node_modules/dtrace-provider/build'
  LD_LIBRARY_PATH=/usr/home/salamander/dtraceprovider/node_modules/dtrace-provider/build/Release/lib.host:/usr/home/salamander/dtraceprovider/node_modules/dtrace-provider/build/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../.; sh libusdt-build.sh
Building libusdt for x86_64
gmake[1]: Entering directory '/usr/home/salamander/dtraceprovider/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 -Wall -Wno-error=unknown-pragmas -I/usr/src/sys/cddl/compat/opensolaris -I/usr/src/sys/cddl/contrib/opensolaris/uts/common -fPIC   -c -o usdt.o usdt.c
In file included from usdt.c:5:0:
usdt_internal.h:14:24: fatal error: sys/dtrace.h: No such file or directory
 #include <sys/dtrace.h>
                        ^
compilation terminated.
gmake[1]: *** [<builtin>: usdt.o] Error 1
gmake[1]: Leaving directory '/usr/home/salamander/dtraceprovider/node_modules/dtrace-provider/libusdt'
gmake: *** [libusdt.target.mk:13: .] Error 2
gmake: Leaving directory '/usr/home/salamander/dtraceprovider/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:276:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:12)
gyp ERR! System FreeBSD 10.3-STABLE
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/home/salamander/dtraceprovider/node_modules/dtrace-provider
gyp ERR! node -v v4.8.2
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok 
/usr/home/salamander/dtraceprovider
└─┬ bunyan@1.8.10
  └── dtrace-provider@0.8.2 

npm WARN enoent ENOENT: no such file or directory, open '/usr/home/salamander/dtraceprovider/package.json'
npm WARN dtraceprovider No description
npm WARN dtraceprovider No repository field.
npm WARN dtraceprovider No README data
npm WARN dtraceprovider No license field.
melloc commented 7 years ago

@SwiftSalamander In order to build on FreeBSD, you'll need to install the headers into /usr/src. (I've done this before by checking out the svn repo, but it looks like you can also get tarballs or install it with sysinstall.) It sounds like from trentm/node-bunyan#506 that you won't be able to do this, however, since it's on a system that you don't have admin rights on.

You can still use node-bunyan even if this module fails to compile, since it depends on node-dtrace-provider in its "optionalDependencies" and this module provides a fallback stub that bunyan will instead use. You will get a warning every time that the module is loaded though, until #96 is resolved.

Alternatively, you could do your npm install someplace where you have a full toolchain and headers installed, and then package that up for deployment to production.

I've been meaning to write up some notes for the README explaining some of the OS-specific notes about compiling and using this module. I'll try to do that sometime soon.

melloc commented 6 years ago

Now that #96 is merged, the warning will no longer be printed every time bunyan is loaded. If you wish to use bunyan -p, you'll want to either get the kernel headers installed on the system, or run the npm install on another FreeBSD system where you can install the headers under /usr/src and then deploy using those.