GCC with patches for OS216
Revision | 5269b24605b17211f34dd40df2d18ba7a7f481e2 (tree) |
---|---|
Time | 2020-05-05 19:42:22 |
Author | Eric Botcazou <ebotcazou@gcc....> |
Commiter | Eric Botcazou |
Silence warning in LTO mode on VxWorks
The link phase is always partial (-r) for VxWorks in kernel mode, which
means that it uses incremental LTO linking by default (-flinker-output=rel).
But in this mode the LTO plugin outputs a warning if one of the object files
involved in the link does not contain LTO bytecode, before switching to
nolto-rel mode. We do not do repeated incremental linking for VxWorks so
silence the warning.
lto-plugin/
* lto-plugin.c: Document -linker-output-auto-notlo-rel option.
(linker_output_set): Change type to bool.
(linker_output_known): Likewise.
(linker_output_auto_nolto_rel): New variable.
(all_symbols_read_handler): Take it into account.
<LDPO_REL>: Do not issue the warning if it is set.
(process_option): Process -linker-output-auto-notlo-rel.
(cleanup_handler): Remove unused variable.
(onload) <LDPT_LINKER_OUTPUT>: Adjust to above type change.
gcc/
* gcc.c (LTO_PLUGIN_SPEC): Define if not already.
(LINK_PLUGIN_SPEC): Execute LTO_PLUGIN_SPEC.
* config/vxworks.h (LTO_PLUGIN_SPEC): Define.
@@ -1,5 +1,11 @@ | ||
1 | 1 | 2020-05-05 Eric Botcazou <ebotcazou@adacore.com> |
2 | 2 | |
3 | + * gcc.c (LTO_PLUGIN_SPEC): Define if not already. | |
4 | + (LINK_PLUGIN_SPEC): Execute LTO_PLUGIN_SPEC. | |
5 | + * config/vxworks.h (LTO_PLUGIN_SPEC): Define. | |
6 | + | |
7 | +2020-05-05 Eric Botcazou <ebotcazou@adacore.com> | |
8 | + | |
3 | 9 | * gimplify.c (gimplify_init_constructor): Do not put the constructor |
4 | 10 | into static memory if it is not complete. |
5 | 11 |
@@ -273,3 +273,11 @@ extern void vxworks_asm_out_destructor (rtx symbol, int priority); | ||
273 | 273 | #undef DWARF_GNAT_ENCODINGS_DEFAULT |
274 | 274 | #define DWARF_GNAT_ENCODINGS_DEFAULT \ |
275 | 275 | (TARGET_VXWORKS7 ? DWARF_GNAT_ENCODINGS_MINIMAL : DWARF_GNAT_ENCODINGS_ALL) |
276 | + | |
277 | +/* The default configuration of incremental LTO linking (-flinker-output=rel) | |
278 | + warns if an object file included in the link does not contain LTO bytecode, | |
279 | + because in this case the output will not contain it either, thus preventing | |
280 | + further incremental LTO linking. We do not do repeated incremental linking | |
281 | + so silence the warning (instead of passing -flinker-output=nolto-rel). */ | |
282 | +#undef LTO_PLUGIN_SPEC | |
283 | +#define LTO_PLUGIN_SPEC "%{!mrtp:-plugin-opt=-linker-output-auto-notlo-rel}" |
@@ -944,6 +944,10 @@ proper position among the other output files. */ | ||
944 | 944 | # endif |
945 | 945 | #endif |
946 | 946 | |
947 | +#ifndef LTO_PLUGIN_SPEC | |
948 | +#define LTO_PLUGIN_SPEC "" | |
949 | +#endif | |
950 | + | |
947 | 951 | /* Conditional to test whether the LTO plugin is used or not. |
948 | 952 | FIXME: For slim LTO we will need to enable plugin unconditionally. This |
949 | 953 | still cause problems with PLUGIN_LD != LD and when plugin is built but |
@@ -968,6 +972,7 @@ proper position among the other output files. */ | ||
968 | 972 | -plugin %(linker_plugin_file) \ |
969 | 973 | -plugin-opt=%(lto_wrapper) \ |
970 | 974 | -plugin-opt=-fresolution=%u.res \ |
975 | + " LTO_PLUGIN_SPEC "\ | |
971 | 976 | %{flinker-output=*:-plugin-opt=-linker-output-known} \ |
972 | 977 | %{!nostdlib:%{!nodefaultlibs:%:pass-through-libs(%(link_gcc_c_sequence))}} \ |
973 | 978 | }" PLUGIN_COND_CLOSE |
@@ -1,3 +1,15 @@ | ||
1 | +2020-05-05 Eric Botcazou <ebotcazou@adacore.com> | |
2 | + | |
3 | + * lto-plugin.c: Document -linker-output-auto-notlo-rel option. | |
4 | + (linker_output_set): Change type to bool. | |
5 | + (linker_output_known): Likewise. | |
6 | + (linker_output_auto_nolto_rel): New variable. | |
7 | + (all_symbols_read_handler): Take it into account. | |
8 | + <LDPO_REL>: Do not issue the warning if it is set. | |
9 | + (process_option): Process -linker-output-auto-notlo-rel. | |
10 | + (cleanup_handler): Remove unused variable. | |
11 | + (onload) <LDPT_LINKER_OUTPUT>: Adjust to above type change. | |
12 | + | |
1 | 13 | 2020-04-28 H.J. Lu <hongjiu.lu@intel.com> |
2 | 14 | |
3 | 15 | PR bootstrap/94739 |
@@ -32,6 +32,9 @@ along with this program; see the file COPYING3. If not see | ||
32 | 32 | -nop: Instead of running lto-wrapper, pass the original to the plugin. This |
33 | 33 | only works if the input files are hybrid. |
34 | 34 | -linker-output-known: Do not determine linker output |
35 | + -linker-output-auto-notlo-rel: Switch from rel to nolto-rel mode without | |
36 | + warning. This is used on systems like VxWorks (kernel) where the link is | |
37 | + always partial and repeated incremental linking is generally not used. | |
35 | 38 | -sym-style={none,win32,underscore|uscore} |
36 | 39 | -pass-through */ |
37 | 40 |
@@ -195,8 +198,9 @@ static bool verbose; | ||
195 | 198 | static char nop; |
196 | 199 | static char *resolution_file = NULL; |
197 | 200 | static enum ld_plugin_output_file_type linker_output; |
198 | -static int linker_output_set; | |
199 | -static int linker_output_known; | |
201 | +static bool linker_output_set; | |
202 | +static bool linker_output_known; | |
203 | +static bool linker_output_auto_nolto_rel; | |
200 | 204 | static const char *link_output_name = NULL; |
201 | 205 | |
202 | 206 | /* The version of gold being used, or -1 if not gold. The number is |
@@ -709,9 +713,10 @@ use_original_files (void) | ||
709 | 713 | static enum ld_plugin_status |
710 | 714 | all_symbols_read_handler (void) |
711 | 715 | { |
716 | + const unsigned num_lto_args | |
717 | + = num_claimed_files + lto_wrapper_num_args + 2 | |
718 | + + !linker_output_known + !linker_output_auto_nolto_rel; | |
712 | 719 | unsigned i; |
713 | - unsigned num_lto_args = num_claimed_files + lto_wrapper_num_args + 2 | |
714 | - + !linker_output_known; | |
715 | 720 | char **lto_argv; |
716 | 721 | const char *linker_output_str = NULL; |
717 | 722 | const char **lto_arg_ptr; |
@@ -743,9 +748,10 @@ all_symbols_read_handler (void) | ||
743 | 748 | case LDPO_REL: |
744 | 749 | if (non_claimed_files) |
745 | 750 | { |
746 | - message (LDPL_WARNING, "incremental linking of LTO and non-LTO " | |
747 | - "objects; using -flinker-output=nolto-rel which will " | |
748 | - "bypass whole program optimization"); | |
751 | + if (!linker_output_auto_nolto_rel) | |
752 | + message (LDPL_WARNING, "incremental linking of LTO and non-LTO" | |
753 | + " objects; using -flinker-output=nolto-rel which will" | |
754 | + " bypass whole program optimization"); | |
749 | 755 | linker_output_str = "-flinker-output=nolto-rel"; |
750 | 756 | } |
751 | 757 | else |
@@ -1291,8 +1297,10 @@ static void | ||
1291 | 1297 | process_option (const char *option) |
1292 | 1298 | { |
1293 | 1299 | if (strcmp (option, "-linker-output-known") == 0) |
1294 | - linker_output_known = 1; | |
1295 | - if (strcmp (option, "-debug") == 0) | |
1300 | + linker_output_known = true; | |
1301 | + else if (strcmp (option, "-linker-output-auto-notlo-rel") == 0) | |
1302 | + linker_output_auto_nolto_rel = true; | |
1303 | + else if (strcmp (option, "-debug") == 0) | |
1296 | 1304 | debug = true; |
1297 | 1305 | else if ((strcmp (option, "-v") == 0) |
1298 | 1306 | || (strcmp (option, "--verbose") == 0)) |
@@ -1390,7 +1398,7 @@ onload (struct ld_plugin_tv *tv) | ||
1390 | 1398 | break; |
1391 | 1399 | case LDPT_LINKER_OUTPUT: |
1392 | 1400 | linker_output = (enum ld_plugin_output_file_type) p->tv_u.tv_val; |
1393 | - linker_output_set = 1; | |
1401 | + linker_output_set = true; | |
1394 | 1402 | break; |
1395 | 1403 | case LDPT_OUTPUT_NAME: |
1396 | 1404 | /* We only use this to make user-friendly temp file names. */ |