Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 369770 - Preprocessor cannot be configured to mimic the behavior effectuated by gcc's -I- option
Summary: Preprocessor cannot be configured to mimic the behavior effectuated by gcc's ...
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 8.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 8.1.1   Edit
Assignee: Markus Schorn CLA
QA Contact: Markus Schorn CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-26 01:03 EST by Markus Schorn CLA
Modified: 2013-02-27 11:46 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Schorn CLA 2012-01-26 01:03:25 EST
The command-line option -I- instructs the preprocessor to split the include search path into two parts, the first of which is used for quote-includes, only. Our preprocessor can be configured with this extra search path part.

In addition to this, the option suppresses the search for quote includes in the directory of the including file. We do not have support for this behavior: The CDT preprocessor cannot be configured to ignore the directory of the including file for quote includes.
Comment 1 Martin Oberhuber CLA 2012-02-07 05:52:18 EST
CQ:WIND00331981 

We have customers who leverage gcc's -I- option in order to "override" one or few of a large System's includes with a locally modified copy. A similar approach is taken by Board Support Packages (BSP's) for embedded OS's, where the BSP's device drivers sometimes need to slightly modify system includes but they can't physically modify those system includes since the BSP is considered an add-on module.

So when original includes can't be modified, the only possible workaround is copying all global include to a local shadow, add respective local include paths first and make any modifications there. This makes it hard to track local modifications though, and the effort mainting the copy and ensuring proper include paths throughout the build system is not adequate.

I'm aware that gcc's -I- option is deprecated, but I claim that the concept of being able to override global includes by a local copy is still important (and may also be made available by compilers other than gcc).
Comment 2 Martin Oberhuber CLA 2012-03-22 05:04:12 EDT
Some evidence that the 'inhibits the use of the directory of the current file directory as the first search directory for #include "file"' aspect is still relevant for large-scale software development, although it is deprecated:

ALU nmake needs it, and references other cpp preprocessors that support it
http://www.bell-labs.com/project/nmake/newsletters/issue021.html

BOOST Wave driver supports it
http://www.boost.org/doc/libs/1_49_0/libs/wave/doc/wave_driver.html

The essential user story is this: As a software provider, I have to support several (say 30) different versions or branches of my software. I'm maintaining a shared workspace for each stream, which has the current version of all sources and binaries and performs automated nightly builds.

As a developer who has to fix an issue, I want to "hook up to" one of those shared workspaces and modify just the files that I have to modify. This "hook up" has to be quick since I need to switch the version I'm working on often during the day. I want to re-use prebuilt binaries from the shared workspace as much as possible: copying the entire workspace is a no-go since it's > 5 Gigabytes each workspace and I cannot afford my 200 developers to copy all stuff all the time; plus, copying an entire tree adds risk with respect to maintaining make dependencies and having incorrect source paths in the ELF files.

So I'm using tools like gmake VPATH / nmake viewpathing in order to maintain only a few locally modified files. The gcc '-I-' option is required in this context such that a locally modified headerfile override is properly picked up even if it is included from a parent header that is global.
Comment 3 Markus Schorn CLA 2012-07-24 04:41:23 EDT
I have enabled suppressing the use of the directory of the current file when the directory '-' is passed as part of the include search path to the preprocessor. 
Added testcase and fix.
Comment 4 CDT Genie CLA 2013-02-27 11:46:44 EST
*** cdt git genie on behalf of Markus Schorn ***

    Bug 369770: Allow suppressing use of directory of current file for resolving includes (effect of option -I-).

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=ecdf231dbc3b3c0f826e12d657855ce006c603ad
Comment 5 CDT Genie CLA 2013-02-27 11:46:48 EST
*** cdt git genie on behalf of Markus Schorn ***

    Bug 369770: Allow suppressing use of directory of current file for resolving includes (effect of option -I-).

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=ee06da3642eb9fd058bfe1649cbefe1a4035d4f1