Bug Summary

File:ccache.c
Location:line 813, column 50
Description:Access to field 'size' results in a dereference of a null pointer (loaded from variable 'hash')

Annotated Source Code

1/*
2 * ccache -- a fast C/C++ compiler cache
3 *
4 * Copyright (C) 2002-2007 Andrew Tridgell
5 * Copyright (C) 2009-2013 Joel Rosdahl
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 3 of the License, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc., 51
19 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include "ccache.h"
23#include "compopt.h"
24#ifdef HAVE_GETOPT_LONG1
25#include <getopt.h>
26#else
27#include "getopt_long.h"
28#endif
29#include "hashtable.h"
30#include "hashtable_itr.h"
31#include "hashutil.h"
32#include "language.h"
33#include "manifest.h"
34
35static const char VERSION_TEXT[] =
36MYNAME"ccache" " version %s\n"
37"\n"
38"Copyright (C) 2002-2007 Andrew Tridgell\n"
39"Copyright (C) 2009-2011 Joel Rosdahl\n"
40"\n"
41"This program is free software; you can redistribute it and/or modify it under\n"
42"the terms of the GNU General Public License as published by the Free Software\n"
43"Foundation; either version 3 of the License, or (at your option) any later\n"
44"version.\n";
45
46static const char USAGE_TEXT[] =
47"Usage:\n"
48" " MYNAME"ccache" " [options]\n"
49" " MYNAME"ccache" " compiler [compiler options]\n"
50" compiler [compiler options] (via symbolic link)\n"
51"\n"
52"Options:\n"
53" -c, --cleanup delete old files and recalculate size counters\n"
54" (normally not needed as this is done automatically)\n"
55" -C, --clear clear the cache completely\n"
56" -F, --max-files=N set maximum number of files in cache to N (use 0 for\n"
57" no limit)\n"
58" -M, --max-size=SIZE set maximum size of cache to SIZE (use 0 for no\n"
59" limit; available suffixes: G, M and K; default\n"
60" suffix: G)\n"
61" -s, --show-stats show statistics summary\n"
62" -z, --zero-stats zero statistics counters\n"
63"\n"
64" -h, --help print this help text\n"
65" -V, --version print version and copyright information\n"
66"\n"
67"See also <http://ccache.samba.org>.\n";
68
69/* current working directory taken from $PWD, or getcwd() if $PWD is bad */
70char *current_working_dir = NULL((void*)0);
71
72/* the base cache directory */
73char *cache_dir = NULL((void*)0);
74
75/* the directory for temporary files */
76static char *temp_dir;
77
78/* the debug logfile name, if set */
79char *cache_logfile = NULL((void*)0);
80
81/* base directory (from CCACHE_BASEDIR) */
82char *base_dir = NULL((void*)0);
83
84/* the original argument list */
85static struct args *orig_args;
86
87/* the source file */
88static char *input_file;
89
90/* The output file being compiled to. */
91static char *output_obj;
92
93/* The path to the dependency file (implicit or specified with -MF). */
94static char *output_dep;
95
96/*
97 * Name (represented as a struct file_hash) of the file containing the cached
98 * object code.
99 */
100static struct file_hash *cached_obj_hash;
101
102/*
103 * Full path to the file containing the cached object code
104 * (cachedir/a/b/cdef[...]-size.o).
105 */
106static char *cached_obj;
107
108/*
109 * Full path to the file containing the standard error output
110 * (cachedir/a/b/cdef[...]-size.stderr).
111 */
112static char *cached_stderr;
113
114/*
115 * Full path to the file containing the dependency information
116 * (cachedir/a/b/cdef[...]-size.d).
117 */
118static char *cached_dep;
119
120/*
121 * Full path to the file containing the manifest
122 * (cachedir/a/b/cdef[...]-size.manifest).
123 */
124static char *manifest_path;
125
126/*
127 * Time of compilation. Used to see if include files have changed after
128 * compilation.
129 */
130static time_t time_of_compilation;
131
132/* Bitmask of SLOPPY_*. */
133unsigned sloppiness = 0;
134
135/*
136 * Files included by the preprocessor and their hashes/sizes. Key: file path.
137 * Value: struct file_hash.
138 */
139static struct hashtable *included_files;
140
141/* is gcc being asked to output dependencies? */
142static bool_Bool generating_dependencies;
143
144/* the extension of the file (without dot) after pre-processing */
145static const char *i_extension;
146
147/* the name of the temporary pre-processor file */
148static char *i_tmpfile;
149
150/* are we compiling a .i or .ii file directly? */
151static bool_Bool direct_i_file;
152
153/* the name of the cpp stderr file */
154static char *cpp_stderr;
155
156/*
157 * Full path to the statistics file in the subdirectory where the cached result
158 * belongs (CCACHE_DIR/X/stats).
159 */
160char *stats_file = NULL((void*)0);
161
162/* can we safely use the unification hashing backend? */
163static bool_Bool enable_unify;
164
165/* should we use the direct mode? */
166static bool_Bool enable_direct = true1;
167
168/*
169 * Whether to enable compression of files stored in the cache. (Manifest files
170 * are always compressed.)
171 */
172static bool_Bool enable_compression = false0;
173
174/* number of levels (1 <= nlevels <= 8) */
175static int nlevels = 2;
176
177/*
178 * Whether we should use the optimization of passing the already existing
179 * preprocessed source code to the compiler.
180 */
181static bool_Bool compile_preprocessed_source_code;
182
183/* Whether the output is a precompiled header */
184static bool_Bool output_is_precompiled_header = false0;
185
186/*
187 * Whether we are using a precompiled header (either via -include or #include).
188 */
189static bool_Bool using_precompiled_header = false0;
190
191/* How long (in microseconds) to wait before breaking a stale lock. */
192unsigned lock_staleness_limit = 2000000;
193
194enum fromcache_call_mode {
195 FROMCACHE_DIRECT_MODE,
196 FROMCACHE_CPP_MODE,
197 FROMCACHE_COMPILED_MODE
198};
199
200/*
201 * This is a string that identifies the current "version" of the hash sum
202 * computed by ccache. If, for any reason, we want to force the hash sum to be
203 * different for the same input in a new ccache version, we can just change
204 * this string. A typical example would be if the format of one of the files
205 * stored in the cache changes in a backwards-incompatible way.
206 */
207static const char HASH_PREFIX[] = "3";
208
209/* Something went badly wrong - just execute the real compiler. */
210static void
211failed(void)
212{
213 char *e;
214
215 /* strip any local args */
216 args_strip(orig_args, "--ccache-");
217
218 if ((e = getenv("CCACHE_PREFIX"))) {
219 char *p = find_executable(e, MYNAME"ccache");
220 if (!p) {
221 fatal("%s: %s", e, strerror(errno(*__errno_location ())));
222 }
223 args_add_prefix(orig_args, p);
224 }
225
226 cc_log("Failed; falling back to running the real compiler");
227 cc_log_argv("Executing ", orig_args->argv);
228 exitfn_call();
229 execv(orig_args->argv[0], orig_args->argv);
230 fatal("%s: execv returned (%s)", orig_args->argv[0], strerror(errno(*__errno_location ())));
231}
232
233static void
234clean_up_tmp_files()
235{
236 /* delete intermediate pre-processor file if needed */
237 if (i_tmpfile) {
238 if (!direct_i_file) {
239 tmp_unlink(i_tmpfile);
240 }
241 free(i_tmpfile);
242 i_tmpfile = NULL((void*)0);
243 }
244
245 /* delete the cpp stderr file if necessary */
246 if (cpp_stderr) {
247 tmp_unlink(cpp_stderr);
248 free(cpp_stderr);
249 cpp_stderr = NULL((void*)0);
250 }
251}
252
253/*
254 * Transform a name to a full path into the cache directory, creating needed
255 * sublevels if needed. Caller frees.
256 */
257static char *
258get_path_in_cache(const char *name, const char *suffix)
259{
260 int i;
261 char *path;
262 char *result;
263
264 path = x_strdup(cache_dir);
265 for (i = 0; i < nlevels; ++i) {
266 char *p = format("%s/%c", path, name[i]);
267 free(path);
268 path = p;
269 if (!getenv("CCACHE_READONLY") && create_dir(path) != 0) {
270 fatal("Failed to create %s: %s", path, strerror(errno(*__errno_location ())));
271 }
272 }
273 result = format("%s/%s%s", path, name + nlevels, suffix);
274 free(path);
275 return result;
276}
277
278/*
279 * This function hashes an include file and stores the path and hash in the
280 * global included_files variable. If the include file is a PCH, cpp_hash is
281 * also updated. Takes over ownership of path.
282 */
283static void
284remember_include_file(char *path, size_t path_len, struct mdfour *cpp_hash)
285{
286 struct mdfour fhash;
287 struct stat st;
288 char *source = NULL((void*)0);
289 size_t size;
290 int result;
291 bool_Bool is_pch;
292
293 if (path_len >= 2 && (path[0] == '<' && path[path_len - 1] == '>')) {
294 /* Typically <built-in> or <command-line>. */
295 goto ignore;
296 }
297
298 if (str_eq(path, input_file)(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((path)) && __builtin_constant_p ((input_file)) &&
(__s1_len = strlen ((path)), __s2_len = strlen ((input_file)
), (!((size_t)(const void *)(((path)) + 1) - (size_t)(const void
*)((path)) == 1) || __s1_len >= 4) && (!((size_t)
(const void *)(((input_file)) + 1) - (size_t)(const void *)((
input_file)) == 1) || __s2_len >= 4)) ? __builtin_strcmp (
(path), (input_file)) : (__builtin_constant_p ((path)) &&
((size_t)(const void *)(((path)) + 1) - (size_t)(const void *
)((path)) == 1) && (__s1_len = strlen ((path)), __s1_len
< 4) ? (__builtin_constant_p ((input_file)) && ((
size_t)(const void *)(((input_file)) + 1) - (size_t)(const void
*)((input_file)) == 1) ? __builtin_strcmp ((path), (input_file
)) : (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) ((input_file)); int __result = (((const
unsigned char *) (const char *) ((path)))[0] - __s2[0]); if (
__s1_len > 0 && __result == 0) { __result = (((const
unsigned char *) (const char *) ((path)))[1] - __s2[1]); if (
__s1_len > 1 && __result == 0) { __result = (((const
unsigned char *) (const char *) ((path)))[2] - __s2[2]); if (
__s1_len > 2 && __result == 0) __result = (((const
unsigned char *) (const char *) ((path)))[3] - __s2[3]); } }
__result; }))) : (__builtin_constant_p ((input_file)) &&
((size_t)(const void *)(((input_file)) + 1) - (size_t)(const
void *)((input_file)) == 1) && (__s2_len = strlen ((
input_file)), __s2_len < 4) ? (__builtin_constant_p ((path
)) && ((size_t)(const void *)(((path)) + 1) - (size_t
)(const void *)((path)) == 1) ? __builtin_strcmp ((path), (input_file
)) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) ((path)); int __result = (((const unsigned
char *) (const char *) ((input_file)))[0] - __s2[0]); if (__s2_len
> 0 && __result == 0) { __result = (((const unsigned
char *) (const char *) ((input_file)))[1] - __s2[1]); if (__s2_len
> 1 && __result == 0) { __result = (((const unsigned
char *) (const char *) ((input_file)))[2] - __s2[2]); if (__s2_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) ((input_file)))[3] - __s2[3]); } } __result
; })))) : __builtin_strcmp ((path), (input_file))))); }) == 0
)
) {
299 /* Don't remember the input file. */
300 goto ignore;
301 }
302
303 if (hashtable_search(included_files, path)) {
304 /* Already known include file. */
305 goto ignore;
306 }
307
308 if (stat(path, &st) != 0) {
309 cc_log("Failed to stat include file %s: %s", path, strerror(errno(*__errno_location ())));
310 goto failure;
311 }
312 if (S_ISDIR(st.st_mode)((((st.st_mode)) & 0170000) == (0040000))) {
313 /* Ignore directory, typically $PWD. */
314 goto ignore;
315 }
316 if (!S_ISREG(st.st_mode)((((st.st_mode)) & 0170000) == (0100000))) {
317 /* Device, pipe, socket or other strange creature. */
318 cc_log("Non-regular include file %s", path);
319 goto failure;
320 }
321
322 /* Let's hash the include file. */
323 if (!(sloppiness & SLOPPY_INCLUDE_FILE_MTIME1)
324 && st.st_mtimest_mtim.tv_sec >= time_of_compilation) {
325 cc_log("Include file %s too new", path);
326 goto failure;
327 }
328
329 hash_start(&fhash);
330
331 is_pch = is_precompiled_header(path);
332 if (is_pch) {
333 struct file_hash pch_hash;
334 if (!hash_file(&fhash, path)) {
335 goto failure;
336 }
337 hash_result_as_bytes(&fhash, pch_hash.hash);
338 pch_hash.size = fhash.totalN;
339 hash_delimiter(cpp_hash, "pch_hash");
340 hash_buffer(cpp_hash, pch_hash.hash, sizeof(pch_hash.hash));
341 }
342 if (enable_direct) {
343 struct file_hash *h;
344
345 if (!is_pch) { /* else: the file has already been hashed. */
346 if (st.st_size > 0) {
347 if (!read_file(path, st.st_size, &source, &size)) {
348 goto failure;
349 }
350 } else {
351 source = x_strdup("");
352 size = 0;
353 }
354
355 result = hash_source_code_string(&fhash, source, size, path);
356 if (result & HASH_SOURCE_CODE_ERROR1
357 || result & HASH_SOURCE_CODE_FOUND_TIME4) {
358 goto failure;
359 }
360 }
361
362 h = x_malloc(sizeof(*h));
363 hash_result_as_bytes(&fhash, h->hash);
364 h->size = fhash.totalN;
365 hashtable_insert(included_files, path, h);
366 } else {
367 free(path);
368 }
369
370 free(source);
371 return;
372
373failure:
374 cc_log("Disabling direct mode");
375 enable_direct = false0;
376 /* Fall through. */
377ignore:
378 free(path);
379 free(source);
380}
381
382/*
383 * Make a relative path from current working directory to path if CCACHE_PREFIX
384 * is a prefix of path. Takes over ownership of path. Caller frees.
385 */
386static char *
387make_relative_path(char *path)
388{
389 char *relpath, *canon_path;
390
391 if (!base_dir || !str_startswith(path, base_dir)((__extension__ (__builtin_constant_p (strlen((base_dir))) &&
((__builtin_constant_p ((path)) && strlen ((path)) <
((size_t) (strlen((base_dir))))) || (__builtin_constant_p ((
base_dir)) && strlen ((base_dir)) < ((size_t) (strlen
((base_dir)))))) ? __extension__ ({ size_t __s1_len, __s2_len
; (__builtin_constant_p ((path)) && __builtin_constant_p
((base_dir)) && (__s1_len = strlen ((path)), __s2_len
= strlen ((base_dir)), (!((size_t)(const void *)(((path)) + 1
) - (size_t)(const void *)((path)) == 1) || __s1_len >= 4)
&& (!((size_t)(const void *)(((base_dir)) + 1) - (size_t
)(const void *)((base_dir)) == 1) || __s2_len >= 4)) ? __builtin_strcmp
((path), (base_dir)) : (__builtin_constant_p ((path)) &&
((size_t)(const void *)(((path)) + 1) - (size_t)(const void *
)((path)) == 1) && (__s1_len = strlen ((path)), __s1_len
< 4) ? (__builtin_constant_p ((base_dir)) && ((size_t
)(const void *)(((base_dir)) + 1) - (size_t)(const void *)((base_dir
)) == 1) ? __builtin_strcmp ((path), (base_dir)) : (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) ((base_dir)); int __result = (((const unsigned char *
) (const char *) ((path)))[0] - __s2[0]); if (__s1_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) ((path)))[1] - __s2[1]); if (__s1_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) ((path)))[2] - __s2[2]); if (__s1_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) ((path)))[3] - __s2[3]); } } __result; }))
) : (__builtin_constant_p ((base_dir)) && ((size_t)(const
void *)(((base_dir)) + 1) - (size_t)(const void *)((base_dir
)) == 1) && (__s2_len = strlen ((base_dir)), __s2_len
< 4) ? (__builtin_constant_p ((path)) && ((size_t
)(const void *)(((path)) + 1) - (size_t)(const void *)((path)
) == 1) ? __builtin_strcmp ((path), (base_dir)) : (- (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) ((path)); int __result = (((const unsigned char *) (
const char *) ((base_dir)))[0] - __s2[0]); if (__s2_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) ((base_dir)))[1] - __s2[1]); if (__s2_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) ((base_dir)))[2] - __s2[2]); if (__s2_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) ((base_dir)))[3] - __s2[3]); } } __result;
})))) : __builtin_strcmp ((path), (base_dir))))); }) : strncmp
((path), (base_dir), strlen((base_dir))))) == 0)
) {
392 return path;
393 }
394
395 if (!current_working_dir) {
396 char *cwd = get_cwd();
397 if (cwd) {
398 current_working_dir = x_realpath(cwd);
399 free(cwd);
400 }
401 if (!current_working_dir) {
402 cc_log("Unable to determine current working directory: %s",
403 strerror(errno(*__errno_location ())));
404 failed();
405 }
406 }
407
408 canon_path = x_realpath(path);
409 if (canon_path) {
410 free(path);
411 path = canon_path;
412 } else {
413 /* path doesn't exist, so leave it as it is. */
414 }
415
416 relpath = get_relative_path(current_working_dir, path);
417 free(path);
418 return relpath;
419}
420
421/*
422 * This function reads and hashes a file. While doing this, it also does these
423 * things:
424 *
425 * - Makes include file paths whose prefix is CCACHE_BASEDIR relative when
426 * computing the hash sum.
427 * - Stores the paths and hashes of included files in the global variable
428 * included_files.
429 */
430static bool_Bool
431process_preprocessed_file(struct mdfour *hash, const char *path)
432{
433 char *data;
434 char *p, *q, *end;
435 size_t size;
436
437 if (!read_file(path, 0, &data, &size)) {
438 return false0;
439 }
440
441 included_files = create_hashtable(1000, hash_from_string, strings_equal);
442
443 /* Bytes between p and q are pending to be hashed. */
444 end = data + size;
445 p = data;
446 q = data;
447 while (q < end - 7) { /* There must be at least 7 characters (# 1 "x") left
448 to potentially find an include file path. */
449 /*
450 * Check if we look at a line containing the file name of an included file.
451 * At least the following formats exist (where N is a positive integer):
452 *
453 * GCC:
454 *
455 * # N "file"
456 * # N "file" N
457 * #pragma GCC pch_preprocess "file"
458 *
459 * HP's compiler:
460 *
461 * #line N "file"
462 *
463 * AIX's compiler:
464 *
465 * #line N "file"
466 * #line N
467 *
468 * Note that there may be other lines starting with '#' left after
469 * preprocessing as well, for instance "# pragma".
470 */
471 if (q[0] == '#'
472 /* GCC: */
473 && ((q[1] == ' ' && q[2] >= '0' && q[2] <= '9')
474 /* GCC precompiled header: */
475 || (q[1] == 'p'
476 && str_startswith(&q[2], "ragma GCC pch_preprocess ")((__extension__ (__builtin_constant_p (strlen(("ragma GCC pch_preprocess "
))) && ((__builtin_constant_p ((&q[2])) &&
strlen ((&q[2])) < ((size_t) (strlen(("ragma GCC pch_preprocess "
))))) || (__builtin_constant_p (("ragma GCC pch_preprocess ")
) && strlen (("ragma GCC pch_preprocess ")) < ((size_t
) (strlen(("ragma GCC pch_preprocess ")))))) ? __extension__ (
{ size_t __s1_len, __s2_len; (__builtin_constant_p ((&q[2
])) && __builtin_constant_p (("ragma GCC pch_preprocess "
)) && (__s1_len = strlen ((&q[2])), __s2_len = strlen
(("ragma GCC pch_preprocess ")), (!((size_t)(const void *)((
(&q[2])) + 1) - (size_t)(const void *)((&q[2])) == 1)
|| __s1_len >= 4) && (!((size_t)(const void *)(((
"ragma GCC pch_preprocess ")) + 1) - (size_t)(const void *)((
"ragma GCC pch_preprocess ")) == 1) || __s2_len >= 4)) ? __builtin_strcmp
((&q[2]), ("ragma GCC pch_preprocess ")) : (__builtin_constant_p
((&q[2])) && ((size_t)(const void *)(((&q[2]
)) + 1) - (size_t)(const void *)((&q[2])) == 1) &&
(__s1_len = strlen ((&q[2])), __s1_len < 4) ? (__builtin_constant_p
(("ragma GCC pch_preprocess ")) && ((size_t)(const void
*)((("ragma GCC pch_preprocess ")) + 1) - (size_t)(const void
*)(("ragma GCC pch_preprocess ")) == 1) ? __builtin_strcmp (
(&q[2]), ("ragma GCC pch_preprocess ")) : (__extension__ (
{ const unsigned char *__s2 = (const unsigned char *) (const char
*) (("ragma GCC pch_preprocess ")); int __result = (((const unsigned
char *) (const char *) ((&q[2])))[0] - __s2[0]); if (__s1_len
> 0 && __result == 0) { __result = (((const unsigned
char *) (const char *) ((&q[2])))[1] - __s2[1]); if (__s1_len
> 1 && __result == 0) { __result = (((const unsigned
char *) (const char *) ((&q[2])))[2] - __s2[2]); if (__s1_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) ((&q[2])))[3] - __s2[3]); } } __result
; }))) : (__builtin_constant_p (("ragma GCC pch_preprocess ")
) && ((size_t)(const void *)((("ragma GCC pch_preprocess "
)) + 1) - (size_t)(const void *)(("ragma GCC pch_preprocess "
)) == 1) && (__s2_len = strlen (("ragma GCC pch_preprocess "
)), __s2_len < 4) ? (__builtin_constant_p ((&q[2])) &&
((size_t)(const void *)(((&q[2])) + 1) - (size_t)(const void
*)((&q[2])) == 1) ? __builtin_strcmp ((&q[2]), ("ragma GCC pch_preprocess "
)) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) ((&q[2])); int __result = (((const
unsigned char *) (const char *) (("ragma GCC pch_preprocess "
)))[0] - __s2[0]); if (__s2_len > 0 && __result ==
0) { __result = (((const unsigned char *) (const char *) (("ragma GCC pch_preprocess "
)))[1] - __s2[1]); if (__s2_len > 1 && __result ==
0) { __result = (((const unsigned char *) (const char *) (("ragma GCC pch_preprocess "
)))[2] - __s2[2]); if (__s2_len > 2 && __result ==
0) __result = (((const unsigned char *) (const char *) (("ragma GCC pch_preprocess "
)))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp ((&
q[2]), ("ragma GCC pch_preprocess "))))); }) : strncmp ((&
q[2]), ("ragma GCC pch_preprocess "), strlen(("ragma GCC pch_preprocess "
))))) == 0)
)
477 /* HP/AIX: */
478 || (q[1] == 'l' && q[2] == 'i' && q[3] == 'n' && q[4] == 'e'
479 && q[5] == ' '))
480 && (q == data || q[-1] == '\n')) {
481 char *path;
482
483 while (q < end && *q != '"' && *q != '\n') {
484 q++;
485 }
486 if (q < end && *q == '\n') {
487 /* A newline before the quotation mark -> no match. */
488 continue;
489 }
490 q++;
491 if (q >= end) {
492 cc_log("Failed to parse included file path");
493 free(data);
494 return false0;
495 }
496 /* q points to the beginning of an include file path */
497 hash_buffer(hash, p, q - p);
498 p = q;
499 while (q < end && *q != '"') {
500 q++;
501 }
502 /* p and q span the include file path */
503 path = x_strndup(p, q - p);
504 path = make_relative_path(path);
505 hash_string(hash, path);
506 remember_include_file(path, q - p, hash);
507 p = q;
508 } else {
509 q++;
510 }
511 }
512
513 hash_buffer(hash, p, (end - p));
514 free(data);
515 return true1;
516}
517
518/* run the real compiler and put the result in cache */
519static void
520to_cache(struct args *args)
521{
522 char *tmp_stdout, *tmp_stderr, *tmp_obj;
523 struct stat st;
524 int status;
525 size_t added_bytes = 0;
526 unsigned added_files = 0;
527
528 tmp_stdout = format("%s.tmp.stdout.%s", cached_obj, tmp_string());
529 tmp_stderr = format("%s.tmp.stderr.%s", cached_obj, tmp_string());
530 tmp_obj = format("%s.tmp.%s", cached_obj, tmp_string());
531
532 args_add(args, "-o");
533 args_add(args, tmp_obj);
534
535 /* Turn off DEPENDENCIES_OUTPUT when running cc1, because
536 * otherwise it will emit a line like
537 *
538 * tmp.stdout.vexed.732.o: /home/mbp/.ccache/tmp.stdout.vexed.732.i
539 *
540 * unsetenv() is on BSD and Linux but not portable. */
541 putenv("DEPENDENCIES_OUTPUT");
542
543 if (compile_preprocessed_source_code) {
544 args_add(args, i_tmpfile);
545 } else {
546 args_add(args, input_file);
547 }
548
549 cc_log("Running real compiler");
550 status = execute(args->argv, tmp_stdout, tmp_stderr);
551 args_pop(args, 3);
552
553 if (stat(tmp_stdout, &st) != 0) {
554 /* The stdout file was removed - cleanup in progress? Better bail out. */
555 cc_log("%s not found: %s", tmp_stdout, strerror(errno(*__errno_location ())));
556 stats_update(STATS_MISSING);
557 tmp_unlink(tmp_stdout);
558 tmp_unlink(tmp_stderr);
559 tmp_unlink(tmp_obj);
560 failed();
561 }
562 if (st.st_size != 0) {
563 cc_log("Compiler produced stdout");
564 stats_update(STATS_STDOUT);
565 tmp_unlink(tmp_stdout);
566 tmp_unlink(tmp_stderr);
567 tmp_unlink(tmp_obj);
568 failed();
569 }
570 tmp_unlink(tmp_stdout);
571
572 /*
573 * Merge stderr from the preprocessor (if any) and stderr from the real
574 * compiler into tmp_stderr.
575 */
576 if (cpp_stderr) {
577 int fd_cpp_stderr;
578 int fd_real_stderr;
579 int fd_result;
580 char *tmp_stderr2;
581
582 tmp_stderr2 = format("%s.tmp.stderr2.%s", cached_obj, tmp_string());
583 if (x_rename(tmp_stderr, tmp_stderr2)) {
584 cc_log("Failed to rename %s to %s: %s", tmp_stderr, tmp_stderr2,
585 strerror(errno(*__errno_location ())));
586 failed();
587 }
588 fd_cpp_stderr = open(cpp_stderr, O_RDONLY00 | O_BINARY0);
589 if (fd_cpp_stderr == -1) {
590 cc_log("Failed opening %s: %s", cpp_stderr, strerror(errno(*__errno_location ())));
591 failed();
592 }
593 fd_real_stderr = open(tmp_stderr2, O_RDONLY00 | O_BINARY0);
594 if (fd_real_stderr == -1) {
595 cc_log("Failed opening %s: %s", tmp_stderr2, strerror(errno(*__errno_location ())));
596 failed();
597 }
598 fd_result = open(tmp_stderr, O_WRONLY01 | O_CREAT0100 | O_TRUNC01000 | O_BINARY0, 0666);
599 if (fd_result == -1) {
600 cc_log("Failed opening %s: %s", tmp_stderr, strerror(errno(*__errno_location ())));
601 failed();
602 }
603 copy_fd(fd_cpp_stderr, fd_result);
604 copy_fd(fd_real_stderr, fd_result);
605 close(fd_cpp_stderr);
606 close(fd_real_stderr);
607 close(fd_result);
608 tmp_unlink(tmp_stderr2);
609 free(tmp_stderr2);
610 }
611
612 if (status != 0) {
613 int fd;
614 cc_log("Compiler gave exit status %d", status);
615 stats_update(STATS_STATUS);
616
617 fd = open(tmp_stderr, O_RDONLY00 | O_BINARY0);
618 if (fd != -1) {
619 if (str_eq(output_obj, "/dev/null")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((output_obj)) && __builtin_constant_p (("/dev/null"
)) && (__s1_len = strlen ((output_obj)), __s2_len = strlen
(("/dev/null")), (!((size_t)(const void *)(((output_obj)) + 1
) - (size_t)(const void *)((output_obj)) == 1) || __s1_len >=
4) && (!((size_t)(const void *)((("/dev/null")) + 1)
- (size_t)(const void *)(("/dev/null")) == 1) || __s2_len >=
4)) ? __builtin_strcmp ((output_obj), ("/dev/null")) : (__builtin_constant_p
((output_obj)) && ((size_t)(const void *)(((output_obj
)) + 1) - (size_t)(const void *)((output_obj)) == 1) &&
(__s1_len = strlen ((output_obj)), __s1_len < 4) ? (__builtin_constant_p
(("/dev/null")) && ((size_t)(const void *)((("/dev/null"
)) + 1) - (size_t)(const void *)(("/dev/null")) == 1) ? __builtin_strcmp
((output_obj), ("/dev/null")) : (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (("/dev/null"
)); int __result = (((const unsigned char *) (const char *) (
(output_obj)))[0] - __s2[0]); if (__s1_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(output_obj)))[1] - __s2[1]); if (__s1_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(output_obj)))[2] - __s2[2]); if (__s1_len > 2 && __result
== 0) __result = (((const unsigned char *) (const char *) ((
output_obj)))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
(("/dev/null")) && ((size_t)(const void *)((("/dev/null"
)) + 1) - (size_t)(const void *)(("/dev/null")) == 1) &&
(__s2_len = strlen (("/dev/null")), __s2_len < 4) ? (__builtin_constant_p
((output_obj)) && ((size_t)(const void *)(((output_obj
)) + 1) - (size_t)(const void *)((output_obj)) == 1) ? __builtin_strcmp
((output_obj), ("/dev/null")) : (- (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) ((output_obj
)); int __result = (((const unsigned char *) (const char *) (
("/dev/null")))[0] - __s2[0]); if (__s2_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("/dev/null")))[1] - __s2[1]); if (__s2_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("/dev/null")))[2] - __s2[2]); if (__s2_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char
*) (("/dev/null")))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
((output_obj), ("/dev/null"))))); }) == 0)
620 || (access(tmp_obj, R_OK4) == 0
621 && move_file(tmp_obj, output_obj, 0) == 0)
622 || errno(*__errno_location ()) == ENOENT2) {
623 /* we can use a quick method of getting the failed output */
624 copy_fd(fd, 2);
625 close(fd);
626 tmp_unlink(tmp_stderr);
627 exit(status);
628 }
629 }
630
631 tmp_unlink(tmp_stderr);
632 tmp_unlink(tmp_obj);
633 failed();
634 }
635
636 if (stat(tmp_obj, &st) != 0) {
637 cc_log("Compiler didn't produce an object file");
638 stats_update(STATS_NOOUTPUT);
639 failed();
640 }
641 if (st.st_size == 0) {
642 cc_log("Compiler produced an empty object file");
643 stats_update(STATS_EMPTYOUTPUT);
644 failed();
645 }
646
647 if (stat(tmp_stderr, &st) != 0) {
648 cc_log("Failed to stat %s: %s", tmp_stderr, strerror(errno(*__errno_location ())));
649 stats_update(STATS_ERROR);
650 failed();
651 }
652 if (st.st_size > 0) {
653 if (move_uncompressed_file(tmp_stderr, cached_stderr,
654 enable_compression) != 0) {
655 cc_log("Failed to move %s to %s: %s", tmp_stderr, cached_stderr,
656 strerror(errno(*__errno_location ())));
657 stats_update(STATS_ERROR);
658 failed();
659 }
660 cc_log("Stored in cache: %s", cached_stderr);
661 if (enable_compression) {
662 stat(cached_stderr, &st);
663 }
664 added_bytes += file_size(&st);
665 added_files += 1;
666 } else {
667 tmp_unlink(tmp_stderr);
668 }
669 if (move_uncompressed_file(tmp_obj, cached_obj, enable_compression) != 0) {
670 cc_log("Failed to move %s to %s: %s", tmp_obj, cached_obj, strerror(errno(*__errno_location ())));
671 stats_update(STATS_ERROR);
672 failed();
673 } else {
674 cc_log("Stored in cache: %s", cached_obj);
675 stat(cached_obj, &st);
676 added_bytes += file_size(&st);
677 added_files += 1;
678 }
679
680 /*
681 * Do an extra stat on the potentially compressed object file for the
682 * size statistics.
683 */
684 if (stat(cached_obj, &st) != 0) {
685 cc_log("Failed to stat %s: %s", cached_obj, strerror(errno(*__errno_location ())));
686 stats_update(STATS_ERROR);
687 failed();
688 }
689
690 stats_update_size(STATS_TOCACHE, added_bytes / 1024, added_files);
691
692 free(tmp_obj);
693 free(tmp_stderr);
694 free(tmp_stdout);
695}
696
697/*
698 * Find the object file name by running the compiler in preprocessor mode.
699 * Returns the hash as a heap-allocated hex string.
700 */
701static struct file_hash *
702get_object_name_from_cpp(struct args *args, struct mdfour *hash)
703{
704 char *input_base;
705 char *tmp;
706 char *path_stdout, *path_stderr;
707 int status;
708 struct file_hash *result;
709
710 /* ~/hello.c -> tmp.hello.123.i
711 limit the basename to 10
712 characters in order to cope with filesystem with small
713 maximum filename length limits */
714 input_base = basename(input_file);
715 tmp = strchr(input_base, '.')(__extension__ (__builtin_constant_p ('.') && !__builtin_constant_p
(input_base) && ('.') == '\0' ? (char *) __rawmemchr
(input_base, '.') : __builtin_strchr (input_base, '.')))
;
716 if (tmp != NULL((void*)0)) {
717 *tmp = 0;
718 }
719 if (strlen(input_base) > 10) {
720 input_base[10] = 0;
721 }
722
723 /* now the run */
724 path_stdout = format("%s/%s.tmp.%s.%s",
725 temp_dir, input_base, tmp_string(), i_extension);
726 path_stderr = format("%s/tmp.cpp_stderr.%s", temp_dir, tmp_string());
727
728 time_of_compilation = time(NULL((void*)0));
729
730 if (!direct_i_file) {
731 /* run cpp on the input file to obtain the .i */
732 args_add(args, "-E");
733 args_add(args, input_file);
734 status = execute(args->argv, path_stdout, path_stderr);
735 args_pop(args, 2);
736 } else {
737 /* we are compiling a .i or .ii file - that means we
738 can skip the cpp stage and directly form the
739 correct i_tmpfile */
740 path_stdout = input_file;
741 if (create_empty_file(path_stderr) != 0) {
742 cc_log("Failed to create %s: %s", path_stderr, strerror(errno(*__errno_location ())));
743 stats_update(STATS_ERROR);
744 failed();
745 }
746 status = 0;
747 }
748
749 if (status != 0) {
750 if (!direct_i_file) {
751 tmp_unlink(path_stdout);
752 }
753 tmp_unlink(path_stderr);
754 cc_log("Preprocessor gave exit status %d", status);
755 stats_update(STATS_PREPROCESSOR);
756 failed();
757 }
758
759 if (enable_unify) {
760 /*
761 * When we are doing the unifying tricks we need to include the
762 * input file name in the hash to get the warnings right.
763 */
764 hash_delimiter(hash, "unifyfilename");
765 hash_string(hash, input_file);
766
767 hash_delimiter(hash, "unifycpp");
768 if (unify_hash(hash, path_stdout) != 0) {
769 stats_update(STATS_ERROR);
770 tmp_unlink(path_stderr);
771 cc_log("Failed to unify %s", path_stdout);
772 failed();
773 }
774 } else {
775 hash_delimiter(hash, "cpp");
776 if (!process_preprocessed_file(hash, path_stdout)) {
777 stats_update(STATS_ERROR);
778 tmp_unlink(path_stderr);
779 failed();
780 }
781 }
782
783 hash_delimiter(hash, "cppstderr");
784 if (!hash_file(hash, path_stderr)) {
785 fatal("Failed to open %s: %s", path_stderr, strerror(errno(*__errno_location ())));
786 }
787
788 i_tmpfile = path_stdout;
789
790 if (compile_preprocessed_source_code) {
791 /*
792 * If we are using the CPP trick, we need to remember this
793 * stderr data and output it just before the main stderr from
794 * the compiler pass.
795 */
796 cpp_stderr = path_stderr;
797 } else {
798 tmp_unlink(path_stderr);
799 free(path_stderr);
800 }
801
802 result = x_malloc(sizeof(*result));
803 hash_result_as_bytes(hash, result->hash);
804 result->size = hash->totalN;
805 return result;
806}
807
808static void
809update_cached_result_globals(struct file_hash *hash)
810{
811 char *object_name;
812
813 object_name = format_hash_as_string(hash->hash, hash->size);
32
Access to field 'size' results in a dereference of a null pointer (loaded from variable 'hash')
814 cached_obj_hash = hash;
815 cached_obj = get_path_in_cache(object_name, ".o");
816 cached_stderr = get_path_in_cache(object_name, ".stderr");
817 cached_dep = get_path_in_cache(object_name, ".d");
818 stats_file = format("%s/%c/stats", cache_dir, object_name[0]);
819 free(object_name);
820}
821
822/*
823 * Hash mtime or content of a file, or the output of a command, according to
824 * the CCACHE_COMPILERCHECK setting.
825 */
826static void
827hash_compiler(struct mdfour *hash, struct stat *st, const char *path,
828 bool_Bool allow_command)
829{
830 const char *compilercheck;
831
832 compilercheck = getenv("CCACHE_COMPILERCHECK");
833 if (!compilercheck) {
834 compilercheck = "mtime";
835 }
836 if (str_eq(compilercheck, "none")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((compilercheck)) && __builtin_constant_p (("none"))
&& (__s1_len = strlen ((compilercheck)), __s2_len = strlen
(("none")), (!((size_t)(const void *)(((compilercheck)) + 1)
- (size_t)(const void *)((compilercheck)) == 1) || __s1_len >=
4) && (!((size_t)(const void *)((("none")) + 1) - (size_t
)(const void *)(("none")) == 1) || __s2_len >= 4)) ? __builtin_strcmp
((compilercheck), ("none")) : (__builtin_constant_p ((compilercheck
)) && ((size_t)(const void *)(((compilercheck)) + 1) -
(size_t)(const void *)((compilercheck)) == 1) && (__s1_len
= strlen ((compilercheck)), __s1_len < 4) ? (__builtin_constant_p
(("none")) && ((size_t)(const void *)((("none")) + 1
) - (size_t)(const void *)(("none")) == 1) ? __builtin_strcmp
((compilercheck), ("none")) : (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (("none"
)); int __result = (((const unsigned char *) (const char *) (
(compilercheck)))[0] - __s2[0]); if (__s1_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) ((compilercheck)))[1] - __s2[1]); if (__s1_len > 1
&& __result == 0) { __result = (((const unsigned char
*) (const char *) ((compilercheck)))[2] - __s2[2]); if (__s1_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) ((compilercheck)))[3] - __s2[3]); } }
__result; }))) : (__builtin_constant_p (("none")) &&
((size_t)(const void *)((("none")) + 1) - (size_t)(const void
*)(("none")) == 1) && (__s2_len = strlen (("none")),
__s2_len < 4) ? (__builtin_constant_p ((compilercheck)) &&
((size_t)(const void *)(((compilercheck)) + 1) - (size_t)(const
void *)((compilercheck)) == 1) ? __builtin_strcmp ((compilercheck
), ("none")) : (- (__extension__ ({ const unsigned char *__s2
= (const unsigned char *) (const char *) ((compilercheck)); int
__result = (((const unsigned char *) (const char *) (("none"
)))[0] - __s2[0]); if (__s2_len > 0 && __result ==
0) { __result = (((const unsigned char *) (const char *) (("none"
)))[1] - __s2[1]); if (__s2_len > 1 && __result ==
0) { __result = (((const unsigned char *) (const char *) (("none"
)))[2] - __s2[2]); if (__s2_len > 2 && __result ==
0) __result = (((const unsigned char *) (const char *) (("none"
)))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp ((compilercheck
), ("none"))))); }) == 0)
) {
837 /* Do nothing. */
838 } else if (str_eq(compilercheck, "mtime")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((compilercheck)) && __builtin_constant_p (("mtime")
) && (__s1_len = strlen ((compilercheck)), __s2_len =
strlen (("mtime")), (!((size_t)(const void *)(((compilercheck
)) + 1) - (size_t)(const void *)((compilercheck)) == 1) || __s1_len
>= 4) && (!((size_t)(const void *)((("mtime")) + 1
) - (size_t)(const void *)(("mtime")) == 1) || __s2_len >=
4)) ? __builtin_strcmp ((compilercheck), ("mtime")) : (__builtin_constant_p
((compilercheck)) && ((size_t)(const void *)(((compilercheck
)) + 1) - (size_t)(const void *)((compilercheck)) == 1) &&
(__s1_len = strlen ((compilercheck)), __s1_len < 4) ? (__builtin_constant_p
(("mtime")) && ((size_t)(const void *)((("mtime")) +
1) - (size_t)(const void *)(("mtime")) == 1) ? __builtin_strcmp
((compilercheck), ("mtime")) : (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (("mtime"
)); int __result = (((const unsigned char *) (const char *) (
(compilercheck)))[0] - __s2[0]); if (__s1_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) ((compilercheck)))[1] - __s2[1]); if (__s1_len > 1
&& __result == 0) { __result = (((const unsigned char
*) (const char *) ((compilercheck)))[2] - __s2[2]); if (__s1_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) ((compilercheck)))[3] - __s2[3]); } }
__result; }))) : (__builtin_constant_p (("mtime")) &&
((size_t)(const void *)((("mtime")) + 1) - (size_t)(const void
*)(("mtime")) == 1) && (__s2_len = strlen (("mtime")
), __s2_len < 4) ? (__builtin_constant_p ((compilercheck))
&& ((size_t)(const void *)(((compilercheck)) + 1) - (
size_t)(const void *)((compilercheck)) == 1) ? __builtin_strcmp
((compilercheck), ("mtime")) : (- (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) ((compilercheck
)); int __result = (((const unsigned char *) (const char *) (
("mtime")))[0] - __s2[0]); if (__s2_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
("mtime")))[1] - __s2[1]); if (__s2_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
("mtime")))[2] - __s2[2]); if (__s2_len > 2 && __result
== 0) __result = (((const unsigned char *) (const char *) ((
"mtime")))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
((compilercheck), ("mtime"))))); }) == 0)
) {
839 hash_delimiter(hash, "cc_mtime");
840 hash_int(hash, st->st_size);
841 hash_int(hash, st->st_mtimest_mtim.tv_sec);
842 } else if (str_eq(compilercheck, "content")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((compilercheck)) && __builtin_constant_p (("content"
)) && (__s1_len = strlen ((compilercheck)), __s2_len =
strlen (("content")), (!((size_t)(const void *)(((compilercheck
)) + 1) - (size_t)(const void *)((compilercheck)) == 1) || __s1_len
>= 4) && (!((size_t)(const void *)((("content")) +
1) - (size_t)(const void *)(("content")) == 1) || __s2_len >=
4)) ? __builtin_strcmp ((compilercheck), ("content")) : (__builtin_constant_p
((compilercheck)) && ((size_t)(const void *)(((compilercheck
)) + 1) - (size_t)(const void *)((compilercheck)) == 1) &&
(__s1_len = strlen ((compilercheck)), __s1_len < 4) ? (__builtin_constant_p
(("content")) && ((size_t)(const void *)((("content"
)) + 1) - (size_t)(const void *)(("content")) == 1) ? __builtin_strcmp
((compilercheck), ("content")) : (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (("content"
)); int __result = (((const unsigned char *) (const char *) (
(compilercheck)))[0] - __s2[0]); if (__s1_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) ((compilercheck)))[1] - __s2[1]); if (__s1_len > 1
&& __result == 0) { __result = (((const unsigned char
*) (const char *) ((compilercheck)))[2] - __s2[2]); if (__s1_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) ((compilercheck)))[3] - __s2[3]); } }
__result; }))) : (__builtin_constant_p (("content")) &&
((size_t)(const void *)((("content")) + 1) - (size_t)(const void
*)(("content")) == 1) && (__s2_len = strlen (("content"
)), __s2_len < 4) ? (__builtin_constant_p ((compilercheck)
) && ((size_t)(const void *)(((compilercheck)) + 1) -
(size_t)(const void *)((compilercheck)) == 1) ? __builtin_strcmp
((compilercheck), ("content")) : (- (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) ((compilercheck
)); int __result = (((const unsigned char *) (const char *) (
("content")))[0] - __s2[0]); if (__s2_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
("content")))[1] - __s2[1]); if (__s2_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
("content")))[2] - __s2[2]); if (__s2_len > 2 && __result
== 0) __result = (((const unsigned char *) (const char *) ((
"content")))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
((compilercheck), ("content"))))); }) == 0)
|| !allow_command) {
843 hash_delimiter(hash, "cc_content");
844 hash_file(hash, path);
845 } else { /* command string */
846 if (!hash_multicommand_output(hash, compilercheck, orig_args->argv[0])) {
847 fatal("Failure running compiler check command: %s", compilercheck);
848 }
849 }
850}
851
852/*
853 * Update a hash sum with information common for the direct and preprocessor
854 * modes.
855 */
856static void
857calculate_common_hash(struct args *args, struct mdfour *hash)
858{
859 struct stat st;
860 char *p;
861
862 hash_string(hash, HASH_PREFIX);
863
864 /*
865 * We have to hash the extension, as a .i file isn't treated the same
866 * by the compiler as a .ii file.
867 */
868 hash_delimiter(hash, "ext");
869 hash_string(hash, i_extension);
870
871 if (stat(args->argv[0], &st) != 0) {
872 cc_log("Couldn't stat compiler %s: %s", args->argv[0], strerror(errno(*__errno_location ())));
873 stats_update(STATS_COMPILER);
874 failed();
875 }
876
877 /*
878 * Hash information about the compiler.
879 */
880 hash_compiler(hash, &st, args->argv[0], true1);
881
882 /*
883 * Also hash the compiler name as some compilers use hard links and
884 * behave differently depending on the real name.
885 */
886 hash_delimiter(hash, "cc_name");
887 p = basename(args->argv[0]);
888 hash_string(hash, p);
889 free(p);
890
891 /* Possibly hash the current working directory. */
892 if (getenv("CCACHE_HASHDIR")) {
893 char *cwd = gnu_getcwd();
894 if (cwd) {
895 hash_delimiter(hash, "cwd");
896 hash_string(hash, cwd);
897 free(cwd);
898 }
899 }
900
901 p = getenv("CCACHE_EXTRAFILES");
902 if (p) {
903 char *path, *q, *saveptr = NULL((void*)0);
904 p = x_strdup(p);
905 q = p;
906 while ((path = strtok_r(q, PATH_DELIM, &saveptr)(__extension__ (__builtin_constant_p (":") && ((size_t
)(const void *)((":") + 1) - (size_t)(const void *)(":") == 1
) && ((const char *) (":"))[0] != '\0' && ((const
char *) (":"))[1] == '\0' ? __strtok_r_1c (q, ((const char *
) (":"))[0], &saveptr) : __strtok_r (q, ":", &saveptr
)))
)) {
907 cc_log("Hashing extra file %s", path);
908 hash_delimiter(hash, "extrafile");
909 if (!hash_file(hash, path)) {
910 stats_update(STATS_BADEXTRAFILE);
911 failed();
912 }
913 q = NULL((void*)0);
914 }
915 free(p);
916 }
917}
918
919/*
920 * Update a hash sum with information specific to the direct and preprocessor
921 * modes and calculate the object hash. Returns the object hash on success,
922 * otherwise NULL. Caller frees.
923 */
924static struct file_hash *
925calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
926{
927 int i;
928 char *manifest_name;
929 struct stat st;
930 int result;
931 struct file_hash *object_hash = NULL((void*)0);
932 char *p;
933
934 /* first the arguments */
935 for (i = 1; i < args->argc; i++) {
936 /* -L doesn't affect compilation. */
937 if (i < args->argc-1 && str_eq(args->argv[i], "-L")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((args->argv[i])) && __builtin_constant_p (("-L")
) && (__s1_len = strlen ((args->argv[i])), __s2_len
= strlen (("-L")), (!((size_t)(const void *)(((args->argv
[i])) + 1) - (size_t)(const void *)((args->argv[i])) == 1)
|| __s1_len >= 4) && (!((size_t)(const void *)(((
"-L")) + 1) - (size_t)(const void *)(("-L")) == 1) || __s2_len
>= 4)) ? __builtin_strcmp ((args->argv[i]), ("-L")) : (
__builtin_constant_p ((args->argv[i])) && ((size_t
)(const void *)(((args->argv[i])) + 1) - (size_t)(const void
*)((args->argv[i])) == 1) && (__s1_len = strlen (
(args->argv[i])), __s1_len < 4) ? (__builtin_constant_p
(("-L")) && ((size_t)(const void *)((("-L")) + 1) - (
size_t)(const void *)(("-L")) == 1) ? __builtin_strcmp ((args
->argv[i]), ("-L")) : (__extension__ ({ const unsigned char
*__s2 = (const unsigned char *) (const char *) (("-L")); int
__result = (((const unsigned char *) (const char *) ((args->
argv[i])))[0] - __s2[0]); if (__s1_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(args->argv[i])))[1] - __s2[1]); if (__s1_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) ((args->argv[i])))[2] - __s2[2]); if (__s1_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) ((args->argv[i])))[3] - __s2[3]); } } __result
; }))) : (__builtin_constant_p (("-L")) && ((size_t)(
const void *)((("-L")) + 1) - (size_t)(const void *)(("-L")) ==
1) && (__s2_len = strlen (("-L")), __s2_len < 4) ?
(__builtin_constant_p ((args->argv[i])) && ((size_t
)(const void *)(((args->argv[i])) + 1) - (size_t)(const void
*)((args->argv[i])) == 1) ? __builtin_strcmp ((args->argv
[i]), ("-L")) : (- (__extension__ ({ const unsigned char *__s2
= (const unsigned char *) (const char *) ((args->argv[i])
); int __result = (((const unsigned char *) (const char *) ((
"-L")))[0] - __s2[0]); if (__s2_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
("-L")))[1] - __s2[1]); if (__s2_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
("-L")))[2] - __s2[2]); if (__s2_len > 2 && __result
== 0) __result = (((const unsigned char *) (const char *) ((
"-L")))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
((args->argv[i]), ("-L"))))); }) == 0)
) {
938 i++;
939 continue;
940 }
941 if (str_startswith(args->argv[i], "-L")((__extension__ (__builtin_constant_p (strlen(("-L"))) &&
((__builtin_constant_p ((args->argv[i])) && strlen
((args->argv[i])) < ((size_t) (strlen(("-L"))))) || (__builtin_constant_p
(("-L")) && strlen (("-L")) < ((size_t) (strlen((
"-L")))))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((args->argv[i])) && __builtin_constant_p (("-L")
) && (__s1_len = strlen ((args->argv[i])), __s2_len
= strlen (("-L")), (!((size_t)(const void *)(((args->argv
[i])) + 1) - (size_t)(const void *)((args->argv[i])) == 1)
|| __s1_len >= 4) && (!((size_t)(const void *)(((
"-L")) + 1) - (size_t)(const void *)(("-L")) == 1) || __s2_len
>= 4)) ? __builtin_strcmp ((args->argv[i]), ("-L")) : (
__builtin_constant_p ((args->argv[i])) && ((size_t
)(const void *)(((args->argv[i])) + 1) - (size_t)(const void
*)((args->argv[i])) == 1) && (__s1_len = strlen (
(args->argv[i])), __s1_len < 4) ? (__builtin_constant_p
(("-L")) && ((size_t)(const void *)((("-L")) + 1) - (
size_t)(const void *)(("-L")) == 1) ? __builtin_strcmp ((args
->argv[i]), ("-L")) : (__extension__ ({ const unsigned char
*__s2 = (const unsigned char *) (const char *) (("-L")); int
__result = (((const unsigned char *) (const char *) ((args->
argv[i])))[0] - __s2[0]); if (__s1_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(args->argv[i])))[1] - __s2[1]); if (__s1_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) ((args->argv[i])))[2] - __s2[2]); if (__s1_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) ((args->argv[i])))[3] - __s2[3]); } } __result
; }))) : (__builtin_constant_p (("-L")) && ((size_t)(
const void *)((("-L")) + 1) - (size_t)(const void *)(("-L")) ==
1) && (__s2_len = strlen (("-L")), __s2_len < 4) ?
(__builtin_constant_p ((args->argv[i])) && ((size_t
)(const void *)(((args->argv[i])) + 1) - (size_t)(const void
*)((args->argv[i])) == 1) ? __builtin_strcmp ((args->argv
[i]), ("-L")) : (- (__extension__ ({ const unsigned char *__s2
= (const unsigned char *) (const char *) ((args->argv[i])
); int __result = (((const unsigned char *) (const char *) ((
"-L")))[0] - __s2[0]); if (__s2_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
("-L")))[1] - __s2[1]); if (__s2_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
("-L")))[2] - __s2[2]); if (__s2_len > 2 && __result
== 0) __result = (((const unsigned char *) (const char *) ((
"-L")))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
((args->argv[i]), ("-L"))))); }) : strncmp ((args->argv
[i]), ("-L"), strlen(("-L"))))) == 0)
) {
942 continue;
943 }
944
945 /* When using the preprocessor, some arguments don't contribute
946 to the hash. The theory is that these arguments will change
947 the output of -E if they are going to have any effect at
948 all. For precompiled headers this might not be the case. */
949 if (!direct_mode && !output_is_precompiled_header
950 && !using_precompiled_header) {
951 if (compopt_affects_cpp(args->argv[i])) {
952 i++;
953 continue;
954 }
955 if (compopt_short(compopt_affects_cpp, args->argv[i])) {
956 continue;
957 }
958 }
959
960 p = NULL((void*)0);
961 if (str_startswith(args->argv[i], "-specs=")((__extension__ (__builtin_constant_p (strlen(("-specs="))) &&
((__builtin_constant_p ((args->argv[i])) && strlen
((args->argv[i])) < ((size_t) (strlen(("-specs="))))) ||
(__builtin_constant_p (("-specs=")) && strlen (("-specs="
)) < ((size_t) (strlen(("-specs=")))))) ? __extension__ ({
size_t __s1_len, __s2_len; (__builtin_constant_p ((args->
argv[i])) && __builtin_constant_p (("-specs=")) &&
(__s1_len = strlen ((args->argv[i])), __s2_len = strlen (
("-specs=")), (!((size_t)(const void *)(((args->argv[i])) +
1) - (size_t)(const void *)((args->argv[i])) == 1) || __s1_len
>= 4) && (!((size_t)(const void *)((("-specs=")) +
1) - (size_t)(const void *)(("-specs=")) == 1) || __s2_len >=
4)) ? __builtin_strcmp ((args->argv[i]), ("-specs=")) : (
__builtin_constant_p ((args->argv[i])) && ((size_t
)(const void *)(((args->argv[i])) + 1) - (size_t)(const void
*)((args->argv[i])) == 1) && (__s1_len = strlen (
(args->argv[i])), __s1_len < 4) ? (__builtin_constant_p
(("-specs=")) && ((size_t)(const void *)((("-specs="
)) + 1) - (size_t)(const void *)(("-specs=")) == 1) ? __builtin_strcmp
((args->argv[i]), ("-specs=")) : (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (("-specs="
)); int __result = (((const unsigned char *) (const char *) (
(args->argv[i])))[0] - __s2[0]); if (__s1_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) ((args->argv[i])))[1] - __s2[1]); if (__s1_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) ((args->argv[i])))[2] - __s2[2]); if (__s1_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) ((args->argv[i])))[3] - __s2[3]); }
} __result; }))) : (__builtin_constant_p (("-specs=")) &&
((size_t)(const void *)((("-specs=")) + 1) - (size_t)(const void
*)(("-specs=")) == 1) && (__s2_len = strlen (("-specs="
)), __s2_len < 4) ? (__builtin_constant_p ((args->argv[
i])) && ((size_t)(const void *)(((args->argv[i])) +
1) - (size_t)(const void *)((args->argv[i])) == 1) ? __builtin_strcmp
((args->argv[i]), ("-specs=")) : (- (__extension__ ({ const
unsigned char *__s2 = (const unsigned char *) (const char *)
((args->argv[i])); int __result = (((const unsigned char *
) (const char *) (("-specs=")))[0] - __s2[0]); if (__s2_len >
0 && __result == 0) { __result = (((const unsigned char
*) (const char *) (("-specs=")))[1] - __s2[1]); if (__s2_len
> 1 && __result == 0) { __result = (((const unsigned
char *) (const char *) (("-specs=")))[2] - __s2[2]); if (__s2_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) (("-specs=")))[3] - __s2[3]); } } __result
; })))) : __builtin_strcmp ((args->argv[i]), ("-specs=")))
)); }) : strncmp ((args->argv[i]), ("-specs="), strlen(("-specs="
))))) == 0)
) {
962 p = args->argv[i] + 7;
963 } else if (str_startswith(args->argv[i], "--specs=")((__extension__ (__builtin_constant_p (strlen(("--specs="))) &&
((__builtin_constant_p ((args->argv[i])) && strlen
((args->argv[i])) < ((size_t) (strlen(("--specs=")))))
|| (__builtin_constant_p (("--specs=")) && strlen ((
"--specs=")) < ((size_t) (strlen(("--specs=")))))) ? __extension__
({ size_t __s1_len, __s2_len; (__builtin_constant_p ((args->
argv[i])) && __builtin_constant_p (("--specs=")) &&
(__s1_len = strlen ((args->argv[i])), __s2_len = strlen (
("--specs=")), (!((size_t)(const void *)(((args->argv[i]))
+ 1) - (size_t)(const void *)((args->argv[i])) == 1) || __s1_len
>= 4) && (!((size_t)(const void *)((("--specs="))
+ 1) - (size_t)(const void *)(("--specs=")) == 1) || __s2_len
>= 4)) ? __builtin_strcmp ((args->argv[i]), ("--specs="
)) : (__builtin_constant_p ((args->argv[i])) && ((
size_t)(const void *)(((args->argv[i])) + 1) - (size_t)(const
void *)((args->argv[i])) == 1) && (__s1_len = strlen
((args->argv[i])), __s1_len < 4) ? (__builtin_constant_p
(("--specs=")) && ((size_t)(const void *)((("--specs="
)) + 1) - (size_t)(const void *)(("--specs=")) == 1) ? __builtin_strcmp
((args->argv[i]), ("--specs=")) : (__extension__ ({ const
unsigned char *__s2 = (const unsigned char *) (const char *)
(("--specs=")); int __result = (((const unsigned char *) (const
char *) ((args->argv[i])))[0] - __s2[0]); if (__s1_len >
0 && __result == 0) { __result = (((const unsigned char
*) (const char *) ((args->argv[i])))[1] - __s2[1]); if (__s1_len
> 1 && __result == 0) { __result = (((const unsigned
char *) (const char *) ((args->argv[i])))[2] - __s2[2]); if
(__s1_len > 2 && __result == 0) __result = (((const
unsigned char *) (const char *) ((args->argv[i])))[3] - __s2
[3]); } } __result; }))) : (__builtin_constant_p (("--specs="
)) && ((size_t)(const void *)((("--specs=")) + 1) - (
size_t)(const void *)(("--specs=")) == 1) && (__s2_len
= strlen (("--specs=")), __s2_len < 4) ? (__builtin_constant_p
((args->argv[i])) && ((size_t)(const void *)(((args
->argv[i])) + 1) - (size_t)(const void *)((args->argv[i
])) == 1) ? __builtin_strcmp ((args->argv[i]), ("--specs="
)) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) ((args->argv[i])); int __result = (
((const unsigned char *) (const char *) (("--specs=")))[0] - __s2
[0]); if (__s2_len > 0 && __result == 0) { __result
= (((const unsigned char *) (const char *) (("--specs=")))[1
] - __s2[1]); if (__s2_len > 1 && __result == 0) {
__result = (((const unsigned char *) (const char *) (("--specs="
)))[2] - __s2[2]); if (__s2_len > 2 && __result ==
0) __result = (((const unsigned char *) (const char *) (("--specs="
)))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp ((args
->argv[i]), ("--specs="))))); }) : strncmp ((args->argv
[i]), ("--specs="), strlen(("--specs="))))) == 0)
) {
964 p = args->argv[i] + 8;
965 }
966 if (p && stat(p, &st) == 0) {
967 /* If given an explicit specs file, then hash that file,
968 but don't include the path to it in the hash. */
969 hash_delimiter(hash, "specs");
970 hash_compiler(hash, &st, p, false0);
971 continue;
972 }
973
974 if (str_startswith(args->argv[i], "-fplugin=")((__extension__ (__builtin_constant_p (strlen(("-fplugin=")))
&& ((__builtin_constant_p ((args->argv[i])) &&
strlen ((args->argv[i])) < ((size_t) (strlen(("-fplugin="
))))) || (__builtin_constant_p (("-fplugin=")) && strlen
(("-fplugin=")) < ((size_t) (strlen(("-fplugin=")))))) ? __extension__
({ size_t __s1_len, __s2_len; (__builtin_constant_p ((args->
argv[i])) && __builtin_constant_p (("-fplugin=")) &&
(__s1_len = strlen ((args->argv[i])), __s2_len = strlen (
("-fplugin=")), (!((size_t)(const void *)(((args->argv[i])
) + 1) - (size_t)(const void *)((args->argv[i])) == 1) || __s1_len
>= 4) && (!((size_t)(const void *)((("-fplugin=")
) + 1) - (size_t)(const void *)(("-fplugin=")) == 1) || __s2_len
>= 4)) ? __builtin_strcmp ((args->argv[i]), ("-fplugin="
)) : (__builtin_constant_p ((args->argv[i])) && ((
size_t)(const void *)(((args->argv[i])) + 1) - (size_t)(const
void *)((args->argv[i])) == 1) && (__s1_len = strlen
((args->argv[i])), __s1_len < 4) ? (__builtin_constant_p
(("-fplugin=")) && ((size_t)(const void *)((("-fplugin="
)) + 1) - (size_t)(const void *)(("-fplugin=")) == 1) ? __builtin_strcmp
((args->argv[i]), ("-fplugin=")) : (__extension__ ({ const
unsigned char *__s2 = (const unsigned char *) (const char *)
(("-fplugin=")); int __result = (((const unsigned char *) (const
char *) ((args->argv[i])))[0] - __s2[0]); if (__s1_len >
0 && __result == 0) { __result = (((const unsigned char
*) (const char *) ((args->argv[i])))[1] - __s2[1]); if (__s1_len
> 1 && __result == 0) { __result = (((const unsigned
char *) (const char *) ((args->argv[i])))[2] - __s2[2]); if
(__s1_len > 2 && __result == 0) __result = (((const
unsigned char *) (const char *) ((args->argv[i])))[3] - __s2
[3]); } } __result; }))) : (__builtin_constant_p (("-fplugin="
)) && ((size_t)(const void *)((("-fplugin=")) + 1) - (
size_t)(const void *)(("-fplugin=")) == 1) && (__s2_len
= strlen (("-fplugin=")), __s2_len < 4) ? (__builtin_constant_p
((args->argv[i])) && ((size_t)(const void *)(((args
->argv[i])) + 1) - (size_t)(const void *)((args->argv[i
])) == 1) ? __builtin_strcmp ((args->argv[i]), ("-fplugin="
)) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) ((args->argv[i])); int __result = (
((const unsigned char *) (const char *) (("-fplugin=")))[0] -
__s2[0]); if (__s2_len > 0 && __result == 0) { __result
= (((const unsigned char *) (const char *) (("-fplugin=")))[
1] - __s2[1]); if (__s2_len > 1 && __result == 0) {
__result = (((const unsigned char *) (const char *) (("-fplugin="
)))[2] - __s2[2]); if (__s2_len > 2 && __result ==
0) __result = (((const unsigned char *) (const char *) (("-fplugin="
)))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp ((args
->argv[i]), ("-fplugin="))))); }) : strncmp ((args->argv
[i]), ("-fplugin="), strlen(("-fplugin="))))) == 0)
975 && stat(args->argv[i] + 9, &st) == 0) {
976 hash_delimiter(hash, "plugin");
977 hash_compiler(hash, &st, args->argv[i] + 9, false0);
978 continue;
979 }
980
981 if (str_eq(args->argv[i], "-Xclang")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((args->argv[i])) && __builtin_constant_p (("-Xclang"
)) && (__s1_len = strlen ((args->argv[i])), __s2_len
= strlen (("-Xclang")), (!((size_t)(const void *)(((args->
argv[i])) + 1) - (size_t)(const void *)((args->argv[i])) ==
1) || __s1_len >= 4) && (!((size_t)(const void *)
((("-Xclang")) + 1) - (size_t)(const void *)(("-Xclang")) == 1
) || __s2_len >= 4)) ? __builtin_strcmp ((args->argv[i]
), ("-Xclang")) : (__builtin_constant_p ((args->argv[i])) &&
((size_t)(const void *)(((args->argv[i])) + 1) - (size_t)
(const void *)((args->argv[i])) == 1) && (__s1_len
= strlen ((args->argv[i])), __s1_len < 4) ? (__builtin_constant_p
(("-Xclang")) && ((size_t)(const void *)((("-Xclang"
)) + 1) - (size_t)(const void *)(("-Xclang")) == 1) ? __builtin_strcmp
((args->argv[i]), ("-Xclang")) : (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (("-Xclang"
)); int __result = (((const unsigned char *) (const char *) (
(args->argv[i])))[0] - __s2[0]); if (__s1_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) ((args->argv[i])))[1] - __s2[1]); if (__s1_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) ((args->argv[i])))[2] - __s2[2]); if (__s1_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) ((args->argv[i])))[3] - __s2[3]); }
} __result; }))) : (__builtin_constant_p (("-Xclang")) &&
((size_t)(const void *)((("-Xclang")) + 1) - (size_t)(const void
*)(("-Xclang")) == 1) && (__s2_len = strlen (("-Xclang"
)), __s2_len < 4) ? (__builtin_constant_p ((args->argv[
i])) && ((size_t)(const void *)(((args->argv[i])) +
1) - (size_t)(const void *)((args->argv[i])) == 1) ? __builtin_strcmp
((args->argv[i]), ("-Xclang")) : (- (__extension__ ({ const
unsigned char *__s2 = (const unsigned char *) (const char *)
((args->argv[i])); int __result = (((const unsigned char *
) (const char *) (("-Xclang")))[0] - __s2[0]); if (__s2_len >
0 && __result == 0) { __result = (((const unsigned char
*) (const char *) (("-Xclang")))[1] - __s2[1]); if (__s2_len
> 1 && __result == 0) { __result = (((const unsigned
char *) (const char *) (("-Xclang")))[2] - __s2[2]); if (__s2_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) (("-Xclang")))[3] - __s2[3]); } } __result
; })))) : __builtin_strcmp ((args->argv[i]), ("-Xclang")))
)); }) == 0)
982 && i + 3 < args->argc
983 && str_eq(args->argv[i+1], "-load")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((args->argv[i+1])) && __builtin_constant_p (("-load"
)) && (__s1_len = strlen ((args->argv[i+1])), __s2_len
= strlen (("-load")), (!((size_t)(const void *)(((args->argv
[i+1])) + 1) - (size_t)(const void *)((args->argv[i+1])) ==
1) || __s1_len >= 4) && (!((size_t)(const void *)
((("-load")) + 1) - (size_t)(const void *)(("-load")) == 1) ||
__s2_len >= 4)) ? __builtin_strcmp ((args->argv[i+1]),
("-load")) : (__builtin_constant_p ((args->argv[i+1])) &&
((size_t)(const void *)(((args->argv[i+1])) + 1) - (size_t
)(const void *)((args->argv[i+1])) == 1) && (__s1_len
= strlen ((args->argv[i+1])), __s1_len < 4) ? (__builtin_constant_p
(("-load")) && ((size_t)(const void *)((("-load")) +
1) - (size_t)(const void *)(("-load")) == 1) ? __builtin_strcmp
((args->argv[i+1]), ("-load")) : (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (("-load"
)); int __result = (((const unsigned char *) (const char *) (
(args->argv[i+1])))[0] - __s2[0]); if (__s1_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) ((args->argv[i+1])))[1] - __s2[1]); if (__s1_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) ((args->argv[i+1])))[2] - __s2[2]); if (
__s1_len > 2 && __result == 0) __result = (((const
unsigned char *) (const char *) ((args->argv[i+1])))[3] -
__s2[3]); } } __result; }))) : (__builtin_constant_p (("-load"
)) && ((size_t)(const void *)((("-load")) + 1) - (size_t
)(const void *)(("-load")) == 1) && (__s2_len = strlen
(("-load")), __s2_len < 4) ? (__builtin_constant_p ((args
->argv[i+1])) && ((size_t)(const void *)(((args->
argv[i+1])) + 1) - (size_t)(const void *)((args->argv[i+1]
)) == 1) ? __builtin_strcmp ((args->argv[i+1]), ("-load"))
: (- (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) ((args->argv[i+1])); int __result =
(((const unsigned char *) (const char *) (("-load")))[0] - __s2
[0]); if (__s2_len > 0 && __result == 0) { __result
= (((const unsigned char *) (const char *) (("-load")))[1] -
__s2[1]); if (__s2_len > 1 && __result == 0) { __result
= (((const unsigned char *) (const char *) (("-load")))[2] -
__s2[2]); if (__s2_len > 2 && __result == 0) __result
= (((const unsigned char *) (const char *) (("-load")))[3] -
__s2[3]); } } __result; })))) : __builtin_strcmp ((args->
argv[i+1]), ("-load"))))); }) == 0)
984 && str_eq(args->argv[i+2], "-Xclang")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((args->argv[i+2])) && __builtin_constant_p (("-Xclang"
)) && (__s1_len = strlen ((args->argv[i+2])), __s2_len
= strlen (("-Xclang")), (!((size_t)(const void *)(((args->
argv[i+2])) + 1) - (size_t)(const void *)((args->argv[i+2]
)) == 1) || __s1_len >= 4) && (!((size_t)(const void
*)((("-Xclang")) + 1) - (size_t)(const void *)(("-Xclang")) ==
1) || __s2_len >= 4)) ? __builtin_strcmp ((args->argv[
i+2]), ("-Xclang")) : (__builtin_constant_p ((args->argv[i
+2])) && ((size_t)(const void *)(((args->argv[i+2]
)) + 1) - (size_t)(const void *)((args->argv[i+2])) == 1) &&
(__s1_len = strlen ((args->argv[i+2])), __s1_len < 4) ?
(__builtin_constant_p (("-Xclang")) && ((size_t)(const
void *)((("-Xclang")) + 1) - (size_t)(const void *)(("-Xclang"
)) == 1) ? __builtin_strcmp ((args->argv[i+2]), ("-Xclang"
)) : (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) (("-Xclang")); int __result = (((const
unsigned char *) (const char *) ((args->argv[i+2])))[0] -
__s2[0]); if (__s1_len > 0 && __result == 0) { __result
= (((const unsigned char *) (const char *) ((args->argv[i
+2])))[1] - __s2[1]); if (__s1_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(args->argv[i+2])))[2] - __s2[2]); if (__s1_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char
*) ((args->argv[i+2])))[3] - __s2[3]); } } __result; })))
: (__builtin_constant_p (("-Xclang")) && ((size_t)(const
void *)((("-Xclang")) + 1) - (size_t)(const void *)(("-Xclang"
)) == 1) && (__s2_len = strlen (("-Xclang")), __s2_len
< 4) ? (__builtin_constant_p ((args->argv[i+2])) &&
((size_t)(const void *)(((args->argv[i+2])) + 1) - (size_t
)(const void *)((args->argv[i+2])) == 1) ? __builtin_strcmp
((args->argv[i+2]), ("-Xclang")) : (- (__extension__ ({ const
unsigned char *__s2 = (const unsigned char *) (const char *)
((args->argv[i+2])); int __result = (((const unsigned char
*) (const char *) (("-Xclang")))[0] - __s2[0]); if (__s2_len
> 0 && __result == 0) { __result = (((const unsigned
char *) (const char *) (("-Xclang")))[1] - __s2[1]); if (__s2_len
> 1 && __result == 0) { __result = (((const unsigned
char *) (const char *) (("-Xclang")))[2] - __s2[2]); if (__s2_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) (("-Xclang")))[3] - __s2[3]); } } __result
; })))) : __builtin_strcmp ((args->argv[i+2]), ("-Xclang")
)))); }) == 0)
985 && stat(args->argv[i+3], &st) == 0) {
986 hash_delimiter(hash, "plugin");
987 hash_compiler(hash, &st, args->argv[i+3], false0);
988 continue;
989 }
990
991 /* All other arguments are included in the hash. */
992 hash_delimiter(hash, "arg");
993 hash_string(hash, args->argv[i]);
994 }
995
996 if (direct_mode) {
997 /* Hash environment variables that affect the preprocessor output. */
998 const char **p;
999 const char *envvars[] = {
1000 "CPATH",
1001 "C_INCLUDE_PATH",
1002 "CPLUS_INCLUDE_PATH",
1003 "OBJC_INCLUDE_PATH",
1004 "OBJCPLUS_INCLUDE_PATH", /* clang */
1005 NULL((void*)0)
1006 };
1007 for (p = envvars; *p != NULL((void*)0) ; ++p) {
1008 char *v = getenv(*p);
1009 if (v) {
1010 hash_delimiter(hash, *p);
1011 hash_string(hash, v);
1012 }
1013 }
1014
1015 if (!(sloppiness & SLOPPY_FILE_MACRO2)) {
1016 /*
1017 * The source code file or an include file may contain
1018 * __FILE__, so make sure that the hash is unique for
1019 * the file name.
1020 */
1021 hash_delimiter(hash, "inputfile");
1022 hash_string(hash, input_file);
1023 }
1024
1025 hash_delimiter(hash, "sourcecode");
1026 result = hash_source_code_file(hash, input_file);
1027 if (result & HASH_SOURCE_CODE_ERROR1) {
1028 failed();
1029 }
1030 if (result & HASH_SOURCE_CODE_FOUND_TIME4) {
1031 cc_log("Disabling direct mode");
1032 enable_direct = false0;
1033 return NULL((void*)0);
1034 }
1035 manifest_name = hash_result(hash);
1036 manifest_path = get_path_in_cache(manifest_name, ".manifest");
1037 free(manifest_name);
1038 cc_log("Looking for object file hash in %s", manifest_path);
1039 object_hash = manifest_get(manifest_path);
1040 if (object_hash) {
1041 cc_log("Got object file hash from manifest");
1042 } else {
1043 cc_log("Did not find object file hash in manifest");
1044 }
1045 } else {
1046 object_hash = get_object_name_from_cpp(args, hash);
1047 cc_log("Got object file hash from preprocessor");
1048 if (generating_dependencies) {
1049 cc_log("Preprocessor created %s", output_dep);
1050 }
1051 }
1052
1053 return object_hash;
1054}
1055
1056/*
1057 * Try to return the compile result from cache. If we can return from cache
1058 * then this function exits with the correct status code, otherwise it returns.
1059 */
1060static void
1061from_cache(enum fromcache_call_mode mode, bool_Bool put_object_in_manifest)
1062{
1063 int fd_stderr;
1064 int ret;
1065 struct stat st;
1066 bool_Bool produce_dep_file;
1067
1068 /* the user might be disabling cache hits */
1069 if (mode != FROMCACHE_COMPILED_MODE && getenv("CCACHE_RECACHE")) {
1070 return;
1071 }
1072
1073 /* Check if the object file is there. */
1074 if (stat(cached_obj, &st) != 0) {
1075 cc_log("Object file %s not in cache", cached_obj);
1076 return;
1077 }
1078
1079 /*
1080 * (If mode != FROMCACHE_DIRECT_MODE, the dependency file is created by
1081 * gcc.)
1082 */
1083 produce_dep_file = generating_dependencies && mode == FROMCACHE_DIRECT_MODE;
1084
1085 /* If the dependency file should be in the cache, check that it is. */
1086 if (produce_dep_file && stat(cached_dep, &st) != 0) {
1087 cc_log("Dependency file %s missing in cache", cached_dep);
1088 return;
1089 }
1090
1091 if (str_eq(output_obj, "/dev/null")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((output_obj)) && __builtin_constant_p (("/dev/null"
)) && (__s1_len = strlen ((output_obj)), __s2_len = strlen
(("/dev/null")), (!((size_t)(const void *)(((output_obj)) + 1
) - (size_t)(const void *)((output_obj)) == 1) || __s1_len >=
4) && (!((size_t)(const void *)((("/dev/null")) + 1)
- (size_t)(const void *)(("/dev/null")) == 1) || __s2_len >=
4)) ? __builtin_strcmp ((output_obj), ("/dev/null")) : (__builtin_constant_p
((output_obj)) && ((size_t)(const void *)(((output_obj
)) + 1) - (size_t)(const void *)((output_obj)) == 1) &&
(__s1_len = strlen ((output_obj)), __s1_len < 4) ? (__builtin_constant_p
(("/dev/null")) && ((size_t)(const void *)((("/dev/null"
)) + 1) - (size_t)(const void *)(("/dev/null")) == 1) ? __builtin_strcmp
((output_obj), ("/dev/null")) : (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (("/dev/null"
)); int __result = (((const unsigned char *) (const char *) (
(output_obj)))[0] - __s2[0]); if (__s1_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(output_obj)))[1] - __s2[1]); if (__s1_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(output_obj)))[2] - __s2[2]); if (__s1_len > 2 && __result
== 0) __result = (((const unsigned char *) (const char *) ((
output_obj)))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
(("/dev/null")) && ((size_t)(const void *)((("/dev/null"
)) + 1) - (size_t)(const void *)(("/dev/null")) == 1) &&
(__s2_len = strlen (("/dev/null")), __s2_len < 4) ? (__builtin_constant_p
((output_obj)) && ((size_t)(const void *)(((output_obj
)) + 1) - (size_t)(const void *)((output_obj)) == 1) ? __builtin_strcmp
((output_obj), ("/dev/null")) : (- (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) ((output_obj
)); int __result = (((const unsigned char *) (const char *) (
("/dev/null")))[0] - __s2[0]); if (__s2_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("/dev/null")))[1] - __s2[1]); if (__s2_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("/dev/null")))[2] - __s2[2]); if (__s2_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char
*) (("/dev/null")))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
((output_obj), ("/dev/null"))))); }) == 0)
) {
1092 ret = 0;
1093 } else {
1094 x_unlink(output_obj);
1095 /* only make a hardlink if the cache file is uncompressed */
1096 if (getenv("CCACHE_HARDLINK") && !file_is_compressed(cached_obj)) {
1097 ret = link(cached_obj, output_obj);
1098 } else {
1099 ret = copy_file(cached_obj, output_obj, 0);
1100 }
1101 }
1102
1103 if (ret == -1) {
1104 if (errno(*__errno_location ()) == ENOENT2) {
1105 /* Someone removed the file just before we began copying? */
1106 cc_log("Object file %s just disappeared from cache", cached_obj);
1107 stats_update(STATS_MISSING);
1108 } else {
1109 cc_log("Failed to copy/link %s to %s: %s",
1110 cached_obj, output_obj, strerror(errno(*__errno_location ())));
1111 stats_update(STATS_ERROR);
1112 failed();
1113 }
1114 x_unlink(output_obj);
1115 x_unlink(cached_stderr);
1116 x_unlink(cached_obj);
1117 x_unlink(cached_dep);
1118 return;
1119 } else {
1120 cc_log("Created %s from %s", output_obj, cached_obj);
1121 }
1122
1123 if (produce_dep_file) {
1124 x_unlink(output_dep);
1125 /* only make a hardlink if the cache file is uncompressed */
1126 if (getenv("CCACHE_HARDLINK") && !file_is_compressed(cached_dep)) {
1127 ret = link(cached_dep, output_dep);
1128 } else {
1129 ret = copy_file(cached_dep, output_dep, 0);
1130 }
1131 if (ret == -1) {
1132 if (errno(*__errno_location ()) == ENOENT2) {
1133 /*
1134 * Someone removed the file just before we
1135 * began copying?
1136 */
1137 cc_log("Dependency file %s just disappeared from cache", output_obj);
1138 stats_update(STATS_MISSING);
1139 } else {
1140 cc_log("Failed to copy/link %s to %s: %s",
1141 cached_dep, output_dep, strerror(errno(*__errno_location ())));
1142 stats_update(STATS_ERROR);
1143 failed();
1144 }
1145 x_unlink(output_obj);
1146 x_unlink(output_dep);
1147 x_unlink(cached_stderr);
1148 x_unlink(cached_obj);
1149 x_unlink(cached_dep);
1150 return;
1151 } else {
1152 cc_log("Created %s from %s", output_dep, cached_dep);
1153 }
1154 }
1155
1156 /* Update modification timestamps to save files from LRU cleanup.
1157 Also gives files a sensible mtime when hard-linking. */
1158 update_mtime(cached_obj);
1159 update_mtime(cached_stderr);
1160 if (produce_dep_file) {
1161 update_mtime(cached_dep);
1162 }
1163
1164 if (generating_dependencies && mode != FROMCACHE_DIRECT_MODE) {
1165 /* Store the dependency file in the cache. */
1166 ret = copy_file(output_dep, cached_dep, enable_compression);
1167 if (ret == -1) {
1168 cc_log("Failed to copy %s to %s: %s", output_dep, cached_dep,
1169 strerror(errno(*__errno_location ())));
1170 /* Continue despite the error. */
1171 } else {
1172 cc_log("Stored in cache: %s", cached_dep);
1173 stat(cached_dep, &st);
1174 stats_update_size(STATS_NONE, file_size(&st) / 1024, 1);
1175 }
1176 }
1177
1178 /* Send the stderr, if any. */
1179 fd_stderr = open(cached_stderr, O_RDONLY00 | O_BINARY0);
1180 if (fd_stderr != -1) {
1181 copy_fd(fd_stderr, 2);
1182 close(fd_stderr);
1183 }
1184
1185 /* Create or update the manifest file. */
1186 if (enable_direct
1187 && put_object_in_manifest
1188 && included_files
1189 && !getenv("CCACHE_READONLY")) {
1190 struct stat st;
1191 size_t old_size = 0; /* in bytes */
1192 if (stat(manifest_path, &st) == 0) {
1193 old_size = file_size(&st);
1194 }
1195 if (manifest_put(manifest_path, cached_obj_hash, included_files)) {
1196 cc_log("Added object file hash to %s", manifest_path);
1197 update_mtime(manifest_path);
1198 stat(manifest_path, &st);
1199 stats_update_size(STATS_NONE,
1200 (file_size(&st) - old_size) / 1024,
1201 old_size == 0 ? 1 : 0);
1202 } else {
1203 cc_log("Failed to add object file hash to %s", manifest_path);
1204 }
1205 }
1206
1207 /* log the cache hit */
1208 switch (mode) {
1209 case FROMCACHE_DIRECT_MODE:
1210 cc_log("Succeded getting cached result");
1211 stats_update(STATS_CACHEHIT_DIR);
1212 break;
1213
1214 case FROMCACHE_CPP_MODE:
1215 cc_log("Succeded getting cached result");
1216 stats_update(STATS_CACHEHIT_CPP);
1217 break;
1218
1219 case FROMCACHE_COMPILED_MODE:
1220 /* Stats already updated in to_cache(). */
1221 break;
1222 }
1223
1224 /* and exit with the right status code */
1225 exit(0);
1226}
1227
1228/* find the real compiler. We just search the PATH to find a executable of the
1229 same name that isn't a link to ourselves */
1230static void
1231find_compiler(int argc, char **argv)
1232{
1233 char *base;
1234 char *path;
1235 char *compiler;
1236
1237 orig_args = args_init(argc, argv);
1238
1239 base = basename(argv[0]);
1240
1241 /* we might be being invoked like "ccache gcc -c foo.c" */
1242 if (same_executable_name(base, MYNAME"ccache")) {
1243 args_remove_first(orig_args);
1244 free(base);
1245 if (is_full_path(argv[1])) {
1246 /* a full path was given */
1247 return;
1248 }
1249 base = basename(argv[1]);
1250 }
1251
1252 /* support user override of the compiler */
1253 if ((path = getenv("CCACHE_CC"))) {
1254 base = x_strdup(path);
1255 }
1256
1257 compiler = find_executable(base, MYNAME"ccache");
1258
1259 /* can't find the compiler! */
1260 if (!compiler) {
1261 stats_update(STATS_COMPILER);
1262 fatal("Could not find compiler \"%s\" in PATH", base);
1263 }
1264 if (str_eq(compiler, argv[0])(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((compiler)) && __builtin_constant_p ((argv[0])) &&
(__s1_len = strlen ((compiler)), __s2_len = strlen ((argv[0]
)), (!((size_t)(const void *)(((compiler)) + 1) - (size_t)(const
void *)((compiler)) == 1) || __s1_len >= 4) && (!
((size_t)(const void *)(((argv[0])) + 1) - (size_t)(const void
*)((argv[0])) == 1) || __s2_len >= 4)) ? __builtin_strcmp
((compiler), (argv[0])) : (__builtin_constant_p ((compiler))
&& ((size_t)(const void *)(((compiler)) + 1) - (size_t
)(const void *)((compiler)) == 1) && (__s1_len = strlen
((compiler)), __s1_len < 4) ? (__builtin_constant_p ((argv
[0])) && ((size_t)(const void *)(((argv[0])) + 1) - (
size_t)(const void *)((argv[0])) == 1) ? __builtin_strcmp ((compiler
), (argv[0])) : (__extension__ ({ const unsigned char *__s2 =
(const unsigned char *) (const char *) ((argv[0])); int __result
= (((const unsigned char *) (const char *) ((compiler)))[0] -
__s2[0]); if (__s1_len > 0 && __result == 0) { __result
= (((const unsigned char *) (const char *) ((compiler)))[1] -
__s2[1]); if (__s1_len > 1 && __result == 0) { __result
= (((const unsigned char *) (const char *) ((compiler)))[2] -
__s2[2]); if (__s1_len > 2 && __result == 0) __result
= (((const unsigned char *) (const char *) ((compiler)))[3] -
__s2[3]); } } __result; }))) : (__builtin_constant_p ((argv[
0])) && ((size_t)(const void *)(((argv[0])) + 1) - (size_t
)(const void *)((argv[0])) == 1) && (__s2_len = strlen
((argv[0])), __s2_len < 4) ? (__builtin_constant_p ((compiler
)) && ((size_t)(const void *)(((compiler)) + 1) - (size_t
)(const void *)((compiler)) == 1) ? __builtin_strcmp ((compiler
), (argv[0])) : (- (__extension__ ({ const unsigned char *__s2
= (const unsigned char *) (const char *) ((compiler)); int __result
= (((const unsigned char *) (const char *) ((argv[0])))[0] -
__s2[0]); if (__s2_len > 0 && __result == 0) { __result
= (((const unsigned char *) (const char *) ((argv[0])))[1] -
__s2[1]); if (__s2_len > 1 && __result == 0) { __result
= (((const unsigned char *) (const char *) ((argv[0])))[2] -
__s2[2]); if (__s2_len > 2 && __result == 0) __result
= (((const unsigned char *) (const char *) ((argv[0])))[3] -
__s2[3]); } } __result; })))) : __builtin_strcmp ((compiler)
, (argv[0]))))); }) == 0)
) {
1265 fatal("Recursive invocation (the name of the ccache binary must be \"%s\")",
1266 MYNAME"ccache");
1267 }
1268 orig_args->argv[0] = compiler;
1269}
1270
1271bool_Bool
1272is_precompiled_header(const char *path)
1273{
1274 return str_eq(get_extension(path), ".gch")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((get_extension(path))) && __builtin_constant_p ((".gch"
)) && (__s1_len = strlen ((get_extension(path))), __s2_len
= strlen ((".gch")), (!((size_t)(const void *)(((get_extension
(path))) + 1) - (size_t)(const void *)((get_extension(path)))
== 1) || __s1_len >= 4) && (!((size_t)(const void
*)(((".gch")) + 1) - (size_t)(const void *)((".gch")) == 1) ||
__s2_len >= 4)) ? __builtin_strcmp ((get_extension(path))
, (".gch")) : (__builtin_constant_p ((get_extension(path))) &&
((size_t)(const void *)(((get_extension(path))) + 1) - (size_t
)(const void *)((get_extension(path))) == 1) && (__s1_len
= strlen ((get_extension(path))), __s1_len < 4) ? (__builtin_constant_p
((".gch")) && ((size_t)(const void *)(((".gch")) + 1
) - (size_t)(const void *)((".gch")) == 1) ? __builtin_strcmp
((get_extension(path)), (".gch")) : (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) ((".gch"
)); int __result = (((const unsigned char *) (const char *) (
(get_extension(path))))[0] - __s2[0]); if (__s1_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) ((get_extension(path))))[1] - __s2[1]); if (__s1_len
> 1 && __result == 0) { __result = (((const unsigned
char *) (const char *) ((get_extension(path))))[2] - __s2[2]
); if (__s1_len > 2 && __result == 0) __result = (
((const unsigned char *) (const char *) ((get_extension(path)
)))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
((".gch")) && ((size_t)(const void *)(((".gch")) + 1
) - (size_t)(const void *)((".gch")) == 1) && (__s2_len
= strlen ((".gch")), __s2_len < 4) ? (__builtin_constant_p
((get_extension(path))) && ((size_t)(const void *)((
(get_extension(path))) + 1) - (size_t)(const void *)((get_extension
(path))) == 1) ? __builtin_strcmp ((get_extension(path)), (".gch"
)) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) ((get_extension(path))); int __result
= (((const unsigned char *) (const char *) ((".gch")))[0] - __s2
[0]); if (__s2_len > 0 && __result == 0) { __result
= (((const unsigned char *) (const char *) ((".gch")))[1] - __s2
[1]); if (__s2_len > 1 && __result == 0) { __result
= (((const unsigned char *) (const char *) ((".gch")))[2] - __s2
[2]); if (__s2_len > 2 && __result == 0) __result =
(((const unsigned char *) (const char *) ((".gch")))[3] - __s2
[3]); } } __result; })))) : __builtin_strcmp ((get_extension(
path)), (".gch"))))); }) == 0)
;
1275}
1276
1277/*
1278 * Process the compiler options into options suitable for passing to the
1279 * preprocessor and the real compiler. The preprocessor options don't include
1280 * -E; this is added later. Returns true on success, otherwise false.
1281 */
1282bool_Bool
1283cc_process_args(struct args *orig_args, struct args **preprocessor_args,
1284 struct args **compiler_args)
1285{
1286 int i;
1287 bool_Bool found_c_opt = false0;
1288 bool_Bool found_S_opt = false0;
1289 bool_Bool found_arch_opt = false0;
1290 bool_Bool found_pch = false0;
1291 bool_Bool found_fpch_preprocess = false0;
1292 const char *explicit_language = NULL((void*)0); /* As specified with -x. */
1293 const char *file_language; /* As deduced from file extension. */
1294 const char *actual_language; /* Language to actually use. */
1295 const char *input_charset = NULL((void*)0);
1296 struct stat st;
1297 /* is the dependency makefile name overridden with -MF? */
1298 bool_Bool dependency_filename_specified = false0;
1299 /* is the dependency makefile target name specified with -MT or -MQ? */
1300 bool_Bool dependency_target_specified = false0;
1301 struct args *stripped_args = NULL((void*)0), *dep_args = NULL((void*)0);
1302 int argc = orig_args->argc;
1303 char **argv = orig_args->argv;
1304 bool_Bool result = true1;
1305
1306 stripped_args = args_init(0, NULL((void*)0));
1307 dep_args = args_init(0, NULL((void*)0));
1308
1309 args_add(stripped_args, argv[0]);
1310
1311 for (i = 1; i < argc; i++) {
1312 /* The user knows best: just swallow the next arg */
1313 if (str_eq(argv[i], "--ccache-skip")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((argv[i])) && __builtin_constant_p (("--ccache-skip"
)) && (__s1_len = strlen ((argv[i])), __s2_len = strlen
(("--ccache-skip")), (!((size_t)(const void *)(((argv[i])) +
1) - (size_t)(const void *)((argv[i])) == 1) || __s1_len >=
4) && (!((size_t)(const void *)((("--ccache-skip")) +
1) - (size_t)(const void *)(("--ccache-skip")) == 1) || __s2_len
>= 4)) ? __builtin_strcmp ((argv[i]), ("--ccache-skip")) :
(__builtin_constant_p ((argv[i])) && ((size_t)(const
void *)(((argv[i])) + 1) - (size_t)(const void *)((argv[i]))
== 1) && (__s1_len = strlen ((argv[i])), __s1_len <
4) ? (__builtin_constant_p (("--ccache-skip")) && ((
size_t)(const void *)((("--ccache-skip")) + 1) - (size_t)(const
void *)(("--ccache-skip")) == 1) ? __builtin_strcmp ((argv[i
]), ("--ccache-skip")) : (__extension__ ({ const unsigned char
*__s2 = (const unsigned char *) (const char *) (("--ccache-skip"
)); int __result = (((const unsigned char *) (const char *) (
(argv[i])))[0] - __s2[0]); if (__s1_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(argv[i])))[1] - __s2[1]); if (__s1_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(argv[i])))[2] - __s2[2]); if (__s1_len > 2 && __result
== 0) __result = (((const unsigned char *) (const char *) ((
argv[i])))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
(("--ccache-skip")) && ((size_t)(const void *)((("--ccache-skip"
)) + 1) - (size_t)(const void *)(("--ccache-skip")) == 1) &&
(__s2_len = strlen (("--ccache-skip")), __s2_len < 4) ? (
__builtin_constant_p ((argv[i])) && ((size_t)(const void
*)(((argv[i])) + 1) - (size_t)(const void *)((argv[i])) == 1
) ? __builtin_strcmp ((argv[i]), ("--ccache-skip")) : (- (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) ((argv[i])); int __result = (((const unsigned char *
) (const char *) (("--ccache-skip")))[0] - __s2[0]); if (__s2_len
> 0 && __result == 0) { __result = (((const unsigned
char *) (const char *) (("--ccache-skip")))[1] - __s2[1]); if
(__s2_len > 1 && __result == 0) { __result = (((const
unsigned char *) (const char *) (("--ccache-skip")))[2] - __s2
[2]); if (__s2_len > 2 && __result == 0) __result =
(((const unsigned char *) (const char *) (("--ccache-skip"))
)[3] - __s2[3]); } } __result; })))) : __builtin_strcmp ((argv
[i]), ("--ccache-skip"))))); }) == 0)
) {
1314 i++;
1315 if (i == argc) {
1316 cc_log("--ccache-skip lacks an argument");
1317 result = false0;
1318 goto out;
1319 }
1320 args_add(stripped_args, argv[i]);
1321 continue;
1322 }
1323
1324 /* Special case for -E. */
1325 if (str_eq(argv[i], "-E")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((argv[i])) && __builtin_constant_p (("-E")) &&
(__s1_len = strlen ((argv[i])), __s2_len = strlen (("-E")), (
!((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const void
*)((argv[i])) == 1) || __s1_len >= 4) && (!((size_t
)(const void *)((("-E")) + 1) - (size_t)(const void *)(("-E")
) == 1) || __s2_len >= 4)) ? __builtin_strcmp ((argv[i]), (
"-E")) : (__builtin_constant_p ((argv[i])) && ((size_t
)(const void *)(((argv[i])) + 1) - (size_t)(const void *)((argv
[i])) == 1) && (__s1_len = strlen ((argv[i])), __s1_len
< 4) ? (__builtin_constant_p (("-E")) && ((size_t
)(const void *)((("-E")) + 1) - (size_t)(const void *)(("-E")
) == 1) ? __builtin_strcmp ((argv[i]), ("-E")) : (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (("-E")); int __result = (((const unsigned char *) (
const char *) ((argv[i])))[0] - __s2[0]); if (__s1_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[1] - __s2[1]); if (__s1_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[2] - __s2[2]); if (__s1_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) ((argv[i])))[3] - __s2[3]); } } __result; }
))) : (__builtin_constant_p (("-E")) && ((size_t)(const
void *)((("-E")) + 1) - (size_t)(const void *)(("-E")) == 1)
&& (__s2_len = strlen (("-E")), __s2_len < 4) ? (
__builtin_constant_p ((argv[i])) && ((size_t)(const void
*)(((argv[i])) + 1) - (size_t)(const void *)((argv[i])) == 1
) ? __builtin_strcmp ((argv[i]), ("-E")) : (- (__extension__ (
{ const unsigned char *__s2 = (const unsigned char *) (const char
*) ((argv[i])); int __result = (((const unsigned char *) (const
char *) (("-E")))[0] - __s2[0]); if (__s2_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("-E")))[1] - __s2[1]); if (__s2_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("-E")))[2] - __s2[2]); if (__s2_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char
*) (("-E")))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
((argv[i]), ("-E"))))); }) == 0)
) {
1326 stats_update(STATS_PREPROCESSING);
1327 result = false0;
1328 goto out;
1329 }
1330
1331 /* These are always too hard. */
1332 if (compopt_too_hard(argv[i])
1333 || str_startswith(argv[i], "@")((__extension__ (__builtin_constant_p (strlen(("@"))) &&
((__builtin_constant_p ((argv[i])) && strlen ((argv[
i])) < ((size_t) (strlen(("@"))))) || (__builtin_constant_p
(("@")) && strlen (("@")) < ((size_t) (strlen(("@"
)))))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((argv[i])) && __builtin_constant_p (("@")) &&
(__s1_len = strlen ((argv[i])), __s2_len = strlen (("@")), (
!((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const void
*)((argv[i])) == 1) || __s1_len >= 4) && (!((size_t
)(const void *)((("@")) + 1) - (size_t)(const void *)(("@")) ==
1) || __s2_len >= 4)) ? __builtin_strcmp ((argv[i]), ("@"
)) : (__builtin_constant_p ((argv[i])) && ((size_t)(const
void *)(((argv[i])) + 1) - (size_t)(const void *)((argv[i]))
== 1) && (__s1_len = strlen ((argv[i])), __s1_len <
4) ? (__builtin_constant_p (("@")) && ((size_t)(const
void *)((("@")) + 1) - (size_t)(const void *)(("@")) == 1) ?
__builtin_strcmp ((argv[i]), ("@")) : (__extension__ ({ const
unsigned char *__s2 = (const unsigned char *) (const char *)
(("@")); int __result = (((const unsigned char *) (const char
*) ((argv[i])))[0] - __s2[0]); if (__s1_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) ((argv[i])))[1] - __s2[1]); if (__s1_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) ((argv[i])))[2] - __s2[2]); if (__s1_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char
*) ((argv[i])))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
(("@")) && ((size_t)(const void *)((("@")) + 1) - (size_t
)(const void *)(("@")) == 1) && (__s2_len = strlen ((
"@")), __s2_len < 4) ? (__builtin_constant_p ((argv[i])) &&
((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const void
*)((argv[i])) == 1) ? __builtin_strcmp ((argv[i]), ("@")) : (
- (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) ((argv[i])); int __result = (((const unsigned
char *) (const char *) (("@")))[0] - __s2[0]); if (__s2_len >
0 && __result == 0) { __result = (((const unsigned char
*) (const char *) (("@")))[1] - __s2[1]); if (__s2_len > 1
&& __result == 0) { __result = (((const unsigned char
*) (const char *) (("@")))[2] - __s2[2]); if (__s2_len > 2
&& __result == 0) __result = (((const unsigned char *
) (const char *) (("@")))[3] - __s2[3]); } } __result; })))) :
__builtin_strcmp ((argv[i]), ("@"))))); }) : strncmp ((argv[
i]), ("@"), strlen(("@"))))) == 0)
1334 || str_startswith(argv[i], "-fdump-")((__extension__ (__builtin_constant_p (strlen(("-fdump-"))) &&
((__builtin_constant_p ((argv[i])) && strlen ((argv[
i])) < ((size_t) (strlen(("-fdump-"))))) || (__builtin_constant_p
(("-fdump-")) && strlen (("-fdump-")) < ((size_t)
(strlen(("-fdump-")))))) ? __extension__ ({ size_t __s1_len,
__s2_len; (__builtin_constant_p ((argv[i])) && __builtin_constant_p
(("-fdump-")) && (__s1_len = strlen ((argv[i])), __s2_len
= strlen (("-fdump-")), (!((size_t)(const void *)(((argv[i])
) + 1) - (size_t)(const void *)((argv[i])) == 1) || __s1_len >=
4) && (!((size_t)(const void *)((("-fdump-")) + 1) -
(size_t)(const void *)(("-fdump-")) == 1) || __s2_len >= 4
)) ? __builtin_strcmp ((argv[i]), ("-fdump-")) : (__builtin_constant_p
((argv[i])) && ((size_t)(const void *)(((argv[i])) +
1) - (size_t)(const void *)((argv[i])) == 1) && (__s1_len
= strlen ((argv[i])), __s1_len < 4) ? (__builtin_constant_p
(("-fdump-")) && ((size_t)(const void *)((("-fdump-"
)) + 1) - (size_t)(const void *)(("-fdump-")) == 1) ? __builtin_strcmp
((argv[i]), ("-fdump-")) : (__extension__ ({ const unsigned char
*__s2 = (const unsigned char *) (const char *) (("-fdump-"))
; int __result = (((const unsigned char *) (const char *) ((argv
[i])))[0] - __s2[0]); if (__s1_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(argv[i])))[1] - __s2[1]); if (__s1_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(argv[i])))[2] - __s2[2]); if (__s1_len > 2 && __result
== 0) __result = (((const unsigned char *) (const char *) ((
argv[i])))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
(("-fdump-")) && ((size_t)(const void *)((("-fdump-"
)) + 1) - (size_t)(const void *)(("-fdump-")) == 1) &&
(__s2_len = strlen (("-fdump-")), __s2_len < 4) ? (__builtin_constant_p
((argv[i])) && ((size_t)(const void *)(((argv[i])) +
1) - (size_t)(const void *)((argv[i])) == 1) ? __builtin_strcmp
((argv[i]), ("-fdump-")) : (- (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) ((argv[i
])); int __result = (((const unsigned char *) (const char *) (
("-fdump-")))[0] - __s2[0]); if (__s2_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
("-fdump-")))[1] - __s2[1]); if (__s2_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
("-fdump-")))[2] - __s2[2]); if (__s2_len > 2 && __result
== 0) __result = (((const unsigned char *) (const char *) ((
"-fdump-")))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
((argv[i]), ("-fdump-"))))); }) : strncmp ((argv[i]), ("-fdump-"
), strlen(("-fdump-"))))) == 0)
) {
1335 cc_log("Compiler option %s is unsupported", argv[i]);
1336 stats_update(STATS_UNSUPPORTED);
1337 result = false0;
1338 goto out;
1339 }
1340
1341 /* These are too hard in direct mode. */
1342 if (enable_direct) {
1343 if (compopt_too_hard_for_direct_mode(argv[i])) {
1344 cc_log("Unsupported compiler option for direct mode: %s", argv[i]);
1345 enable_direct = false0;
1346 }
1347 }
1348
1349 /* Multiple -arch options are too hard. */
1350 if (str_eq(argv[i], "-arch")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((argv[i])) && __builtin_constant_p (("-arch")) &&
(__s1_len = strlen ((argv[i])), __s2_len = strlen (("-arch")
), (!((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const
void *)((argv[i])) == 1) || __s1_len >= 4) && (!(
(size_t)(const void *)((("-arch")) + 1) - (size_t)(const void
*)(("-arch")) == 1) || __s2_len >= 4)) ? __builtin_strcmp
((argv[i]), ("-arch")) : (__builtin_constant_p ((argv[i])) &&
((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const void
*)((argv[i])) == 1) && (__s1_len = strlen ((argv[i])
), __s1_len < 4) ? (__builtin_constant_p (("-arch")) &&
((size_t)(const void *)((("-arch")) + 1) - (size_t)(const void
*)(("-arch")) == 1) ? __builtin_strcmp ((argv[i]), ("-arch")
) : (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) (("-arch")); int __result = (((const unsigned
char *) (const char *) ((argv[i])))[0] - __s2[0]); if (__s1_len
> 0 && __result == 0) { __result = (((const unsigned
char *) (const char *) ((argv[i])))[1] - __s2[1]); if (__s1_len
> 1 && __result == 0) { __result = (((const unsigned
char *) (const char *) ((argv[i])))[2] - __s2[2]); if (__s1_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) ((argv[i])))[3] - __s2[3]); } } __result
; }))) : (__builtin_constant_p (("-arch")) && ((size_t
)(const void *)((("-arch")) + 1) - (size_t)(const void *)(("-arch"
)) == 1) && (__s2_len = strlen (("-arch")), __s2_len <
4) ? (__builtin_constant_p ((argv[i])) && ((size_t)(
const void *)(((argv[i])) + 1) - (size_t)(const void *)((argv
[i])) == 1) ? __builtin_strcmp ((argv[i]), ("-arch")) : (- (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) ((argv[i])); int __result = (((const unsigned char *
) (const char *) (("-arch")))[0] - __s2[0]); if (__s2_len >
0 && __result == 0) { __result = (((const unsigned char
*) (const char *) (("-arch")))[1] - __s2[1]); if (__s2_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) (("-arch")))[2] - __s2[2]); if (__s2_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) (("-arch")))[3] - __s2[3]); } } __result; }
)))) : __builtin_strcmp ((argv[i]), ("-arch"))))); }) == 0)
) {
1351 if (found_arch_opt) {
1352 cc_log("More than one -arch compiler option is unsupported");
1353 stats_update(STATS_UNSUPPORTED);
1354 result = false0;
1355 goto out;
1356 } else {
1357 found_arch_opt = true1;
1358 }
1359 }
1360
1361 if (str_eq(argv[i], "-fpch-preprocess")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((argv[i])) && __builtin_constant_p (("-fpch-preprocess"
)) && (__s1_len = strlen ((argv[i])), __s2_len = strlen
(("-fpch-preprocess")), (!((size_t)(const void *)(((argv[i])
) + 1) - (size_t)(const void *)((argv[i])) == 1) || __s1_len >=
4) && (!((size_t)(const void *)((("-fpch-preprocess"
)) + 1) - (size_t)(const void *)(("-fpch-preprocess")) == 1) ||
__s2_len >= 4)) ? __builtin_strcmp ((argv[i]), ("-fpch-preprocess"
)) : (__builtin_constant_p ((argv[i])) && ((size_t)(const
void *)(((argv[i])) + 1) - (size_t)(const void *)((argv[i]))
== 1) && (__s1_len = strlen ((argv[i])), __s1_len <
4) ? (__builtin_constant_p (("-fpch-preprocess")) &&
((size_t)(const void *)((("-fpch-preprocess")) + 1) - (size_t
)(const void *)(("-fpch-preprocess")) == 1) ? __builtin_strcmp
((argv[i]), ("-fpch-preprocess")) : (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (("-fpch-preprocess"
)); int __result = (((const unsigned char *) (const char *) (
(argv[i])))[0] - __s2[0]); if (__s1_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(argv[i])))[1] - __s2[1]); if (__s1_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(argv[i])))[2] - __s2[2]); if (__s1_len > 2 && __result
== 0) __result = (((const unsigned char *) (const char *) ((
argv[i])))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
(("-fpch-preprocess")) && ((size_t)(const void *)(((
"-fpch-preprocess")) + 1) - (size_t)(const void *)(("-fpch-preprocess"
)) == 1) && (__s2_len = strlen (("-fpch-preprocess"))
, __s2_len < 4) ? (__builtin_constant_p ((argv[i])) &&
((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const void
*)((argv[i])) == 1) ? __builtin_strcmp ((argv[i]), ("-fpch-preprocess"
)) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) ((argv[i])); int __result = (((const unsigned
char *) (const char *) (("-fpch-preprocess")))[0] - __s2[0])
; if (__s2_len > 0 && __result == 0) { __result = (
((const unsigned char *) (const char *) (("-fpch-preprocess")
))[1] - __s2[1]); if (__s2_len > 1 && __result == 0
) { __result = (((const unsigned char *) (const char *) (("-fpch-preprocess"
)))[2] - __s2[2]); if (__s2_len > 2 && __result ==
0) __result = (((const unsigned char *) (const char *) (("-fpch-preprocess"
)))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp ((argv
[i]), ("-fpch-preprocess"))))); }) == 0)
) {
1362 found_fpch_preprocess = true1;
1363 }
1364
1365 /* we must have -c */
1366 if (str_eq(argv[i], "-c")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((argv[i])) && __builtin_constant_p (("-c")) &&
(__s1_len = strlen ((argv[i])), __s2_len = strlen (("-c")), (
!((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const void
*)((argv[i])) == 1) || __s1_len >= 4) && (!((size_t
)(const void *)((("-c")) + 1) - (size_t)(const void *)(("-c")
) == 1) || __s2_len >= 4)) ? __builtin_strcmp ((argv[i]), (
"-c")) : (__builtin_constant_p ((argv[i])) && ((size_t
)(const void *)(((argv[i])) + 1) - (size_t)(const void *)((argv
[i])) == 1) && (__s1_len = strlen ((argv[i])), __s1_len
< 4) ? (__builtin_constant_p (("-c")) && ((size_t
)(const void *)((("-c")) + 1) - (size_t)(const void *)(("-c")
) == 1) ? __builtin_strcmp ((argv[i]), ("-c")) : (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (("-c")); int __result = (((const unsigned char *) (
const char *) ((argv[i])))[0] - __s2[0]); if (__s1_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[1] - __s2[1]); if (__s1_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[2] - __s2[2]); if (__s1_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) ((argv[i])))[3] - __s2[3]); } } __result; }
))) : (__builtin_constant_p (("-c")) && ((size_t)(const
void *)((("-c")) + 1) - (size_t)(const void *)(("-c")) == 1)
&& (__s2_len = strlen (("-c")), __s2_len < 4) ? (
__builtin_constant_p ((argv[i])) && ((size_t)(const void
*)(((argv[i])) + 1) - (size_t)(const void *)((argv[i])) == 1
) ? __builtin_strcmp ((argv[i]), ("-c")) : (- (__extension__ (
{ const unsigned char *__s2 = (const unsigned char *) (const char
*) ((argv[i])); int __result = (((const unsigned char *) (const
char *) (("-c")))[0] - __s2[0]); if (__s2_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("-c")))[1] - __s2[1]); if (__s2_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("-c")))[2] - __s2[2]); if (__s2_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char
*) (("-c")))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
((argv[i]), ("-c"))))); }) == 0)
) {
1367 args_add(stripped_args, argv[i]);
1368 found_c_opt = true1;
1369 continue;
1370 }
1371
1372 /* -S changes the default extension */
1373 if (str_eq(argv[i], "-S")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((argv[i])) && __builtin_constant_p (("-S")) &&
(__s1_len = strlen ((argv[i])), __s2_len = strlen (("-S")), (
!((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const void
*)((argv[i])) == 1) || __s1_len >= 4) && (!((size_t
)(const void *)((("-S")) + 1) - (size_t)(const void *)(("-S")
) == 1) || __s2_len >= 4)) ? __builtin_strcmp ((argv[i]), (
"-S")) : (__builtin_constant_p ((argv[i])) && ((size_t
)(const void *)(((argv[i])) + 1) - (size_t)(const void *)((argv
[i])) == 1) && (__s1_len = strlen ((argv[i])), __s1_len
< 4) ? (__builtin_constant_p (("-S")) && ((size_t
)(const void *)((("-S")) + 1) - (size_t)(const void *)(("-S")
) == 1) ? __builtin_strcmp ((argv[i]), ("-S")) : (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (("-S")); int __result = (((const unsigned char *) (
const char *) ((argv[i])))[0] - __s2[0]); if (__s1_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[1] - __s2[1]); if (__s1_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[2] - __s2[2]); if (__s1_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) ((argv[i])))[3] - __s2[3]); } } __result; }
))) : (__builtin_constant_p (("-S")) && ((size_t)(const
void *)((("-S")) + 1) - (size_t)(const void *)(("-S")) == 1)
&& (__s2_len = strlen (("-S")), __s2_len < 4) ? (
__builtin_constant_p ((argv[i])) && ((size_t)(const void
*)(((argv[i])) + 1) - (size_t)(const void *)((argv[i])) == 1
) ? __builtin_strcmp ((argv[i]), ("-S")) : (- (__extension__ (
{ const unsigned char *__s2 = (const unsigned char *) (const char
*) ((argv[i])); int __result = (((const unsigned char *) (const
char *) (("-S")))[0] - __s2[0]); if (__s2_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("-S")))[1] - __s2[1]); if (__s2_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("-S")))[2] - __s2[2]); if (__s2_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char
*) (("-S")))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
((argv[i]), ("-S"))))); }) == 0)
) {
1374 args_add(stripped_args, argv[i]);
1375 found_S_opt = true1;
1376 continue;
1377 }
1378
1379 /*
1380 * Special handling for -x: remember the last specified language before the
1381 * input file and strip all -x options from the arguments.
1382 */
1383 if (str_eq(argv[i], "-x")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((argv[i])) && __builtin_constant_p (("-x")) &&
(__s1_len = strlen ((argv[i])), __s2_len = strlen (("-x")), (
!((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const void
*)((argv[i])) == 1) || __s1_len >= 4) && (!((size_t
)(const void *)((("-x")) + 1) - (size_t)(const void *)(("-x")
) == 1) || __s2_len >= 4)) ? __builtin_strcmp ((argv[i]), (
"-x")) : (__builtin_constant_p ((argv[i])) && ((size_t
)(const void *)(((argv[i])) + 1) - (size_t)(const void *)((argv
[i])) == 1) && (__s1_len = strlen ((argv[i])), __s1_len
< 4) ? (__builtin_constant_p (("-x")) && ((size_t
)(const void *)((("-x")) + 1) - (size_t)(const void *)(("-x")
) == 1) ? __builtin_strcmp ((argv[i]), ("-x")) : (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (("-x")); int __result = (((const unsigned char *) (
const char *) ((argv[i])))[0] - __s2[0]); if (__s1_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[1] - __s2[1]); if (__s1_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[2] - __s2[2]); if (__s1_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) ((argv[i])))[3] - __s2[3]); } } __result; }
))) : (__builtin_constant_p (("-x")) && ((size_t)(const
void *)((("-x")) + 1) - (size_t)(const void *)(("-x")) == 1)
&& (__s2_len = strlen (("-x")), __s2_len < 4) ? (
__builtin_constant_p ((argv[i])) && ((size_t)(const void
*)(((argv[i])) + 1) - (size_t)(const void *)((argv[i])) == 1
) ? __builtin_strcmp ((argv[i]), ("-x")) : (- (__extension__ (
{ const unsigned char *__s2 = (const unsigned char *) (const char
*) ((argv[i])); int __result = (((const unsigned char *) (const
char *) (("-x")))[0] - __s2[0]); if (__s2_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("-x")))[1] - __s2[1]); if (__s2_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("-x")))[2] - __s2[2]); if (__s2_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char
*) (("-x")))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
((argv[i]), ("-x"))))); }) == 0)
) {
1384 if (i == argc-1) {
1385 cc_log("Missing argument to %s", argv[i]);
1386 stats_update(STATS_ARGS);
1387 result = false0;
1388 goto out;
1389 }
1390 if (!input_file) {
1391 explicit_language = argv[i+1];
1392 }
1393 i++;
1394 continue;
1395 }
1396 if (str_startswith(argv[i], "-x")((__extension__ (__builtin_constant_p (strlen(("-x"))) &&
((__builtin_constant_p ((argv[i])) && strlen ((argv[
i])) < ((size_t) (strlen(("-x"))))) || (__builtin_constant_p
(("-x")) && strlen (("-x")) < ((size_t) (strlen((
"-x")))))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((argv[i])) && __builtin_constant_p (("-x")) &&
(__s1_len = strlen ((argv[i])), __s2_len = strlen (("-x")), (
!((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const void
*)((argv[i])) == 1) || __s1_len >= 4) && (!((size_t
)(const void *)((("-x")) + 1) - (size_t)(const void *)(("-x")
) == 1) || __s2_len >= 4)) ? __builtin_strcmp ((argv[i]), (
"-x")) : (__builtin_constant_p ((argv[i])) && ((size_t
)(const void *)(((argv[i])) + 1) - (size_t)(const void *)((argv
[i])) == 1) && (__s1_len = strlen ((argv[i])), __s1_len
< 4) ? (__builtin_constant_p (("-x")) && ((size_t
)(const void *)((("-x")) + 1) - (size_t)(const void *)(("-x")
) == 1) ? __builtin_strcmp ((argv[i]), ("-x")) : (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (("-x")); int __result = (((const unsigned char *) (
const char *) ((argv[i])))[0] - __s2[0]); if (__s1_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[1] - __s2[1]); if (__s1_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[2] - __s2[2]); if (__s1_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) ((argv[i])))[3] - __s2[3]); } } __result; }
))) : (__builtin_constant_p (("-x")) && ((size_t)(const
void *)((("-x")) + 1) - (size_t)(const void *)(("-x")) == 1)
&& (__s2_len = strlen (("-x")), __s2_len < 4) ? (
__builtin_constant_p ((argv[i])) && ((size_t)(const void
*)(((argv[i])) + 1) - (size_t)(const void *)((argv[i])) == 1
) ? __builtin_strcmp ((argv[i]), ("-x")) : (- (__extension__ (
{ const unsigned char *__s2 = (const unsigned char *) (const char
*) ((argv[i])); int __result = (((const unsigned char *) (const
char *) (("-x")))[0] - __s2[0]); if (__s2_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("-x")))[1] - __s2[1]); if (__s2_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("-x")))[2] - __s2[2]); if (__s2_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char
*) (("-x")))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
((argv[i]), ("-x"))))); }) : strncmp ((argv[i]), ("-x"), strlen
(("-x"))))) == 0)
) {
1397 if (!input_file) {
1398 explicit_language = &argv[i][2];
1399 }
1400 continue;
1401 }
1402
1403 /* we need to work out where the output was meant to go */
1404 if (str_eq(argv[i], "-o")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((argv[i])) && __builtin_constant_p (("-o")) &&
(__s1_len = strlen ((argv[i])), __s2_len = strlen (("-o")), (
!((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const void
*)((argv[i])) == 1) || __s1_len >= 4) && (!((size_t
)(const void *)((("-o")) + 1) - (size_t)(const void *)(("-o")
) == 1) || __s2_len >= 4)) ? __builtin_strcmp ((argv[i]), (
"-o")) : (__builtin_constant_p ((argv[i])) && ((size_t
)(const void *)(((argv[i])) + 1) - (size_t)(const void *)((argv
[i])) == 1) && (__s1_len = strlen ((argv[i])), __s1_len
< 4) ? (__builtin_constant_p (("-o")) && ((size_t
)(const void *)((("-o")) + 1) - (size_t)(const void *)(("-o")
) == 1) ? __builtin_strcmp ((argv[i]), ("-o")) : (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (("-o")); int __result = (((const unsigned char *) (
const char *) ((argv[i])))[0] - __s2[0]); if (__s1_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[1] - __s2[1]); if (__s1_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[2] - __s2[2]); if (__s1_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) ((argv[i])))[3] - __s2[3]); } } __result; }
))) : (__builtin_constant_p (("-o")) && ((size_t)(const
void *)((("-o")) + 1) - (size_t)(const void *)(("-o")) == 1)
&& (__s2_len = strlen (("-o")), __s2_len < 4) ? (
__builtin_constant_p ((argv[i])) && ((size_t)(const void
*)(((argv[i])) + 1) - (size_t)(const void *)((argv[i])) == 1
) ? __builtin_strcmp ((argv[i]), ("-o")) : (- (__extension__ (
{ const unsigned char *__s2 = (const unsigned char *) (const char
*) ((argv[i])); int __result = (((const unsigned char *) (const
char *) (("-o")))[0] - __s2[0]); if (__s2_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("-o")))[1] - __s2[1]); if (__s2_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("-o")))[2] - __s2[2]); if (__s2_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char
*) (("-o")))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
((argv[i]), ("-o"))))); }) == 0)
) {
1405 if (i == argc-1) {
1406 cc_log("Missing argument to %s", argv[i]);
1407 stats_update(STATS_ARGS);
1408 result = false0;
1409 goto out;
1410 }
1411 output_obj = make_relative_path(x_strdup(argv[i+1]));
1412 i++;
1413 continue;
1414 }
1415
1416 /* alternate form of -o, with no space */
1417 if (str_startswith(argv[i], "-o")((__extension__ (__builtin_constant_p (strlen(("-o"))) &&
((__builtin_constant_p ((argv[i])) && strlen ((argv[
i])) < ((size_t) (strlen(("-o"))))) || (__builtin_constant_p
(("-o")) && strlen (("-o")) < ((size_t) (strlen((
"-o")))))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((argv[i])) && __builtin_constant_p (("-o")) &&
(__s1_len = strlen ((argv[i])), __s2_len = strlen (("-o")), (
!((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const void
*)((argv[i])) == 1) || __s1_len >= 4) && (!((size_t
)(const void *)((("-o")) + 1) - (size_t)(const void *)(("-o")
) == 1) || __s2_len >= 4)) ? __builtin_strcmp ((argv[i]), (
"-o")) : (__builtin_constant_p ((argv[i])) && ((size_t
)(const void *)(((argv[i])) + 1) - (size_t)(const void *)((argv
[i])) == 1) && (__s1_len = strlen ((argv[i])), __s1_len
< 4) ? (__builtin_constant_p (("-o")) && ((size_t
)(const void *)((("-o")) + 1) - (size_t)(const void *)(("-o")
) == 1) ? __builtin_strcmp ((argv[i]), ("-o")) : (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (("-o")); int __result = (((const unsigned char *) (
const char *) ((argv[i])))[0] - __s2[0]); if (__s1_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[1] - __s2[1]); if (__s1_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[2] - __s2[2]); if (__s1_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) ((argv[i])))[3] - __s2[3]); } } __result; }
))) : (__builtin_constant_p (("-o")) && ((size_t)(const
void *)((("-o")) + 1) - (size_t)(const void *)(("-o")) == 1)
&& (__s2_len = strlen (("-o")), __s2_len < 4) ? (
__builtin_constant_p ((argv[i])) && ((size_t)(const void
*)(((argv[i])) + 1) - (size_t)(const void *)((argv[i])) == 1
) ? __builtin_strcmp ((argv[i]), ("-o")) : (- (__extension__ (
{ const unsigned char *__s2 = (const unsigned char *) (const char
*) ((argv[i])); int __result = (((const unsigned char *) (const
char *) (("-o")))[0] - __s2[0]); if (__s2_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("-o")))[1] - __s2[1]); if (__s2_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("-o")))[2] - __s2[2]); if (__s2_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char
*) (("-o")))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
((argv[i]), ("-o"))))); }) : strncmp ((argv[i]), ("-o"), strlen
(("-o"))))) == 0)
) {
1418 output_obj = make_relative_path(x_strdup(&argv[i][2]));
1419 continue;
1420 }
1421
1422 /* debugging is handled specially, so that we know if we
1423 can strip line number info
1424 */
1425 if (str_startswith(argv[i], "-g")((__extension__ (__builtin_constant_p (strlen(("-g"))) &&
((__builtin_constant_p ((argv[i])) && strlen ((argv[
i])) < ((size_t) (strlen(("-g"))))) || (__builtin_constant_p
(("-g")) && strlen (("-g")) < ((size_t) (strlen((
"-g")))))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((argv[i])) && __builtin_constant_p (("-g")) &&
(__s1_len = strlen ((argv[i])), __s2_len = strlen (("-g")), (
!((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const void
*)((argv[i])) == 1) || __s1_len >= 4) && (!((size_t
)(const void *)((("-g")) + 1) - (size_t)(const void *)(("-g")
) == 1) || __s2_len >= 4)) ? __builtin_strcmp ((argv[i]), (
"-g")) : (__builtin_constant_p ((argv[i])) && ((size_t
)(const void *)(((argv[i])) + 1) - (size_t)(const void *)((argv
[i])) == 1) && (__s1_len = strlen ((argv[i])), __s1_len
< 4) ? (__builtin_constant_p (("-g")) && ((size_t
)(const void *)((("-g")) + 1) - (size_t)(const void *)(("-g")
) == 1) ? __builtin_strcmp ((argv[i]), ("-g")) : (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (("-g")); int __result = (((const unsigned char *) (
const char *) ((argv[i])))[0] - __s2[0]); if (__s1_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[1] - __s2[1]); if (__s1_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[2] - __s2[2]); if (__s1_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) ((argv[i])))[3] - __s2[3]); } } __result; }
))) : (__builtin_constant_p (("-g")) && ((size_t)(const
void *)((("-g")) + 1) - (size_t)(const void *)(("-g")) == 1)
&& (__s2_len = strlen (("-g")), __s2_len < 4) ? (
__builtin_constant_p ((argv[i])) && ((size_t)(const void
*)(((argv[i])) + 1) - (size_t)(const void *)((argv[i])) == 1
) ? __builtin_strcmp ((argv[i]), ("-g")) : (- (__extension__ (
{ const unsigned char *__s2 = (const unsigned char *) (const char
*) ((argv[i])); int __result = (((const unsigned char *) (const
char *) (("-g")))[0] - __s2[0]); if (__s2_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("-g")))[1] - __s2[1]); if (__s2_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("-g")))[2] - __s2[2]); if (__s2_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char
*) (("-g")))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
((argv[i]), ("-g"))))); }) : strncmp ((argv[i]), ("-g"), strlen
(("-g"))))) == 0)
) {
1426 args_add(stripped_args, argv[i]);
1427 if (enable_unify && !str_eq(argv[i], "-g0")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((argv[i])) && __builtin_constant_p (("-g0")) &&
(__s1_len = strlen ((argv[i])), __s2_len = strlen (("-g0")),
(!((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const void
*)((argv[i])) == 1) || __s1_len >= 4) && (!((size_t
)(const void *)((("-g0")) + 1) - (size_t)(const void *)(("-g0"
)) == 1) || __s2_len >= 4)) ? __builtin_strcmp ((argv[i]),
("-g0")) : (__builtin_constant_p ((argv[i])) && ((size_t
)(const void *)(((argv[i])) + 1) - (size_t)(const void *)((argv
[i])) == 1) && (__s1_len = strlen ((argv[i])), __s1_len
< 4) ? (__builtin_constant_p (("-g0")) && ((size_t
)(const void *)((("-g0")) + 1) - (size_t)(const void *)(("-g0"
)) == 1) ? __builtin_strcmp ((argv[i]), ("-g0")) : (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (("-g0")); int __result = (((const unsigned char *) (
const char *) ((argv[i])))[0] - __s2[0]); if (__s1_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[1] - __s2[1]); if (__s1_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[2] - __s2[2]); if (__s1_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) ((argv[i])))[3] - __s2[3]); } } __result; }
))) : (__builtin_constant_p (("-g0")) && ((size_t)(const
void *)((("-g0")) + 1) - (size_t)(const void *)(("-g0")) == 1
) && (__s2_len = strlen (("-g0")), __s2_len < 4) ?
(__builtin_constant_p ((argv[i])) && ((size_t)(const
void *)(((argv[i])) + 1) - (size_t)(const void *)((argv[i]))
== 1) ? __builtin_strcmp ((argv[i]), ("-g0")) : (- (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) ((argv[i])); int __result = (((const unsigned char *
) (const char *) (("-g0")))[0] - __s2[0]); if (__s2_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) (("-g0")))[1] - __s2[1]); if (__s2_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) (("-g0")))[2] - __s2[2]); if (__s2_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) (("-g0")))[3] - __s2[3]); } } __result; })
))) : __builtin_strcmp ((argv[i]), ("-g0"))))); }) == 0)
) {
1428 cc_log("%s used; disabling unify mode", argv[i]);
1429 enable_unify = false0;
1430 }
1431 if (str_eq(argv[i], "-g3")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((argv[i])) && __builtin_constant_p (("-g3")) &&
(__s1_len = strlen ((argv[i])), __s2_len = strlen (("-g3")),
(!((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const void
*)((argv[i])) == 1) || __s1_len >= 4) && (!((size_t
)(const void *)((("-g3")) + 1) - (size_t)(const void *)(("-g3"
)) == 1) || __s2_len >= 4)) ? __builtin_strcmp ((argv[i]),
("-g3")) : (__builtin_constant_p ((argv[i])) && ((size_t
)(const void *)(((argv[i])) + 1) - (size_t)(const void *)((argv
[i])) == 1) && (__s1_len = strlen ((argv[i])), __s1_len
< 4) ? (__builtin_constant_p (("-g3")) && ((size_t
)(const void *)((("-g3")) + 1) - (size_t)(const void *)(("-g3"
)) == 1) ? __builtin_strcmp ((argv[i]), ("-g3")) : (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (("-g3")); int __result = (((const unsigned char *) (
const char *) ((argv[i])))[0] - __s2[0]); if (__s1_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[1] - __s2[1]); if (__s1_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[2] - __s2[2]); if (__s1_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) ((argv[i])))[3] - __s2[3]); } } __result; }
))) : (__builtin_constant_p (("-g3")) && ((size_t)(const
void *)((("-g3")) + 1) - (size_t)(const void *)(("-g3")) == 1
) && (__s2_len = strlen (("-g3")), __s2_len < 4) ?
(__builtin_constant_p ((argv[i])) && ((size_t)(const
void *)(((argv[i])) + 1) - (size_t)(const void *)((argv[i]))
== 1) ? __builtin_strcmp ((argv[i]), ("-g3")) : (- (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) ((argv[i])); int __result = (((const unsigned char *
) (const char *) (("-g3")))[0] - __s2[0]); if (__s2_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) (("-g3")))[1] - __s2[1]); if (__s2_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) (("-g3")))[2] - __s2[2]); if (__s2_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) (("-g3")))[3] - __s2[3]); } } __result; })
))) : __builtin_strcmp ((argv[i]), ("-g3"))))); }) == 0)
) {
1432 /*
1433 * Fix for bug 7190 ("commandline macros (-D)
1434 * have non-zero lineno when using -g3").
1435 */
1436 cc_log("%s used; not compiling preprocessed code", argv[i]);
1437 compile_preprocessed_source_code = false0;
1438 }
1439 continue;
1440 }
1441
1442 /* These options require special handling, because they
1443 behave differently with gcc -E, when the output
1444 file is not specified. */
1445 if (str_eq(argv[i], "-MD")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((argv[i])) && __builtin_constant_p (("-MD")) &&
(__s1_len = strlen ((argv[i])), __s2_len = strlen (("-MD")),
(!((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const void
*)((argv[i])) == 1) || __s1_len >= 4) && (!((size_t
)(const void *)((("-MD")) + 1) - (size_t)(const void *)(("-MD"
)) == 1) || __s2_len >= 4)) ? __builtin_strcmp ((argv[i]),
("-MD")) : (__builtin_constant_p ((argv[i])) && ((size_t
)(const void *)(((argv[i])) + 1) - (size_t)(const void *)((argv
[i])) == 1) && (__s1_len = strlen ((argv[i])), __s1_len
< 4) ? (__builtin_constant_p (("-MD")) && ((size_t
)(const void *)((("-MD")) + 1) - (size_t)(const void *)(("-MD"
)) == 1) ? __builtin_strcmp ((argv[i]), ("-MD")) : (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (("-MD")); int __result = (((const unsigned char *) (
const char *) ((argv[i])))[0] - __s2[0]); if (__s1_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[1] - __s2[1]); if (__s1_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[2] - __s2[2]); if (__s1_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) ((argv[i])))[3] - __s2[3]); } } __result; }
))) : (__builtin_constant_p (("-MD")) && ((size_t)(const
void *)((("-MD")) + 1) - (size_t)(const void *)(("-MD")) == 1
) && (__s2_len = strlen (("-MD")), __s2_len < 4) ?
(__builtin_constant_p ((argv[i])) && ((size_t)(const
void *)(((argv[i])) + 1) - (size_t)(const void *)((argv[i]))
== 1) ? __builtin_strcmp ((argv[i]), ("-MD")) : (- (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) ((argv[i])); int __result = (((const unsigned char *
) (const char *) (("-MD")))[0] - __s2[0]); if (__s2_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) (("-MD")))[1] - __s2[1]); if (__s2_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) (("-MD")))[2] - __s2[2]); if (__s2_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) (("-MD")))[3] - __s2[3]); } } __result; })
))) : __builtin_strcmp ((argv[i]), ("-MD"))))); }) == 0)
|| str_eq(argv[i], "-MMD")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((argv[i])) && __builtin_constant_p (("-MMD")) &&
(__s1_len = strlen ((argv[i])), __s2_len = strlen (("-MMD"))
, (!((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const
void *)((argv[i])) == 1) || __s1_len >= 4) && (!(
(size_t)(const void *)((("-MMD")) + 1) - (size_t)(const void *
)(("-MMD")) == 1) || __s2_len >= 4)) ? __builtin_strcmp ((
argv[i]), ("-MMD")) : (__builtin_constant_p ((argv[i])) &&
((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const void
*)((argv[i])) == 1) && (__s1_len = strlen ((argv[i])
), __s1_len < 4) ? (__builtin_constant_p (("-MMD")) &&
((size_t)(const void *)((("-MMD")) + 1) - (size_t)(const void
*)(("-MMD")) == 1) ? __builtin_strcmp ((argv[i]), ("-MMD")) :
(__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) (("-MMD")); int __result = (((const unsigned
char *) (const char *) ((argv[i])))[0] - __s2[0]); if (__s1_len
> 0 && __result == 0) { __result = (((const unsigned
char *) (const char *) ((argv[i])))[1] - __s2[1]); if (__s1_len
> 1 && __result == 0) { __result = (((const unsigned
char *) (const char *) ((argv[i])))[2] - __s2[2]); if (__s1_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) ((argv[i])))[3] - __s2[3]); } } __result
; }))) : (__builtin_constant_p (("-MMD")) && ((size_t
)(const void *)((("-MMD")) + 1) - (size_t)(const void *)(("-MMD"
)) == 1) && (__s2_len = strlen (("-MMD")), __s2_len <
4) ? (__builtin_constant_p ((argv[i])) && ((size_t)(
const void *)(((argv[i])) + 1) - (size_t)(const void *)((argv
[i])) == 1) ? __builtin_strcmp ((argv[i]), ("-MMD")) : (- (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) ((argv[i])); int __result = (((const unsigned char *
) (const char *) (("-MMD")))[0] - __s2[0]); if (__s2_len >
0 && __result == 0) { __result = (((const unsigned char
*) (const char *) (("-MMD")))[1] - __s2[1]); if (__s2_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) (("-MMD")))[2] - __s2[2]); if (__s2_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) (("-MMD")))[3] - __s2[3]); } } __result; }
)))) : __builtin_strcmp ((argv[i]), ("-MMD"))))); }) == 0)
) {
1446 generating_dependencies = true1;
1447 args_add(dep_args, argv[i]);
1448 continue;
1449 }
1450 if (str_startswith(argv[i], "-MF")((__extension__ (__builtin_constant_p (strlen(("-MF"))) &&
((__builtin_constant_p ((argv[i])) && strlen ((argv[
i])) < ((size_t) (strlen(("-MF"))))) || (__builtin_constant_p
(("-MF")) && strlen (("-MF")) < ((size_t) (strlen
(("-MF")))))) ? __extension__ ({ size_t __s1_len, __s2_len; (
__builtin_constant_p ((argv[i])) && __builtin_constant_p
(("-MF")) && (__s1_len = strlen ((argv[i])), __s2_len
= strlen (("-MF")), (!((size_t)(const void *)(((argv[i])) + 1
) - (size_t)(const void *)((argv[i])) == 1) || __s1_len >=
4) && (!((size_t)(const void *)((("-MF")) + 1) - (size_t
)(const void *)(("-MF")) == 1) || __s2_len >= 4)) ? __builtin_strcmp
((argv[i]), ("-MF")) : (__builtin_constant_p ((argv[i])) &&
((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const void
*)((argv[i])) == 1) && (__s1_len = strlen ((argv[i])
), __s1_len < 4) ? (__builtin_constant_p (("-MF")) &&
((size_t)(const void *)((("-MF")) + 1) - (size_t)(const void
*)(("-MF")) == 1) ? __builtin_strcmp ((argv[i]), ("-MF")) : (
__extension__ ({ const unsigned char *__s2 = (const unsigned char
*) (const char *) (("-MF")); int __result = (((const unsigned
char *) (const char *) ((argv[i])))[0] - __s2[0]); if (__s1_len
> 0 && __result == 0) { __result = (((const unsigned
char *) (const char *) ((argv[i])))[1] - __s2[1]); if (__s1_len
> 1 && __result == 0) { __result = (((const unsigned
char *) (const char *) ((argv[i])))[2] - __s2[2]); if (__s1_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) ((argv[i])))[3] - __s2[3]); } } __result
; }))) : (__builtin_constant_p (("-MF")) && ((size_t)
(const void *)((("-MF")) + 1) - (size_t)(const void *)(("-MF"
)) == 1) && (__s2_len = strlen (("-MF")), __s2_len <
4) ? (__builtin_constant_p ((argv[i])) && ((size_t)(
const void *)(((argv[i])) + 1) - (size_t)(const void *)((argv
[i])) == 1) ? __builtin_strcmp ((argv[i]), ("-MF")) : (- (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) ((argv[i])); int __result = (((const unsigned char *
) (const char *) (("-MF")))[0] - __s2[0]); if (__s2_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) (("-MF")))[1] - __s2[1]); if (__s2_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) (("-MF")))[2] - __s2[2]); if (__s2_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) (("-MF")))[3] - __s2[3]); } } __result; })
))) : __builtin_strcmp ((argv[i]), ("-MF"))))); }) : strncmp (
(argv[i]), ("-MF"), strlen(("-MF"))))) == 0)
) {
1451 char *arg;
1452 bool_Bool separate_argument = (strlen(argv[i]) == 3);
1453 dependency_filename_specified = true1;
1454 free(output_dep);
1455 if (separate_argument) {
1456 /* -MF arg */
1457 if (i >= argc - 1) {
1458 cc_log("Missing argument to %s", argv[i]);
1459 stats_update(STATS_ARGS);
1460 result = false0;
1461 goto out;
1462 }
1463 arg = argv[i + 1];
1464 i++;
1465 } else {
1466 /* -MFarg */
1467 arg = &argv[i][3];
1468 }
1469 output_dep = make_relative_path(x_strdup(arg));
1470 /* Keep the format of the args the same */
1471 if (separate_argument) {
1472 args_add(dep_args, "-MF");
1473 args_add(dep_args, output_dep);
1474 } else {
1475 char *option = format("-MF%s", output_dep);
1476 args_add(dep_args, option);
1477 free(option);
1478 }
1479 continue;
1480 }
1481 if (str_startswith(argv[i], "-MQ")((__extension__ (__builtin_constant_p (strlen(("-MQ"))) &&
((__builtin_constant_p ((argv[i])) && strlen ((argv[
i])) < ((size_t) (strlen(("-MQ"))))) || (__builtin_constant_p
(("-MQ")) && strlen (("-MQ")) < ((size_t) (strlen
(("-MQ")))))) ? __extension__ ({ size_t __s1_len, __s2_len; (
__builtin_constant_p ((argv[i])) && __builtin_constant_p
(("-MQ")) && (__s1_len = strlen ((argv[i])), __s2_len
= strlen (("-MQ")), (!((size_t)(const void *)(((argv[i])) + 1
) - (size_t)(const void *)((argv[i])) == 1) || __s1_len >=
4) && (!((size_t)(const void *)((("-MQ")) + 1) - (size_t
)(const void *)(("-MQ")) == 1) || __s2_len >= 4)) ? __builtin_strcmp
((argv[i]), ("-MQ")) : (__builtin_constant_p ((argv[i])) &&
((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const void
*)((argv[i])) == 1) && (__s1_len = strlen ((argv[i])
), __s1_len < 4) ? (__builtin_constant_p (("-MQ")) &&
((size_t)(const void *)((("-MQ")) + 1) - (size_t)(const void
*)(("-MQ")) == 1) ? __builtin_strcmp ((argv[i]), ("-MQ")) : (
__extension__ ({ const unsigned char *__s2 = (const unsigned char
*) (const char *) (("-MQ")); int __result = (((const unsigned
char *) (const char *) ((argv[i])))[0] - __s2[0]); if (__s1_len
> 0 && __result == 0) { __result = (((const unsigned
char *) (const char *) ((argv[i])))[1] - __s2[1]); if (__s1_len
> 1 && __result == 0) { __result = (((const unsigned
char *) (const char *) ((argv[i])))[2] - __s2[2]); if (__s1_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) ((argv[i])))[3] - __s2[3]); } } __result
; }))) : (__builtin_constant_p (("-MQ")) && ((size_t)
(const void *)((("-MQ")) + 1) - (size_t)(const void *)(("-MQ"
)) == 1) && (__s2_len = strlen (("-MQ")), __s2_len <
4) ? (__builtin_constant_p ((argv[i])) && ((size_t)(
const void *)(((argv[i])) + 1) - (size_t)(const void *)((argv
[i])) == 1) ? __builtin_strcmp ((argv[i]), ("-MQ")) : (- (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) ((argv[i])); int __result = (((const unsigned char *
) (const char *) (("-MQ")))[0] - __s2[0]); if (__s2_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) (("-MQ")))[1] - __s2[1]); if (__s2_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) (("-MQ")))[2] - __s2[2]); if (__s2_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) (("-MQ")))[3] - __s2[3]); } } __result; })
))) : __builtin_strcmp ((argv[i]), ("-MQ"))))); }) : strncmp (
(argv[i]), ("-MQ"), strlen(("-MQ"))))) == 0)
|| str_startswith(argv[i], "-MT")((__extension__ (__builtin_constant_p (strlen(("-MT"))) &&
((__builtin_constant_p ((argv[i])) && strlen ((argv[
i])) < ((size_t) (strlen(("-MT"))))) || (__builtin_constant_p
(("-MT")) && strlen (("-MT")) < ((size_t) (strlen
(("-MT")))))) ? __extension__ ({ size_t __s1_len, __s2_len; (
__builtin_constant_p ((argv[i])) && __builtin_constant_p
(("-MT")) && (__s1_len = strlen ((argv[i])), __s2_len
= strlen (("-MT")), (!((size_t)(const void *)(((argv[i])) + 1
) - (size_t)(const void *)((argv[i])) == 1) || __s1_len >=
4) && (!((size_t)(const void *)((("-MT")) + 1) - (size_t
)(const void *)(("-MT")) == 1) || __s2_len >= 4)) ? __builtin_strcmp
((argv[i]), ("-MT")) : (__builtin_constant_p ((argv[i])) &&
((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const void
*)((argv[i])) == 1) && (__s1_len = strlen ((argv[i])
), __s1_len < 4) ? (__builtin_constant_p (("-MT")) &&
((size_t)(const void *)((("-MT")) + 1) - (size_t)(const void
*)(("-MT")) == 1) ? __builtin_strcmp ((argv[i]), ("-MT")) : (
__extension__ ({ const unsigned char *__s2 = (const unsigned char
*) (const char *) (("-MT")); int __result = (((const unsigned
char *) (const char *) ((argv[i])))[0] - __s2[0]); if (__s1_len
> 0 && __result == 0) { __result = (((const unsigned
char *) (const char *) ((argv[i])))[1] - __s2[1]); if (__s1_len
> 1 && __result == 0) { __result = (((const unsigned
char *) (const char *) ((argv[i])))[2] - __s2[2]); if (__s1_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) ((argv[i])))[3] - __s2[3]); } } __result
; }))) : (__builtin_constant_p (("-MT")) && ((size_t)
(const void *)((("-MT")) + 1) - (size_t)(const void *)(("-MT"
)) == 1) && (__s2_len = strlen (("-MT")), __s2_len <
4) ? (__builtin_constant_p ((argv[i])) && ((size_t)(
const void *)(((argv[i])) + 1) - (size_t)(const void *)((argv
[i])) == 1) ? __builtin_strcmp ((argv[i]), ("-MT")) : (- (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) ((argv[i])); int __result = (((const unsigned char *
) (const char *) (("-MT")))[0] - __s2[0]); if (__s2_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) (("-MT")))[1] - __s2[1]); if (__s2_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) (("-MT")))[2] - __s2[2]); if (__s2_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) (("-MT")))[3] - __s2[3]); } } __result; })
))) : __builtin_strcmp ((argv[i]), ("-MT"))))); }) : strncmp (
(argv[i]), ("-MT"), strlen(("-MT"))))) == 0)
) {
1482 char *relpath;
1483 dependency_target_specified = true1;
1484 if (strlen(argv[i]) == 3) {
1485 /* -MQ arg or -MT arg */
1486 if (i >= argc - 1) {
1487 cc_log("Missing argument to %s", argv[i]);
1488 stats_update(STATS_ARGS);
1489 result = false0;
1490 goto out;
1491 }
1492 args_add(dep_args, argv[i]);
1493 relpath = make_relative_path(x_strdup(argv[i + 1]));
1494 args_add(dep_args, relpath);
1495 free(relpath);
1496 i++;
1497 } else {
1498 char *arg_opt;
1499 char *option;
1500 arg_opt = x_strndup(argv[i], 3);
1501 relpath = make_relative_path(x_strdup(argv[i] + 3));
1502 option = format("%s%s", arg_opt, relpath);
1503 args_add(dep_args, option);
1504 free(arg_opt);
1505 free(relpath);
1506 free(option);
1507 }
1508 continue;
1509 }
1510 if (str_startswith(argv[i], "--sysroot=")((__extension__ (__builtin_constant_p (strlen(("--sysroot="))
) && ((__builtin_constant_p ((argv[i])) && strlen
((argv[i])) < ((size_t) (strlen(("--sysroot="))))) || (__builtin_constant_p
(("--sysroot=")) && strlen (("--sysroot=")) < ((size_t
) (strlen(("--sysroot=")))))) ? __extension__ ({ size_t __s1_len
, __s2_len; (__builtin_constant_p ((argv[i])) && __builtin_constant_p
(("--sysroot=")) && (__s1_len = strlen ((argv[i])), __s2_len
= strlen (("--sysroot=")), (!((size_t)(const void *)(((argv[
i])) + 1) - (size_t)(const void *)((argv[i])) == 1) || __s1_len
>= 4) && (!((size_t)(const void *)((("--sysroot="
)) + 1) - (size_t)(const void *)(("--sysroot=")) == 1) || __s2_len
>= 4)) ? __builtin_strcmp ((argv[i]), ("--sysroot=")) : (
__builtin_constant_p ((argv[i])) && ((size_t)(const void
*)(((argv[i])) + 1) - (size_t)(const void *)((argv[i])) == 1
) && (__s1_len = strlen ((argv[i])), __s1_len < 4)
? (__builtin_constant_p (("--sysroot=")) && ((size_t
)(const void *)((("--sysroot=")) + 1) - (size_t)(const void *
)(("--sysroot=")) == 1) ? __builtin_strcmp ((argv[i]), ("--sysroot="
)) : (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) (("--sysroot=")); int __result = (((const
unsigned char *) (const char *) ((argv[i])))[0] - __s2[0]); if
(__s1_len > 0 && __result == 0) { __result = (((const
unsigned char *) (const char *) ((argv[i])))[1] - __s2[1]); if
(__s1_len > 1 && __result == 0) { __result = (((const
unsigned char *) (const char *) ((argv[i])))[2] - __s2[2]); if
(__s1_len > 2 && __result == 0) __result = (((const
unsigned char *) (const char *) ((argv[i])))[3] - __s2[3]); }
} __result; }))) : (__builtin_constant_p (("--sysroot=")) &&
((size_t)(const void *)((("--sysroot=")) + 1) - (size_t)(const
void *)(("--sysroot=")) == 1) && (__s2_len = strlen (
("--sysroot=")), __s2_len < 4) ? (__builtin_constant_p ((argv
[i])) && ((size_t)(const void *)(((argv[i])) + 1) - (
size_t)(const void *)((argv[i])) == 1) ? __builtin_strcmp ((argv
[i]), ("--sysroot=")) : (- (__extension__ ({ const unsigned char
*__s2 = (const unsigned char *) (const char *) ((argv[i])); int
__result = (((const unsigned char *) (const char *) (("--sysroot="
)))[0] - __s2[0]); if (__s2_len > 0 && __result ==
0) { __result = (((const unsigned char *) (const char *) (("--sysroot="
)))[1] - __s2[1]); if (__s2_len > 1 && __result ==
0) { __result = (((const unsigned char *) (const char *) (("--sysroot="
)))[2] - __s2[2]); if (__s2_len > 2 && __result ==
0) __result = (((const unsigned char *) (const char *) (("--sysroot="
)))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp ((argv
[i]), ("--sysroot="))))); }) : strncmp ((argv[i]), ("--sysroot="
), strlen(("--sysroot="))))) == 0)
) {
1511 char *relpath = make_relative_path(x_strdup(argv[i] + 10));
1512 char *option = format("--sysroot=%s", relpath);
1513 args_add(stripped_args, option);
1514 free(relpath);
1515 free(option);
1516 continue;
1517 }
1518 if (str_startswith(argv[i], "-Wp,")((__extension__ (__builtin_constant_p (strlen(("-Wp,"))) &&
((__builtin_constant_p ((argv[i])) && strlen ((argv[
i])) < ((size_t) (strlen(("-Wp,"))))) || (__builtin_constant_p
(("-Wp,")) && strlen (("-Wp,")) < ((size_t) (strlen
(("-Wp,")))))) ? __extension__ ({ size_t __s1_len, __s2_len; (
__builtin_constant_p ((argv[i])) && __builtin_constant_p
(("-Wp,")) && (__s1_len = strlen ((argv[i])), __s2_len
= strlen (("-Wp,")), (!((size_t)(const void *)(((argv[i])) +
1) - (size_t)(const void *)((argv[i])) == 1) || __s1_len >=
4) && (!((size_t)(const void *)((("-Wp,")) + 1) - (size_t
)(const void *)(("-Wp,")) == 1) || __s2_len >= 4)) ? __builtin_strcmp
((argv[i]), ("-Wp,")) : (__builtin_constant_p ((argv[i])) &&
((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const void
*)((argv[i])) == 1) && (__s1_len = strlen ((argv[i])
), __s1_len < 4) ? (__builtin_constant_p (("-Wp,")) &&
((size_t)(const void *)((("-Wp,")) + 1) - (size_t)(const void
*)(("-Wp,")) == 1) ? __builtin_strcmp ((argv[i]), ("-Wp,")) :
(__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) (("-Wp,")); int __result = (((const unsigned
char *) (const char *) ((argv[i])))[0] - __s2[0]); if (__s1_len
> 0 && __result == 0) { __result = (((const unsigned
char *) (const char *) ((argv[i])))[1] - __s2[1]); if (__s1_len
> 1 && __result == 0) { __result = (((const unsigned
char *) (const char *) ((argv[i])))[2] - __s2[2]); if (__s1_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) ((argv[i])))[3] - __s2[3]); } } __result
; }))) : (__builtin_constant_p (("-Wp,")) && ((size_t
)(const void *)((("-Wp,")) + 1) - (size_t)(const void *)(("-Wp,"
)) == 1) && (__s2_len = strlen (("-Wp,")), __s2_len <
4) ? (__builtin_constant_p ((argv[i])) && ((size_t)(
const void *)(((argv[i])) + 1) - (size_t)(const void *)((argv
[i])) == 1) ? __builtin_strcmp ((argv[i]), ("-Wp,")) : (- (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) ((argv[i])); int __result = (((const unsigned char *
) (const char *) (("-Wp,")))[0] - __s2[0]); if (__s2_len >
0 && __result == 0) { __result = (((const unsigned char
*) (const char *) (("-Wp,")))[1] - __s2[1]); if (__s2_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) (("-Wp,")))[2] - __s2[2]); if (__s2_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) (("-Wp,")))[3] - __s2[3]); } } __result; }
)))) : __builtin_strcmp ((argv[i]), ("-Wp,"))))); }) : strncmp
((argv[i]), ("-Wp,"), strlen(("-Wp,"))))) == 0)
) {
1519 if (str_startswith(argv[i], "-Wp,-MD,")((__extension__ (__builtin_constant_p (strlen(("-Wp,-MD,"))) &&
((__builtin_constant_p ((argv[i])) && strlen ((argv[
i])) < ((size_t) (strlen(("-Wp,-MD,"))))) || (__builtin_constant_p
(("-Wp,-MD,")) && strlen (("-Wp,-MD,")) < ((size_t
) (strlen(("-Wp,-MD,")))))) ? __extension__ ({ size_t __s1_len
, __s2_len; (__builtin_constant_p ((argv[i])) && __builtin_constant_p
(("-Wp,-MD,")) && (__s1_len = strlen ((argv[i])), __s2_len
= strlen (("-Wp,-MD,")), (!((size_t)(const void *)(((argv[i]
)) + 1) - (size_t)(const void *)((argv[i])) == 1) || __s1_len
>= 4) && (!((size_t)(const void *)((("-Wp,-MD,"))
+ 1) - (size_t)(const void *)(("-Wp,-MD,")) == 1) || __s2_len
>= 4)) ? __builtin_strcmp ((argv[i]), ("-Wp,-MD,")) : (__builtin_constant_p
((argv[i])) && ((size_t)(const void *)(((argv[i])) +
1) - (size_t)(const void *)((argv[i])) == 1) && (__s1_len
= strlen ((argv[i])), __s1_len < 4) ? (__builtin_constant_p
(("-Wp,-MD,")) && ((size_t)(const void *)((("-Wp,-MD,"
)) + 1) - (size_t)(const void *)(("-Wp,-MD,")) == 1) ? __builtin_strcmp
((argv[i]), ("-Wp,-MD,")) : (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (("-Wp,-MD,"
)); int __result = (((const unsigned char *) (const char *) (
(argv[i])))[0] - __s2[0]); if (__s1_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(argv[i])))[1] - __s2[1]); if (__s1_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(argv[i])))[2] - __s2[2]); if (__s1_len > 2 && __result
== 0) __result = (((const unsigned char *) (const char *) ((
argv[i])))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
(("-Wp,-MD,")) && ((size_t)(const void *)((("-Wp,-MD,"
)) + 1) - (size_t)(const void *)(("-Wp,-MD,")) == 1) &&
(__s2_len = strlen (("-Wp,-MD,")), __s2_len < 4) ? (__builtin_constant_p
((argv[i])) && ((size_t)(const void *)(((argv[i])) +
1) - (size_t)(const void *)((argv[i])) == 1) ? __builtin_strcmp
((argv[i]), ("-Wp,-MD,")) : (- (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) ((argv[i
])); int __result = (((const unsigned char *) (const char *) (
("-Wp,-MD,")))[0] - __s2[0]); if (__s2_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
("-Wp,-MD,")))[1] - __s2[1]); if (__s2_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
("-Wp,-MD,")))[2] - __s2[2]); if (__s2_len > 2 && __result
== 0) __result = (((const unsigned char *) (const char *) ((
"-Wp,-MD,")))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
((argv[i]), ("-Wp,-MD,"))))); }) : strncmp ((argv[i]), ("-Wp,-MD,"
), strlen(("-Wp,-MD,"))))) == 0)
&& !strchr(argv[i] + 8, ',')(__extension__ (__builtin_constant_p (',') && !__builtin_constant_p
(argv[i] + 8) && (',') == '\0' ? (char *) __rawmemchr
(argv[i] + 8, ',') : __builtin_strchr (argv[i] + 8, ',')))
) {
1520 generating_dependencies = true1;
1521 dependency_filename_specified = true1;
1522 free(output_dep);
1523 output_dep = make_relative_path(x_strdup(argv[i] + 8));
1524 args_add(dep_args, argv[i]);
1525 continue;
1526 } else if (str_startswith(argv[i], "-Wp,-MMD,")((__extension__ (__builtin_constant_p (strlen(("-Wp,-MMD,")))
&& ((__builtin_constant_p ((argv[i])) && strlen
((argv[i])) < ((size_t) (strlen(("-Wp,-MMD,"))))) || (__builtin_constant_p
(("-Wp,-MMD,")) && strlen (("-Wp,-MMD,")) < ((size_t
) (strlen(("-Wp,-MMD,")))))) ? __extension__ ({ size_t __s1_len
, __s2_len; (__builtin_constant_p ((argv[i])) && __builtin_constant_p
(("-Wp,-MMD,")) && (__s1_len = strlen ((argv[i])), __s2_len
= strlen (("-Wp,-MMD,")), (!((size_t)(const void *)(((argv[i
])) + 1) - (size_t)(const void *)((argv[i])) == 1) || __s1_len
>= 4) && (!((size_t)(const void *)((("-Wp,-MMD,")
) + 1) - (size_t)(const void *)(("-Wp,-MMD,")) == 1) || __s2_len
>= 4)) ? __builtin_strcmp ((argv[i]), ("-Wp,-MMD,")) : (__builtin_constant_p
((argv[i])) && ((size_t)(const void *)(((argv[i])) +
1) - (size_t)(const void *)((argv[i])) == 1) && (__s1_len
= strlen ((argv[i])), __s1_len < 4) ? (__builtin_constant_p
(("-Wp,-MMD,")) && ((size_t)(const void *)((("-Wp,-MMD,"
)) + 1) - (size_t)(const void *)(("-Wp,-MMD,")) == 1) ? __builtin_strcmp
((argv[i]), ("-Wp,-MMD,")) : (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (("-Wp,-MMD,"
)); int __result = (((const unsigned char *) (const char *) (
(argv[i])))[0] - __s2[0]); if (__s1_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(argv[i])))[1] - __s2[1]); if (__s1_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(argv[i])))[2] - __s2[2]); if (__s1_len > 2 && __result
== 0) __result = (((const unsigned char *) (const char *) ((
argv[i])))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
(("-Wp,-MMD,")) && ((size_t)(const void *)((("-Wp,-MMD,"
)) + 1) - (size_t)(const void *)(("-Wp,-MMD,")) == 1) &&
(__s2_len = strlen (("-Wp,-MMD,")), __s2_len < 4) ? (__builtin_constant_p
((argv[i])) && ((size_t)(const void *)(((argv[i])) +
1) - (size_t)(const void *)((argv[i])) == 1) ? __builtin_strcmp
((argv[i]), ("-Wp,-MMD,")) : (- (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) ((argv[i
])); int __result = (((const unsigned char *) (const char *) (
("-Wp,-MMD,")))[0] - __s2[0]); if (__s2_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("-Wp,-MMD,")))[1] - __s2[1]); if (__s2_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("-Wp,-MMD,")))[2] - __s2[2]); if (__s2_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char
*) (("-Wp,-MMD,")))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
((argv[i]), ("-Wp,-MMD,"))))); }) : strncmp ((argv[i]), ("-Wp,-MMD,"
), strlen(("-Wp,-MMD,"))))) == 0)
1527 && !strchr(argv[i] + 9, ',')(__extension__ (__builtin_constant_p (',') && !__builtin_constant_p
(argv[i] + 9) && (',') == '\0' ? (char *) __rawmemchr
(argv[i] + 9, ',') : __builtin_strchr (argv[i] + 9, ',')))
) {
1528 generating_dependencies = true1;
1529 dependency_filename_specified = true1;
1530 free(output_dep);
1531 output_dep = make_relative_path(x_strdup(argv[i] + 9));
1532 args_add(dep_args, argv[i]);
1533 continue;
1534 } else if (enable_direct) {
1535 /*
1536 * -Wp, can be used to pass too hard options to
1537 * the preprocessor. Hence, disable direct
1538 * mode.
1539 */
1540 cc_log("Unsupported compiler option for direct mode: %s", argv[i]);
1541 enable_direct = false0;
1542 }
1543 }
1544 if (str_eq(argv[i], "-MP")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((argv[i])) && __builtin_constant_p (("-MP")) &&
(__s1_len = strlen ((argv[i])), __s2_len = strlen (("-MP")),
(!((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const void
*)((argv[i])) == 1) || __s1_len >= 4) && (!((size_t
)(const void *)((("-MP")) + 1) - (size_t)(const void *)(("-MP"
)) == 1) || __s2_len >= 4)) ? __builtin_strcmp ((argv[i]),
("-MP")) : (__builtin_constant_p ((argv[i])) && ((size_t
)(const void *)(((argv[i])) + 1) - (size_t)(const void *)((argv
[i])) == 1) && (__s1_len = strlen ((argv[i])), __s1_len
< 4) ? (__builtin_constant_p (("-MP")) && ((size_t
)(const void *)((("-MP")) + 1) - (size_t)(const void *)(("-MP"
)) == 1) ? __builtin_strcmp ((argv[i]), ("-MP")) : (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (("-MP")); int __result = (((const unsigned char *) (
const char *) ((argv[i])))[0] - __s2[0]); if (__s1_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[1] - __s2[1]); if (__s1_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) ((argv[i])))[2] - __s2[2]); if (__s1_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) ((argv[i])))[3] - __s2[3]); } } __result; }
))) : (__builtin_constant_p (("-MP")) && ((size_t)(const
void *)((("-MP")) + 1) - (size_t)(const void *)(("-MP")) == 1
) && (__s2_len = strlen (("-MP")), __s2_len < 4) ?
(__builtin_constant_p ((argv[i])) && ((size_t)(const
void *)(((argv[i])) + 1) - (size_t)(const void *)((argv[i]))
== 1) ? __builtin_strcmp ((argv[i]), ("-MP")) : (- (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) ((argv[i])); int __result = (((const unsigned char *
) (const char *) (("-MP")))[0] - __s2[0]); if (__s2_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) (("-MP")))[1] - __s2[1]); if (__s2_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) (("-MP")))[2] - __s2[2]); if (__s2_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) (("-MP")))[3] - __s2[3]); } } __result; })
))) : __builtin_strcmp ((argv[i]), ("-MP"))))); }) == 0)
) {
1545 args_add(dep_args, argv[i]);
1546 continue;
1547 }
1548
1549 /* Input charset needs to be handled specially. */
1550 if (str_startswith(argv[i], "-finput-charset=")((__extension__ (__builtin_constant_p (strlen(("-finput-charset="
))) && ((__builtin_constant_p ((argv[i])) && strlen
((argv[i])) < ((size_t) (strlen(("-finput-charset="))))) ||
(__builtin_constant_p (("-finput-charset=")) && strlen
(("-finput-charset=")) < ((size_t) (strlen(("-finput-charset="
)))))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((argv[i])) && __builtin_constant_p (("-finput-charset="
)) && (__s1_len = strlen ((argv[i])), __s2_len = strlen
(("-finput-charset=")), (!((size_t)(const void *)(((argv[i])
) + 1) - (size_t)(const void *)((argv[i])) == 1) || __s1_len >=
4) && (!((size_t)(const void *)((("-finput-charset="
)) + 1) - (size_t)(const void *)(("-finput-charset=")) == 1) ||
__s2_len >= 4)) ? __builtin_strcmp ((argv[i]), ("-finput-charset="
)) : (__builtin_constant_p ((argv[i])) && ((size_t)(const
void *)(((argv[i])) + 1) - (size_t)(const void *)((argv[i]))
== 1) && (__s1_len = strlen ((argv[i])), __s1_len <
4) ? (__builtin_constant_p (("-finput-charset=")) &&
((size_t)(const void *)((("-finput-charset=")) + 1) - (size_t
)(const void *)(("-finput-charset=")) == 1) ? __builtin_strcmp
((argv[i]), ("-finput-charset=")) : (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (("-finput-charset="
)); int __result = (((const unsigned char *) (const char *) (
(argv[i])))[0] - __s2[0]); if (__s1_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(argv[i])))[1] - __s2[1]); if (__s1_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(argv[i])))[2] - __s2[2]); if (__s1_len > 2 && __result
== 0) __result = (((const unsigned char *) (const char *) ((
argv[i])))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
(("-finput-charset=")) && ((size_t)(const void *)(((
"-finput-charset=")) + 1) - (size_t)(const void *)(("-finput-charset="
)) == 1) && (__s2_len = strlen (("-finput-charset="))
, __s2_len < 4) ? (__builtin_constant_p ((argv[i])) &&
((size_t)(const void *)(((argv[i])) + 1) - (size_t)(const void
*)((argv[i])) == 1) ? __builtin_strcmp ((argv[i]), ("-finput-charset="
)) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) ((argv[i])); int __result = (((const unsigned
char *) (const char *) (("-finput-charset=")))[0] - __s2[0])
; if (__s2_len > 0 && __result == 0) { __result = (
((const unsigned char *) (const char *) (("-finput-charset=")
))[1] - __s2[1]); if (__s2_len > 1 && __result == 0
) { __result = (((const unsigned char *) (const char *) (("-finput-charset="
)))[2] - __s2[2]); if (__s2_len > 2 && __result ==
0) __result = (((const unsigned char *) (const char *) (("-finput-charset="
)))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp ((argv
[i]), ("-finput-charset="))))); }) : strncmp ((argv[i]), ("-finput-charset="
), strlen(("-finput-charset="))))) == 0)
) {
1551 input_charset = argv[i];
1552 continue;
1553 }
1554
1555 /*
1556 * Options taking an argument that that we may want to rewrite
1557 * to relative paths to get better hit rate. A secondary effect
1558 * is that paths in the standard error output produced by the
1559 * compiler will be normalized.
1560 */
1561 if (compopt_takes_path(argv[i])) {
1562 char *relpath;
1563 char *pchpath;
1564 if (i == argc-1) {
1565 cc_log("Missing argument to %s", argv[i]);
1566 stats_update(STATS_ARGS);
1567 result = false0;
1568 goto out;
1569 }
1570
1571 args_add(stripped_args, argv[i]);
1572 relpath = make_relative_path(x_strdup(argv[i+1]));
1573 args_add(stripped_args, relpath);
1574
1575 /* Try to be smart about detecting precompiled headers */
1576 pchpath = format("%s.gch", argv[i+1]);
1577 if (stat(pchpath, &st) == 0) {
1578 cc_log("Detected use of precompiled header: %s", pchpath);
1579 found_pch = true1;
1580 }
1581
1582 free(pchpath);
1583 free(relpath);
1584 i++;
1585 continue;
1586 }
1587
1588 /* Same as above but options with concatenated argument. */
1589 if (compopt_short(compopt_takes_path, argv[i])) {
1590 char *relpath;
1591 char *option;
1592 relpath = make_relative_path(x_strdup(argv[i] + 2));
1593 option = format("-%c%s", argv[i][1], relpath);
1594 args_add(stripped_args, option);
1595 free(relpath);
1596 free(option);
1597 continue;
1598 }
1599
1600 /* options that take an argument */
1601 if (compopt_takes_arg(argv[i])) {
1602 if (i == argc-1) {
1603 cc_log("Missing argument to %s", argv[i]);
1604 stats_update(STATS_ARGS);
1605 result = false0;
1606 goto out;
1607 }
1608 args_add(stripped_args, argv[i]);
1609 args_add(stripped_args, argv[i+1]);
1610 i++;
1611 continue;
1612 }
1613
1614 /* other options */
1615 if (argv[i][0] == '-') {
1616 args_add(stripped_args, argv[i]);
1617 continue;
1618 }
1619
1620 /* if an argument isn't a plain file then assume its
1621 an option, not an input file. This allows us to
1622 cope better with unusual compiler options */
1623 if (stat(argv[i], &st) != 0 || !S_ISREG(st.st_mode)((((st.st_mode)) & 0170000) == (0100000))) {
1624 cc_log("%s is not a regular file, not considering as input file",
1625 argv[i]);
1626 args_add(stripped_args, argv[i]);
1627 continue;
1628 }
1629
1630 if (input_file) {
1631 if (language_for_file(argv[i])) {
1632 cc_log("Multiple input files: %s and %s", input_file, argv[i]);
1633 stats_update(STATS_MULTIPLE);
1634 } else if (!found_c_opt) {
1635 cc_log("Called for link with %s", argv[i]);
1636 if (strstr(argv[i], "conftest.")) {
1637 stats_update(STATS_CONFTEST);
1638 } else {
1639 stats_update(STATS_LINK);
1640 }
1641 } else {
1642 cc_log("Unsupported source extension: %s", argv[i]);
1643 stats_update(STATS_SOURCELANG);
1644 }
1645 result = false0;
1646 goto out;
1647 }
1648
1649 /* Rewrite to relative to increase hit rate. */
1650 input_file = make_relative_path(x_strdup(argv[i]));
1651 }
1652
1653 if (!input_file) {
1654 cc_log("No input file found");
1655 stats_update(STATS_NOINPUT);
1656 result = false0;
1657 goto out;
1658 }
1659
1660 if (found_pch || found_fpch_preprocess) {
1661 using_precompiled_header = true1;
1662 if (!(sloppiness & SLOPPY_TIME_MACROS4)) {
1663 cc_log("You have to specify \"time_macros\" sloppiness when using"
1664 " precompiled headers to get direct hits");
1665 cc_log("Disabling direct mode");
1666 stats_update(STATS_CANTUSEPCH);
1667 result = false0;
1668 goto out;
1669 }
1670 }
1671
1672 if (explicit_language && str_eq(explicit_language, "none")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((explicit_language)) && __builtin_constant_p (("none"
)) && (__s1_len = strlen ((explicit_language)), __s2_len
= strlen (("none")), (!((size_t)(const void *)(((explicit_language
)) + 1) - (size_t)(const void *)((explicit_language)) == 1) ||
__s1_len >= 4) && (!((size_t)(const void *)((("none"
)) + 1) - (size_t)(const void *)(("none")) == 1) || __s2_len >=
4)) ? __builtin_strcmp ((explicit_language), ("none")) : (__builtin_constant_p
((explicit_language)) && ((size_t)(const void *)(((explicit_language
)) + 1) - (size_t)(const void *)((explicit_language)) == 1) &&
(__s1_len = strlen ((explicit_language)), __s1_len < 4) ?
(__builtin_constant_p (("none")) && ((size_t)(const void
*)((("none")) + 1) - (size_t)(const void *)(("none")) == 1) ?
__builtin_strcmp ((explicit_language), ("none")) : (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (("none")); int __result = (((const unsigned char *)
(const char *) ((explicit_language)))[0] - __s2[0]); if (__s1_len
> 0 && __result == 0) { __result = (((const unsigned
char *) (const char *) ((explicit_language)))[1] - __s2[1]);
if (__s1_len > 1 && __result == 0) { __result = (
((const unsigned char *) (const char *) ((explicit_language))
)[2] - __s2[2]); if (__s1_len > 2 && __result == 0
) __result = (((const unsigned char *) (const char *) ((explicit_language
)))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
(("none")) && ((size_t)(const void *)((("none")) + 1
) - (size_t)(const void *)(("none")) == 1) && (__s2_len
= strlen (("none")), __s2_len < 4) ? (__builtin_constant_p
((explicit_language)) && ((size_t)(const void *)(((explicit_language
)) + 1) - (size_t)(const void *)((explicit_language)) == 1) ?
__builtin_strcmp ((explicit_language), ("none")) : (- (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) ((explicit_language)); int __result = (((const unsigned
char *) (const char *) (("none")))[0] - __s2[0]); if (__s2_len
> 0 && __result == 0) { __result = (((const unsigned
char *) (const char *) (("none")))[1] - __s2[1]); if (__s2_len
> 1 && __result == 0) { __result = (((const unsigned
char *) (const char *) (("none")))[2] - __s2[2]); if (__s2_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) (("none")))[3] - __s2[3]); } } __result
; })))) : __builtin_strcmp ((explicit_language), ("none")))))
; }) == 0)
) {
1673 explicit_language = NULL((void*)0);
1674 }
1675 file_language = language_for_file(input_file);
1676 if (explicit_language) {
1677 if (!language_is_supported(explicit_language)) {
1678 cc_log("Unsupported language: %s", explicit_language);
1679 stats_update(STATS_SOURCELANG);
1680 result = false0;
1681 goto out;
1682 }
1683 actual_language = explicit_language;
1684 } else {
1685 actual_language = file_language;
1686 }
1687
1688 output_is_precompiled_header =
1689 actual_language && strstr(actual_language, "-header") != NULL((void*)0);
1690
1691 if (!found_c_opt) {
1692 if (output_is_precompiled_header) {
1693 args_add(stripped_args, "-c");
1694 } else {
1695 cc_log("No -c option found");
1696 /* I find that having a separate statistic for autoconf tests is useful,
1697 as they are the dominant form of "called for link" in many cases */
1698 if (strstr(input_file, "conftest.")) {
1699 stats_update(STATS_CONFTEST);
1700 } else {
1701 stats_update(STATS_LINK);
1702 }
1703 result = false0;
1704 goto out;
1705 }
1706 }
1707
1708 if (!actual_language) {
1709 cc_log("Unsupported source extension: %s", input_file);
1710 stats_update(STATS_SOURCELANG);
1711 result = false0;
1712 goto out;
1713 }
1714
1715 direct_i_file = language_is_preprocessed(actual_language);
1716
1717 if (output_is_precompiled_header) {
1718 /* It doesn't work to create the .gch from preprocessed source. */
1719 cc_log("Creating precompiled header; not compiling preprocessed code");
1720 compile_preprocessed_source_code = false0;
1721 }
1722
1723 i_extension = getenv("CCACHE_EXTENSION");
1724 if (!i_extension) {
1725 const char *p_language = p_language_for_language(actual_language);
1726 i_extension = extension_for_language(p_language) + 1;
1727 }
1728
1729 /* don't try to second guess the compilers heuristics for stdout handling */
1730 if (output_obj && str_eq(output_obj, "-")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((output_obj)) && __builtin_constant_p (("-")) &&
(__s1_len = strlen ((output_obj)), __s2_len = strlen (("-"))
, (!((size_t)(const void *)(((output_obj)) + 1) - (size_t)(const
void *)((output_obj)) == 1) || __s1_len >= 4) && (
!((size_t)(const void *)((("-")) + 1) - (size_t)(const void *
)(("-")) == 1) || __s2_len >= 4)) ? __builtin_strcmp ((output_obj
), ("-")) : (__builtin_constant_p ((output_obj)) && (
(size_t)(const void *)(((output_obj)) + 1) - (size_t)(const void
*)((output_obj)) == 1) && (__s1_len = strlen ((output_obj
)), __s1_len < 4) ? (__builtin_constant_p (("-")) &&
((size_t)(const void *)((("-")) + 1) - (size_t)(const void *
)(("-")) == 1) ? __builtin_strcmp ((output_obj), ("-")) : (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (("-")); int __result = (((const unsigned char *) (const
char *) ((output_obj)))[0] - __s2[0]); if (__s1_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) ((output_obj)))[1] - __s2[1]); if (__s1_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) ((output_obj)))[2] - __s2[2]); if (__s1_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char
*) ((output_obj)))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
(("-")) && ((size_t)(const void *)((("-")) + 1) - (size_t
)(const void *)(("-")) == 1) && (__s2_len = strlen ((
"-")), __s2_len < 4) ? (__builtin_constant_p ((output_obj)
) && ((size_t)(const void *)(((output_obj)) + 1) - (size_t
)(const void *)((output_obj)) == 1) ? __builtin_strcmp ((output_obj
), ("-")) : (- (__extension__ ({ const unsigned char *__s2 = (
const unsigned char *) (const char *) ((output_obj)); int __result
= (((const unsigned char *) (const char *) (("-")))[0] - __s2
[0]); if (__s2_len > 0 && __result == 0) { __result
= (((const unsigned char *) (const char *) (("-")))[1] - __s2
[1]); if (__s2_len > 1 && __result == 0) { __result
= (((const unsigned char *) (const char *) (("-")))[2] - __s2
[2]); if (__s2_len > 2 && __result == 0) __result =
(((const unsigned char *) (const char *) (("-")))[3] - __s2[
3]); } } __result; })))) : __builtin_strcmp ((output_obj), ("-"
))))); }) == 0)
) {
1731 stats_update(STATS_OUTSTDOUT);
1732 cc_log("Output file is -");
1733 result = false0;
1734 goto out;
1735 }
1736
1737 if (!output_obj) {
1738 if (output_is_precompiled_header) {
1739 output_obj = format("%s.gch", input_file);
1740 } else {
1741 char *p;
1742 output_obj = x_strdup(input_file);
1743 if ((p = strrchr(output_obj, '/'))) {
1744 output_obj = p+1;
1745 }
1746 p = strrchr(output_obj, '.');
1747 if (!p || !p[1]) {
1748 cc_log("Badly formed object filename");
1749 stats_update(STATS_ARGS);
1750 result = false0;
1751 goto out;
1752 }
1753 p[1] = found_S_opt ? 's' : 'o';
1754 p[2] = 0;
1755 }
1756 }
1757
1758 /* cope with -o /dev/null */
1759 if (!str_eq(output_obj,"/dev/null")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((output_obj)) && __builtin_constant_p (("/dev/null"
)) && (__s1_len = strlen ((output_obj)), __s2_len = strlen
(("/dev/null")), (!((size_t)(const void *)(((output_obj)) + 1
) - (size_t)(const void *)((output_obj)) == 1) || __s1_len >=
4) && (!((size_t)(const void *)((("/dev/null")) + 1)
- (size_t)(const void *)(("/dev/null")) == 1) || __s2_len >=
4)) ? __builtin_strcmp ((output_obj), ("/dev/null")) : (__builtin_constant_p
((output_obj)) && ((size_t)(const void *)(((output_obj
)) + 1) - (size_t)(const void *)((output_obj)) == 1) &&
(__s1_len = strlen ((output_obj)), __s1_len < 4) ? (__builtin_constant_p
(("/dev/null")) && ((size_t)(const void *)((("/dev/null"
)) + 1) - (size_t)(const void *)(("/dev/null")) == 1) ? __builtin_strcmp
((output_obj), ("/dev/null")) : (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (("/dev/null"
)); int __result = (((const unsigned char *) (const char *) (
(output_obj)))[0] - __s2[0]); if (__s1_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(output_obj)))[1] - __s2[1]); if (__s1_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(output_obj)))[2] - __s2[2]); if (__s1_len > 2 && __result
== 0) __result = (((const unsigned char *) (const char *) ((
output_obj)))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
(("/dev/null")) && ((size_t)(const void *)((("/dev/null"
)) + 1) - (size_t)(const void *)(("/dev/null")) == 1) &&
(__s2_len = strlen (("/dev/null")), __s2_len < 4) ? (__builtin_constant_p
((output_obj)) && ((size_t)(const void *)(((output_obj
)) + 1) - (size_t)(const void *)((output_obj)) == 1) ? __builtin_strcmp
((output_obj), ("/dev/null")) : (- (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) ((output_obj
)); int __result = (((const unsigned char *) (const char *) (
("/dev/null")))[0] - __s2[0]); if (__s2_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("/dev/null")))[1] - __s2[1]); if (__s2_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (("/dev/null")))[2] - __s2[2]); if (__s2_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char
*) (("/dev/null")))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
((output_obj), ("/dev/null"))))); }) == 0)
1760 && stat(output_obj, &st) == 0
1761 && !S_ISREG(st.st_mode)((((st.st_mode)) & 0170000) == (0100000))) {
1762 cc_log("Not a regular file: %s", output_obj);
1763 stats_update(STATS_DEVICE);
1764 result = false0;
1765 goto out;
1766 }
1767
1768 /*
1769 * Some options shouldn't be passed to the real compiler when it compiles
1770 * preprocessed code:
1771 *
1772 * -finput-charset=XXX (otherwise conversion happens twice)
1773 * -x XXX (otherwise the wrong language is selected)
1774 */
1775 *preprocessor_args = args_copy(stripped_args);
1776 if (input_charset) {
1777 args_add(*preprocessor_args, input_charset);
1778 }
1779 if (found_pch) {
1780 args_add(*preprocessor_args, "-fpch-preprocess");
1781 }
1782 if (explicit_language) {
1783 args_add(*preprocessor_args, "-x");
1784 args_add(*preprocessor_args, explicit_language);
1785 }
1786
1787 /*
1788 * Add flags for dependency generation only to the preprocessor command line.
1789 */
1790 if (generating_dependencies) {
1791 if (!dependency_filename_specified) {
1792 char *default_depfile_name;
1793 char *base_name;
1794
1795 base_name = remove_extension(output_obj);
1796 default_depfile_name = format("%s.d", base_name);
1797 free(base_name);
1798 args_add(dep_args, "-MF");
1799 args_add(dep_args, default_depfile_name);
1800 output_dep = make_relative_path(x_strdup(default_depfile_name));
1801 }
1802
1803 if (!dependency_target_specified) {
1804 args_add(dep_args, "-MQ");
1805 args_add(dep_args, output_obj);
1806 }
1807 }
1808
1809 if (compile_preprocessed_source_code) {
1810 *compiler_args = args_copy(stripped_args);
1811 if (explicit_language) {
1812 /*
1813 * Workaround for a bug in Apple's patched distcc -- it doesn't properly
1814 * reset the language specified with -x, so if -x is given, we have to
1815 * specify the preprocessed language explicitly.
1816 */
1817 args_add(*compiler_args, "-x");
1818 args_add(*compiler_args, p_language_for_language(explicit_language));
1819 }
1820 } else {
1821 *compiler_args = args_copy(*preprocessor_args);
1822 }
1823
1824 /*
1825 * Only pass dependency arguments to the preprocesor since Intel's C++
1826 * compiler doesn't produce a correct .d file when compiling preprocessed
1827 * source.
1828 */
1829 args_extend(*preprocessor_args, dep_args);
1830
1831out:
1832 args_free(stripped_args);
1833 args_free(dep_args);
1834 return result;
1835}
1836
1837/* Reset the global state. Used by the test suite. */
1838void
1839cc_reset(void)
1840{
1841 free(current_working_dir); current_working_dir = NULL((void*)0);
1842 free(cache_dir); cache_dir = NULL((void*)0);
1843 cache_logfile = NULL((void*)0);
1844 base_dir = NULL((void*)0);
1845 args_free(orig_args); orig_args = NULL((void*)0);
1846 free(input_file); input_file = NULL((void*)0);
1847 free(output_obj); output_obj = NULL((void*)0);
1848 free(output_dep); output_dep = NULL((void*)0);
1849 free(cached_obj_hash); cached_obj_hash = NULL((void*)0);
1850 free(cached_obj); cached_obj = NULL((void*)0);
1851 free(cached_stderr); cached_stderr = NULL((void*)0);
1852 free(cached_dep); cached_dep = NULL((void*)0);
1853 free(manifest_path); manifest_path = NULL((void*)0);
1854 time_of_compilation = 0;
1855 sloppiness = false0;
1856 if (included_files) {
1857 hashtable_destroy(included_files, 1); included_files = NULL((void*)0);
1858 }
1859 generating_dependencies = false0;
1860 i_extension = NULL((void*)0);
1861 i_tmpfile = NULL((void*)0);
1862 direct_i_file = false0;
1863 free(cpp_stderr); cpp_stderr = NULL((void*)0);
1864 free(stats_file); stats_file = NULL((void*)0);
1865 enable_unify = false0;
1866 enable_direct = true1;
1867 enable_compression = false0;
1868 nlevels = 2;
1869 compile_preprocessed_source_code = false0;
1870 output_is_precompiled_header = false0;
1871}
1872
1873static unsigned
1874parse_sloppiness(char *p)
1875{
1876 unsigned result = 0;
1877 char *word, *q, *saveptr = NULL((void*)0);
1878
1879 if (!p) {
1880 return result;
1881 }
1882 p = x_strdup(p);
1883 q = p;
1884 while ((word = strtok_r(q, ", ", &saveptr)(__extension__ (__builtin_constant_p (", ") && ((size_t
)(const void *)((", ") + 1) - (size_t)(const void *)(", ") ==
1) && ((const char *) (", "))[0] != '\0' && (
(const char *) (", "))[1] == '\0' ? __strtok_r_1c (q, ((const
char *) (", "))[0], &saveptr) : __strtok_r (q, ", ", &
saveptr)))
)) {
1885 if (str_eq(word, "file_macro")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((word)) && __builtin_constant_p (("file_macro")) &&
(__s1_len = strlen ((word)), __s2_len = strlen (("file_macro"
)), (!((size_t)(const void *)(((word)) + 1) - (size_t)(const void
*)((word)) == 1) || __s1_len >= 4) && (!((size_t)
(const void *)((("file_macro")) + 1) - (size_t)(const void *)
(("file_macro")) == 1) || __s2_len >= 4)) ? __builtin_strcmp
((word), ("file_macro")) : (__builtin_constant_p ((word)) &&
((size_t)(const void *)(((word)) + 1) - (size_t)(const void *
)((word)) == 1) && (__s1_len = strlen ((word)), __s1_len
< 4) ? (__builtin_constant_p (("file_macro")) && (
(size_t)(const void *)((("file_macro")) + 1) - (size_t)(const
void *)(("file_macro")) == 1) ? __builtin_strcmp ((word), ("file_macro"
)) : (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) (("file_macro")); int __result = (((const
unsigned char *) (const char *) ((word)))[0] - __s2[0]); if (
__s1_len > 0 && __result == 0) { __result = (((const
unsigned char *) (const char *) ((word)))[1] - __s2[1]); if (
__s1_len > 1 && __result == 0) { __result = (((const
unsigned char *) (const char *) ((word)))[2] - __s2[2]); if (
__s1_len > 2 && __result == 0) __result = (((const
unsigned char *) (const char *) ((word)))[3] - __s2[3]); } }
__result; }))) : (__builtin_constant_p (("file_macro")) &&
((size_t)(const void *)((("file_macro")) + 1) - (size_t)(const
void *)(("file_macro")) == 1) && (__s2_len = strlen (
("file_macro")), __s2_len < 4) ? (__builtin_constant_p ((word
)) && ((size_t)(const void *)(((word)) + 1) - (size_t
)(const void *)((word)) == 1) ? __builtin_strcmp ((word), ("file_macro"
)) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) ((word)); int __result = (((const unsigned
char *) (const char *) (("file_macro")))[0] - __s2[0]); if (
__s2_len > 0 && __result == 0) { __result = (((const
unsigned char *) (const char *) (("file_macro")))[1] - __s2[
1]); if (__s2_len > 1 && __result == 0) { __result
= (((const unsigned char *) (const char *) (("file_macro")))
[2] - __s2[2]); if (__s2_len > 2 && __result == 0)
__result = (((const unsigned char *) (const char *) (("file_macro"
)))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp ((word
), ("file_macro"))))); }) == 0)
) {
1886 cc_log("Being sloppy about __FILE__");
1887 result |= SLOPPY_FILE_MACRO2;
1888 }
1889 if (str_eq(word, "include_file_mtime")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((word)) && __builtin_constant_p (("include_file_mtime"
)) && (__s1_len = strlen ((word)), __s2_len = strlen (
("include_file_mtime")), (!((size_t)(const void *)(((word)) +
1) - (size_t)(const void *)((word)) == 1) || __s1_len >= 4
) && (!((size_t)(const void *)((("include_file_mtime"
)) + 1) - (size_t)(const void *)(("include_file_mtime")) == 1
) || __s2_len >= 4)) ? __builtin_strcmp ((word), ("include_file_mtime"
)) : (__builtin_constant_p ((word)) && ((size_t)(const
void *)(((word)) + 1) - (size_t)(const void *)((word)) == 1)
&& (__s1_len = strlen ((word)), __s1_len < 4) ? (
__builtin_constant_p (("include_file_mtime")) && ((size_t
)(const void *)((("include_file_mtime")) + 1) - (size_t)(const
void *)(("include_file_mtime")) == 1) ? __builtin_strcmp ((word
), ("include_file_mtime")) : (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (("include_file_mtime"
)); int __result = (((const unsigned char *) (const char *) (
(word)))[0] - __s2[0]); if (__s1_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(word)))[1] - __s2[1]); if (__s1_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(word)))[2] - __s2[2]); if (__s1_len > 2 && __result
== 0) __result = (((const unsigned char *) (const char *) ((
word)))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
(("include_file_mtime")) && ((size_t)(const void *)(
(("include_file_mtime")) + 1) - (size_t)(const void *)(("include_file_mtime"
)) == 1) && (__s2_len = strlen (("include_file_mtime"
)), __s2_len < 4) ? (__builtin_constant_p ((word)) &&
((size_t)(const void *)(((word)) + 1) - (size_t)(const void *
)((word)) == 1) ? __builtin_strcmp ((word), ("include_file_mtime"
)) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) ((word)); int __result = (((const unsigned
char *) (const char *) (("include_file_mtime")))[0] - __s2[0
]); if (__s2_len > 0 && __result == 0) { __result =
(((const unsigned char *) (const char *) (("include_file_mtime"
)))[1] - __s2[1]); if (__s2_len > 1 && __result ==
0) { __result = (((const unsigned char *) (const char *) (("include_file_mtime"
)))[2] - __s2[2]); if (__s2_len > 2 && __result ==
0) __result = (((const unsigned char *) (const char *) (("include_file_mtime"
)))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp ((word
), ("include_file_mtime"))))); }) == 0)
) {
1890 cc_log("Being sloppy about include file mtime");
1891 result |= SLOPPY_INCLUDE_FILE_MTIME1;
1892 }
1893 if (str_eq(word, "time_macros")(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
((word)) && __builtin_constant_p (("time_macros")) &&
(__s1_len = strlen ((word)), __s2_len = strlen (("time_macros"
)), (!((size_t)(const void *)(((word)) + 1) - (size_t)(const void
*)((word)) == 1) || __s1_len >= 4) && (!((size_t)
(const void *)((("time_macros")) + 1) - (size_t)(const void *
)(("time_macros")) == 1) || __s2_len >= 4)) ? __builtin_strcmp
((word), ("time_macros")) : (__builtin_constant_p ((word)) &&
((size_t)(const void *)(((word)) + 1) - (size_t)(const void *
)((word)) == 1) && (__s1_len = strlen ((word)), __s1_len
< 4) ? (__builtin_constant_p (("time_macros")) &&
((size_t)(const void *)((("time_macros")) + 1) - (size_t)(const
void *)(("time_macros")) == 1) ? __builtin_strcmp ((word), (
"time_macros")) : (__extension__ ({ const unsigned char *__s2
= (const unsigned char *) (const char *) (("time_macros")); int
__result = (((const unsigned char *) (const char *) ((word))
)[0] - __s2[0]); if (__s1_len > 0 && __result == 0
) { __result = (((const unsigned char *) (const char *) ((word
)))[1] - __s2[1]); if (__s1_len > 1 && __result ==
0) { __result = (((const unsigned char *) (const char *) ((word
)))[2] - __s2[2]); if (__s1_len > 2 && __result ==
0) __result = (((const unsigned char *) (const char *) ((word
)))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
(("time_macros")) && ((size_t)(const void *)((("time_macros"
)) + 1) - (size_t)(const void *)(("time_macros")) == 1) &&
(__s2_len = strlen (("time_macros")), __s2_len < 4) ? (__builtin_constant_p
((word)) && ((size_t)(const void *)(((word)) + 1) - (
size_t)(const void *)((word)) == 1) ? __builtin_strcmp ((word
), ("time_macros")) : (- (__extension__ ({ const unsigned char
*__s2 = (const unsigned char *) (const char *) ((word)); int
__result = (((const unsigned char *) (const char *) (("time_macros"
)))[0] - __s2[0]); if (__s2_len > 0 && __result ==
0) { __result = (((const unsigned char *) (const char *) (("time_macros"
)))[1] - __s2[1]); if (__s2_len > 1 && __result ==
0) { __result = (((const unsigned char *) (const char *) (("time_macros"
)))[2] - __s2[2]); if (__s2_len > 2 && __result ==
0) __result = (((const unsigned char *) (const char *) (("time_macros"
)))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp ((word
), ("time_macros"))))); }) == 0)
) {
1894 cc_log("Being sloppy about __DATE__ and __TIME__");
1895 result |= SLOPPY_TIME_MACROS4;
1896 }
1897 q = NULL((void*)0);
1898 }
1899 free(p);
1900 return result;
1901}
1902
1903/* Make a copy of stderr that will not be cached, so things like
1904 distcc can send networking errors to it. */
1905static void
1906setup_uncached_err(void)
1907{
1908 char *buf;
1909 int uncached_fd;
1910
1911 uncached_fd = dup(2);
1912 if (uncached_fd == -1) {
1913 cc_log("dup(2) failed: %s", strerror(errno(*__errno_location ())));
1914 failed();
1915 }
1916
1917 /* leak a pointer to the environment */
1918 buf = format("UNCACHED_ERR_FD=%d", uncached_fd);
1919
1920 if (putenv(buf) == -1) {
1921 cc_log("putenv failed: %s", strerror(errno(*__errno_location ())));
1922 failed();
1923 }
1924}
1925
1926/* the main ccache driver function */
1927static void
1928ccache(int argc, char *argv[])
1929{
1930 bool_Bool put_object_in_manifest = false0;
1931 struct file_hash *object_hash;
1932 struct file_hash *object_hash_from_manifest = NULL((void*)0);
1933 char *env;
1934 struct mdfour common_hash;
1935 struct mdfour direct_hash;
1936 struct mdfour cpp_hash;
1937
1938 /* Arguments (except -E) to send to the preprocessor. */
1939 struct args *preprocessor_args;
1940
1941 /* Arguments to send to the real compiler. */
1942 struct args *compiler_args;
1943
1944 find_compiler(argc, argv);
1945 setup_uncached_err();
1946
1947 if (getenv("CCACHE_DISABLE")) {
13
Taking false branch
1948 cc_log("ccache is disabled");
1949 failed();
1950 }
1951
1952 if (!getenv("CCACHE_READONLY")) {
14
Taking false branch
1953 if (create_cachedirtag(cache_dir) != 0) {
1954 cc_log("failed to create %s/CACHEDIR.TAG (%s)\n",
1955 cache_dir, strerror(errno(*__errno_location ())));
1956 failed();
1957 }
1958 }
1959
1960 sloppiness = parse_sloppiness(getenv("CCACHE_SLOPPINESS"));
1961
1962 cc_log_argv("Command line: ", argv);
1963 cc_log("Hostname: %s", get_hostname());
1964 cc_log("Working directory: %s", current_working_dir);
1965
1966 if (base_dir) {
15
Assuming 'base_dir' is null
16
Taking false branch
1967 cc_log("Base directory: %s", base_dir);
1968 }
1969
1970 if (getenv("CCACHE_UNIFY")) {
17
Taking false branch
1971 cc_log("Unify mode enabled");
1972 enable_unify = true1;
1973 }
1974
1975 if (getenv("CCACHE_NODIRECT") || enable_unify) {
18
Taking false branch
1976 cc_log("Direct mode disabled");
1977 enable_direct = false0;
1978 }
1979
1980 if (getenv("CCACHE_COMPRESS")) {
19
Taking false branch
1981 cc_log("Compression enabled");
1982 enable_compression = true1;
1983 }
1984
1985 if ((env = getenv("CCACHE_NLEVELS"))) {
20
Assuming 'env' is null
21
Taking false branch
1986 nlevels = atoi(env);
1987 if (nlevels < 1) nlevels = 1;
1988 if (nlevels > 8) nlevels = 8;
1989 }
1990
1991 if (!cc_process_args(orig_args, &preprocessor_args, &compiler_args)) {
22
Taking false branch
1992 failed();
1993 }
1994
1995 cc_log("Source file: %s", input_file);
1996 if (generating_dependencies) {
23
Assuming 'generating_dependencies' is 0
24
Taking false branch
1997 cc_log("Dependency file: %s", output_dep);
1998 }
1999 cc_log("Object file: %s", output_obj);
2000
2001 hash_start(&common_hash);
2002 calculate_common_hash(preprocessor_args, &common_hash);
2003
2004 /* try to find the hash using the manifest */
2005 direct_hash = common_hash;
2006 if (enable_direct) {
25
Assuming 'enable_direct' is 0
26
Taking false branch
2007 cc_log("Trying direct lookup");
2008 object_hash = calculate_object_hash(preprocessor_args, &direct_hash, 1);
2009 if (object_hash) {
2010 update_cached_result_globals(object_hash);
2011
2012 /*
2013 * If we can return from cache at this point then do
2014 * so.
2015 */
2016 from_cache(FROMCACHE_DIRECT_MODE, 0);
2017
2018 /*
2019 * Wasn't able to return from cache at this point.
2020 * However, the object was already found in manifest,
2021 * so don't readd it later.
2022 */
2023 put_object_in_manifest = false0;
2024
2025 object_hash_from_manifest = object_hash;
2026 } else {
2027 /* Add object to manifest later. */
2028 put_object_in_manifest = true1;
2029 }
2030 }
2031
2032 /*
2033 * Find the hash using the preprocessed output. Also updates
2034 * included_files.
2035 */
2036 cpp_hash = common_hash;
2037 cc_log("Running preprocessor");
2038 object_hash = calculate_object_hash(preprocessor_args, &cpp_hash, 0);
27
Value assigned to 'object_hash'
2039 if (!object_hash) {
28
Assuming 'object_hash' is null
29
Taking true branch
2040 fatal("internal error: object hash from cpp returned NULL");
2041 }
2042 update_cached_result_globals(object_hash);
30
Passing null pointer value via 1st parameter 'hash'
31
Calling 'update_cached_result_globals'
2043
2044 if (object_hash_from_manifest
2045 && !file_hashes_equal(object_hash_from_manifest, object_hash)) {
2046 /*
2047 * The hash from manifest differs from the hash of the
2048 * preprocessor output. This could be because:
2049 *
2050 * - The preprocessor produces different output for the same
2051 * input (not likely).
2052 * - There's a bug in ccache (maybe incorrect handling of
2053 * compiler arguments).
2054 * - The user has used a different CCACHE_BASEDIR (most
2055 * likely).
2056 *
2057 * The best thing here would probably be to remove the hash
2058 * entry from the manifest. For now, we use a simpler method:
2059 * just remove the manifest file.
2060 */
2061 cc_log("Hash from manifest doesn't match preprocessor output");
2062 cc_log("Likely reason: different CCACHE_BASEDIRs used");
2063 cc_log("Removing manifest as a safety measure");
2064 x_unlink(manifest_path);
2065
2066 put_object_in_manifest = true1;
2067 }
2068
2069 /* if we can return from cache at this point then do */
2070 from_cache(FROMCACHE_CPP_MODE, put_object_in_manifest);
2071
2072 if (getenv("CCACHE_READONLY")) {
2073 cc_log("Read-only mode; running real compiler");
2074 failed();
2075 }
2076
2077 env = getenv("CCACHE_PREFIX");
2078 if (env) {
2079 char *p = find_executable(env, MYNAME"ccache");
2080 if (!p) {
2081 fatal("%s: %s", env, strerror(errno(*__errno_location ())));
2082 }
2083 cc_log("Using command-line prefix %s", env);
2084 args_add_prefix(compiler_args, p);
2085 }
2086
2087 /* run real compiler, sending output to cache */
2088 to_cache(compiler_args);
2089
2090 /* return from cache */
2091 from_cache(FROMCACHE_COMPILED_MODE, put_object_in_manifest);
2092
2093 /* oh oh! */
2094 cc_log("Secondary from_cache failed");
2095 stats_update(STATS_ERROR);
2096 failed();
2097}
2098
2099static void
2100check_cache_dir(void)
2101{
2102 if (!cache_dir) {
2103 fatal("Unable to determine cache directory");
2104 }
2105}
2106
2107/* the main program when not doing a compile */
2108static int
2109ccache_main_options(int argc, char *argv[])
2110{
2111 int c;
2112 size_t v;
2113
2114 static const struct option options[] = {
2115 {"show-stats", no_argument0, 0, 's'},
2116 {"zero-stats", no_argument0, 0, 'z'},
2117 {"cleanup", no_argument0, 0, 'c'},
2118 {"clear", no_argument0, 0, 'C'},
2119 {"max-files", required_argument1, 0, 'F'},
2120 {"max-size", required_argument1, 0, 'M'},
2121 {"help", no_argument0, 0, 'h'},
2122 {"version", no_argument0, 0, 'V'},
2123 {0, 0, 0, 0}
2124 };
2125
2126 while ((c = getopt_long(argc, argv, "hszcCF:M:V", options, NULL((void*)0))) != -1) {
2127 switch (c) {
2128 case 'V':
2129 fprintf(stdoutstdout, VERSION_TEXT, CCACHE_VERSION);
2130 exit(0);
2131
2132 case 'h':
2133 fputs(USAGE_TEXT, stdoutstdout);
2134 exit(0);
2135
2136 case 's':
2137 check_cache_dir();
2138 stats_summary();
2139 break;
2140
2141 case 'c':
2142 check_cache_dir();
2143 cleanup_all(cache_dir);
2144 printf("Cleaned cache\n");
2145 break;
2146
2147 case 'C':
2148 check_cache_dir();
2149 wipe_all(cache_dir);
2150 printf("Cleared cache\n");
2151 break;
2152
2153 case 'z':
2154 check_cache_dir();
2155 stats_zero();
2156 printf("Statistics cleared\n");
2157 break;
2158
2159 case 'F':
2160 check_cache_dir();
2161 v = atoi(optarg);
2162 if (stats_set_limits(v, -1) == 0) {
2163 if (v == 0) {
2164 printf("Unset cache file limit\n");
2165 } else {
2166 printf("Set cache file limit to %u\n", (unsigned)v);
2167 }
2168 } else {
2169 printf("Could not set cache file limit.\n");
2170 exit(1);
2171 }
2172 break;
2173
2174 case 'M':
2175 check_cache_dir();
2176 v = value_units(optarg);
2177 if (stats_set_limits(-1, v) == 0) {
2178 if (v == 0) {
2179 printf("Unset cache size limit\n");
2180 } else {
2181 char *s = format_size(v);
2182 printf("Set cache size limit to %s\n", s);
2183 free(s);
2184 }
2185 } else {
2186 printf("Could not set cache size limit.\n");
2187 exit(1);
2188 }
2189 break;
2190
2191 default:
2192 fputs(USAGE_TEXT, stderrstderr);
2193 exit(1);
2194 }
2195 }
2196
2197 return 0;
2198}
2199
2200int
2201ccache_main(int argc, char *argv[])
2202{
2203 char *p;
2204 char *program_name;
2205
2206 exitfn_init();
2207 exitfn_add_nullary(stats_flush);
2208 exitfn_add_nullary(clean_up_tmp_files);
2209
2210 /* check for logging early so cc_log messages start working ASAP */
2211 cache_logfile = getenv("CCACHE_LOGFILE");
2212 cc_log("=== CCACHE STARTED =========================================");
2213
2214 /* the user might have set CCACHE_UMASK */
2215 p = getenv("CCACHE_UMASK");
2216 if (p) {
1
Assuming 'p' is null
2
Taking false branch
2217 mode_t mask;
2218 errno(*__errno_location ()) = 0;
2219 mask = strtol(p, NULL((void*)0), 8);
2220 if (errno(*__errno_location ()) == 0) {
2221 umask(mask);
2222 }
2223 }
2224
2225 cache_dir = getenv("CCACHE_DIR");
2226 if (cache_dir) {
3
Assuming 'cache_dir' is null
4
Taking false branch
2227 cache_dir = x_strdup(cache_dir);
2228 } else {
2229 const char *home_directory = get_home_directory();
2230 if (home_directory) {
5
Assuming 'home_directory' is null
6
Taking false branch
2231 cache_dir = format("%s/.ccache", home_directory);
2232 }
2233 }
2234
2235 /* check if we are being invoked as "ccache" */
2236 program_name = basename(argv[0]);
2237 if (same_executable_name(program_name, MYNAME"ccache")) {
7
Taking false branch
2238 if (argc < 2) {
2239 fputs(USAGE_TEXT, stderrstderr);
2240 exit(1);
2241 }
2242 /* if the first argument isn't an option, then assume we are
2243 being passed a compiler name and options */
2244 if (argv[1][0] == '-') {
2245 return ccache_main_options(argc, argv);
2246 }
2247 }
2248 free(program_name);
2249
2250 check_cache_dir();
2251
2252 temp_dir = getenv("CCACHE_TEMPDIR");
2253 if (!temp_dir) {
8
Assuming 'temp_dir' is non-null
9
Taking false branch
2254 temp_dir = format("%s/tmp", cache_dir);
2255 }
2256
2257 base_dir = getenv("CCACHE_BASEDIR");
2258 if (base_dir && base_dir[0] != '/') {
2259 cc_log("Ignoring non-absolute base directory %s", base_dir);
2260 base_dir = NULL((void*)0);
2261 }
2262
2263 compile_preprocessed_source_code = !getenv("CCACHE_CPP2");
2264
2265 /* make sure the cache dir exists */
2266 if (create_dir(cache_dir) != 0) {
10
Taking false branch
2267 fprintf(stderrstderr,
2268 "ccache: failed to create %s (%s)\n",
2269 cache_dir, strerror(errno(*__errno_location ())));
2270 exit(1);
2271 }
2272
2273 /* make sure the temp dir exists */
2274 if (create_dir(temp_dir) != 0) {
11
Taking false branch
2275 fprintf(stderrstderr,
2276 "ccache: failed to create %s (%s)\n",
2277 temp_dir, strerror(errno(*__errno_location ())));
2278 exit(1);
2279 }
2280
2281 ccache(argc, argv);
12
Calling 'ccache'
2282 return 1;
2283}