GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "intl.h"
#include "diagnostic.h"
#include "obstack.h"
#include "opts.h"
#include "options.h"
#include "simple-object.h"
Macros | |
#define | LTO_SECTION_NAME_PREFIX ".gnu.lto_" |
#define | DUMPBASE_SUFFIX ".ltrans18446744073709551615" |
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 () |
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 |
#define DUMPBASE_SUFFIX ".ltrans18446744073709551615" |
Template of LTRANS dumpbase suffix.
#define LTO_SECTION_NAME_PREFIX ".gnu.lto_" |
Wrapper to call lto. Used by collect2 and the linker plugin. Copyright (C) 2009-2013 Free Software Foundation, Inc.
Factored out of collect2 by Rafael Espindola espin dola @goog le.c om
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/. This program is passed a gcc, a list of gcc arguments and a list of object files containing IL. It scans the argument list to check if we are in whopr mode or not modifies the arguments and needed and prints a list of output files on stdout.
Example:
$ lto-wrapper gcc/xgcc -B gcc a.o b.o -o test -flto
The above will print something like /tmp/ccwbQ8B2.lto.o
If WHOPR is used instead, more than one file might be produced ./ccXj2DTk.lto.ltrans.o ./ccCJuXGv.lto.ltrans.o From lto-streamer.h which we cannot include with -fkeep-inline-functions. ??? Split out a lto-streamer-core.h.
enum lto_mode_d |
|
static |
Just die. CMSGID is the error message.
Die when sys call fails. CMSGID is the error message.
|
static |
Append OPTION to the options array DECODED_OPTIONS with size DECODED_OPTIONS_COUNT.
Referenced by merge_and_complain().
|
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 |
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 |
Get the same signal again, this time not handled, so its normal effect occurs.
|
static |
Execute program ARGV[0] with arguments ARGV. Wait for it to finish.
|
static |
Create decoded options from the COLLECT_GCC and COLLECT_GCC_OPTIONS environment according to LANG_MASK.
References fatal().
|
static |
Delete tempfiles.
Setting cleanup_done prevents an infinite loop if one of the calls to maybe_unlink_file fails.
|
static |
|
static |
|
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, CL_TARGET, fatal(), cl_option::flags, cl_decoded_option::opt_index, and cl_decoded_option::orig_option_with_args_text.
|
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.
|
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.
|
static |
|
static |
|
static |
Current LTO mode.
|
static |
|
static |
|
static |
Referenced by coalesce_allocnos(), and reload_as_needed().
|
static |
int verbose |