gcc: Environment Variables

1 
1 3.20 Environment Variables Affecting GCC
1 ========================================
1 
1 This section describes several environment variables that affect how GCC
1 operates.  Some of them work by specifying directories or prefixes to
1 use when searching for various kinds of files.  Some are used to specify
1 other aspects of the compilation environment.
1 
1  Note that you can also specify places to search using options such as
1 '-B', '-I' and '-L' (⇒Directory Options).  These take precedence
1 over places specified using environment variables, which in turn take
11 precedence over those specified by the configuration of GCC.  ⇒
 Controlling the Compilation Driver 'gcc' (gccint)Driver.
1 
1 'LANG'
1 'LC_CTYPE'
1 'LC_MESSAGES'
1 'LC_ALL'
1      These environment variables control the way that GCC uses
1      localization information which allows GCC to work with different
1      national conventions.  GCC inspects the locale categories
1      'LC_CTYPE' and 'LC_MESSAGES' if it has been configured to do so.
1      These locale categories can be set to any value supported by your
1      installation.  A typical value is 'en_GB.UTF-8' for English in the
1      United Kingdom encoded in UTF-8.
1 
1      The 'LC_CTYPE' environment variable specifies character
1      classification.  GCC uses it to determine the character boundaries
1      in a string; this is needed for some multibyte encodings that
1      contain quote and escape characters that are otherwise interpreted
1      as a string end or escape.
1 
1      The 'LC_MESSAGES' environment variable specifies the language to
1      use in diagnostic messages.
1 
1      If the 'LC_ALL' environment variable is set, it overrides the value
1      of 'LC_CTYPE' and 'LC_MESSAGES'; otherwise, 'LC_CTYPE' and
1      'LC_MESSAGES' default to the value of the 'LANG' environment
1      variable.  If none of these variables are set, GCC defaults to
1      traditional C English behavior.
1 
1 'TMPDIR'
1      If 'TMPDIR' is set, it specifies the directory to use for temporary
1      files.  GCC uses temporary files to hold the output of one stage of
1      compilation which is to be used as input to the next stage: for
1      example, the output of the preprocessor, which is the input to the
1      compiler proper.
1 
1 'GCC_COMPARE_DEBUG'
1      Setting 'GCC_COMPARE_DEBUG' is nearly equivalent to passing
1      '-fcompare-debug' to the compiler driver.  See the documentation of
1      this option for more details.
1 
1 'GCC_EXEC_PREFIX'
1      If 'GCC_EXEC_PREFIX' is set, it specifies a prefix to use in the
1      names of the subprograms executed by the compiler.  No slash is
1      added when this prefix is combined with the name of a subprogram,
1      but you can specify a prefix that ends with a slash if you wish.
1 
1      If 'GCC_EXEC_PREFIX' is not set, GCC attempts to figure out an
1      appropriate prefix to use based on the pathname it is invoked with.
1 
1      If GCC cannot find the subprogram using the specified prefix, it
1      tries looking in the usual places for the subprogram.
1 
1      The default value of 'GCC_EXEC_PREFIX' is 'PREFIX/lib/gcc/' where
1      PREFIX is the prefix to the installed compiler.  In many cases
1      PREFIX is the value of 'prefix' when you ran the 'configure'
1      script.
1 
1      Other prefixes specified with '-B' take precedence over this
1      prefix.
1 
1      This prefix is also used for finding files such as 'crt0.o' that
1      are used for linking.
1 
1      In addition, the prefix is used in an unusual way in finding the
1      directories to search for header files.  For each of the standard
1      directories whose name normally begins with '/usr/local/lib/gcc'
1      (more precisely, with the value of 'GCC_INCLUDE_DIR'), GCC tries
1      replacing that beginning with the specified prefix to produce an
1      alternate directory name.  Thus, with '-Bfoo/', GCC searches
1      'foo/bar' just before it searches the standard directory
1      '/usr/local/lib/bar'.  If a standard directory begins with the
1      configured PREFIX then the value of PREFIX is replaced by
1      'GCC_EXEC_PREFIX' when looking for header files.
1 
1 'COMPILER_PATH'
1      The value of 'COMPILER_PATH' is a colon-separated list of
1      directories, much like 'PATH'.  GCC tries the directories thus
1      specified when searching for subprograms, if it cannot find the
1      subprograms using 'GCC_EXEC_PREFIX'.
1 
1 'LIBRARY_PATH'
1      The value of 'LIBRARY_PATH' is a colon-separated list of
1      directories, much like 'PATH'.  When configured as a native
1      compiler, GCC tries the directories thus specified when searching
1      for special linker files, if it cannot find them using
1      'GCC_EXEC_PREFIX'.  Linking using GCC also uses these directories
1      when searching for ordinary libraries for the '-l' option (but
1      directories specified with '-L' come first).
1 
1 'LANG'
1      This variable is used to pass locale information to the compiler.
1      One way in which this information is used is to determine the
1      character set to be used when character literals, string literals
1      and comments are parsed in C and C++.  When the compiler is
1      configured to allow multibyte characters, the following values for
1      'LANG' are recognized:
1 
1      'C-JIS'
1           Recognize JIS characters.
1      'C-SJIS'
1           Recognize SJIS characters.
1      'C-EUCJP'
1           Recognize EUCJP characters.
1 
1      If 'LANG' is not defined, or if it has some other value, then the
1      compiler uses 'mblen' and 'mbtowc' as defined by the default locale
1      to recognize and translate multibyte characters.
1 
1 Some additional environment variables affect the behavior of the
1 preprocessor.
1 
1 'CPATH'
1 'C_INCLUDE_PATH'
1 'CPLUS_INCLUDE_PATH'
1 'OBJC_INCLUDE_PATH'
1      Each variable's value is a list of directories separated by a
1      special character, much like 'PATH', in which to look for header
1      files.  The special character, 'PATH_SEPARATOR', is
1      target-dependent and determined at GCC build time.  For Microsoft
1      Windows-based targets it is a semicolon, and for almost all other
1      targets it is a colon.
1 
1      'CPATH' specifies a list of directories to be searched as if
1      specified with '-I', but after any paths given with '-I' options on
1      the command line.  This environment variable is used regardless of
1      which language is being preprocessed.
1 
1      The remaining environment variables apply only when preprocessing
1      the particular language indicated.  Each specifies a list of
1      directories to be searched as if specified with '-isystem', but
1      after any paths given with '-isystem' options on the command line.
1 
1      In all these variables, an empty element instructs the compiler to
1      search its current working directory.  Empty elements can appear at
1      the beginning or end of a path.  For instance, if the value of
1      'CPATH' is ':/special/include', that has the same effect as
1      '-I. -I/special/include'.
1 
1 'DEPENDENCIES_OUTPUT'
1      If this variable is set, its value specifies how to output
1      dependencies for Make based on the non-system header files
1      processed by the compiler.  System header files are ignored in the
1      dependency output.
1 
1      The value of 'DEPENDENCIES_OUTPUT' can be just a file name, in
1      which case the Make rules are written to that file, guessing the
1      target name from the source file name.  Or the value can have the
1      form 'FILE TARGET', in which case the rules are written to file
1      FILE using TARGET as the target name.
1 
1      In other words, this environment variable is equivalent to
11      combining the options '-MM' and '-MF' (⇒Preprocessor
      Options), with an optional '-MT' switch too.
1 
1 'SUNPRO_DEPENDENCIES'
1      This variable is the same as 'DEPENDENCIES_OUTPUT' (see above),
1      except that system header files are not ignored, so it implies '-M'
1      rather than '-MM'.  However, the dependence on the main input file
1      is omitted.  ⇒Preprocessor Options.
1 
1 'SOURCE_DATE_EPOCH'
1      If this variable is set, its value specifies a UNIX timestamp to be
1      used in replacement of the current date and time in the '__DATE__'
1      and '__TIME__' macros, so that the embedded timestamps become
1      reproducible.
1 
1      The value of 'SOURCE_DATE_EPOCH' must be a UNIX timestamp, defined
1      as the number of seconds (excluding leap seconds) since 01 Jan 1970
1      00:00:00 represented in ASCII; identical to the output of ''date
1      +%s'' on GNU/Linux and other systems that support the '%s'
1      extension in the 'date' command.
1 
1      The value should be a known timestamp such as the last modification
1      time of the source or package and it should be set by the build
1      process.
1