This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [distcc] gcc bootstraps with distcc
Alexandre Oliva wrote:-
> After some further discussion on IRC, I ended up having to go with a
> different format to implement the directory line markers. Here's the
> implementation. Ok to install?
It's worth noting that there was never a consensus on what to do.
I dislike this approach as 1) it's ugly, and 2) it gives us a wart
we can't lose, so I probably won't approve the patch. You know
what I like, but dismissed it as "unacceptable".
That said, there are things I'd like improved if we go down this
route.
> + if (CPP_OPTION (pfile, current_directory))
> + {
> + const char *name = pfile->map->to_file;
> + const char *dir = getpwd ();
> + char *dir_with_slashes = alloca (strlen (dir) + 3);
> +
> + memcpy (dir_with_slashes, dir, strlen (dir));
> + memcpy (dir_with_slashes + strlen (dir), "//", 3);
> +
> + if (pfile->cb.dir_change)
> + pfile->cb.dir_change (pfile, dir);
> + /* Emit file renames that will be recognized by
> + read_directory_filename, since dir_change doesn't output
> + anything. */
> + _cpp_do_file_change (pfile, LC_RENAME, dir_with_slashes, 1, 0);
> + _cpp_do_file_change (pfile, LC_RENAME, name, 1, 0);
> + }
Is the second rename necessary? I don't see why it should be;
if not let's not do it.
> +read_original_directory (cpp_reader *pfile)
> +{
> + const cpp_token *hash, *token;
> +
> + /* Lex ahead; if the first tokens are of the form # NUM, then
> + process the directive, otherwise back up. */
> + hash = _cpp_lex_direct (pfile);
> + if (hash->type != CPP_HASH)
> + {
> + _cpp_backup_tokens (pfile, 1);
> + return;
> + }
> +
> + token = _cpp_lex_direct (pfile);
> +
> + if (token->type != CPP_NUMBER)
> + {
> + _cpp_backup_tokens (pfile, 2);
> + return;
> + }
> +
> + token = _cpp_lex_direct (pfile);
> +
> + if (token->type != CPP_STRING
> + || ! (token->val.str.len >= 5
> + && token->val.str.text[token->val.str.len-2] == '/'
> + && token->val.str.text[token->val.str.len-3] == '/'))
> + {
> + _cpp_backup_tokens (pfile, 3);
> + return;
> + }
> +
> + if (pfile->cb.dir_change)
> + {
> + char *debugdir = alloca (token->val.str.len - 3);
> +
> + memcpy (debugdir, (const char *) token->val.str.text + 1,
> + token->val.str.len - 4);
> + debugdir[token->val.str.len - 4] = '\0';
> +
> + if (! pfile->cb.dir_change (pfile, debugdir))
> + cpp_error (pfile, DL_ERROR,
> + "too late to set debug directory");
> + }
> +
> + /* We want to process the fake line changes as regular changes, to
> + get them output. */
> + _cpp_backup_tokens (pfile, 3);
> +
> + CPP_OPTION (pfile, current_directory) = 0;
> }
This is really horrible. cb.dir_change should return void, things about
"too late" are no concern of cpplib.
> void (*line_change) (cpp_reader *, const cpp_token *, int);
> void (*file_change) (cpp_reader *, const struct line_map *);
> + bool (*dir_change) (cpp_reader *, const char *);
> void (*include) (cpp_reader *, unsigned int, const unsigned char *,
> const char *, int);
> void (*define) (cpp_reader *, unsigned int, cpp_hashnode *);
See above.
> @@ -743,7 +743,7 @@ static const char *cpp_unique_options =
> %{!Q:-quiet} %{nostdinc*} %{C} %{CC} %{v} %{I*} %{P} %I\
> %{MD:-MD %{!o:%b.d}%{o*:%.d%*}}\
> %{MMD:-MMD %{!o:%b.d}%{o*:%.d%*}}\
> - %{M} %{MM} %{MF*} %{MG} %{MP} %{MQ*} %{MT*}\
> + %{M} %{MM} %{MF*} %{MG} %{MP} %{Mpwd} %{MQ*} %{MT*}\
> %{!E:%{!M:%{!MM:%{MD|MMD:%{o*:-MQ %*}}}}}\
> %{trigraphs} %{remap} %{g3:-dD} %{H} %C %{D*&U*&A*} %{i*} %Z %i\
> %{E|M|MM:%W{o*}}";
Is there a good reason for this? If not, let's go with -fpwd as
default and -fno-pwd.
Neil.