Skip to content

[cling] Clang is conditionally invoked with the wrong driver mode depending on the executable's name #23493

Description

@silverweed

Check duplicate issues.

  • Checked for duplicates

Description

(see also llvm/llvm-project#225385 for the original report)

When ROOT is initialized it also initializes Cling, a complex process that involves invoking Clang with some predefined set of flags. When Clang is invoked this way, the ClangExecutable argument (used in Driver::BuildCompilation, which is where this bug likely originates) is not set to clang but to the name of the executable that is initializing ROOT.

One can easily reproduce this behavior by compiling this ROOT code:

// compile with: c++ -o cl thisfile.cpp $(root-config --cflags --libs) (you need to source thisroot.sh)
#include <TROOT.h>
int main() {
// this causes ROOT to be initialized
gROOT;
}

and name the resulting binary cl (or anything containing cl- or ending with cl). In this case, the errors will come from Cling, in a form similar to this:

warning: unknown argument ignored in clang-cl: '-fcxx-modules'
warning: unknown argument ignored in clang-cl: '-fmodules-cache-path=/home/user/root_build/debug/lib'
warning: unknown argument ignored in clang-cl: '-std=c++17'
warning: unknown argument ignored in clang-cl: '-fsigned-char'
warning: unknown argument ignored in clang-cl: '-fsized-deallocation'
warning: unknown argument ignored in clang-cl: '-fmodules-cache-path=/home/user/root_build/debug/lib'
warning: unknown argument ignored in clang-cl: '-fno-implicit-module-maps'
warning: unknown argument ignored in clang-cl: '-Rmodule-build'
warning: unknown argument ignored in clang-cl: '-fno-autolink'
warning: unknown argument ignored in clang-cl: '-cxx-isystem'
warning: unknown argument ignored in clang-cl: '-cxx-isystem'
warning: unknown argument ignored in clang-cl: '-cxx-isystem'
warning: unknown argument ignored in clang-cl: '-nostdinc++'
warning: unable to find a Visual Studio installation; try running Clang from a developer command prompt
cl: /home/user/root/interpreter/cling/lib/Interpreter/CIFactory.cpp:1025: bool (anonymous namespace)::SetupCompiler(CompilerInstance *, const CompilerOptions &, bool, bool): Assertion `LangOpts.CPlusPlus17 && "Language version mismatch"' failed.
fish: Job 1, './cl' terminated by signal SIGABRT (Abort)

Reproducer

Create a C++ file containing

#include <TROOT.h>
int main() { gROOT; }

Compile it to a binary named foocl and run it.

ROOT version

master

Installation method

any

Operating system

any

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions