OpenCL apps quote include paths they pass to the OpenCL compiler. If the OpenCL compiler is called via a shell, the shell removes quotes before passing the argument to the compiler. Since we call Clang as a library, we have to remove quotes before passing the argument. --- src/gallium/state_trackers/clover/llvm/invocation.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp index 96f6a48..74ab859 100644 --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp @@ -152,6 +152,21 @@ namespace { while (!ss.eof()) { std::string opt; getline(ss, opt, ' '); + if (opt.substr(0, 2) == std::string("-I")) + { + // OpenCL programs are not aware that we are not a shell and could + // therefore pass a quoted include path. We should unquote it + // before passing it to the compiler. + // We do not want to use std::string::replace here, as include path + // can contain quotes in file names. + std::cout << opt.substr(0, 2) << std::endl; + if ((opt[2] == '"' && opt[opt.length() - 1] == '"') || + (opt[2] == '\'' && opt[opt.length() - 1] == '\'')) + { + // "-I" + path, subtracting 4 characters for -I and two quotes + opt = opt.substr(0, 2) + opt.substr(3, opt.length() - 4); + } + } opts_array.push_back(opt); } -- 2.7.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev