public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jpakkane at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/105467] New: Dependency file produced by C++ modules causes Ninja errors
Date: Tue, 03 May 2022 15:04:37 +0000	[thread overview]
Message-ID: <bug-105467-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105467

            Bug ID: 105467
           Summary: Dependency file produced by C++ modules causes Ninja
                    errors
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jpakkane at gmail dot com
  Target Milestone: ---

Currently if you try to build C++ modules using Ninja and a dependency file,
things fail with this fairly cryptic error message (that comes from Ninja):

inputs may not also have inputs

The commend line is this:

g++ -Igcc/modtest.p -Igcc '-I../test cases/unit/85 cpp modules/gcc'
-fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch
-Wnon-virtual-dtor -std=c++20 -O0 -g -fmodules-ts -MD -MQ
gcc/modtest.p/src0.cxx.o -MF gcc/modtest.p/src0.cxx.o.d -o
gcc/modtest.p/src0.cxx.o -c '../test cases/unit/85 cpp modules/gcc/src0.cxx

and the generated dependency file looks like this:

gcc/modtest.p/src0.cxx.o gcm.cache/M0.gcm: \
 ../test\ cases/unit/85\ cpp\ modules/gcc/src0.cxx \
 /usr/include/stdc-predef.h
gcc/modtest.p/src0.cxx.o gcm.cache/M0.gcm: M1.c++m
M0.c++m: gcm.cache/M0.gcm
.PHONY: M0.c++m
gcm.cache/M0.gcm:| gcc/modtest.p/src0.cxx.o
CXX_IMPORTS += M1.c++m

This sets things up so that the object file depends on the sources and the
generated module file depends on the object file only. Ninja does not like this
and errors out because it thinks that outputs (the .o file in this case) may
not be used as a dependency to other outputs.

A possible fix would be to set the dependencies of the module output to be the
same source files as are used for the object file. Something like this:

gcc/modtest.p/src0.cxx.o gcm.cache/M0.gcm: \
 ../test\ cases/unit/85\ cpp\ modules/gcc/src0.cxx \
 /usr/include/stdc-predef.h
gcc/modtest.p/src0.cxx.o gcm.cache/M0.gcm: M1.c++m
M0.c++m: gcm.cache/M0.gcm
.PHONY: M0.c++m
gcm.cache/M0.gcm: \
 ../test\ cases/unit/85\ cpp\ modules/gcc/src0.cxx \
 /usr/include/stdc-predef.h
CXX_IMPORTS += M1.c++m

The corresponding Ninja bug is here:
https://github.com/ninja-build/ninja/issues/1962

             reply	other threads:[~2022-05-03 15:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-03 15:04 jpakkane at gmail dot com [this message]
2023-10-18  1:32 ` [Bug c++/105467] " bugzilla.gcc at me dot benboeckel.net
2023-10-20 19:55 ` jpakkane at gmail dot com
2023-12-23  4:38 ` saifi.khan at nishan dot io
2023-12-30 14:18 ` jpakkane at gmail dot com
2023-12-30 15:04 ` pinskia at gcc dot gnu.org
2023-12-30 16:34 ` jpakkane at gmail dot com
2023-12-30 18:11 ` pinskia at gcc dot gnu.org
2023-12-30 19:15 ` bugzilla.gcc at me dot benboeckel.net
2023-12-30 19:16 ` bugzilla.gcc at me dot benboeckel.net

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-105467-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).