Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 326671

Summary: [Performance] MBS generated makefiles for static library projects add dependencies on referenced archives
Product: [Tools] CDT Reporter: James Blackburn <jamesblackburn+eclipse>
Component: cdt-build-managedAssignee: James Blackburn <jamesblackburn+eclipse>
Status: RESOLVED FIXED QA Contact: Chris Recoskie <recoskie>
Severity: normal    
Priority: P3    
Version: 7.0   
Target Milestone: 8.0   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:
Attachments:
Description Flags
patch 1 jamesblackburn+eclipse: iplog-

Description James Blackburn CLA 2010-09-30 10:08:52 EDT
The MBS generated makefile makes the top-level archiver rule depend on static library in referenced projects.

The result is that archives are very frequently remade taking time.

To reproduce:
1) Create 2 static library projects p1, p2
2) Add a CDT reference between them
3) Build the project doing the referencing.

The generated makefile looks like:

dependents:
	-cd /projects/firepath/apps/work/jamesb/runtime-New_configuration/p1/Debug && $(MAKE) clean all

# Tool invocations
libp2.a: $(OBJS) $(USER_OBJS) /projects/firepath/apps/work/jamesb/runtime-New_configuration/p1/Debug/libp1.a
	@echo 'Building target: $@'
	@echo 'Invoking: GCC Archiver'
	ar -r "libp2.a" $(OBJS) $(USER_OBJS) $(LIBS)
	@echo 'Finished building target: $@'
	@echo ' '

Although there may be an include dependency between the source in the two projects, building the archive doesn't actually require the archive from the referenced project (this dependency is important for .exes and .sos).

The call-tree producing this is:

(1) GnuMakefileGenerator.getToolInputsOutputs(...) line: 1812	
(2) GnuMakefileGenerator.addRuleForTool(...) line: 1584	
(3) GnuMakefileGenerator.addTargetsRules(...) line: 1500	
(4) GnuMakefileGenerator.addTargets(...) line: 1422	
(5) GnuMakefileGenerator.populateTopMakefile(...) line: 1139	
(6) GnuMakefileGenerator.generateMakefiles(...) line: 722	
(7) CommonBuilder.performMakefileGeneration(...) line: 999	

The referenced artifacts are picked up in (4) as Vector<String> managedProjectOutputs containing the outputs of all the referenced configurations.  Then in (1) they're all added to the set of tool dependencies.

As this referenced outputs are used as an input to the tool, there should be some way of suppressing the addition of these dependencies.
Comment 1 James Blackburn CLA 2010-09-30 11:17:31 EDT
Created attachment 179968 [details]
patch 1

A potential patch for the issue.

Don't generate refConfigs if the build configuration artifact type is a static archive. This may be too coarse-grained to commit, I'm not sure.  However the current beavhiour invalidates the current archive far too frequently.
Comment 2 James Blackburn CLA 2011-02-13 11:46:40 EST
Committed to HEAD.
Comment 3 CDT Genie CLA 2011-02-13 12:22:09 EST
*** cdt cvs genie on behalf of jblackburn ***
Bug 326671 - [Performance] MBS generated makefiles for static library projects add dependencies on referenced archives

[*] GnuMakefileGenerator.java 1.100 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java?root=Tools_Project&r1=1.99&r2=1.100
Comment 4 CDT Genie CLA 2011-02-15 07:21:53 EST
*** cdt cvs genie on behalf of jblackburn ***
Bug 326671 - Fix potential NPE when building old tests.

[*] GnuMakefileGenerator.java 1.101 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java?root=Tools_Project&r1=1.100&r2=1.101