The rootcling_tmp.cxx file is compiled using -DR__LLVMRESOURCEDIR=<resource-directory-path>" and the path is substituted using the macro "stringify(s)" which expands to #s. When building in a directory that contains "linux" in the path (e.g. "/tmp/x86_64-linux-gcc5/build"), this interacts poorly with the non-posix definition of the macro "linux:" (resulting in a resource path containing /tmp/x86_64--gcc5/build) and the build fails. The fundamental problem is that if the compilation path contains a string that happens to match a defined macro, the compilation will fail.
I've checked at gcc5 as compiled by Debian defines the macro "linux". If it is not defined by the compiler, it will be defined in RConfig.h which contains the lines
I've verified this compiling ROOT 6.04.06 with cmake, however I suspect it applies to other versions. The work around is to change the compilation location (sometimes difficult). A possible fix is to change rootcling.cxx to not depend on cpp to substitute the resource directory name during the build (e.g. use a search-replace while copying to rootcling_tmp.cxx),