aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorGiuliano Belinassi <giuliano.belinassi@usp.br>2020-08-07 19:06:02 -0300
committerGiuliano Belinassi <giuliano.belinassi@usp.br>2020-08-07 19:06:02 -0300
commit542730f087133690b47e036dfd43eb0db8a650ce (patch)
treec5e4ebdaf8e6d41a52206c713f031117dce4ab87 /gcc
parentc3b38f65b51d043133e6e69a8ae3ae24534bcdfe (diff)
downloadgcc-542730f087133690b47e036dfd43eb0db8a650ce.zip
gcc-542730f087133690b47e036dfd43eb0db8a650ce.tar.gz
gcc-542730f087133690b47e036dfd43eb0db8a650ce.tar.bz2
Fix bootstrap comparison failure
Previously, bootstrap comparison failed when promoting symbols to global because: 1. Randomness was used for promotion. 2. Order matters when partial linking, and such order was also random. This commit fixes those issues. gcc/ChangeLog: 2020-08-07 Giuliano Belinasssi <giuliano.belinassi@usp.br> * cgraphunit.c (childno): New variable. (maybe_compile_in_parallel): Store current child number. * gcc.c (sort_asm_files): New function. * toplev.c (init_additional_asm_names_file): Output child number. * toplev.h (init_additional_asm_names_file): Update interface. * tree.c (get_file_function_name): Do not use randomness when promoting names.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/cgraphunit.c10
-rw-r--r--gcc/gcc.c22
-rw-r--r--gcc/toplev.c39
-rw-r--r--gcc/toplev.h2
-rw-r--r--gcc/tree.c4
6 files changed, 63 insertions, 24 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2887adc..c3a573e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2020-08-07 Giuliano Belinasssi <giuliano.belinassi@usp.br>
+
+ * cgraphunit.c (childno): New variable.
+ (maybe_compile_in_parallel): Store current child number.
+ * gcc.c (sort_asm_files): New function.
+ * toplev.c (init_additional_asm_names_file): Output child number.
+ * toplev.h (init_additional_asm_names_file): Update interface.
+ * tree.c (get_file_function_name): Do not use randomness when
+ promoting names.
+
2020-08-06 Giuliano Belinasssi <giuliano.belinassi@usp.br>
* symtab.c (change_decl_assembler_name): Remove RTL output if
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index a5d5b86..ef606db 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -2765,7 +2765,12 @@ static bool is_number (const char *str)
return true;
}
-static bool maybe_compile_in_parallel (void)
+/* If forked, which child am I? */
+
+static int childno = -1;
+
+static bool
+maybe_compile_in_parallel (void)
{
struct symtab_node *node;
int partitions, i, j;
@@ -2901,6 +2906,7 @@ static bool maybe_compile_in_parallel (void)
pids[j] = fork ();
if (pids[j] == 0)
{
+ childno = j;
lto_apply_partition_mask (ltrans_partitions[j]);
return true;
}
@@ -2966,7 +2972,7 @@ symbol_table::compile (const char *name)
/* Output everything. */
init_asm_output (name);
if (split_outputs)
- handle_additional_asm (true);
+ handle_additional_asm (childno);
switch_to_section (text_section);
(*debug_hooks->assembly_start) ();
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 88ac31e..852db3f 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -3311,6 +3311,26 @@ static bool has_hidden_E (int argc, const char *argv[])
return false;
}
+static void
+sort_asm_files (vec <char *> *_lines)
+{
+ vec <char *> &lines = *_lines;
+ int i, n = lines.length ();
+ char **temp_buf = XALLOCAVEC (char *, n);
+
+ for (i = 0; i < n; i++)
+ temp_buf[i] = lines[i];
+
+ for (i = 0; i < n; i++)
+ {
+ char *no_str = strtok (temp_buf[i], " ");
+ char *name = strtok (NULL, "");
+
+ int pos = atoi (no_str);
+ lines[pos] = name;
+ }
+}
+
/* Append -fsplit-output=<tempfile> to all calls to compilers. Return true
if a additional call to LD is required to merge the resulting files. */
@@ -3383,6 +3403,8 @@ static void append_split_outputs (extra_arg_storer *storer,
parallelize. */
}
+ sort_asm_files (&additional_asm_files);
+
if (n_commands != 1)
fatal_error (input_location,
"Auto parallelism is unsupported when piping commands");
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 057812d..df26a64 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -915,33 +915,34 @@ init_additional_asm_names_file (void)
/* Reinitialize the assembler file and store it in the additional asm file. */
-void handle_additional_asm (bool child)
+void
+handle_additional_asm (int childno)
{
gcc_assert (split_outputs);
- if (child)
- {
- const char *temp_asm_name = make_temp_file (".s");
- asm_file_name = temp_asm_name;
+ if (childno < 0)
+ return;
- if (asm_out_file == stdout)
- fatal_error (UNKNOWN_LOCATION, "Unexpected asm output to stdout");
+ const char *temp_asm_name = make_temp_file (".s");
+ asm_file_name = temp_asm_name;
- fclose (asm_out_file);
+ if (asm_out_file == stdout)
+ fatal_error (UNKNOWN_LOCATION, "Unexpected asm output to stdout");
- asm_out_file = fopen (temp_asm_name, "w");
- if (!asm_out_file)
- fatal_error (UNKNOWN_LOCATION, "Unable to create asm output file.");
- }
+ fclose (asm_out_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.");
+ asm_out_file = fopen (temp_asm_name, "w");
+ if (!asm_out_file)
+ fatal_error (UNKNOWN_LOCATION, "Unable to create asm output file");
- fprintf (additional_asm_filenames, "%s\n", asm_file_name);
- fclose (additional_asm_filenames);
+ /* 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 to open the temporary asm files container");
+
+ fprintf (additional_asm_filenames, "%d %s\n", childno, 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 7159f5f..bae7eb4 100644
--- a/gcc/toplev.h
+++ b/gcc/toplev.h
@@ -105,6 +105,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 (bool);
+extern void handle_additional_asm (int);
#endif /* ! GCC_TOPLEV_H */
diff --git a/gcc/tree.c b/gcc/tree.c
index 32977e5..c1bc823 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -9686,8 +9686,7 @@ get_file_function_name (const char *type)
q = (char *) alloca (9 + 19 + len + 1);
memcpy (q, file, len + 1);
- snprintf (q + len, 9 + 19 + 1, "_%08X_" HOST_WIDE_INT_PRINT_HEX,
- crc32_string (0, name), get_random_seed (false));
+ snprintf (q + len, 9 + 19 + 1, "_%08X", crc32_string (0, name));
p = q;
}
@@ -9700,6 +9699,7 @@ get_file_function_name (const char *type)
Use a global object (which is already required to be unique over
the program) rather than the file name (which imposes extra
constraints). */
+
sprintf (buf, FILE_FUNCTION_FORMAT, type, p);
filter_name (buf);