[distcc] gcc bootstraps with distcc
Neil Booth
neil@daikokuya.co.uk
Wed Jul 2 05:43:00 GMT 2003
Alexandre Oliva wrote:-
> Here's a patch for GCC that I've just tested, that was enough to get
> GCC to bootstrap using distcc, using distccrel (attached) as per the
> instructions in it.
>
> It seems like the other problem I had before, of getting different
> line numbers depending on whether separate or integrated preprocessing
> is done is no longer present. Wheee!
Um. Odd. I hope we never revisit this then 8-)
> source and build trees. The reasons -Mpwd is not enabled by default
> are backward compatibility (the <directory> directive might be
> unexpected, even though it's in a format that is entirely
> backward-compatible), efficiency and to enable ccache caches to be
> shared by multiple build trees.
Ignoring the other two, is this last reason a good reason still for
it not to be default?
> Index: gcc/c-lex.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/c-lex.c,v
> retrieving revision 1.206
> diff -u -p -r1.206 c-lex.c
> --- gcc/c-lex.c 30 Jun 2003 19:36:20 -0000 1.206
> +++ gcc/c-lex.c 2 Jul 2003 04:13:03 -0000
> @@ -242,6 +242,14 @@ fe_file_change (const struct line_map *n
>
> (*debug_hooks->end_source_file) (to_line);
> }
> + else if (new_map->reason == LC_RENAME)
> + {
> + if (strncmp (new_map->to_file, "<directory>",
> + strlen ("<directory>")) == 0)
> + set_src_pwd (new_map->to_file + strlen ("<directory>"));
> + if (input_filename == main_input_filename)
> + main_input_filename = new_map->to_file;
> + }
>
> update_header_times (new_map->to_file);
> in_system_header = new_map->sysp != 0;
I don't like this. If we're going to do this directory thing, and I
don't see why not if it's useful, we should provide a separate
callback and not overload this one (which is hairy enough as-is).
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/cppinit.c,v
> retrieving revision 1.284
> diff -u -p -r1.284 cppinit.c
> --- gcc/cppinit.c 17 Jun 2003 06:17:42 -0000 1.284
> +++ gcc/cppinit.c 2 Jul 2003 04:13:05 -0000
> @@ -29,7 +29,8 @@ Foundation, 59 Temple Place - Suite 330,
>
> static void init_library (void);
> static void mark_named_operators (cpp_reader *);
> -static void read_original_filename (cpp_reader *);
> +static bool read_original_filename (cpp_reader *);
> +static bool read_original_directory (cpp_reader *);
> static void post_options (cpp_reader *);
>
> /* If we have designated initializers (GCC >2.7) these tables can be
> @@ -428,6 +429,8 @@ cpp_add_dependency_target (cpp_reader *p
> const char *
> cpp_read_main_file (cpp_reader *pfile, const char *fname)
> {
> + char *pwd;
> +
> sanity_checks (pfile);
>
> post_options (pfile);
> @@ -457,8 +460,24 @@ cpp_read_main_file (cpp_reader *pfile, c
>
> /* For foo.i, read the original filename foo.c now, for the benefit
> of the front ends. */
> - if (CPP_OPTION (pfile, preprocessed))
> - read_original_filename (pfile);
> + if (CPP_OPTION (pfile, preprocessed)
> + && read_original_filename (pfile))
> + pwd = NULL;
> + else if (CPP_OPTION (pfile, current_directory))
> + pwd = getpwd ();
> + else
> + pwd = NULL;
> +
> + if (pwd)
> + {
> + char *dir = concat ("<directory>", pwd, NULL);
> + const char *name = pfile->map->to_file;
> + unsigned int line = pfile->line;
> + int sysp = pfile->map->sysp;
> +
> + _cpp_do_file_change (pfile, LC_RENAME, dir, 1, 0);
> + _cpp_do_file_change (pfile, LC_RENAME, name, line, sysp);
> + }
My above suggestion would thankfully lose most of this, no?
> +/* For preprocessed files, if the tokens following the first filename
> + line are of the form # NUM "<directory>...", handle the directive
> + so we know the original current directory. This will generate
> + file_change callbacks, which the front ends must handle
> + appropriately given their state of initialization. */
> +static bool
> +read_original_directory (cpp_reader *pfile)
> +{
> + const cpp_token *token, *token1, *token2;
> +
> + /* Lex ahead; if the first tokens are of the form # NUM, then
> + process the directive, otherwise back up. */
> + token = _cpp_lex_direct (pfile);
> + if (token->type == CPP_HASH)
> + {
> + token1 = _cpp_lex_direct (pfile);
> +
> + /* If it's a #line directive, handle it. */
> + if (token1->type == CPP_NUMBER)
> + {
> + token2 = _cpp_lex_direct (pfile);
> + _cpp_backup_tokens (pfile, 2);
> +
> + if (token2->type == CPP_STRING
> + && strncmp ((const char *)token2->val.str.text, "<directory>",
> + strlen ("<directory>")) == 0)
> + {
> + const char *name = pfile->map->to_file;
> + unsigned int line = pfile->line;
> + int sysp = pfile->map->sysp;
> +
> + _cpp_handle_directive (pfile, token->flags & PREV_WHITE);
> +
> + _cpp_do_file_change (pfile, LC_RENAME, name, line, sysp);
> + return true;
> + }
> }
> + else
> + _cpp_backup_tokens (pfile, 1);
> }
>
> /* Backup as if nothing happened. */
> _cpp_backup_tokens (pfile, 1);
> +
> + return false;
> }
Can you give me some time to think about where this information is
stored? I'm not sure if I prefer something like this, or perhaps
somehow storing it in the first #line. I'd also be interested in
Zack's thoughts (cc-ed in case he missed this post; I almost did).
Neil.
More information about the Gcc-patches
mailing list