Date: Wed, 05 Oct 2016 10:43:11 +0000 From: bugzilla-noreply@freebsd.org To: freebsd-toolchain@FreeBSD.org Subject: [Bug 213217] [patch] Passing -isystem <sysroot>/usr/include to clang breaks C++ compilation Message-ID: <bug-213217-29464-Sxp3qMIZw4@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-213217-29464@https.bugs.freebsd.org/bugzilla/> References: <bug-213217-29464@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D213217 Dimitry Andric <dim@FreeBSD.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dim@FreeBSD.org Status|New |Closed Resolution|--- |Rejected --- Comment #2 from Dimitry Andric <dim@FreeBSD.org> --- Short answer: Don't use -isystem /usr/include. If you do so for C++ programs, you mess up the include search path order. = If you must do it for some reason, you must also add -isystem entries for the = C++ include directories, and at the front of the list. For example, a C++ program will use the following search path by default (w= here x.y.z is the clang version): #include "..." search starts here: #include <...> search starts here: /usr/include/c++/v1 /usr/bin/../lib/clang/x.y.z/include /usr/include End of search list. >From libc++ 3.8.0 onwards, if you include a C standard header, such as <cstddef>, you will get libc++'s wrapper header first. This header sets up= a few things, then does #include_next<stddef.h>, and with the above search pa= th, this finds /usr/include/stddef.h. (We don't install clang's internal stdde= f.h, since it is not compatible with our system headers yet.) However, if you add -isystem /usr/include, you force /usr/include to be the first in the list, e.g. the search path will become: ignoring duplicate directory "/usr/include" #include "..." search starts here: #include <...> search starts here: /usr/include /usr/include/c++/v1 /usr/bin/../lib/clang/x.y.z/include End of search list. If you now include <cstddef>, and it eventually does #include_next<stddef.h= >, it will attempt to search the paths *after* /usr/include/c++/v1, and will n= ot be able to find the header. Summary: If for some reason you must completely rebuild the header search p= ath from scratch, you need to add -isystem /usr/include/c++/v1 *before* -isyst= em /usr/include. But it is better not to do this at all. :) --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-213217-29464-Sxp3qMIZw4>