~cmiller/ubuntu/utopic/ccache/also-clang

« back to all changes in this revision

Viewing changes to ccache.yo

  • Committer: Bazaar Package Importer
  • Author(s): Loïc Minier
  • Date: 2010-10-13 17:14:13 UTC
  • mfrom: (5.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20101013171413-4ehrj1y89huf069u
Tags: 3.0.1-1ubuntu1
* Merge with Debian; remaining changes:
  - Add gcc/g++-4.4 and -4.5 symlinks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
mailto(bugs@ccache.samba.org)
2
 
manpage(ccache)(1)(April 2002)()()
3
 
manpagename(ccache)(a fast compiler cache)
4
 
manpagesynopsis()
5
 
 
6
 
ccache [OPTION]
7
 
 
8
 
ccache <compiler> [COMPILER OPTIONS]
9
 
 
10
 
<compiler> [COMPILER OPTIONS]
11
 
 
12
 
manpagedescription()
13
 
 
14
 
ccache is a compiler cache. It speeds up re-compilation of C/C++ code 
15
 
by caching previous compiles and detecting when the same compile is
16
 
being done again.
17
 
 
18
 
manpagesection(OPTIONS SUMMARY)
19
 
 
20
 
Here is a summary of the options to ccache.
21
 
 
22
 
verb(
23
 
-s                      show statistics summary
24
 
-z                      zero statistics
25
 
-c                      run a cache cleanup
26
 
-C                      clear the cache completely
27
 
-F <maxfiles>           set maximum files in cache
28
 
-M <maxsize>            set maximum size of cache (use G, M or K)
29
 
-h                      this help page
30
 
-V                      print version number
31
 
)
32
 
 
33
 
manpageoptions()
34
 
 
35
 
These options only apply when you invoke ccache as "ccache". When
36
 
invoked as a compiler none of these options apply. In that case your
37
 
normal compiler options apply and you should refer to your compilers
38
 
documentation.
39
 
 
40
 
startdit()
41
 
dit(bf(-h)) Print a options summary page
42
 
 
43
 
dit(bf(-s)) Print the current statistics summary for the cache. The
44
 
statistics are stored spread across the subdirectories of the
45
 
cache. Using "ccache -s" adds up the statistics across all
46
 
subdirectories and prints the totals.
47
 
 
48
 
dit(bf(-z)) Zero the cache statistics. 
49
 
 
50
 
dit(bf(-V)) Print the ccache version number
51
 
 
52
 
dit(bf(-c)) Clean the cache and re-calculate the cache file count and
53
 
size totals. Normally the -c option should not be necessary as ccache
54
 
keeps the cache below the specified limits at runtime and keeps
55
 
statistics up to date on each compile. This option is mostly useful
56
 
if you manually modify the cache contents or believe that the cache
57
 
size statistics may be inaccurate.
58
 
 
59
 
dit(bf(-C)) Clear the entire cache, removing all cached files.
60
 
 
61
 
dit(bf(-F maxfiles)) This sets the maximum number of files allowed in
62
 
the cache. The value is stored inside the cache directory and applies
63
 
to all future compiles. Due to the way the value is stored the actual
64
 
value used is always rounded down to the nearest multiple of 16.
65
 
 
66
 
dit(bf(-M maxsize)) This sets the maximum cache size. You can specify
67
 
a value in gigabytes, megabytes or kilobytes by appending a G, M or K
68
 
to the value. The default is gigabytes. The actual value stored is
69
 
rounded down to the nearest multiple of 16 kilobytes.
70
 
 
71
 
enddit()
72
 
 
73
 
manpagesection(INSTALLATION)
74
 
 
75
 
There are two ways to use ccache. You can either prefix your compile
76
 
commands with "ccache" or you can create a symbolic link between
77
 
ccache and the names of your compilers. The first method is most
78
 
convenient if you just want to try out ccache or wish to use it for
79
 
some specific projects. The second method is most useful for when you
80
 
wish to use ccache for all your compiles.
81
 
 
82
 
To install for usage by the first method just copy ccache to somewhere
83
 
in your path. 
84
 
 
85
 
To install for the second method do something like this:
86
 
verb(
87
 
  cp ccache /usr/local/bin/
88
 
  ln -s /usr/local/bin/ccache /usr/local/bin/gcc
89
 
  ln -s /usr/local/bin/ccache /usr/local/bin/g++
90
 
  ln -s /usr/local/bin/ccache /usr/local/bin/cc
91
 
)
92
 
This will work as long as /usr/local/bin comes before the path to gcc
93
 
(which is usually in /usr/bin). After installing you may wish to run
94
 
"which gcc" to make sure that the correct link is being used.
95
 
 
96
 
Note! Do not use a hard link, use a symbolic link. A hardlink will
97
 
cause "interesting" problems.
98
 
 
99
 
manpagesection(EXTRA OPTIONS)
100
 
 
101
 
When run as a compiler front end ccache usually just takes the same
102
 
command line options as the compiler you are using. The only exception
103
 
to this is the option '--ccache-skip'. That option can be used to tell
104
 
ccache that the next option is definitely not a input filename, and
105
 
should be passed along to the compiler as-is. 
106
 
 
107
 
The reason this can be important is that ccache does need to parse the
108
 
command line and determine what is an input filename and what is a
109
 
compiler option, as it needs the input filename to determine the name
110
 
of the resulting object file (among other things). The heuristic
111
 
ccache uses in this parse is that any string on the command line that
112
 
exists as a file is treated as an input file name (usually a C
113
 
file). By using --ccache-skip you can force an option to not be
114
 
treated as an input file name and instead be passed along to the
115
 
compiler as a command line option.
116
 
 
117
 
manpagesection(ENVIRONMENT VARIABLES)
118
 
 
119
 
ccache uses a number of environment variables to control operation. In
120
 
most cases you won't need any of these as the defaults will be fine.
121
 
 
122
 
startdit()
123
 
 
124
 
dit(bf(CCACHE_DIR)) the CCACHE_DIR environment variable specifies
125
 
where ccache will keep its cached compiler output. The default is
126
 
"$HOME/.ccache".
127
 
 
128
 
dit(bf(CCACHE_TEMPDIR)) the CCACHE_TEMPDIR environment variable specifies
129
 
where ccache will put temporary files. The default is the same as
130
 
CCACHE_DIR. Note that the CCACHE_TEMPDIR path must be on the same
131
 
filesystem as the CCACHE_DIR path, so that renames of files between
132
 
the two directories can work.
133
 
 
134
 
dit(bf(CCACHE_LOGFILE)) If you set the CCACHE_LOGFILE environment
135
 
variable then ccache will write some log information on cache hits
136
 
and misses in that file. This is useful for tracking down problems.
137
 
 
138
 
dit(bf(CCACHE_PATH)) You can optionally set CCACHE_PATH to a colon
139
 
separated path where ccache will look for the real compilers. If you
140
 
don't do this then ccache will look for the first executable matching
141
 
the compiler name in the normal PATH that isn't a symbolic link to
142
 
ccache itself.
143
 
 
144
 
dit(bf(CCACHE_CC)) You can optionally set CCACHE_CC to force the name
145
 
of the compiler to use. If you don't do this then ccache works it out
146
 
from the command line.
147
 
 
148
 
dit(bf(CCACHE_PREFIX)) This option adds a prefix to the command line
149
 
that ccache runs when invoking the compiler. Also see the section
150
 
below on using ccache with distcc.
151
 
 
152
 
dit(bf(CCACHE_DISABLE)) If you set the environment variable
153
 
CCACHE_DISABLE then ccache will just call the real compiler,
154
 
bypassing the cache completely.
155
 
 
156
 
dit(bf(CCACHE_READONLY)) the CCACHE_READONLY environment variable
157
 
tells ccache to attempt to use existing cached object files, but not
158
 
to try to add anything new to the cache. If you are using this because
159
 
your CCACHE_DIR is read-only, then you may find that you also need to
160
 
set CCACHE_TEMPDIR as otherwise ccache will fail to create the
161
 
temporary files.
162
 
 
163
 
dit(bf(CCACHE_CPP2)) If you set the environment variable CCACHE_CPP2
164
 
then ccache will not use the optimisation of avoiding the 2nd call to
165
 
the pre-processor by compiling the pre-processed output that was used
166
 
for finding the hash in the case of a cache miss. This is primarily a
167
 
debugging option, although it is possible that some unusual compilers
168
 
will have problems with the intermediate filename extensions used in
169
 
this optimisation, in which case this option could allow ccache to be
170
 
used.
171
 
 
172
 
dit(bf(CCACHE_NOSTATS)) If you set the environment variable
173
 
CCACHE_NOSTATS then ccache will not update the statistics files on
174
 
each compile.
175
 
 
176
 
dit(bf(CCACHE_NLEVELS)) The environment variable CCACHE_NLEVELS allows
177
 
you to choose the number of levels of hash in the cache directory. The
178
 
default is 2. The minimum is 1 and the maximum is 8. 
179
 
 
180
 
dit(bf(CCACHE_HARDLINK)) If you set the environment variable
181
 
CCACHE_HARDLINK then ccache will attempt to use hard links from the
182
 
cache directory when creating the compiler output rather than using a
183
 
file copy. Using hard links is faster, but can confuse programs like
184
 
'make' that rely on modification times.
185
 
 
186
 
dit(bf(CCACHE_RECACHE)) This forces ccache to not use any cached
187
 
results, even if it finds them. New results are still cached, but
188
 
existing cache entries are ignored.
189
 
 
190
 
dit(bf(CCACHE_UMASK)) This sets the umask for ccache and all child
191
 
processes (such as the compiler). This is mostly useful when you wish
192
 
to share your cache with other users. Note that this also affects the
193
 
file permissions set on the object files created from your
194
 
compilations.
195
 
 
196
 
dit(bf(CCACHE_HASHDIR)) This tells ccache to hash the current working
197
 
directory when calculating the hash that is used to distinguish two
198
 
compiles. This prevents a problem with the storage of the current
199
 
working directory in the debug info of a object file, which can lead
200
 
ccache to give a cached object file that has the working directory in
201
 
the debug info set incorrectly. This option is off by default as the
202
 
incorrect setting of this debug info rarely causes problems. If you
203
 
strike problems with gdb not using the correct directory then enable
204
 
this option.
205
 
 
206
 
dit(bf(CCACHE_UNIFY)) If you set the environment variable CCACHE_UNIFY
207
 
then ccache will use the C/C++ unifier when hashing the pre-processor
208
 
output if -g is not used in the compile. The unifier is slower than a
209
 
normal hash, so setting this environment variable loses a little bit
210
 
of speed, but it means that ccache can take advantage of not
211
 
recompiling when the changes to the source code consist of
212
 
reformatting only. Note that using CCACHE_UNIFY changes the hash, so
213
 
cached compiles with CCACHE_UNIFY set cannot be used when
214
 
CCACHE_UNIFY is not set and vice versa. The reason the unifier is off
215
 
by default is that it can give incorrect line number information in
216
 
compiler warning messages.
217
 
 
218
 
dit(bf(CCACHE_EXTENSION)) Normally ccache tries to automatically
219
 
determine the extension to use for intermediate C pre-processor files
220
 
based on the type of file being compiled. Unfortunately this sometimes
221
 
doesn't work, for example when using the aCC compiler on HP-UX. On
222
 
systems like this you can use the CCACHE_EXTENSION option to override
223
 
the default. On HP-UX set this environment variable to "i" if you use
224
 
the aCC compiler.
225
 
 
226
 
enddit()
227
 
 
228
 
manpagesection(CACHE SIZE MANAGEMENT)
229
 
 
230
 
By default ccache has a one gigabyte limit on the cache size and no
231
 
maximum number of files. You can set a different limit using the
232
 
"ccache -M" and "ccache -F" options, which set the size and number of
233
 
files limits.
234
 
 
235
 
When these limits are reached ccache will reduce the cache to 20%
236
 
below the numbers you specified in order to avoid doing the cache
237
 
clean operation too often.
238
 
 
239
 
manpagesection(HOW IT WORKS)
240
 
 
241
 
The basic idea is to detect when you are compiling exactly the same
242
 
code a 2nd time and use the previously compiled output. You detect
243
 
that it is the same code by forming a hash of:
244
 
 
245
 
itemize(
246
 
  it() the pre-processor output from running the compiler with -E
247
 
  it() the command line options
248
 
  it() the real compilers size and modification time
249
 
  it() any stderr output generated by the compiler
250
 
)
251
 
 
252
 
These are hashed using md4 (a strong hash) and a cache file is formed
253
 
based on that hash result. When the same compilation is done a second
254
 
time ccache is able to supply the correct compiler output (including
255
 
all warnings etc) from the cache.
256
 
 
257
 
ccache has been carefully written to always produce exactly the same
258
 
compiler output that you would get without the cache. If you ever
259
 
discover a case where ccache changes the output of your compiler then
260
 
please let me know.
261
 
 
262
 
manpagesection(USING CCACHE WITH DISTCC)
263
 
 
264
 
distcc is a very useful program for distributing compilation across a
265
 
range of compiler servers. It is often useful to combine distcc with
266
 
ccache, so that compiles that are done are sped up by distcc, but that
267
 
ccache avoids the compile completely where possible.
268
 
 
269
 
To use distcc with ccache I recommend using the CCACHE_PREFIX
270
 
option. You just need to set the environment variable CCACHE_PREFIX to
271
 
'distcc' and ccache will prefix the command line used with the
272
 
compiler with the command 'distcc'. 
273
 
 
274
 
manpagesection(SHARING A CACHE)
275
 
 
276
 
A group of developers can increase the cache hit rate by sharing a
277
 
cache directory.  The hard links however cause unwanted side effects,
278
 
as all links to a cached file share the file's modification timestamp.
279
 
This results in false dependencies to be triggered by timestamp-based
280
 
build systems whenever another user links to an existing
281
 
file. Typically, users will see that their libraries and binaries are
282
 
relinked without reason.  To share a cache without side effects, the
283
 
following conditions need to be met:
284
 
 
285
 
itemize(
286
 
  it() Use the same bf(CCACHE_DIR) environment variable setting
287
 
  it() Set the bf(CCACHE_NOLINK) environment variable
288
 
  it() Make sure everyone sets the CCACHE_UMASK environment variable
289
 
  to 002, this ensures that cached files are accessible to everyone in
290
 
  the group.
291
 
  it() Make sure that all users have write permission in the entire
292
 
  cache directory (and that you trust all users of the shared cache). 
293
 
  it() Make sure that the setgid bit is set on all directories in the
294
 
  cache. This tells the filesystem to inherit group ownership for new
295
 
  directories. The command "chmod g+s `find $CCACHE_DIR -type d`" might
296
 
  be useful for this.
297
 
)
298
 
 
299
 
manpagesection(HISTORY)
300
 
 
301
 
ccache was inspired by the compilercache shell script script written
302
 
by Erik Thiele and I would like to thank him for an excellent piece of
303
 
work. See 
304
 
url(http://www.erikyyy.de/compilercache/)(http://www.erikyyy.de/compilercache/)
305
 
for the Erik's scripts.
306
 
 
307
 
I wrote ccache because I wanted to get a bit more speed out of a
308
 
compiler cache and I wanted to remove some of the limitations of the
309
 
shell-script version.
310
 
 
311
 
manpagesection(DIFFERENCES FROM COMPILERCACHE)
312
 
 
313
 
The biggest differences between Erik's compilercache script and ccache
314
 
are:
315
 
itemize(
316
 
it() ccache is written in C, which makes it a bit faster (calling out to
317
 
  external programs is mostly what slowed down the scripts).
318
 
it() ccache can automatically find the real compiler
319
 
it() ccache keeps statistics on hits/misses
320
 
it() ccache can do automatic cache management
321
 
it() ccache can cache compiler output that includes warnings. In many
322
 
  cases this gives ccache a much higher cache hit rate.
323
 
it() ccache can handle a much wider ranger of compiler options
324
 
it() ccache avoids a double call to cpp on a cache miss
325
 
)
326
 
 
327
 
manpagesection(BUGS)
328
 
 
329
 
When the cache is stored on an NFS filesystem, the filesystem must be
330
 
exported with the bf(no_subtree_check) option to make renames between
331
 
directories reliable.
332
 
 
333
 
manpagesection(CREDITS)
334
 
 
335
 
Thanks to the following people for their contributions to ccache
336
 
itemize(
337
 
 it() Erik Thiele for the original compilercache script
338
 
 it() Luciano Rocha for the idea of compiling the pre-processor output
339
 
 to avoid a 2nd cpp pass
340
 
 it() Paul Russell for many suggestions and the debian packaging
341
 
)
342
 
 
343
 
manpageauthor()
344
 
 
345
 
ccache was written by Andrew Tridgell
346
 
url(http://samba.org/~tridge/)(http://samba.org/~tridge/)
347
 
 
348
 
If you wish to report a problem or make a suggestion then please email
349
 
bugs@ccache.samba.org
350
 
 
351
 
ccache is released under the GNU General Public License version 2 or
352
 
later. Please see the file COPYING for license details.