aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorGiuliano Belinassi <giuliano.belinassi@usp.br>2020-05-15 12:15:34 -0300
committerGiuliano Belinassi <giuliano.belinassi@usp.br>2020-05-15 12:15:34 -0300
commitdc1ede0455cfb5906dbf3865f2cc784c6709be52 (patch)
treebc2884fc4cd7af435d0cfafc74b69817eeb187a8 /gcc
parent223f59d53e23f58cf00f9dc3153e14e31597ff34 (diff)
downloadgcc-dc1ede0455cfb5906dbf3865f2cc784c6709be52.zip
gcc-dc1ede0455cfb5906dbf3865f2cc784c6709be52.tar.gz
gcc-dc1ede0455cfb5906dbf3865f2cc784c6709be52.tar.bz2
Revert "Handle `as' calls when splitting asm output."
This commit has a missing 'ChangeLog' This reverts commit 223f59d53e23f58cf00f9dc3153e14e31597ff34.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/gcc.c249
-rw-r--r--gcc/toplev.c4
2 files changed, 54 insertions, 199 deletions
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 16a11a2..8f530a9 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -349,11 +349,6 @@ class extra_arg_storer
return ret;
}
- void store (char *str)
- {
- string_vec.safe_push (str);
- }
-
~extra_arg_storer ()
{
release_extra_args ();
@@ -387,6 +382,9 @@ class extra_arg_storer
vec<char *> string_vec;
};
+/* Store additional strings for further release. */
+static extra_arg_storer extra_args;
+
/* Forward declaration for prototypes. */
struct path_prefix;
struct prefix_list;
@@ -3163,197 +3161,39 @@ static int get_number_of_args (const char *argv[])
static const char *fsplit_arg (extra_arg_storer *);
-/* Accumulate each line in lines vec. */
-
-void
-get_file_by_lines (extra_arg_storer *storer, vec<char *> *lines, FILE* file)
-{
- int buf_size = 32, len = 0;
- char *buf = XNEWVEC (char, buf_size);
-
- while (1)
- {
- if (!fgets (buf + len, buf_size, file))
- break;
-
- len = strlen (buf);
- if (buf[len - 1] == '\n') /* Check if we indeed read the entire line. */
- {
- buf[len - 1] = '\0';
- /* Yes. Insert into the lines vector. */
- lines->safe_push (buf);
- len = 0;
-
- /* Store the created string for future release. */
- storer->store (buf);
- }
- else
- {
- /* No. Increase the buffer size and read again. */
- buf = XRESIZEVEC (char, buf, buf_size * 2);
- }
- }
-}
-
-static void identify_asm_file (int argc, const char *argv[],
- int *infile_pos, int *outfile_pos)
-{
- int i;
-
- static const char *asm_extension[] = {"s", "S"};
- static const char *obj_extension[] = {"o", "O"};
-
- bool infile_found = false;
- bool outfile_found = false;
-
- for (i = 0; i < argc; i++)
- {
- const char *arg = argv[i];
- const char *ext = argv[i];
- unsigned j;
-
- /* Jump to last '.' of string. */
- while (*arg)
- if (*arg++ == '.')
- ext = arg;
-
- if (!infile_found)
- for (j = 0; j < ARRAY_SIZE (asm_extension); ++j)
- if (!strcmp (ext, asm_extension[j]))
- {
- infile_found = true;
- *infile_pos = i;
- break;
- }
-
- if (!outfile_found)
- for (j = 0; j < ARRAY_SIZE (asm_extension); ++j)
- if (!strcmp (ext, obj_extension[j]))
- {
- outfile_found = true;
- *outfile_pos = i;
- break;
- }
-
- if (infile_found && outfile_found)
- return;
- }
-
- gcc_assert (infile_found && outfile_found);
-
-}
-
-/* Language is one of three things:
-
- 1) The name of a real programming language.
- 2) NULL, indicating that no one has figured out
- what it is yet.
- 3) '*', indicating that the file should be passed
- to the linker. */
-struct infile
-{
- const char *name;
- const char *language;
- const char *temp_additional_asm;
- struct compiler *incompiler;
- bool compiled;
- bool preprocessed;
-};
-
-/* Also a vector of input files specified. */
-
-static struct infile *infiles;
-static struct infile *current_infile = NULL;
-
-int n_infiles;
-
-static int n_infiles_alloc;
-
-
/* Append -fsplit-output=<tempfile> to all calls to compilers. */
static void append_split_outputs (extra_arg_storer *storer,
- struct command **_commands, int *_n_commands)
+ struct command *commands, int n_commands)
{
int i;
- struct command *commands = *_commands;
- int n_commands = *_n_commands;
-
- const char **argv;
- int argc;
-
- const char *extra_argument;
-
- if (is_compiler (commands[0].prog))
- {
- extra_argument = fsplit_arg (storer);
-
- argc = get_number_of_args (commands[0].argv);
- argv = storer->create_new (argc + 2);
-
- memcpy (argv, commands[0].argv, argc * sizeof (const char *));
- argv[argc++] = extra_argument;
- argv[argc] = NULL;
-
- commands[0].argv = argv;
- }
-
- else if (is_assembler (commands[0].prog))
+ for (i = 0; i < n_commands; i++)
{
- vec<char *> additional_asm_files;
-
- FILE *temp_asm_file;
-
- struct command orig;
- const char **orig_argv;
- int orig_argc;
-
- int infile_pos;
- int outfile_pos;
-
- if (n_commands != 1)
- fatal_error (input_location, "Auto parallelism is unsupported when piping commands");
-
- temp_asm_file = fopen (current_infile->temp_additional_asm, "r");
-
- if (!temp_asm_file)
- fatal_error (input_location, "Temporary file containing additional asm files not found");
-
- get_file_by_lines (storer, &additional_asm_files, temp_asm_file);
- fclose (temp_asm_file);
-
- /* Get original command. */
- orig = commands[0];
- orig_argv = commands[0].argv;
- orig_argc = get_number_of_args (orig.argv);
+ const char **argv;
+ int argc;
-
- /* Update commands array to include the extra `as' calls. */
- *_n_commands = additional_asm_files.length ();
- n_commands = *_n_commands;
+ const char *extra_argument;
- gcc_assert (n_commands > 0);
+ if (is_compiler (commands[i].prog))
+ {
+ extra_argument = fsplit_arg (storer);
- *_commands = XRESIZEVEC (struct command, *_commands, n_commands);
- commands = *_commands;
+ argc = get_number_of_args (commands[i].argv);
+ argv = storer->create_new (argc + 2);
- identify_asm_file (orig_argc, orig_argv, &infile_pos, &outfile_pos);
+ memcpy (argv, commands[i].argv, argc * sizeof (const char *));
+ argv[argc++] = extra_argument;
+ argv[argc] = NULL;
- for (i = 0; i < n_commands; i++)
+ commands[i].argv = argv;
+ }
+ else if (is_assembler (commands[i].prog))
{
- const char **argv = storer->create_new (orig_argc + 1);
- memcpy (argv, orig_argv, (orig_argc + 1) * sizeof (const char *));
-
- argv[infile_pos] = additional_asm_files[i];
- /* argv[outfile_pos] ?? do what? */
- commands[i].prog = orig.prog;
- commands[i].argv = argv;
}
}
-
}
DEBUG_FUNCTION void
@@ -3401,13 +3241,9 @@ execute (void)
char *string;
struct pex_obj *pex;
const char *arg;
- int ret_code;
struct command *commands; /* each command buffer with above info. */
- /* Store additional strings for further release. */
- extra_arg_storer extra_args;
-
gcc_assert (!processing_spec_function);
if (wrapper_string)
@@ -3425,7 +3261,7 @@ execute (void)
n_commands++;
/* Get storage for each command. */
- commands = (struct command *) XNEWVEC (struct command, n_commands);
+ commands = (struct command *) alloca (n_commands * sizeof (struct command));
/* Split argbuf into its separate piped processes,
and record info about each one.
@@ -3521,8 +3357,7 @@ execute (void)
returning. This prevents spurious warnings about
unused linker input files, etc. */
execution_count++;
- ret_code = 0;
- goto cleanup;
+ return 0;
}
#ifdef DEBUG
fnotice (stderr, "\nGo ahead? (y or n) ");
@@ -3533,10 +3368,7 @@ execute (void)
;
if (i != 'y' && i != 'Y')
- {
- ret_code = 0;
- goto cleanup;
- }
+ return 0;
#endif /* DEBUG */
}
@@ -3568,7 +3400,7 @@ execute (void)
#endif
if (!have_S)
- append_split_outputs (&extra_args, &commands, &n_commands);
+ append_split_outputs (&extra_args, commands, n_commands);
/* Run each piped subprocess. */
@@ -3609,7 +3441,7 @@ execute (void)
{
int *statuses;
struct pex_time *times = NULL;
- ret_code = 0;
+ int ret_code = 0;
statuses = (int *) alloca (n_commands * sizeof (int));
if (!pex_get_status (pex, n_commands, statuses))
@@ -3745,12 +3577,9 @@ execute (void)
if (commands[0].argv[0] != commands[0].prog)
free (CONST_CAST (char *, commands[0].argv[0]));
- goto cleanup;
- }
-cleanup:
- free (commands);
- return ret_code;
+ return ret_code;
+ }
}
/* Find all the switches given to us
@@ -3820,6 +3649,32 @@ static int n_switches_alloc_debug_check[2];
static char *debug_check_temp_file[2];
+/* Language is one of three things:
+
+ 1) The name of a real programming language.
+ 2) NULL, indicating that no one has figured out
+ what it is yet.
+ 3) '*', indicating that the file should be passed
+ to the linker. */
+struct infile
+{
+ const char *name;
+ const char *language;
+ const char *temp_additional_asm;
+ struct compiler *incompiler;
+ bool compiled;
+ bool preprocessed;
+};
+
+/* Also a vector of input files specified. */
+
+static struct infile *infiles;
+static struct infile *current_infile = NULL;
+
+int n_infiles;
+
+static int n_infiles_alloc;
+
static const char *fsplit_arg (extra_arg_storer *storer)
{
const char *tempname = make_temp_file ("additional-asm");
diff --git a/gcc/toplev.c b/gcc/toplev.c
index f50dd8f..acd1ba7 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -914,7 +914,7 @@ init_additional_asm_names_file (int n, const char *names[])
error ("Unable to create a temporary write-only file.");
for (i = 0; i < n; ++i)
- fprintf(additional_asm_filenames, "%s\n", names[i]);
+ fputs(names[i], additional_asm_filenames);
}
@@ -1993,7 +1993,7 @@ lang_dependent_init (const char *name)
if (!flag_wpa)
{
init_asm_output (name);
- init_additional_asm_names_file (1, &asm_file_name);
+ init_additional_asm_names_file (1, &name);
/* If stack usage information is desired, open the output file. */
if (flag_stack_usage && !flag_generate_lto)