Bug 1413762

Summary: Turn on --with-dtrace for nodejs
Product: [Fedora] Fedora Reporter: Kinston Hughes <k2683901>
Component: nodejsAssignee: NodeJS Packaging SIG <nodejs-sig>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 25CC: jamielinux, mrunge, nodejs-sig, piotr1212, sgallagh, tchollingsworth, thrcka, zsvetlik
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: nodejs-6.9.4-2.fc25 nodejs-6.9.4-2.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-01-21 19:22:25 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Kinston Hughes 2017-01-16 22:05:22 UTC
Description of problem:

.spec file has had configure --without-dtrace set since the initial commit in 2012. Linxux tracing has come a long way since then and now that fc25 ships the 4.9 kernel with bpf, the use of tracing is increasingly becoming a standard tool for admins and devs. 

It would be nice to have nodejs ship with USDT tracepoints out of the box in fedora, please turn it on and push a new build.

Comment 1 Kinston Hughes 2017-01-16 22:13:43 UTC
Postgres ships --with-dtrace on fedora, there seems to be a "BuildRequires: systemtap-sdt-devel" involved. In case it helps.

Comment 2 Stephen Gallagher 2017-01-17 12:38:52 UTC
Postgres's --with-dtrace option also carries compatibility for systemtap. Node.js doesn't... it specifically requires Dtrace (which isn't available on Fedora).

Comment 3 Kinston Hughes 2017-01-17 19:13:22 UTC
(In reply to Stephen Gallagher from comment #2)
> Postgres's --with-dtrace option also carries compatibility for systemtap.
> Node.js doesn't... it specifically requires Dtrace (which isn't available on
> Fedora).

I guess that's is no longer the case. 
# ./configure --help | grep -i tap
 --systemtap-includes=SYSTEMTAP_INCLUDES
                        directory containing systemtap header files

So node does know about systemtap.

Second, here's a blog post by Brendan Gregg showing nodejs provides USDT tracepoints which the kernel BPF
can use: http://www.brendangregg.com/blog/2016-10-12/linux-bcc-nodejs-usdt.html

Finally, I've just pulled and successfully compiled node once with --with-dtrace and once without. Turning that flag produces a binary which includes the USDTs missing from the currently shipped fedora package.

# readelf -n ~/bin/node

<...>
Displaying notes found at file offset 0x01b809bc with length 0x000003c4:
  Owner                 Data size	Description
  stapsdt              0x0000003c	NT_STAPSDT (SystemTap probe descriptors)
    Provider: node
    Name: gc__start 
<...>

Please turn on --with-dtrace for node.

Comment 4 Kinston Hughes 2017-01-17 19:16:31 UTC
I noticed that Node now also has --with-lttng, but I don't know that offers anything beyond --with-dtrace beyond requiring different tools. FYI.

Comment 5 Kinston Hughes 2017-01-17 19:23:37 UTC
From Node Changelog (https://github.com/nodejs/node/commit/38c0c47bbe280ddc42054418091571e532d82a1e)


-2013.05.13, Version 0.11.2 (Unstable)
+2013.06.26, Version 0.11.3 (Unstable) 
<...>
+* dtrace: unify dtrace and systemtap interfaces (Timothy J Fontaine)

first fedora package dates to 2012, but tracing support for systemtap on linux has been possible for 2+ years. Recently, with
kernel 4.9, it's finally become possible to use the BPF kernel facilities instead of relying on systemtap to leverage that.

Comment 6 Stephen Gallagher 2017-01-18 14:23:08 UTC
Rebuilding the Node.js package in Fedora after adding `BuildRequires: systemtap-sdt-devel` and setting `--with-dtrace` in configure leads to a failure:

https://koji.fedoraproject.org/koji/taskinfo?taskID=17321978

If someone would like to take a look at the spec, it's https://paste.fedoraproject.org/529733/14847493/

I don't have any additional time to spend on this today, but if someone wants to propose a correction to that spec, I'm listening.

Comment 7 Kinston Hughes 2017-01-18 22:05:59 UTC
I hate build scripts.

This is a bug in the systemtap provided `dtrace` shim, which fails to properly handle the CFLAGS envar when it contains new line.

From spec:

export CFLAGS='%{optflags} -g \
               -D_LARGEFILE_SOURCE \
               -D_FILE_OFFSET_BITS=64 \
               -DZLIB_CONST \
               -fno-delete-null-pointer-checks'
export CXXFLAGS='%{optflags} -g \
                 -D_LARGEFILE_SOURCE \
                 -D_FILE_OFFSET_BITS=64 \
                 -DZLIB_CONST \
                 -fno-delete-null-pointer-checks'

The package compiles if you add the following lines right after:

# Explicit new lines in C(XX)FLAGS can break naive build scripts
export CFLAGS="$(echo ${CFLAGS} | tr '\n\\' '  ')"
export CXXFLAGS="$(echo ${CXXFLAGS} | tr '\n\\' '  ')"

I've opened an issue on the systemtap bugzilla, see:
https://sourceware.org/bugzilla/show_bug.cgi?id=21063

Comment 8 Kinston Hughes 2017-01-18 22:07:44 UTC
I want those two hours of my life back, dammit.

Comment 9 Stephen Gallagher 2017-01-19 13:50:16 UTC
(In reply to Kinston Hughes from comment #7)
> I hate build scripts.
> 
> This is a bug in the systemtap provided `dtrace` shim, which fails to
> properly handle the CFLAGS envar when it contains new line.

That was some mighty fine detective work, Kinston! Thanks very much for tracking it down. I doubt I'd have put in enough effort to find that.

I'm running a scratch build now; assuming it succeeds, I will push it to dist-git and do an official build for Rawhide, F25 and EPEL 7.

p.s. I gave you credit in the Changelog.

Comment 10 Fedora Update System 2017-01-19 19:28:34 UTC
nodejs-6.9.4-2.fc25 libuv-1.10.2-1.fc25 has been submitted as an update to Fedora 25. https://bodhi.fedoraproject.org/updates/FEDORA-2017-922de2d990

Comment 11 Fedora Update System 2017-01-19 19:28:51 UTC
nodejs-6.9.4-2.el7 libuv-1.10.2-1.el7 has been submitted as an update to Fedora EPEL 7. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2017-834d4d8dc8

Comment 12 Kinston Hughes 2017-01-19 21:39:05 UTC
Thanks! 

Side note, I had the CFLAGS envars still set in a terminal after I finished investigating and a bunch of other unrelated projects I compiled exhibited mysterious deaths as well. I'm too frightened to go near the fedora packaging guidelines , but it just seems like doing multi-line envars in the SPEC file should be a no-no.

Comment 13 Fedora Update System 2017-01-20 18:47:18 UTC
libuv-1.10.2-1.el7, nodejs-6.9.4-2.el7 has been pushed to the Fedora EPEL 7 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2017-834d4d8dc8

Comment 14 Fedora Update System 2017-01-20 19:56:03 UTC
libuv-1.10.2-1.fc25, nodejs-6.9.4-2.fc25 has been pushed to the Fedora 25 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-922de2d990

Comment 15 Fedora Update System 2017-01-21 19:22:25 UTC
libuv-1.10.2-1.fc25, nodejs-6.9.4-2.fc25 has been pushed to the Fedora 25 stable repository. If problems still persist, please make note of it in this bug report.

Comment 16 Fedora Update System 2017-02-07 03:47:10 UTC
libuv-1.10.2-1.el7, nodejs-6.9.4-2.el7 has been pushed to the Fedora EPEL 7 stable repository. If problems still persist, please make note of it in this bug report.