Uploaded image for project: 'ROOT'
  1. ROOT
  2. ROOT-8991

Cling exports buggy include paths to AcLIC

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: High
    • Resolution: Unresolved
    • Affects Version/s: master
    • Fix Version/s: 6.12/02, 6.14/00
    • Component/s: Cling, Dictionaries
    • Labels:
      None
    • Environment:
      • Debian GNU/Linux "sid"
      • GCC 7.2.0

      Description

      Hi,

      While building ROOT, using GCC 7 (though I don't think it's restricted to that version) the build system writes

        interpreter/llvm/src/tools/cling/lib/Interpreter/cling-compiledata.h 

      which contains lines like

      #define CLING_CXX_INCL "/usr/include/c++/7:/usr/include/x6_64-linux-gnu/c++/7:/usr/include/c++/7/bakward"
      #define CLING_CXX_RLTV "x86_64-linux-gnu-g++ -O2 -DNDEBUG"
      #define CLING_INCLUDE_PATHS ""

      The value of CLING_CXX_INCL is propagated through the code so that TSystem::GetIncludePath will return a string like

      -I"/opt/root/etc" -I"/opt/root/etc/cling" -I"/opt/root/include" -I"/usr/include/c++/7" -I"/usr/include/x6_64-linux-gnu/c++/7" -I"/usr/include/c++/7/bakward"

      (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

      Foo.C

      #include <iostream>
       
      struct Foo 
      {
        Foo() {}
        ~Foo() {}
        void print() { std::cout << "Hello, I'm Foo" << std::endl; }
      };

      and then try to AcLic load that code

      Root> gSystem->AddIncludePath("-I/usr/include/c++/7");
      Root> gROOT->LoadMacro("Foo.C+")

      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.

      Yours,

      Christian

        Attachments

          Activity

            People

            Assignee:
            axel Axel Naumann
            Reporter:
            cholm Christian Holm Christensen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: