This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [distcc] gcc bootstraps with distcc


Alexandre Oliva wrote:-

> Here it is bootstrapped on i686-pc-linux-gnu.  I ended up using
> -fworking-directory, instead of -fwd (or -fpwd, that I discarded
> because I couldn't figure out what the `p' stood for :-)

OK, thanks.

> I ended up having to change specs, to get -g* flags passed to the
> preprocessor, such that it could decide whether to enable or disable
> -fworking-directory by default.

I'm not sure about this - someone separated out the -g stuff for a good
reason that I can't recall (hence the cpp_debug_options or whatever
it's called in gcc.c).  Can you do something sensible without it, or
investigate why it was separated?

> +  /* If we're generating preprocessor output, emit current directory
> +     if explicitly requested or if debugging information is enabled.
> +     ??? Maybe we should only do it for debugging formats that
> +     actually output the current directory?  */
> +  cpp_opts->working_directory
> +    = (flag_preprocess_only
> +       && (flag_working_directory == 1
> +	   || (flag_working_directory == -1
> +	       && debug_info_level != DINFO_LEVEL_NONE)));

A nit: please de-obfucate this a litte.  The flag_preprocess_only
should not be necessary (see below).  Maybe have

   if (flag_working_directory == -1)
      flag_working_directory = debug_info_level != DINFO_LEVEL_NONE;
   cpp_opts->working_directory = flag_working_directory;

>  /* If we have designated initializers (GCC >2.7) these tables can be
> @@ -470,6 +471,24 @@ cpp_read_main_file (cpp_reader *pfile, c
>    if (CPP_OPTION (pfile, preprocessed))
>      read_original_filename (pfile);
>  
> +  if (CPP_OPTION (pfile, working_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);
> +    }

Please put this inside the if (preprocessed) condition.

> +    {
> +      _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';
> +
> +      pfile->cb.dir_change (pfile, debugdir);
> +    }      
> +
> +  /* We want to process the fake line changes as regular changes, to
> +     get them output.  */
> +  _cpp_backup_tokens (pfile, 3);
> +
> +  CPP_OPTION (pfile, working_directory) = false;

I don't understand the need for both this callback and the one above.
It's be nice if the logic were only in the read_original_directory function.
Could you explain?

Otherwise I think we're close to agreeing this.

Neil.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]