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

Bug 341391

Summary: [Scanner Discovery] The build output parser adds include directories to the wrong files
Product: [Tools] CDT Reporter: Jonathan Watt <jwatt>
Component: cdt-buildAssignee: cdt-build-inbox <cdt-build-inbox>
Status: NEW --- QA Contact: Jonah Graham <jonah>
Severity: normal    
Priority: P3 CC: cdtdoug, yevshif
Version: 7.0.2   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
build log for small subdirectory none

Description Jonathan Watt CLA 2011-03-30 12:35:38 EDT
The build output parser seems to add the include directories specified for any given file using the -I option to every single file in the *entire* project(!).

Say I have the Mozilla source code in the directory '/src', the
objdir is '/src/obj', the file I'm interested in is
'/src/content/svg/content/src/nsSVGSVGElement.cpp', and its object file is
built at /src/obj/content/svg/content/src/nsSVGSVGElement.o. I take the following snippet of build output for nsSVGSVGElement.cpp, save it to a file, and load it via |C/C++ Build > Discovery Options|.

nsSVGOuterSVGFrame.cpp
g++-4.2 -o nsSVGOuterSVGFrame.o -c  -fvisibility=hidden -DMOZILLA_INTERNAL_API
-D_IMPL_NS_COM -DEXPORT_XPT_API -DEXPORT_XPTC_API -D_IMPL_NS_GFX
-D_IMPL_NS_WIDGET -DIMPL_XREAPI -DIMPL_NS_NET -DIMPL_THEBES 
-DSTATIC_EXPORTABLE_JS_API -DOSTYPE=\"Darwin10.6.0\" -DOSARCH=Darwin
-D_IMPL_NS_LAYOUT -I/src/layout/svg/base/src/../../../base
-I/src/layout/svg/base/src/../../../generic
-I/src/layout/svg/base/src/../../../style
-I/src/layout/svg/base/src/../../../xul/base/src
-I/src/layout/svg/base/src/../../../../content/svg/content/src
-I/src/layout/svg/base/src/../../../../content/base/src 
-I/src/layout/svg/base/src -I. -I../../../../dist/include
-I../../../../dist/include/nsprpub  -I/src/obj/dist/include/nspr
-I/src/obj/dist/include/nss       -fPIC -fmessage-length=0 -fno-rtti
-fno-exceptions -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth
-Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wcast-align -Wno-invalid-offsetof
-Wno-variadic-macros -Werror=return-type -fno-strict-aliasing -fpascal-strings
-fno-common -fshort-wchar -pthread -DNO_X11 -pipe  -DDEBUG -D_DEBUG -DTRACING
-g  -fmessage-length=0 -DMOZILLA_CLIENT -include ../../../../mozilla-config.h
-MD -MF .deps/nsSVGOuterSVGFrame.pp
/src/layout/svg/base/src/nsSVGOuterSVGFrame.cpp

That loaded, now in the per-file properties for nsSVGSVGElement.cpp under |C/C++ General > Paths and Symbols > Includes| I get a list of all the -I includes from the build output as expected. However, all other files in the source also get these same include directories listed in *their* per-file properties, which is certainly not expected!

Ultimately this problem is causing every file to end up with a list of all the include directories ever specified for any file in the build, which is a rather long list of include directories, and messes up things for some source files quite badly.
Comment 1 Andrew Gvozdev CLA 2011-03-30 12:41:41 EDT
Do you use "per project" scanner discovery which is there by default? That is what it does.
Comment 2 Jonathan Watt CLA 2011-03-30 12:57:03 EDT
A quick note about comment 0 - there's a mismatch between the file name I talked about and the file name listed in the build output, but that was just a typo due to running multiple tests. I tested on the same file as the build output, so the comment is valid other than the typo.)
Comment 3 Jonathan Watt CLA 2011-03-30 12:58:54 EDT
It took me a little while to figure out what you mean by "per project scanner discovery", but I'm guessing you're asking what the "Discovery profile" field under |C/C++ Build > Discovery Options| is set to? I just left that as it was, with its default value of "Managed build system - per project scanner info profile".

I have now tried changing the "Discovery profile" field to "GCC per file scanner info profile" instead, and repeated the steps in comment 0. This time the -I directories are added to *no* files at all. Not even the source file the build output snippet is for.

(As an aside, I don't quite understand why the default is to merge all includes, since I can't see how that would ever be useful. Also, doesn't Eclipse know that this is *un*managed code in the project, so couldn't it make "GCC per file scanner info profile" the default in that case?)
Comment 4 Andrew Gvozdev CLA 2011-03-30 14:36:54 EDT
You are using "g++-4.2" as a command, that looks like something which could prevent parsing. Can you:
1. do "Clear" on "Discovery Options" page for each language separately
2. change the command to "gcc" in build output file and try to process it again?

Also I see that the directories are represented by relative paths, I would try to change one to be absolute existing path to find out if it is able to parse the easy way.
Comment 5 Jonathan Watt CLA 2011-03-31 07:34:30 EDT
Created attachment 192265 [details]
build log for small subdirectory

I'm currently trying to get this working with the build output logged from building one of the small subdirectories. This is the log I'm using.
Comment 6 Jonathan Watt CLA 2011-03-31 07:46:59 EDT
(In reply to comment #4)
> Can you:
> 1. do "Clear" on "Discovery Options" page for each language separately
> 2. change the command to "gcc" in build output file and try to process it
> again?

I've now tried that, and I also tried with g++. I tried changing the paths to be absolute paths, build directory relative paths, and project relative paths. And I've tried a ton of other tweaking, and manual rebuilt the index over and over again each time. Unfortunately nothing seems to be working. Not even the defines from the log are showing up in the symbols list for nsSVGDocument.cpp, or in workspace/.metadata/.plugins/org.eclipse.cdt.make.core/test.sc

I'm currently just stabbing around in the dark, so a way to get log output to help figure out exactly what's going on would be great.