diff options
author | Giuliano Belinassi <giuliano.belinassi@usp.br> | 2020-06-17 21:04:45 -0300 |
---|---|---|
committer | Giuliano Belinassi <giuliano.belinassi@usp.br> | 2020-06-17 21:04:45 -0300 |
commit | affffe8d3130277801f15d108654a896322e914c (patch) | |
tree | 0a4a530edd9b2aa2db0973529bb3947d630b7824 /gcc | |
parent | 3ec7662202099738819ea521b65faada5c0a6c70 (diff) | |
download | gcc-affffe8d3130277801f15d108654a896322e914c.zip gcc-affffe8d3130277801f15d108654a896322e914c.tar.gz gcc-affffe8d3130277801f15d108654a896322e914c.tar.bz2 |
Fix undefined reference when linking to libc
When compiling with -fvisibility=hidden, libc functions was being
marked as hidden and then ld could not be linked with libc. This
commit fixes that.
It also temporarly fix issues with undefined references with functions
that get passed down as argument and called in another function by
looking for references inside the function.
gcc/ChangeLog
2020-06-17 Giuliano Belinassi <giuliano.belinassi@usp.br>
* cgraphunit.c (ipa_passes): Flush asm file, and handle
crash of child process.
* gcc.c (execute): Print additional ld call if verbose flag is
provided.
* ipa-visibility.c (gate): Run if split_outputs.
* lto-cgraph.c (lto_apply_partition_mask): Only mark body_removed
if node is not a defintion.
* lto-partition.c (analyse_symbol_references): Merge partitions of
functions which we take address of.
(lto_promote_cross_file_statics): call promote_symbol only if
promote is provided.
* lto-partition.h: update lto_promote_cross_file_statics
declaration.
* config/i386/i386-expand.c (ix86_expand_builtin): Initialize
icode.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 18 | ||||
-rw-r--r-- | gcc/cgraphunit.c | 25 | ||||
-rw-r--r-- | gcc/config/i386/i386-expand.c | 3 | ||||
-rw-r--r-- | gcc/gcc.c | 3 | ||||
-rw-r--r-- | gcc/ipa-visibility.c | 5 | ||||
-rw-r--r-- | gcc/lto-cgraph.c | 5 | ||||
-rw-r--r-- | gcc/lto-partition.c | 38 | ||||
-rw-r--r-- | gcc/lto-partition.h | 2 | ||||
-rw-r--r-- | gcc/lto/lto.c | 2 | ||||
-rw-r--r-- | gcc/toplev.c | 35 | ||||
-rw-r--r-- | gcc/toplev.h | 2 |
11 files changed, 93 insertions, 45 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 04a42c1..2e6611a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,21 @@ +2020-06-17 Giuliano Belinassi <giuliano.belinassi@usp.br> + + * cgraphunit.c (ipa_passes): Flush asm file, and handle + crash of child process. + * gcc.c (execute): Print additional ld call if verbose flag is + provided. + * ipa-visibility.c (gate): Run if split_outputs. + * lto-cgraph.c (lto_apply_partition_mask): Only mark body_removed + if node is not a defintion. + * lto-partition.c (analyse_symbol_references): Merge partitions of + functions which we take address of. + (lto_promote_cross_file_statics): call promote_symbol only if + promote is provided. + * lto-partition.h: update lto_promote_cross_file_statics + declaration. + * config/i386/i386-expand.c (ix86_expand_builtin): Initialize + icode. + 2020-06-08 Giuliano Belinassi <giuliano.belinassi@usp.br> * cgraphunit.c (cgraph_node::expand): Quick return if no body is diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 27ffcb3..8e27e87 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -2680,7 +2680,7 @@ ipa_passes (void) /* Find out statics that need to be promoted to globals with hidden visibility because they are accessed from multiple partitions. */ - lto_promote_cross_file_statics (); + lto_promote_cross_file_statics (false); /* Check if we have variables being referenced across partitions. */ lto_check_usage_from_other_partitions (); @@ -2696,6 +2696,9 @@ ipa_passes (void) init_additional_asm_names_file (); + /* Flush asm file, so we don't get repeated output as we fork. */ + fflush (asm_out_file); + /* Run serially for now. */ for (i = 0; i < partitions; ++i) { @@ -2706,14 +2709,32 @@ ipa_passes (void) pids[i] = fork (); if (pids[i] == 0) { - handle_additional_asm (); + handle_additional_asm (true); lto_apply_partition_mask (ltrans_partitions[i]); + goto continue_compilation; } else { int wstatus; waitpid (pids[i], &wstatus, 0); + + if (WIFEXITED (wstatus)) + { + if (WEXITSTATUS (wstatus) == 0) + continue; + else + { + fprintf (stderr, "Child %d exited with error\n", i); + internal_error ("Child exited with error"); + } + + } + else if (WIFSIGNALED (wstatus)) + { + fprintf (stderr, "Child %d aborted due to signal\n", i); + internal_error ("Child aborted with error"); + } } } exit (0); diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c index 2653158..c6ba86a 100644 --- a/gcc/config/i386/i386-expand.c +++ b/gcc/config/i386/i386-expand.c @@ -10929,7 +10929,8 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget, machine_mode mode, int ignore) { size_t i; - enum insn_code icode, icode2; + enum insn_code icode = (enum insn_code) 0, + icode2 = (enum insn_code) 0; tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0); tree arg0, arg1, arg2, arg3, arg4; rtx op0, op1, op2, op3, op4, pat, pat2, insn; @@ -3934,6 +3934,9 @@ execute (void) ? PEX_RECORD_TIMES : 0), progname, temp_filename); + if (verbose_flag) + print_command (&additional_ld); + async_launch_commands (pex, 1, &additional_ld); ret = await_commands_to_finish (pex, 1, &additional_ld); pex_free (pex); diff --git a/gcc/ipa-visibility.c b/gcc/ipa-visibility.c index fed913c..1459e5d 100644 --- a/gcc/ipa-visibility.c +++ b/gcc/ipa-visibility.c @@ -962,8 +962,9 @@ public: virtual bool gate (function *) { - /* Do not re-run on ltrans stage. */ - return !flag_ltrans; + /* Only run on ltrans strage if split-args was provided. */ + bool ret = !flag_ltrans || split_outputs; + return ret; } virtual unsigned int execute (function *) { diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c index dd2df8f..41a2399 100644 --- a/gcc/lto-cgraph.c +++ b/gcc/lto-cgraph.c @@ -2108,10 +2108,9 @@ lto_apply_partition_mask (ltrans_partition partition) { maybe_release_function_dominators (cnode); cnode->release_body (); - cnode->body_removed = true; + if (!cnode->definition) + cnode->body_removed = true; } - - node->in_other_partition = true; } } diff --git a/gcc/lto-partition.c b/gcc/lto-partition.c index a1eef09..812a3f1 100644 --- a/gcc/lto-partition.c +++ b/gcc/lto-partition.c @@ -472,21 +472,23 @@ analyse_symbol_references (symtab_node *node, int set) /* Add all duplicated references to the partition. */ for (i = 0; node->iterate_reference (i, ref); i++) - if (ref->referred->get_partitioning_class () == SYMBOL_DUPLICATE) - { - symtab_node *node1 = ref->referred; - analyse_symbol (node1, set); - } - /* References to a readonly variable may be constant foled into its value. - Recursively look into the initializers of the constant variable and add - references, too. */ - else if (is_a <varpool_node *> (ref->referred) - /* && (dyn_cast <varpool_node *> (ref->referred) - ->ctor_useable_for_folding_p ()))*/) - { - symtab_node *node1 = ref->referred; - analyse_symbol (node1, set); - } + { + if (ref->referred->get_partitioning_class () == SYMBOL_DUPLICATE) + { + symtab_node *node1 = ref->referred; + analyse_symbol (node1, set); + } + /* References to a readonly variable may be constant foled into its value. + Recursively look into the initializers of the constant variable and add + references, too. */ + /* Check if we have a reference to global variable or function. */ + if (is_a <varpool_node *> (ref->referred) + || is_a <cgraph_node *> (ref->referred)) + { + symtab_node *node1 = ref->referred; + analyse_symbol (node1, set); + } + } } static bool analyse_symbol_1 (symtab_node *node, int set) @@ -1390,7 +1392,7 @@ rename_statics (lto_symtab_encoder_t encoder, symtab_node *node) all inlinees are added. */ void -lto_promote_cross_file_statics (void) +lto_promote_cross_file_statics (bool promote) { unsigned i, n_sets; @@ -1436,8 +1438,8 @@ lto_promote_cross_file_statics (void) validize_symbol_for_target (node); continue; } - - promote_symbol (node); + if (promote) + promote_symbol (node); } } delete lto_clone_numbers; diff --git a/gcc/lto-partition.h b/gcc/lto-partition.h index 074a695..7428b03 100644 --- a/gcc/lto-partition.h +++ b/gcc/lto-partition.h @@ -36,7 +36,7 @@ extern vec<ltrans_partition> ltrans_partitions; void lto_1_to_1_map (void); void lto_max_map (void); void lto_balanced_map (int, int); -void lto_promote_cross_file_statics (void); +void lto_promote_cross_file_statics (bool promote); void free_ltrans_partitions (void); void lto_promote_statics_nonwpa (void); void lto_check_usage_from_other_partitions (void); diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c index 1c37814..803b992 100644 --- a/gcc/lto/lto.c +++ b/gcc/lto/lto.c @@ -515,7 +515,7 @@ do_whole_program_analysis (void) /* Find out statics that need to be promoted to globals with hidden visibility because they are accessed from multiple partitions. */ - lto_promote_cross_file_statics (); + lto_promote_cross_file_statics (true); if (dump_file) dump_end (partition_dump_id, dump_file); dump_file = NULL; diff --git a/gcc/toplev.c b/gcc/toplev.c index 21f2019..447cb8f 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -915,30 +915,33 @@ init_additional_asm_names_file (void) /* Reinitialize the assembler file and store it in the additional asm file. */ -void handle_additional_asm (void) +void handle_additional_asm (bool child) { gcc_assert (split_outputs); - const char *temp_asm_name = make_temp_file (".s"); - asm_file_name = temp_asm_name; + if (child) + { + const char *temp_asm_name = make_temp_file (".s"); + asm_file_name = temp_asm_name; - if (asm_out_file == stdout) - fatal_error (UNKNOWN_LOCATION, "Unexpected asm output to stdout"); + if (asm_out_file == stdout) + fatal_error (UNKNOWN_LOCATION, "Unexpected asm output to stdout"); - fclose (asm_out_file); + fclose (asm_out_file); - asm_out_file = fopen (temp_asm_name, "w"); - if (!asm_out_file) - fatal_error (UNKNOWN_LOCATION, "Unable to create asm output file."); + asm_out_file = fopen (temp_asm_name, "w"); + if (!asm_out_file) + fatal_error (UNKNOWN_LOCATION, "Unable to create asm output file."); + } - /* Reopen file as append mode. Here we assume that write to append file is - atomic, as it is in Linux. */ - additional_asm_filenames = fopen (split_outputs, "a"); - if (!additional_asm_filenames) - fatal_error (UNKNOWN_LOCATION, "Unable open the temporary asm files container."); + /* Reopen file as append mode. Here we assume that write to append file is + atomic, as it is in Linux. */ + additional_asm_filenames = fopen (split_outputs, "a"); + if (!additional_asm_filenames) + fatal_error (UNKNOWN_LOCATION, "Unable open the temporary asm files container."); - fprintf (additional_asm_filenames, "%s\n", asm_file_name); - fclose (additional_asm_filenames); + fprintf (additional_asm_filenames, "%s\n", asm_file_name); + fclose (additional_asm_filenames); } /* A helper function; used as the reallocator function for cpp's line diff --git a/gcc/toplev.h b/gcc/toplev.h index 2069c79..11a1d3d 100644 --- a/gcc/toplev.h +++ b/gcc/toplev.h @@ -104,6 +104,6 @@ extern void parse_alignment_opts (void); extern void initialize_rtl (void); extern void init_additional_asm_names_file (void); -extern void handle_additional_asm (void); +extern void handle_additional_asm (bool); #endif /* ! GCC_TOPLEV_H */ |