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

Ninja not executing archive command despite its presence in build.ninja file #2553

Open
reshmavk opened this issue Jan 15, 2025 · 8 comments

Comments

@reshmavk
Copy link

We are trying to build glib2 with the latest ninja 1.12.1.
In AIX, we archive shared libraries. The rule for the same is written in build.ninja as follows:
rule AIX_LINKER
command = ar -q -v $out $in && rm -f $in
description = Archiving AIX shared library

and the command to build the archive is as follows.
build glib/libglib-2.0.a: AIX_LINKER glib/libglib-2.0.so.0

This command is not being executed.
In the build all: section of the build.ninja file, we do have the "glib/libglib-2.0.a" target.
Ninja was working fine till 1.11.1 in AIX. Please let me know what could be the reason for this.

@digit-google
Copy link
Contributor

Can you be more specific about what's going on here, what I mean is:

  • When you say the command is not being executed, is during a clean build or an incremental one? Under any other specific conditions?

  • Your command is removing the input on completion of the ar tool. This is suspicious as it means that Ninja incremental builds will always try to rebuild the .so, then the archive after that. Are you sure this is something you really need? This also looks the opposite of what you are describing here, so this is rather puzzling.

  • What is the output of ninja -t commands glib/libglib-2.0.a, which should print the command. It should end with the ar ... command line.

  • Does glib/libglib-2.0.a appears in the output of ninja -t inputs all at all? If not your build plan is probably invalid.

A minimal build.ninja that reproduces the issue would be helpful here.

@reshmavk
Copy link
Author

It is a clean build and it creates glib/libglib-2.0.so.0 file but not glib/libglib-2.0.a.

"ninja -t commands glib/libglib-2.0.a" command ends with the ar command as follows:
ar -q -v glib/libglib-2.0.a glib/libglib-2.0.so.0 && rm -f glib/libglib-2.0.so.0
However it doesn't execute this ar command.

The output of "ninja -t inputs all" doesn't include glib/libglib-2.0.a. This is the same even in the working case.

@reshmavk
Copy link
Author

I just wanted to understand more. Can you tell why "ninja -t inputs all" should have "glib/libglib-2.0.a" in the output?
Should this come from meson or ninja?

@digit-google
Copy link
Contributor

digit-google commented Jan 16, 2025

ninja -t inputs <target> prints all transitive inputs for a given <target> by parsing the build graph.
Note: this ignores validation targets.

If ninja -t inputs all does not list the archive target, it is not a transitive dependency, then ninja all will not rebuild it.

Are you sure the archive is listed in your build all: ... statement, and is not a validation target?

@reshmavk
Copy link
Author

Yes, the archive is listed in "build all:" and is not a validation target. Even in a clean build,it doesn't create the archive.

How can we make sure ninja -t inputs all lists the archive target? Is it required to write something in the build.ninja file?

@digit-google
Copy link
Contributor

Then this looks like a bug in the ninja -t inputs logic then (which did change in 1.12), but also the rest of the logic used for regular builds (which is even more puzzling).

A reproduction case is needed to inspect what's going on here. Can you share your Ninja build plan somewhere? We don't need build artifacts or source files, just the .ninja files.

@reshmavk
Copy link
Author

build.ninja.txt

@reshmavk
Copy link
Author

Please ignore the echo commands in rules c_LINKER and AIX_LINKER. I added those for debugging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants