Bug 21063 - dtrace script causes mysterious build failures due to improper forming of gcc command line
Summary: dtrace script causes mysterious build failures due to improper forming of gcc...
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: runtime (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-18 22:02 UTC by Kinston Hughes
Modified: 2017-01-22 22:21 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kinston Hughes 2017-01-18 22:02:58 UTC
From https://bugzilla.redhat.com/show_bug.cgi?id=1413762

When users provide a CFLAGS envar which containts newlines, the dtrace script fails with:

gcc: error: 
   : No such file or directory

For example, the fedora rpm spec file for creating packages defines:

CFLAGS="-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -g \
               -D_LARGEFILE_SOURCE \
               -D_FILE_OFFSET_BITS=64 \
               -DZLIB_CONST \
               -fno-delete-null-pointer-checks"

and the multiple lines cause the dtrace script to die. Possibly, this error has caused packagers to believe systemtap USDT's have not been available in project where in fact it has been, because using "--with-dtrace" caused compilation errors which were taken as due to general unavailability of the real dtrace tool on linux.

The problem is towards the end of the `dtrace script`:

        cmd=split(cc1) + defines + includes + split(cflags) +\
             ["-fPIC", "-I.", "-I/usr/include", "-c", fname, "-o",
              filename + suffix]

where cflags should be sanitized so that examples like the above CFLAGS are tolerated.
Comment 1 Frank Ch. Eigler 2017-01-21 07:33:26 UTC
I'm having trouble reproducing this with a plain set of commands lines.  Do you have a copy&paste'able recipe to trigger the behaviour?
Comment 2 Kinston Hughes 2017-01-21 22:36:00 UTC
(In reply to Frank Ch. Eigler from comment #1)
> I'm having trouble reproducing this with a plain set of commands lines.  Do
> you have a copy&paste'able recipe to trigger the behaviour?

Sorry, this should do it.

```
#!/bin/sh

wget https://raw.githubusercontent.com/nodejs/node/master/src/node_provider.d

export CFLAGS='-g \
               -fno-delete-null-pointer-checks'
dtrace -G -s node_provider.d -o node_provider.h
```
Comment 3 Frank Ch. Eigler 2017-01-21 23:00:28 UTC
commit 100bca3f124 should fix this.  The problem here seems to be the \ character in the string rather than new lines, but the patch nukes them both.
Comment 4 Kinston Hughes 2017-01-22 22:21:57 UTC
(In reply to Frank Ch. Eigler from comment #3)
> commit 100bca3f124 should fix this.  The problem here seems to be the \
> character in the string rather than new lines, but the patch nukes them both.

ah yes, a case of tunnel vision on my part. 

Thanks you again for being o responsive, I usually dread plunging into bugzillaz for fear of either limbo or pedantic deflection but it's been simple and quick to get hiccups in stap addressed. I salute you, sir.