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"
#include "lto-section-names.h"
#include "collect-utils.h"
#include "opts-diagnostic.h"
#include "opt-suggestions.h"
#include "opts-jobserver.h"
Data Structures | |
class | lto_diagnostic_option_manager |
Macros | |
#define | INCLUDE_STRING |
#define | OFFLOAD_TARGET_NAMES_ENV "OFFLOAD_TARGET_NAMES" |
#define | OFFLOAD_TARGET_DEFAULT_ENV "OFFLOAD_TARGET_DEFAULT" |
#define | TARGET_EXECUTABLE_SUFFIX "" |
#define | DUMPBASE_SUFFIX "ltrans18446744073709551615" |
Enumerations | |
enum | lto_mode_d { LTO_MODE_NONE , LTO_MODE_LTO , LTO_MODE_WHOPR } |
Functions | |
static void ** | free_array_of_ptrs (void **ptr, unsigned n) |
void | tool_cleanup (bool) |
static void | lto_wrapper_cleanup (void) |
void | maybe_unlink (const char *file) |
static vec< cl_decoded_option > | get_options_from_collect_gcc_options (const char *collect_gcc, const char *collect_gcc_options) |
static int | find_option (vec< cl_decoded_option > &options, size_t opt_index, unsigned start=0) |
static int | find_option (vec< cl_decoded_option > &options, cl_decoded_option *option) |
static void | merge_flto_options (vec< cl_decoded_option > &decoded_options, cl_decoded_option *foption, bool force) |
static void | merge_and_complain (vec< cl_decoded_option > &decoded_options, vec< cl_decoded_option > fdecoded_options, vec< cl_decoded_option > decoded_cl_options) |
static unsigned | parse_env_var (const char *str, char ***pvalues, const char *append) |
static void | append_compiler_options (obstack *argv_obstack, vec< cl_decoded_option > opts) |
static void | append_diag_options (obstack *argv_obstack, vec< cl_decoded_option > opts) |
static void | append_linker_options (obstack *argv_obstack, vec< cl_decoded_option > opts) |
static void | append_offload_options (obstack *argv_obstack, const char *target, vec< cl_decoded_option > options) |
static int | access_check (const char *name, int mode) |
static const char * | compile_offload_image (const char *target, const char *compiler_path, unsigned in_argc, char *in_argv[], vec< cl_decoded_option > compiler_opts, vec< cl_decoded_option > linker_opts, char **filename) |
static void | compile_images_for_offload_targets (unsigned in_argc, char *in_argv[], vec< cl_decoded_option > compiler_opts, vec< cl_decoded_option > linker_opts) |
static void | copy_file (const char *dest, const char *src) |
static void | find_crtoffloadtable (int save_temps, const char *dumppfx) |
static bool | find_and_merge_options (int fd, off_t file_offset, const char *prefix, vec< cl_decoded_option > decoded_cl_options, bool first, vec< cl_decoded_option > *opts, const char *collect_gcc) |
const char * | debug_objcopy (const char *infile, bool rename) |
int | cmp_priority (const void *a, const void *b) |
static void | init_num_threads (void) |
void | print_lto_docs_link () |
static bool | make_exists (void) |
static void | run_gcc (unsigned argc, char *argv[]) |
int | main (int argc, char *argv[]) |
Variables | |
static enum lto_mode_d | lto_mode = LTO_MODE_NONE |
static char * | ltrans_output_file |
static char * | flto_out |
static unsigned int | nr |
static int * | ltrans_priorities |
static char ** | input_names |
static char ** | output_names |
static char ** | offload_names |
static char * | offload_objects_file_name |
static char * | makefile |
static unsigned int | num_deb_objs |
static const char ** | early_debug_object_names |
static bool | xassembler_options_error = false |
const char | tool_name [] = "lto-wrapper" |
static unsigned long | nthreads_var = 0 |
#define DUMPBASE_SUFFIX "ltrans18446744073709551615" |
Template of LTRANS dumpbase suffix.
Referenced by run_gcc().
#define INCLUDE_STRING |
Wrapper to call lto. Used by collect2 and the linker plugin. Copyright (C) 2009-2024 Free Software Foundation, Inc. Factored out of collect2 by Rafael Espindola <espindola@google.com> 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
#define OFFLOAD_TARGET_DEFAULT_ENV "OFFLOAD_TARGET_DEFAULT" |
Referenced by compile_offload_image().
#define OFFLOAD_TARGET_NAMES_ENV "OFFLOAD_TARGET_NAMES" |
Environment variable, used for passing the names of offload targets from GCC driver to lto-wrapper.
Referenced by compile_images_for_offload_targets().
#define TARGET_EXECUTABLE_SUFFIX "" |
By default there is no special suffix for target executables.
Referenced by run_gcc().
enum lto_mode_d |
|
static |
Check whether NAME can be accessed in MODE. This is like access, except that it never considers directories to be executable.
Referenced by compile_offload_image(), and find_crtoffloadtable().
|
static |
Append options OPTS from lto or offload_lto sections to ARGV_OBSTACK.
References cl_options, CL_TARGET, cl_option::flags, i, option(), and xassembler_options_error.
Referenced by compile_offload_image(), and run_gcc().
|
static |
Append diag options in OPTS to ARGV_OBSTACK.
Referenced by compile_offload_image().
|
static |
Append linker options OPTS to ARGV_OBSTACK.
References CL_COMMON, CL_DRIVER, cl_options, CL_TARGET, cl_option::flags, i, and option().
Referenced by run_gcc().
|
static |
Extract options for TARGET offload compiler from OPTIONS and append them to ARGV_OBSTACK.
References gcc_assert, i, NULL, and option().
Referenced by compile_offload_image().
int cmp_priority | ( | const void * | a, |
const void * | b ) |
|
static |
The main routine dealing with offloading. The routine builds a target image for each offload target. IN_ARGC and IN_ARGV specify options and input object files. As all of them could contain target sections, we pass them all to target compilers.
References compile_offload_image(), fatal_error(), free(), free_array_of_ptrs(), i, input_location, names, NULL, offload_names, OFFLOAD_TARGET_NAMES_ENV, and parse_env_var().
Referenced by run_gcc().
|
static |
Prepare a target image for offload TARGET, using mkoffload tool from COMPILER_PATH. Return the name of the resultant object file.
References access_check(), append_compiler_options(), append_diag_options(), append_offload_options(), dumpbase, dumppfx, fatal_error(), fork_execute(), free_array_of_ptrs(), i, input_location, NULL, obstack, OFFLOAD_TARGET_DEFAULT_ENV, parse_env_var(), verbose, and X_OK.
Referenced by compile_images_for_offload_targets().
|
static |
Copy a file from SRC to DEST.
References fatal_error(), fopen, and input_location.
Referenced by find_crtoffloadtable().
const char * debug_objcopy | ( | const char * | infile, |
bool | rename ) |
Copy early debug info sections from INFILE to a new file whose name is returned. Return NULL on error.
References fatal_error(), NULL, O_BINARY, and O_RDONLY.
Referenced by run_gcc().
|
static |
A subroutine of run_gcc. Examine the open file FD for lto sections with name prefix PREFIX, at FILE_OFFSET, and store any options we find in OPTS. Return true if we found a matching section, false otherwise. COLLECT_GCC holds the value of the environment variable with the same name.
References free(), get_options_from_collect_gcc_options(), merge_and_complain(), offset, and SEEK_SET.
Referenced by run_gcc().
|
static |
Find the crtoffloadtable.o file in LIBRARY_PATH, make copy and pass name of the copy to the linker.
References access_check(), copy_file(), dumppfx, fatal_error(), free_array_of_ptrs(), i, input_location, NULL, parse_env_var(), and R_OK.
Referenced by run_gcc().
|
static |
References find_option(), and option().
|
static |
Find option in OPTIONS based on OPT_INDEX, starting at START. -1 value is returned if the option is not present.
References i.
Referenced by find_option(), merge_and_complain(), and merge_flto_options().
|
static |
Auxiliary function that frees elements of PTR and PTR itself. N is number of elements to be freed. If PTR is NULL, nothing is freed. If an element is NULL, subsequent elements are not freed.
References free(), i, and NULL.
Referenced by compile_images_for_offload_targets(), compile_offload_image(), find_crtoffloadtable(), run_gcc(), and tool_cleanup().
|
static |
Create decoded options from the COLLECT_GCC and COLLECT_GCC_OPTIONS environment.
References CL_DRIVER, decode_cmdline_options_to_array(), free(), i, NULL, obstack, and parse_options_from_collect_gcc_options().
Referenced by find_and_merge_options(), and run_gcc().
|
static |
|
static |
References utils_cleanup().
Referenced by main().
int main | ( | int | argc, |
char * | argv[] ) |
|
static |
Test that a make command is present and working, return true if so.
References CONST_CAST, and NULL.
Referenced by run_gcc().
void maybe_unlink | ( | const char * | file | ) |
Unlink a temporary LTRANS file unless requested otherwise.
References errno, fatal_error(), file_exists(), input_location, may_unlink_output_file, notice(), output_file, and verbose.
Referenced by run_gcc(), and tool_cleanup().
|
static |
Try to merge and complain about options FDECODED_OPTIONS when applied ontop of DECODED_OPTIONS.
References cl_decoded_option::arg, CF_BRANCH, CF_CHECK, CF_FULL, CF_NONE, CF_RETURN, cl_options, CL_TARGET, fatal_error(), find_option(), cl_option::flags, gcc_unreachable, i, input_location, MAX, merge_flto_options(), NULL, cl_decoded_option::opt_index, cl_decoded_option::orig_option_with_args_text, cl_decoded_option::value, warning(), and xassembler_options_error.
Referenced by find_and_merge_options().
|
static |
Merge -flto FOPTION into vector of DECODED_OPTIONS. If FORCE is true then FOPTION overrides previous settings.
References cl_decoded_option::arg, and find_option().
Referenced by merge_and_complain(), and run_gcc().
|
static |
Parse STR, saving found tokens into PVALUES and return their number. Tokens are assumed to be delimited by ':'. If APPEND is non-null, append it to every token we find.
Referenced by compile_images_for_offload_targets(), compile_offload_image(), and find_crtoffloadtable().
void print_lto_docs_link | ( | ) |
Print link to -flto documentation with a hint message.
References global_dc, inform(), diagnostic_context::m_printer, diagnostic_context::make_option_url(), pp_begin_url(), pp_end_url(), pp_formatted_text(), pp_string(), pretty_printer::set_url_format(), pretty_printer::supports_urls_p(), UNKNOWN_LOCATION, and URL_FORMAT_DEFAULT.
Referenced by run_gcc().
|
static |
Execute gcc. ARGC is the number of arguments. ARGV contains the arguments.
References append_compiler_options(), append_linker_options(), cmp_priority(), collect_execute(), compile_images_for_offload_targets(), CONST_CAST, debug_objcopy(), diagnostic_color_init(), diagnostic_urls_init(), DIR_SEPARATOR, do_wait(), dumpbase, DUMPBASE_SUFFIX, dumppfx, early_debug_object_names, jobserver_info::error_msg, fatal_error(), find_and_merge_options(), find_crtoffloadtable(), flto_out, fopen, fork_execute(), fputc(), free(), free_array_of_ptrs(), get_options_from_collect_gcc_options(), global_dc, HOST_BIT_BUCKET, i, init_num_threads(), input_location, input_names, jobserver_info::is_active, lto_mode, LTO_MODE_LTO, LTO_MODE_WHOPR, LTO_SECTION_NAME_PREFIX, ltrans_output_file, ltrans_priorities, make_exists(), makefile, maybe_unlink(), merge_flto_options(), nr, nthreads_var, NULL, num_deb_objs, O_BINARY, O_RDONLY, obstack, offload_names, offload_objects_file_name, OFFLOAD_SECTION_NAME_PREFIX, option(), output_names, prepend_xassembler_to_collect_as_options(), print_lto_docs_link(), qsort, diagnostic_context::set_show_highlight_colors(), startswith(), TARGET_EXECUTABLE_SUFFIX, temporary_obstack, verbose, vNULL, and warning().
Referenced by main().
void tool_cleanup | ( | bool | from_signal | ) |
Delete tempfiles. Called from utils_cleanup.
References c_file, early_debug_object_names, flto_out, free_array_of_ptrs(), i, input_names, lto_o_files, ltrans_output_file, makefile, maybe_unlink(), maybe_unlink_list(), nr, num_deb_objs, o_file, offload_names, offload_objects_file_name, output_names, and verbose.
Referenced by utils_cleanup().
|
static |
Referenced by run_gcc(), and tool_cleanup().
|
static |
Referenced by run_gcc(), and tool_cleanup().
|
static |
Referenced by run_gcc(), and tool_cleanup().
|
static |
Current LTO mode.
Referenced by run_gcc().
|
static |
Referenced by run_gcc(), and tool_cleanup().
|
static |
Referenced by run_gcc().
|
static |
Referenced by run_gcc(), and tool_cleanup().
|
static |
Referenced by add_range_and_copies_from_move_list(), allocate_reload_reg(), assign_spill_hard_regs(), choose_reload_regs(), emit_reload_insns(), fast_allocation(), find_reloads(), forget_old_reloads_1(), ira_build(), ira_reassign_pseudos(), lower_eh_constructs_2(), mergesort(), dom_oracle::register_transitives(), run_gcc(), setup_slot_coalesced_allocno_live_ranges(), slot_coalesced_allocno_live_ranges_intersect_p(), tool_cleanup(), and update_conflict_allocno_hard_prefs().
|
static |
Number of CPUs that can be used for parallel LTRANS phase.
Referenced by init_num_threads(), and run_gcc().
|
static |
Referenced by run_gcc(), and tool_cleanup().
|
static |
Referenced by compile_images_for_offload_targets(), run_gcc(), and tool_cleanup().
|
static |
Referenced by run_gcc(), and tool_cleanup().
|
static |
Referenced by run_gcc(), and tool_cleanup().
const char tool_name[] = "lto-wrapper" |
Provided by the tool itself.
The name of the tool, printed in error messages.
Referenced by append_compiler_options(), and merge_and_complain().