Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple outputs in gcc depfile #1184

Closed
jpakkane opened this issue Sep 13, 2016 · 8 comments
Closed

Support multiple outputs in gcc depfile #1184

jpakkane opened this issue Sep 13, 2016 · 8 comments
Labels

Comments

@jpakkane
Copy link

ninja: error: build.ninja:233: multiple outputs aren't (yet?) supported by depslog; bring this up on the mailing list if it affects you

This has been around a long time and is known to be difficult. However this is becoming more and more acute. There are many compilers that produce multiple files for each input, for example Fortran produces .o and .mod. Some compilers want to compile many files at once, e.g. somecomp -c foo1.src foo2.src foo3.src which produces three object files in one go.

In Meson we are getting reports from users who have custom compile steps such as converting one IDL file to multiple source files where this fails because depslog can have deps only for one output file.

Please add this functionality. Thanks.

@nico nico added the feature label Sep 20, 2016
@nico
Copy link
Collaborator

nico commented Sep 20, 2016

It's a valid feature request, and we should figure out how to do this. In the meantime, maybe meson could add deps = lines to edges with more than one output.

@mikkelfj
Copy link

mikkelfj commented Sep 21, 2016

I am experimenting with meson for use with in IDL compiler (flatcc for flatbuffers). The tool generates a single depfile, currently only with one target, but in reality it has multiple targets: myschema_reader.h, myschema_builder.h etc., but furthermore there are included subschema subschema1_reader.h etc. It suffice to depend on the top-level myschema_reader.h for correct builds usually, but the ninja clean reports errors with subschema. There is a related issue about ninja not supporting dynamically generated output such as subschema1_reader.h, even if it supports dynamically generated dependencies, so I'm not sure if it is that simple to get clean working.

I'm only learning meson, so there may be mistakes, but in this rule file there are more comments on my experience: https://github.com/dvidelabs/flatcc/blob/meson/rules/meson.build

@evmar
Copy link
Collaborator

evmar commented Sep 21, 2016

"ninja clean" can only delete files it knows about; if at all possible, I recommend putting your build output in a different directory so cleaning is as easy as rm -rf build.

@mikkelfj
Copy link

Wrt. separate build dir, that already happens, so it is not a showstopper.

@jpakkane
Copy link
Author

In the meantime, maybe meson could add deps = lines to edges with more than one output.

If we do that Ninja will immediately halt saying that dep file has more than one output. We simply can't enable it until this is fixed. Nobody would be able to compile code with that.

For more details see this bug in Gnome's bugzilla.

@drothlis
Copy link
Contributor

There is a subset of this behaviour that might be simpler to fix: A depfile with additional outputs that don't have any dependencies. Like this:

res.xml: res1.dat res2.dat
res1.dat:
res2.dat:

Compilers output these additional targets for each of the dependencies so that make won't complain if you remove one of these implicit dependencies. However Ninja already handles missing dependencies so these additional targets aren't strictly necessary. The solution for this case would be to ignore targets (in the depfile) with no dependencies.

This solution would seem to handle the Gnome bug that @jpakkane mentioned in the previous comment.

C pre-processors are configurable enough that you can turn off those phony targets (GCC only produces them if you add -MP). However other types of compilers might not have this option (as in @jpakkane's case).

gnomesysadmins pushed a commit to GNOME/glib that referenced this issue Nov 20, 2016
This includes phony targets for each dependency in the the generated
dependency file which allows building with `ninja` which doesn't like
the phony targets[1] but also allows silencing `make` errors similar to
gcc's -MP option.

[1] - ninja-build/ninja#1184

https://bugzilla.gnome.org/show_bug.cgi?id=774368
@greneholt
Copy link

For anyone that is being blocked by this issue, you may find these pull requests and patches helpful:
#1236
https://github.com/moroten/ninja/tree/multiple-outputs-with-deps

@jhasse jhasse added this to the 1.10.0 milestone Nov 14, 2018
@jhasse jhasse removed this from the 1.10.0 milestone Aug 30, 2019
@mathstuf
Copy link
Contributor

#1534 should have fixed this (and is in 1.10.0).

@jhasse jhasse closed this as completed Jan 29, 2020
bogind added a commit to bogind/QGIS that referenced this issue Feb 8, 2025
Previous link was to ninja release of version 1.7.2, which caused a build error on Windows (raises multiple outputs aren't (yet?) supported by depslog;" which according to - ninja-build/ninja#1184
should be fixed in ninja version >=1.10.
Changed the link to current latest which is 1.12.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants