From: Junyan He <junyan...@linux.intel.com>

In clang, The PCH file will be used as an AST source, so
the check is strict. The macro define is also checked,
and if anything is different, the PCH is invalid and
the build processing will start from scratch.
Disable the PCH valid check now to solve this problem now
but not thoroughly, because some options and macro define
may really change the PCH AST struct and have impact on
our CL source code.

Signed-off-by: Junyan He <junyan...@linux.intel.com>
---
 backend/src/backend/program.cpp | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/backend/src/backend/program.cpp b/backend/src/backend/program.cpp
index 294bb16..3de699a 100644
--- a/backend/src/backend/program.cpp
+++ b/backend/src/backend/program.cpp
@@ -569,6 +569,9 @@ namespace gbe {
     clang::LangOptions & lang_opts = Clang.getLangOpts();
     lang_opts.OpenCL = 1;
 
+    clang::PreprocessorOptions prep_opt = Clang.getPreprocessorOpts();
+    prep_opt.DisablePCHValidation = 1;
+
     //llvm flags need command line parsing to take effect
     if (!Clang.getFrontendOpts().LLVMArgs.empty()) {
       unsigned NumArgs = Clang.getFrontendOpts().LLVMArgs.size();
@@ -650,27 +653,23 @@ namespace gbe {
     if(options)
       clOpt += options;
 
-    if (options || !OCL_USE_PCH) {
-      /* Some building option may cause the prebuild pch header file
-         not compatible with the XXX.cl source. We need rebuild all here.*/
-      usePCH = false;
-    } else {
-      std::string dirs = PCH_OBJECT_DIR;
-      std::istringstream idirs(dirs);
-
-      while (getline(idirs, pchHeaderName, ';')) {
-        if(access(pchHeaderName.c_str(), R_OK) == 0) {
-          usePCH = true;
-          break;
-        }
+    std::string dirs = PCH_OBJECT_DIR;
+    std::istringstream idirs(dirs);
+
+    while (getline(idirs, pchHeaderName, ';')) {
+      if(access(pchHeaderName.c_str(), R_OK) == 0) {
+        usePCH = true;
+        break;
       }
     }
+
     if (usePCH) {
       clOpt += " -include-pch ";
       clOpt += pchHeaderName;
       clOpt += " ";
     } else
       fwrite(ocl_stdlib_str.c_str(), strlen(ocl_stdlib_str.c_str()), 1, 
clFile);
+
     // Write the source to the cl file
     fwrite(source, strlen(source), 1, clFile);
     fclose(clFile);
-- 
1.8.3.2

_______________________________________________
Beignet mailing list
Beignet@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet

Reply via email to