Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 322168 - source files with specific settings disable secondary outputs
Summary: source files with specific settings disable secondary outputs
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-build-managed (show other bugs)
Version: 6.0.2   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal with 2 votes (vote)
Target Milestone: 8.3.0   Edit
Assignee: Andrew Gvozdev CLA
QA Contact: Chris Recoskie CLA
URL:
Whiteboard:
Keywords:
: 227607 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-08-09 13:56 EDT by Liviu Ionescu CLA
Modified: 2013-11-04 06:02 EST (History)
7 users (show)

See Also:


Attachments
all_tests (27.93 KB, application/zip)
2013-11-04 06:02 EST, Liviu Ionescu CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Liviu Ionescu CLA 2010-08-09 13:56:49 EDT
Build Identifier: 20100617-1415 

one of the users of my GNU ARM Plug-in (SourceForge) noticed a weird problem: when using file specific settings, the secondaryOutputs are no longer generated (I use the secondary outputs to convert from elf to hex and for other embedded specific outputs)

I studied the problem and noticed that when using file specific settings, the generated makefile is incomplete, in my case, instead of:

	# Add inputs and outputs from these tool invocations to the build variables 
	SECONDARY_FLASH += \
	t01cpp.hex \

	SECONDARY_LIST += \
	t01cpp.lst \

	SECONDARY_SIZE += \
	t01cpp.siz \

I get

	# Add inputs and outputs from these tool invocations to the build variables 
	SECONDARY_FLASH += \

	SECONDARY_LIST += \

	SECONDARY_SIZE += \

i.e. the secondaryOutputs targets are null.
 
after a debugging session on CDT, I discovered that calculateToolInputsOutputs() in GnuMakefileGenerator.java calls the embedded visit() code twice, once for the higher level tools and again for the file with specific configs.

on the first run, the getTopBuildOutputVars() map is completely filled in, including the secondary output definitions.

on the second run, the same map is completely reinitialised with empty definitions, so all settings from the first run are lost.

I'm not fully aware of the consequences (like some of the entries in the map accumulating duplicate values from each run with identical tools?), but at least in my tests not reinitialising the map for each run generated the correct secondary output definitions.

another good question is what happens with hierarchic folder settings, does the settings overwrite or accumulate?
 

the changes I made are in GnuMakefileGenerator.java, around line 3955, I entered a new line before

		addMacroAdditionPrefix(map, macroName, "", false);	//$NON-NLS-1$

and the result looks like this:

		if (!map.containsKey(macroName))
			addMacroAdditionPrefix(map, macroName, "", false);	//$NON-NLS-1$



Reproducible: Always

Steps to Reproduce:
1. create a project using a toolchain with secondary outputs
2. build the project, everything is fine, the secondary outputs are created
3. change the settings for a single file (like a preprocessor definition)
4. build the project: the secondary outputs are no longer created
Comment 1 Krzysztof Wesołowski CLA 2011-09-05 09:20:29 EDT
This bug also affects Windows (7Pro) platform.

Changing setting of projects subfolder also breaks secondary outputs.

Eclipse version:
Version: Helios Service Release 2
Build id: 20110301-1815
Comment 2 Andrew McLachlan CLA 2012-12-10 07:16:20 EST
Could someone tell me if this fix has made it into an official CDT release?
Comment 3 Shannon Holland CLA 2013-06-10 14:03:39 EDT
Are there any updates to this bug?
Comment 4 Branko Drevensek CLA 2013-08-29 11:04:48 EDT
Just bumped into this. It looks this is still present in Kepler. :/
Comment 5 Liviu Ionescu CLA 2013-10-24 11:08:59 EDT
https://git.eclipse.org/r/#/c/17735/
Comment 6 Liviu Ionescu CLA 2013-10-24 11:24:42 EDT
I ran the org.eclipse.cdt.managedbuilder.core.tests and out of the 318 test cases, on my OS X, 11 (eleven) fail anyway, either with or without my patch, so I assume I'm not breaking anything.
Comment 7 Andrew Gvozdev CLA 2013-10-31 16:54:53 EDT
Liviu, could you comment on the solution suggested in bug 227607?
Comment 8 Liviu Ionescu CLA 2013-10-31 18:23:04 EDT
I guess it is ok. In my plug-in, the tools that have secondary buildVariables use the linker output, so they are present only in the root container, and need not be processed more than once.

I could not think of a configuration using secondary buildVariables in the few tools (AS, GCC, G++) referred in folder or file containers, but on the other side I cannot tell that there are not/will not be, since people with more imagination may find interesting usage cases for them...

Comparing solutions, for my patch there is a remote theoretical risk of adding an entry for multiple times, while for the patch suggested in bug 227607 there is a risk of not adding an entry that was defined for tools that are used only in folder/file containers (assuming that this is possible).
Comment 9 Andrew Gvozdev CLA 2013-11-02 16:08:10 EDT
OK. I like your patch better. Committed to master via Gerrit. Thank you.
Comment 10 Andrew Gvozdev CLA 2013-11-02 16:09:14 EDT
*** Bug 227607 has been marked as a duplicate of this bug. ***
Comment 11 Liviu Ionescu CLA 2013-11-02 16:21:54 EDT
None of the two solutions is perfect. Probably on the next bug related to this issue, a thorough analysis will be done and a better solution implemented.

Thank you, Andrew, for your support.
Comment 12 Andrew Gvozdev CLA 2013-11-02 18:10:37 EDT
BTW, what are the managedbuild test cases that fail on your system?
Comment 13 Liviu Ionescu CLA 2013-11-04 06:02:19 EST
Created attachment 237165 [details]
all_tests

the failed tests os OS X, packed