]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/gcc/gcc-command-options/environment-variables-affecting-gcc.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / doc / gcc / gcc-command-options / environment-variables-affecting-gcc.rst
CommitLineData
c63539ff
ML
1..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6.. index:: environment variables
7
8.. _environment-variables:
9
10Environment Variables Affecting GCC
11***********************************
12
13Environment
14^^^^^^^^^^^
15
16This section describes several environment variables that affect how GCC
17operates. Some of them work by specifying directories or prefixes to use
18when searching for various kinds of files. Some are used to specify other
19aspects of the compilation environment.
20
21Note that you can also specify places to search using options such as
22:option:`-B`, :option:`-I` and :option:`-L` (see :ref:`directory-options`). These
23take precedence over places specified using environment variables, which
24in turn take precedence over those specified by the configuration of GCC.
25See :ref:`gccint:driver`.
26
27.. envvar:: LANG, LC_COLLATE, LC_MONETARY, LC_NUMERIC, LC_TIME
28
29 .. index:: locale
30
31 These environment variables control the way that GCC uses
32 localization information which allows GCC to work with different
33 national conventions. GCC inspects the locale categories
34 :envvar:`LC_CTYPE` and :envvar:`LC_MESSAGES` if it has been configured to do
35 so. These locale categories can be set to any value supported by your
36 installation. A typical value is :samp:`en_GB.UTF-8` for English in the United
37 Kingdom encoded in UTF-8.
38
39 The :envvar:`LC_CTYPE` environment variable specifies character
40 classification. GCC uses it to determine the character boundaries in
41 a string; this is needed for some multibyte encodings that contain quote
42 and escape characters that are otherwise interpreted as a string
43 end or escape.
44
45 The :envvar:`LC_MESSAGES` environment variable specifies the language to
46 use in diagnostic messages.
47
48 If the :envvar:`LC_ALL` environment variable is set, it overrides the value
49 of :envvar:`LC_CTYPE` and :envvar:`LC_MESSAGES`; otherwise, :envvar:`LC_CTYPE`
50 and :envvar:`LC_MESSAGES` default to the value of the :envvar:`LANG`
51 environment variable. If none of these variables are set, GCC
52 defaults to traditional C English behavior.
53
54.. envvar:: TMPDIR
55
56 If :envvar:`TMPDIR` is set, it specifies the directory to use for temporary
57 files. GCC uses temporary files to hold the output of one stage of
58 compilation which is to be used as input to the next stage: for example,
59 the output of the preprocessor, which is the input to the compiler
60 proper.
61
62.. envvar:: GCC_COMPARE_DEBUG
63
64 Setting :envvar:`GCC_COMPARE_DEBUG` is nearly equivalent to passing
65 :option:`-fcompare-debug` to the compiler driver. See the documentation
66 of this option for more details.
67
68.. envvar:: GCC_EXEC_PREFIX
69
70 If :envvar:`GCC_EXEC_PREFIX` is set, it specifies a prefix to use in the
71 names of the subprograms executed by the compiler. No slash is added
72 when this prefix is combined with the name of a subprogram, but you can
73 specify a prefix that ends with a slash if you wish.
74
75 If :envvar:`GCC_EXEC_PREFIX` is not set, GCC attempts to figure out
76 an appropriate prefix to use based on the pathname it is invoked with.
77
78 If GCC cannot find the subprogram using the specified prefix, it
79 tries looking in the usual places for the subprogram.
80
81 The default value of :envvar:`GCC_EXEC_PREFIX` is
82 :samp:`{prefix}/lib/gcc/` where :samp:`{prefix}` is the prefix to
83 the installed compiler. In many cases :samp:`{prefix}` is the value
84 of ``prefix`` when you ran the :samp:`configure` script.
85
86 Other prefixes specified with :option:`-B` take precedence over this prefix.
87
88 This prefix is also used for finding files such as :samp:`crt0.o` that are
89 used for linking.
90
91 In addition, the prefix is used in an unusual way in finding the
92 directories to search for header files. For each of the standard
93 directories whose name normally begins with :samp:`/usr/local/lib/gcc`
94 (more precisely, with the value of :envvar:`GCC_INCLUDE_DIR`), GCC tries
95 replacing that beginning with the specified prefix to produce an
96 alternate directory name. Thus, with :option:`-Bfoo/`, GCC searches
97 :samp:`foo/bar` just before it searches the standard directory
98 :samp:`/usr/local/lib/bar`.
99 If a standard directory begins with the configured
100 :samp:`{prefix}` then the value of :samp:`{prefix}` is replaced by
101 :envvar:`GCC_EXEC_PREFIX` when looking for header files.
102
103.. envvar:: COMPILER_PATH
104
105 The value of :envvar:`COMPILER_PATH` is a colon-separated list of
106 directories, much like :envvar:`PATH`. GCC tries the directories thus
107 specified when searching for subprograms, if it cannot find the
108 subprograms using :envvar:`GCC_EXEC_PREFIX`.
109
110.. envvar:: LIBRARY_PATH
111
112 The value of :envvar:`LIBRARY_PATH` is a colon-separated list of
113 directories, much like :envvar:`PATH`. When configured as a native compiler,
114 GCC tries the directories thus specified when searching for special
115 linker files, if it cannot find them using :envvar:`GCC_EXEC_PREFIX`. Linking
116 using GCC also uses these directories when searching for ordinary
117 libraries for the :option:`-l` option (but directories specified with
118 :option:`-L` come first).
119
120.. index:: locale definition
121
122.. envvar:: LANG
123
124 This variable is used to pass locale information to the compiler. One way in
125 which this information is used is to determine the character set to be used
126 when character literals, string literals and comments are parsed in C and C++.
127 When the compiler is configured to allow multibyte characters,
128 the following values for :envvar:`LANG` are recognized:
129
130 :samp:`C-JIS`
131 Recognize JIS characters.
132
133 :samp:`C-SJIS`
134 Recognize SJIS characters.
135
136 :samp:`C-EUCJP`
137 Recognize EUCJP characters.
138
139 If :envvar:`LANG` is not defined, or if it has some other value, then the
140 compiler uses ``mblen`` and ``mbtowc`` as defined by the default locale to
141 recognize and translate multibyte characters.
142
143.. envvar:: GCC_EXTRA_DIAGNOSTIC_OUTPUT
144
145 If :envvar:`GCC_EXTRA_DIAGNOSTIC_OUTPUT` is set to one of the following values,
146 then additional text will be emitted to stderr when fix-it hints are
147 emitted. :option:`-fdiagnostics-parseable-fixits` and
148 :option:`-fno-diagnostics-parseable-fixits` take precedence over this
149 environment variable.
150
151 :samp:`fixits-v1`
152 Emit parseable fix-it hints, equivalent to
153 :option:`-fdiagnostics-parseable-fixits`. In particular, columns are
154 expressed as a count of bytes, starting at byte 1 for the initial column.
155
156 :samp:`fixits-v2`
157 As ``fixits-v1``, but columns are expressed as display columns,
158 as per :option:`-fdiagnostics-column-unit=display`.
159
160Some additional environment variables affect the behavior of the
161preprocessor.
162
3ed1b4ce 163.. include:: ../../../../doc/cppenv.rst