GCC Middle and Back End API Reference
lto-wrapper.c File Reference

Enumerations

enum  lto_mode_d {
  LTO_MODE_NONE, LTO_MODE_LTO, LTO_MODE_WHOPR, LTO_MODE_NONE,
  LTO_MODE_LTO, LTO_MODE_WHOPR
}

Functions

static void maybe_unlink_file (const char *)
static void lto_wrapper_cleanup ()
static void fatal_signal ()
static void __attribute__ ((format(printf, 1, 2)))
static struct pex_obj * collect_execute ()
static int collect_wait ()
static void maybe_unlink_file ()
static void fork_execute ()
static void get_options_from_collect_gcc_options (const char *collect_gcc, const char *collect_gcc_options, unsigned int lang_mask, struct cl_decoded_option **decoded_options, unsigned int *decoded_options_count)
static void append_option (struct cl_decoded_option **decoded_options, unsigned int *decoded_options_count, struct cl_decoded_option *option)
static void merge_and_complain (struct cl_decoded_option **decoded_options, unsigned int *decoded_options_count, struct cl_decoded_option *fdecoded_options, unsigned int fdecoded_options_count)
static void run_gcc ()
int main ()

Variables

int debug
int verbose
static enum lto_mode_d lto_mode = LTO_MODE_NONE
static char * ltrans_output_file
static char * flto_out
static char * args_name
static unsigned int nr
static char ** input_names
static char ** output_names
static char * makefile

Enumeration Type Documentation

enum lto_mode_d
Enumerator:
LTO_MODE_NONE 
LTO_MODE_LTO 
LTO_MODE_WHOPR 
LTO_MODE_NONE 
LTO_MODE_LTO 
LTO_MODE_WHOPR 

Function Documentation

static void __attribute__ ( (format(printf, 1, 2))  )
static
   Just die. CMSGID is the error message. 
   Die when sys call fails. CMSGID is the error message.  
static void append_option ( struct cl_decoded_option **  decoded_options,
unsigned int *  decoded_options_count,
struct cl_decoded_option option 
)
static
   Append OPTION to the options array DECODED_OPTIONS with size
   DECODED_OPTIONS_COUNT.  

Referenced by merge_and_complain().

static struct pex_obj* collect_execute ( )
staticread
   Execute a program, and wait for the reply. ARGV are the arguments. The
   last one must be NULL. 
     Do not use PEX_LAST here, we use our stdout for communicating with
     collect2 or the linker-plugin.  Any output from the sub-process
     will confuse that.  
static int collect_wait ( )
static
   Wait for a process to finish, and exit if a nonzero status is found.
   PROG is the program name. PEX is the process we should wait for. 
static void fatal_signal ( )
static
     Get the same signal again, this time not handled,
     so its normal effect occurs.  
static void fork_execute ( )
static
   Execute program ARGV[0] with arguments ARGV. Wait for it to finish.  
static void get_options_from_collect_gcc_options ( const char *  collect_gcc,
const char *  collect_gcc_options,
unsigned int  lang_mask,
struct cl_decoded_option **  decoded_options,
unsigned int *  decoded_options_count 
)
static
   Create decoded options from the COLLECT_GCC and COLLECT_GCC_OPTIONS
   environment according to LANG_MASK.  

References fatal().

static void lto_wrapper_cleanup ( )
static
    Delete tempfiles.  
     Setting cleanup_done prevents an infinite loop if one of the
     calls to maybe_unlink_file fails. 
int main ( )
   Entry point.  
     We *MUST* set SIGCHLD to SIG_DFL so that the wait4() call will
     receive the signal.  A different setting is inheritable 
     We may be called with all the arguments stored in some file and
     passed with @file.  Expand them into argv before processing.  
static void maybe_unlink_file ( const char *  )
static
static void maybe_unlink_file ( )
static
   Unlink a temporary LTRANS file unless requested otherwise.  

References args_name, and fatal().

static void merge_and_complain ( struct cl_decoded_option **  decoded_options,
unsigned int *  decoded_options_count,
struct cl_decoded_option fdecoded_options,
unsigned int  fdecoded_options_count 
)
static
   Try to merge and complain about options FDECODED_OPTIONS when applied
   ontop of DECODED_OPTIONS.  
     ???  Merge options from files.  Most cases can be
     handled by either unioning or intersecting
     (for example -fwrapv is a case for unioning,
     -ffast-math is for intersection).  Most complaints
     about real conflicts between different options can
     be deferred to the compiler proper.  Options that
     we can neither safely handle by intersection nor
     unioning would need to be complained about here.
     Ideally we'd have a flag in the opt files that
     tells whether to union or intersect or reject.
     In absence of that it's unclear what a good default is.
     It's also difficult to get positional handling correct.  
     The following does what the old LTO option code did,
     union all target and a selected set of common options.  
             Fallthru.  
             Do what the old LTO code did - collect exactly one option
             setting per OPT code, we pick the first we encounter.
             ???  This doesn't make too much sense, but when it doesn't
             then we should complain.  

References append_option(), cl_options, fatal(), cl_option::flags, cl_decoded_option::opt_index, and cl_decoded_option::orig_option_with_args_text.

static void run_gcc ( )
static
   Execute gcc. ARGC is the number of arguments. ARGV contains the arguments. 
     Get the driver and options.  
     Look at saved options in the IL files.  
     Initalize the common arguments for the driver.  
     Append compiler driver arguments as far as they were merged.  
         File options have been properly filtered by lto-opts.c.  
             Drop arguments that we want to take from the link line.  
         For now do what the original LTO option code was doing - pass
         on any CL_TARGET flag and a few selected others.  
         Pass the option on.  
     Append linker driver arguments.  Compiler options from the linker
     driver arguments will override / merge with those from the compiler.  
         Do not pass on frontend specific flags not suitable for lto.  
             We generate new intermediate output, drop this arg.  
             Fallthru.  
             We've handled these LTO options, do not pass them on.  
             Ignore these, they are determined by the input files.
             ???  We fail to diagnose a possible mismatch here.  
         Pass the option on.  
     Remember at which point we can scrub args to re-use the commons.  
     Append the input objects and possible preceding arguments.  
         Parse the list of LTRANS inputs from the WPA stage.  
         Execute the LTRANS stage for each input file (or prepare a
         makefile to invoke this in parallel).  
             If it's a pass-through file do nothing.  
             Replace the .o suffix with a .ltrans.o suffix and write
             the resulting name to the LTRANS output list.  
             Adjust the dumpbase if the linker output file was seen.  
                 If we are not preserving the ltrans input files then
                 truncate them as soon as we have processed it.  This
                 reduces temporary disk-space usage.  
                 Avoid passing --jobserver-fd= and similar flags 
                 unless jobserver mode is explicitly enabled.  

Variable Documentation

char* args_name
static

Referenced by maybe_unlink_file().

int debug
   End of lto-streamer.h copy.  
     Print the slot this node is in, and its code, and address.  
char* flto_out
static
char** input_names
static
enum lto_mode_d lto_mode = LTO_MODE_NONE
static
   Current LTO mode.  
char* ltrans_output_file
static
char* makefile
static
unsigned int nr
static
char** output_names
static
int verbose