Bug#594820: marked as done (clang: specify libstdc++ version of headers to use)

Sylvestre Ledru sylvestre at debian.org
Fri May 27 15:51:26 UTC 2011


reopen 594820
thanks

Le vendredi 27 mai 2011 à 16:28 +0200, Michael Wild a écrit :
> On 05/27/2011 02:03 AM, Debian Bug Tracking System wrote:
> > 
> 
> Sorry, still doesn't work for me:
> 
> echo "#include <fenv.h>" | clang -xc++ -E - | fgrep fenv.h
> # 1 "/usr/include/c++/4.5/fenv.h" 1 3
> # 31 "/usr/include/c++/4.5/fenv.h" 3
> # 31 "/usr/include/c++/4.5/fenv.h" 3
> # 34 "/usr/include/c++/4.5/fenv.h" 2 3
> # 1 "/usr/include/c++/4.4/fenv.h" 1 3
> # 36 "/usr/include/c++/4.5/fenv.h" 2 3
> 
> Instead of /usr/include/c++/4.5/fenv.h including /usr/include/fenv.h,
> clang finds /usr/include/c++/4.4/fenv.h instead.

On my system, it does use version 4.5:
$ cat plop.c
#include <fenv.h>

int main(){
	return 0;
}

[17:46:38][sylvestre at korcula] /tmp$ clang -o plop plop.cpp 
[17:46:41][sylvestre at korcula] /tmp$ cp plop.cpp plop.c
[17:46:47][sylvestre at korcula] /tmp$ clang -o plop plop.c

Which gcc version do you have on your system ?
(I am using my workstation to test, it might be a bit dirty).

> The problem is, that clang still searches all possible
> /usr/include/c++/4.X directories in descending version-order, where it
> should stop after the first one found.
No, looks like it continues. 
It is adding paths into the vector:
  std::vector<std::pair<IncludeDirGroup, DirectoryLookup> > IncludePath;

(you can try with the -v option of clang).

> This was solved for me by forcing
> the include-directories in the configure-options (refer to my
> debdiff.patch for the details).


When the options are set, it disables the automatic detection (which
makes more than half of your patch useless)
in ./lib/Frontend/InitHeaderSearch.cpp
void InitHeaderSearch::
AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple) {
  llvm::Triple::OSType os = triple.getOS();
  llvm::StringRef CxxIncludeRoot(CXX_INCLUDE_ROOT);
  if (CxxIncludeRoot != "") {
    llvm::StringRef CxxIncludeArch(CXX_INCLUDE_ARCH);
    if (CxxIncludeArch == "")
      AddGnuCPlusPlusIncludePaths(CxxIncludeRoot, triple.str().c_str(),
                                  CXX_INCLUDE_32BIT_DIR,
CXX_INCLUDE_64BIT_DIR,
                                  triple);
    else
      AddGnuCPlusPlusIncludePaths(CxxIncludeRoot, CXX_INCLUDE_ARCH,
                                  CXX_INCLUDE_32BIT_DIR,
CXX_INCLUDE_64BIT_DIR,
                                  triple);
    return;
  }

Thanks,
Sylvestre






More information about the Pkg-llvm-team mailing list