This is the mail archive of the gcc-bugs@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]

[Bug driver/12448] New: -NT / -NQ don't behave as documented.


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12448

           Summary: -NT / -NQ don't behave as documented.
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: driver
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: taylor at candd dot org
                CC: gcc-bugs at gcc dot gnu dot org

In gcc/doc/cppopts.texi, in the description of -MT it says:

    Change the target of the rule emitted by dependency generation.  By
    default CPP takes the name of the main input file, including any path,
    deletes any file suffix such as @samp{.c}, and appends the platform's
    usual object suffix.  The result is the target.

    An @option{-MT} option will set the target to be exactly the string you
    specify.  If you want multiple targets, you can specify them as a single
    argument to @option{-MT}, or use multiple @option{-MT} options.

My reading of this is that if you specify -MT <target>, then the
default target will *NOT* be used.

And examining the code, that appears to be the intent -- for each
target specified with -MT / -MQ, deps_add_target is called.  And after
processing such arguments, deps_add_default_target is called (by
cpp_read_main_file) which only adds the default target if there are no
targets already specified.

But, that isn't the full story.  In gcc.c, variable
cpp_unique_options, we find this line:

    %{!E:%{!M:%{!MM:%{MD|MMD:%{o*:-MQ %*}}}}}

which causes the default target to get added unilaterally.

I believe that either this line should disappear totally or it should
be changed to:

    %{!E:%{!M:%{!MM:%{!MT:%{!MQ:%{MD|MMD:%{o*:-MQ %*}}}}}}}

i.e., have !MT && !MQ added as a condition.

I have lightly tested both solutions; they both appear to work.


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