[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    icecream/client
From:       Luboš Luňák <l.lunak () kde ! org>
Date:       2012-07-08 15:26:21
Message-ID: 20120708152621.0C68DAC7A9 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1304630 by lunakl:

support for -rewrite-includes with clang

Clang works suboptimally with separate preprocessing step, it e.g.
quotes source in warning/error messages, or disables some warnings
if they come from macro expansion. Therefore make it possible
to do the preprocessing remotely together with compiling and only
expand #include directives locally.

There exists a Clang patch that implements -rewrite-includes for this,
and it's been only recently merged upstream. Currently
ICECC_REWRITE_INCLUDE is used to determine if the flag should be used
or not.



 M  +16 -6     arg.cpp  
 M  +3 -0      cpp.cpp  
 M  +15 -0     local.cpp  


--- trunk/icecream/client/arg.cpp #1304629:1304630
@@ -111,6 +111,8 @@
     bool seen_mf = false;
     bool seen_md = false;
     bool fno_color_diagnostics = false;
+    // if rewriting includes and precompiling on remote machine, then cpp args are not local
+    Argument_Type Arg_Cpp = compiler_only_rewrite_includes( job ) ? Arg_Rest : Arg_Local;
     if( icerun ) {
         always_local = true;
         job.setLanguage( CompileJob::Lang_Custom );
@@ -254,8 +256,14 @@
                     args.append(argv[i], Arg_Local);
                 }
             } else if (str_equal("-D", a)
-                       || str_equal("-I", a)
-                       || str_equal("-U", a)
+                       || str_equal("-U", a) ) {
+                args.append(a, Arg_Cpp);
+                /* skip next word, being option argument */
+                if (argv[i+1]) {
+		    ++i;
+                    args.append(  argv[i], Arg_Cpp );
+		}
+            } else if (str_equal("-I", a)
                        || str_equal("-L", a)
                        || str_equal("-l", a)
                        || str_equal("-MF", a)
@@ -281,13 +289,15 @@
 		}
             } else if (str_startswith("-Wp,", a)
                  || str_startswith("-D", a)
-                 || str_startswith("-U", a)
-                 || str_startswith("-I", a)
+                 || str_startswith("-U", a)) {
+                args.append(a, Arg_Cpp);
+            } else if (str_startswith("-I", a)
                  || str_startswith("-l", a)
                  || str_startswith("-L", a)) {
                 args.append(a, Arg_Local);
-            } else if (str_equal("-undef", a)
-                 || str_equal("-nostdinc", a)
+            } else if (str_equal("-undef", a)) {
+                args.append(a, Arg_Cpp);
+            } else if (str_equal("-nostdinc", a)
                  || str_equal("-nostdinc++", a)
                  || str_equal("-MD", a)
                  || str_equal("-MMD", a)
--- trunk/icecream/client/cpp.cpp #1304629:1304630
@@ -116,6 +116,7 @@
 	    int argc = flags.size();
 	    argc++; // the program
 	    argc += 2; // -E file.i
+	    argc += 1; // -Wp,-rewrite-includes
 	    argv = new char*[argc + 1];
    	    argv[0] = strdup( find_compiler( job ).c_str() );
 	    int i = 1;
@@ -125,6 +126,8 @@
 	    }
 	    argv[i++] = strdup( "-E" );
 	    argv[i++] = strdup( job.inputFile().c_str() );
+	    if ( compiler_only_rewrite_includes( job ))
+	        argv[i++] = strdup( "-Wp,-rewrite-includes" );
 	    argv[i++] = 0;
 	}
 
--- trunk/icecream/client/local.cpp #1304629:1304630
@@ -122,6 +122,21 @@
     return job.compilerName().find("clang") != string::npos;
 }
 
+/*
+Clang works suboptimally when handling an already preprocessed source file,
+for example error messages quote (already preprocessed) parts of the source.
+Therefore it is better to only locally merge all #include files into the source
+file and do the actual preprocessing remotely together with compiling.
+There exists a Clang patch to implement option -rewrite-includes that does
+such #include rewritting, and it's been only recently merged upstream.
+*/
+bool compiler_only_rewrite_includes( const CompileJob& job )
+{
+    if ( compiler_is_clang( job ))
+        return getenv( "ICECC_REWRITE_INCLUDES" ) != NULL;
+    return false;
+}
+
 static volatile int lock_fd = 0;
 static volatile int user_break_signal = 0;
 static volatile pid_t child_pid;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic