Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 334317 - trailing white space in XDCTARGETS corrupts the environment
Summary: trailing white space in XDCTARGETS corrupts the environment
Status: CLOSED FIXED
Alias: None
Product: RTSC
Classification: Technology
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P1 major (vote)
Target Milestone: ---   Edit
Assignee: Dave Russo CLA
QA Contact:
URL:
Whiteboard: target:3.21; target 3.20
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-13 15:58 EST by Dave Russo CLA
Modified: 2011-06-20 14:05 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Russo CLA 2011-01-13 15:58:34 EST
For any package, say hello, a "top-level" build that uses XDCTARGETS with trailing white space results in XDCTARGETS being defined with the definition of another environment variable appended to the end(!).

For example:
    % xdc XDCTARGETS="native" .debug -P hello/ | grep XDCTARGETS
    XDCTARGETS = native
But:
    % xdc XDCTARGETS="native " .debug -P hello/ | grep XDCTAR
    XDCTARGETS = native XDCPATH=^/../hijacks;^/../imports

This appears to be a GNU make bug in it's handling of MAKEFLAGS.  Using an environment variable instead of a make flag does not have the same problem:
    % setenv XDCTARGETS native
    % xdc .debug -P hello/ | grep XDCTAR
    XDCTARGETS = native
    % setenv XDCTARGETS "native "
    % xdc .debug -P hello/ | grep XDCTAR
    XDCTARGETS = native
Comment 1 Dave Russo CLA 2011-01-14 13:07:12 EST
The root cause of the problem is the redefinition of MAKEOVERRIDES in xdc_top.mak:

MAKEOVERRIDES := $(patsubst XDCBUILDCFG=%,XDCBUILDCFG=$(subst $(space),\$(space
),$(XDCBUILDCFG)),$(MAKEOVERRIDES))

Prior to this statement MAKEOVERRIDES contains:
    XDCTARGETS=native\  XDCPATH=^/../hijacks;^/../imports

Notice the _two_ spaces after the backslash.  After the redefinition above, MAKEOVERRIDES contains:
    XDCTARGETS=native\ XDCPATH=^/../hijacks;^/../imports

The $(patsubst) function removed one of the spaces after the \, effectively concatenating the next variable, XDCPATH, with the definition of XDCTARGETS.
Comment 2 Dave Russo CLA 2011-01-14 17:30:41 EST
fixed in r1276 (xdc-w23) destined for 3.21

The root cause can result in improper settings being passed to sub-makes whenever _any_ make flag (with trailing white space) is passed on the command line.

After a review of the fix, this should also be "back ported" to 3.20.x
Comment 3 Sasha Slijepcevic CLA 2011-02-24 18:46:28 EST
Verified the bug on one of many different variants of the problem. Depending on where on the command line an additional space is added, the build is affected differently.
With 3.21.00.30 and the following command line, XDCBUILDCFG is not set correctly:
> $XDCTOOLS/xdctools_3_21_00_30_eng/Linux/xdc XDCBUILDCFG=$ZS/config.bld XDCTARGETS="native " -PR .
making all: Thu Feb 24 15:38:06 PST 2011 ...
======== .interfaces [.] ========
making package.mak (because of .xdcenv.mak) ...
Warning: no config.bld file was found along the package path.
         The config.bld file specifies the location of the 
         compiler tool-chains required to compile runtime content.
         Without this file, the XDC tools assume no targets are to be
         used.

With 3.21.00.40, the right XDCBUILDCFG is found and the code is built for the target "native". There is still warning because the string "native " is split into "native" and "", and the second one is treated as an additional targets, but that's a different bug.

> $XDCTOOLS/xdctools_3_21_00_40_eng/Linux/xdc XDCBUILDCFG=$ZS/config.bld XDCTARGETS="native " -PR .
making all: Thu Feb 24 15:38:39 PST 2011 ...
======== .interfaces [.] ========
making package.mak (because of .xdcenv.mak) ...
Warning: Target specification '' does not match any loaded target module.
Valid Build Targets:
gnu.targets.Linux86
Comment 4 Dave Russo CLA 2011-06-20 14:03:11 EDT
Shipped in XDCtools 3.21.
Comment 5 Dave Russo CLA 2011-06-20 14:05:13 EDT
Shipped in XDCtools 3.21