Closed kasaurov closed 7 years ago
Moreover class Driver has the only one public ctor:
Driver(StringRef ClangExecutable, StringRef DefaultTargetTriple,
DiagnosticsEngine &Diags,
IntrusiveRefCntPtr<vfs::FileSystem> VFS = nullptr);
which first argument is a path to clang executable. Thus the path is always specified before BuildCompilation() invocation. Looks like a flawn interface implementation in clang.
Workaround submitted https://github.com/RadeonOpenCompute/ROCm-OpenCL-Driver/commit/97082fcff5de4ae727c7dd85d30fe6c6afcdc8df The issue is worth to be filed here https://bugs.llvm.org
The current Clang driver implementation filters out the first argument in BuildCompilation(args). In AMD OpenCL Driver the first argument passed to BuildCompilation() is "-x cl" and so it is filtered out.
Historically in Clang the first argument is thought as binary name. Some time ago argv was passed to BuildCompilation, since change https://llvm.org/svn/llvm-project/cfe/trunk@128142 they changed the interface, but still filters out the first argument.
Silent cutting of the first argument in public method doesn't look very convenient and sounds like a rudiment which should be fixed in Clang. Such a change in Clang may take time (as many implementations may rely on the current behaviour), meanwhile a simple fix in AMD OpenCL Driver will do.