Page MenuHomePhabricator

[Driver] Detect libstdc++ include paths for native gcc (-m32 and -m64) on Debian i386

Authored by MaskRay on Sat, Apr 3, 9:28 PM.



Take gcc-8 on Debian i386 as an example. The target-specific libstdc++ search
path (GPLUSPLUS_TOOL_INCLUDE_DIR) uses the multiarch name i386-linux-gnu,
instead of the triple of the GCC installation i686-linux-gnu (the directory
under usr/lib/gcc/):


Clang currently detects /usr/lib/gcc/i686-linux-gnu/8/../../../include/i686-linux-gnu/c++/8.
This patch changes the second i686-linux-gnu to i386-linux-gnu so that
/usr/include/i386-linux-gnu/c++/8 can be found.

Fix PR49827 - this was somehow regressed by my previous libstdc++ include path
cleanups and fixes for gcc-cross, but it seems that the paths were never properly tested before.

Diff Detail

Event Timeline

MaskRay requested review of this revision.Sat, Apr 3, 9:28 PM
MaskRay created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptSat, Apr 3, 9:28 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
MaskRay updated this revision to Diff 335127.Sat, Apr 3, 9:54 PM

git add two .keep files

MaskRay added a comment.EditedSun, Apr 4, 12:18 AM

From an upstream multiarch build of gcc, the libstdc++ search paths are


(this is similar to cross gcc on Debian, except that cross gcc usually uses ../../../../$triple/include/c++/$v)

If you specify --target=x86_64-linux-gnu and install it to /usr, the paths will become.

/usr/include/c++/11.0.1/x86_64-linux-gnu  # for i686-linux-gnu this should be /usr/include/c++/11.0.1/i686-linux-gnu (i686 instead of i386)

If Debian can drop the incdir patch for native gcc, it can reduce some maintenance burden and clang driver can still detect the libstdc++ search paths

sylvestre.ledru accepted this revision.Sun, Apr 4, 9:21 AM
sylvestre.ledru added a subscriber: doko.

Many thanks. it fixed my issues!

/usr/include/i386-linux-gnu/c++/8 is indeed much nicer :)

Thanks for all your hard work on fixing the header detection. it was indeed too complex!

And, thanks for asking for review ;)

About the g++-multiarch-incdir.diff, I cced the gcc maintainer!

This revision is now accepted and ready to land.Sun, Apr 4, 9:21 AM