From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7E5C3383602B; Tue, 3 May 2022 15:04:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E5C3383602B From: "jpakkane at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jpakkane at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 May 2022 15:04:37 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105467 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=3Dalways -D_FILE_OFFSET_BITS=3D64 -Wall -Winvalid-pch -Wnon-virtual-dtor -std=3Dc++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 +=3D 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 +=3D M1.c++m The corresponding Ninja bug is here: https://github.com/ninja-build/ninja/issues/1962=