[distcc] gcc bootstraps with distcc

Alexandre Oliva aoliva@redhat.com
Tue Aug 5 18:03:00 GMT 2003


On Aug  5, 2003, Neil Booth <neil@daikokuya.co.uk> wrote:

>> 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)

Is cpp_unique_options what you have in mind?

The reason it's there is to prevent options that may be passed both to
the compiler and to the preprocessor from being passed twice.  This is
the reason why I didn't add %{g*} to cpp_unique_options, and rather to
cpp_options.  Alternatively, I could move it from cc1_options to
cpp_unique_options, and then both cpp_options, and the specs for cc1
would get -g* from a single location (or so it seems to me, this seems
fragile and I'm not very familiar with these specs).

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

It is not, but if we're using the integrated preprocessor, there's no
reason for us to actually emit the working directory directive: the
default behavior will be perfectly correct.

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

I didn't want to modify flag_working_directory, thinking of a compile
server that might take different inputs with different command lines.
I'm not entirely sure how this is supposed to work, though, so I'll
make the change you requested.

>> +  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.

???  I don't see how this would work.  The very point of this code is
to emit the dir_change directive when our input is not preprocessed.
I might move it to an else, but then gcc -E -fno-working-directory |
gcc -E -fpreprocessed -fworking-directory would not have a working
directory line in the output.

>> +  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);
>> +    }      

> 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?

The second callback is called if read_original_directory() is called
and succeeds in reading a directory from a preprocessed input.  If we
don't have preprocessed input, we never call read_original_file(),
that is the only caller of read_original_directory().  So, in the
common case of preprocessing a non-preprocessed input, we need the
first callback in order to get a directory directive in the first
place.  In case we find a working directory directive in the
preprocessed input, we disable the working directory option at the end
of read_original_directory(), such that the callback in
cpp_read_main_file() doesn't get exercised.

If you'd rather have a single callback point,
read_original_directory() wouldn't be the place: cpp_read_main_file()
would.  I could arrange for cpp_read_main_file to pass
read_original_file (that would pass on to read_original_directory) a
pointer to a directory name, initialized to getpwd(), and that
read_original_directory() would override in case it found the
directive in a preprocessed input, but I don't quite find this
appealing :-)  Do you agree?

Besides the change to sanitize_cpp_options() that I agreed to above,
any other changes you'd like me to make?  I won't waste bandwidth
posting the revised patch right now, since there may be need for
further changes, but if you'd approve the patch with this one change,
please let me know, and I'll post the (hopefully :-) final patch and
check it in.

> Otherwise I think we're close to agreeing this.

Woohoo! :-) :-)  This is excellent news :-)

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer



More information about the Gcc-patches mailing list