From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yann E. MORIN Date: Mon, 1 Aug 2016 23:59:09 +0200 Subject: [Buildroot] [PATCH 1/2] package/Makefile.in should grab HOST_DIR headers using -isystem instead of -I. In-Reply-To: <20160725195227.21112-1-draeman@bbn.com> References: <20160725195227.21112-1-draeman@bbn.com> Message-ID: <20160801215909.GA5990@free.fr> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: buildroot@busybox.net David, All, On 2016-07-25 15:52 -0400, David Raeman spake thusly: > HOST_CFLAGS includes a search path for HOST_DIR/usr/include using -I. When > HOST_CFLAGS is used by a package, these flags are passed to the compiler ahead > of flags passed by the package's internal make system. If a package has a > header file with the same name as a header file in HOST_DIR, this causes the > toolchain to prefer the file from the system include directory because its -I > appears first on the command line. I believe conflicts should prefer the file > provided by the package. This can be accomplished by using -isystem, which is > more appropriate then -I for system-level include paths. [--SNIP--] In fact, this does not work, and the patch was reverted (for background). What we need is that gcc follows the following sequence when looking for headers: 1- search paths specified with -I by the package 2- search our $(HOST_DIR)/usr/include 3- search the host system /usr/include However, I can't find anything in the gcc manpage that allows to add the search path we need in (2). All I can see is -idirafter, to add search paths after all other non-system and system paths. So, probably the following would not be very far from what we'd have to do: -nostdinc -idirafter $(HOST_DIR)/usr/include -idirafter /usr/include This tells gcc to not look at the system include path, so it is left with only the paths specified by the package, and then as a fallback, out $(HOST_DIR)/usr/include, and then as a last resort, the host-system /usr/include dirs, since the last two are -idirafter: -idirafter dir Search dir for header files, but do it after all directories specified with -I and the standard system directories have been exhausted. dir is treated as a system include directory. Thoughts? David, would you care to see if: 1- it fixes your own problem? 2- it fixes the python issues we've had with -isystem? Regards, Yann E. MORIN. -- .-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'