While building ROOT, using GCC 7 (though I don't think it's restricted to that version) the build system writes
which contains lines like
The value of CLING_CXX_INCL is propagated through the code so that TSystem::GetIncludePath will return a string like
(BTW, why do you dump headers in prefix/etc - that seems like a gross misuse of that directory - /etc is for the system admin to configure - which is probably not what you want)
The returned string from TSystem::GetIncludePath is used when AcLic loading code - both for generating the dictionary (via rootcling) and for the compiler. However, for the compiler one must not include directories such as /usr/include/c++/7. It leads to compile time errors.
To see this, do a simple test, like
and then try to AcLic load that code
You will get errors from GCC complaining about missing declarations of __builtin_addressof from deep inside the private headers of GCC - all because the header path includes the private directory.
The best solution is for gInterpreter->GetIncludePath not to return the content of CLING_CXX_INCL unless the returned path should be used for rootcling (i.e., add extra parameter - say bool includePrivate=false)
My temporary solution is to hack TSystem::CompileMacro to filter out problematic header paths.