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

r.mapcalc: Add explicit dependency on mapcalc.tab.h #3415

Merged
merged 1 commit into from
Feb 15, 2024

Conversation

bmwiedemann
Copy link
Contributor

Add explicit dependency on mapcalc.tab.h
and use a .META file to tell make that
both .c and .h are created by one call
to allow for reproducible builds.

Without this change, r.mapcalc and r3.mapcalc
would be rebuilt a 2nd time in a make -j1 run
with a slightly changed order of mapcalc.yy.o and mapcalc.tab.o

This patch was done while working on reproducible builds for openSUSE.

@github-actions github-actions bot added raster Related to raster data processing module labels Feb 11, 2024
raster/r.mapcalc/Makefile Outdated Show resolved Hide resolved
@neteler neteler changed the title Add explicit dependency on mapcalc.tab.h r.mapcalc: Add explicit dependency on mapcalc.tab.h Feb 11, 2024
@echoix
Copy link
Member

echoix commented Feb 11, 2024

Thanks! I think I found one of these missing dependencies in issue #3406, but I didn't have the knowledge to finish debugging and writing a fix. I know using gnu make 4.4 with make --shuffle -j $(nproc) fails at different places for seemingly different reasons, but this is definitely one of the problematic modules.

@bmwiedemann
Copy link
Contributor Author

For debugging I ran make -d with -j1 and -j4 to create http://rb.zq1.de/other/grass/build-log-1.txt.zstd http://rb.zq1.de/other/grass/build-log-4.txt.zstd (10+15 MB compressed, 600+630 MB uncompressed)

In the -j1 version you can see that such

Prerequisite 'mapcalc.tab.h' is newer than target 'OBJ.x86_64-pc-linux-gnu/column_shift.o'.
../../include/Make/Compile.make:32: update target 'OBJ.x86_64-pc-linux-gnu/column_shift.o' due to: mapcalc.tab.h

appear and trigger rebuilds of r.mapcalc and r3.mapcalc .

But there might still be other issues left such as random missing .png files:
https://rb.zq1.de/compare.factory-20240131/diffs/grass-compare.out

@echoix
Copy link
Member

echoix commented Feb 12, 2024

For debugging I ran make -d with -j1 and -j4 to create http://rb.zq1.de/other/grass/build-log-1.txt.zstd http://rb.zq1.de/other/grass/build-log-4.txt.zstd (10+15 MB compressed, 600+630 MB uncompressed)

In the -j1 version you can see that such


Prerequisite 'mapcalc.tab.h' is newer than target 'OBJ.x86_64-pc-linux-gnu/column_shift.o'.

../../include/Make/Compile.make:32: update target 'OBJ.x86_64-pc-linux-gnu/column_shift.o' due to: mapcalc.tab.h

appear and trigger rebuilds of r.mapcalc and r3.mapcalc .

But there might still be other issues left such as random missing .png files:

https://rb.zq1.de/compare.factory-20240131/diffs/grass-compare.out

I think you are describing another bug we caught earlier this year, but wasn't pinned down. I'm sure the solution will be through a makefile fix

#3038

@echoix
Copy link
Member

echoix commented Feb 13, 2024

Just for personal curiosity, is adding an extra file the best way to define extra dependencies in targets? Is the file copied out to the installed directories or included in the bindist?

Other than that, I would approve if I was confident enough with that level of Makefile, which isn't the case. Is anyone one else more knowledgeable for this?

@neteler
Copy link
Member

neteler commented Feb 13, 2024

Just for personal curiosity, is adding an extra file the best way to define extra dependencies in targets? Is the file copied out to the installed directories or included in the bindist?

As we moved it to OBJ.$ARCH the .META file is not copied into bindist but just generated in the "compile space" subdirectory which is eventually cleaned up.

@echoix
Copy link
Member

echoix commented Feb 13, 2024

Ok I see. Then who has the knowledge to approve and merge this PR?

wenzeslaus
wenzeslaus previously approved these changes Feb 13, 2024
Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given @bmwiedemann's activity elsewhere, I feel like I can confidently approve this contribution even with my low confidence in Makefiles.

The only heads up I see is that touch fails on systems with no access to touch which is apparently some HPC systems. However, we are using touch already, so no change there.

neteler
neteler previously approved these changes Feb 13, 2024
Copy link
Member

@neteler neteler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work on reproducible builds of GRASS GIS!

@neteler neteler added this to the 8.4.0 milestone Feb 13, 2024
@neteler
Copy link
Member

neteler commented Feb 13, 2024

I tagged it as "backport to 8.2" but we will not release 8.2.x any more - however, this PR might go into the upcoming 8.3.2 release (https://github.com/OSGeo/grass/milestone/24).

@echoix
Copy link
Member

echoix commented Feb 13, 2024

What's the relation with using an extra file vs .INTERMEDIATE or .SECONDARY special targets?

to tell make that both .c and .h are needed
This allows for reproducible builds.

Without this change, r.mapcalc and r3.mapcalc
would be rebuilt a 2nd time in a make -j1 run
with slightly varied order of mapcalc.yy.o and mapcalc.tab.o

This might help improve OSGeo#3406

This patch was done while working on reproducible builds for openSUSE.
@bmwiedemann
Copy link
Contributor Author

I experimented some more and found a way to make it do the right thing without the extra .META file and with less overall changes.

Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This one is indeed much nicer!

@echoix
Copy link
Member

echoix commented Feb 14, 2024

@neteler Would you want to merge this new revision?

@nilason
Copy link
Contributor

nilason commented Feb 14, 2024

But there might still be other issues left such as random missing .png files: https://rb.zq1.de/compare.factory-20240131/diffs/grass-compare.out

That looks like #3038.

I have not been able to reproduce either with -d -j1 or -d -j8 on Mac. Cannot produce anything like:

Prerequisite 'mapcalc.tab.h' is newer than target 'OBJ.x86_64-pc-linux-gnu/column_shift.o'.

@neteler neteler merged commit 4360677 into OSGeo:main Feb 15, 2024
25 checks passed
neteler pushed a commit that referenced this pull request Feb 15, 2024
Add explicit dependency on mapcalc.tab.c to tell make that both .c and .h are needed
This allows for reproducible builds.

Without this change, r.mapcalc and r3.mapcalc
would be rebuilt a 2nd time in a make -j1 run
with slightly varied order of mapcalc.yy.o and mapcalc.tab.o

This might help improve #3406

This patch was done while working on reproducible builds for openSUSE.
neteler pushed a commit that referenced this pull request Feb 15, 2024
Add explicit dependency on mapcalc.tab.c to tell make that both .c and .h are needed
This allows for reproducible builds.

Without this change, r.mapcalc and r3.mapcalc
would be rebuilt a 2nd time in a make -j1 run
with slightly varied order of mapcalc.yy.o and mapcalc.tab.o

This might help improve #3406

This patch was done while working on reproducible builds for openSUSE.
@neteler neteler modified the milestones: 8.4.0, 8.3.2 Feb 15, 2024
@neteler
Copy link
Member

neteler commented Feb 15, 2024

Backported to

Comment on lines +23 to +25
$(OBJDIR)/*.o: mapcalc.tab.h mapcalc.tab.c
$(OBJDIR)/mapcalc.yy.o: mapcalc.tab.h mapcalc.tab.c

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$(OBJDIR)/*.o: mapcalc.tab.h mapcalc.tab.c
$(OBJDIR)/mapcalc.yy.o: mapcalc.tab.h mapcalc.tab.c
$(OBJDIR)/*.o $(OBJDIR)/mapcalc.yy.o: mapcalc.tab.h mapcalc.tab.c

While it bothers me not to be able to reproduce this issue (and to full depth understand what's going on), I think this solution is good. If my suggested simplification works I'd personally prefer to have this in one line (as they are logically interconnected). Or even better, would the following solve the issue

$(OBJDIR)/*.o: mapcalc.tab.h mapcalc.tab.c

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too late :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nilason I'm sorry, I just merged it (didn't understand that you wanted to keep it open and modify further). So, a new PR will be needed...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nilason I'm sorry, I just merged it (didn't understand that you wanted to keep it open and modify further). So, a new PR will be needed...

No worries! The one line solution I suggested should work (as it is basically the same). I can't test the latter suggestion (just adding mapcalc.tab.c as a pre-requisite to $(OBJDIR)/*.o targets) for solving the issue at hand, perhaps @bmwiedemann can chip in. The end-effect should be the same, but the code more concise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$(OBJDIR)/*.o: mapcalc.tab.h mapcalc.tab.c alone did not work - my guess is that the wildcard only matches existing files. Combining both in one line should work - I'm giving it a test-run now and should have results in an hour.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$(OBJDIR)/*.o: mapcalc.tab.h mapcalc.tab.c alone did not work - my guess is that the wildcard only matches existing files. Combining both in one line should work - I'm giving it a test-run now and should have results in an hour.

Thanks for testing and for your contribution!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$(OBJDIR)/*.o $(OBJDIR)/mapcalc.yy.o: mapcalc.tab.h mapcalc.tab.c worked fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$(OBJDIR)/*.o $(OBJDIR)/mapcalc.yy.o: mapcalc.tab.h mapcalc.tab.c worked fine.

Thought so, thanks! I'll put up a PR, simplifying this.

Would you have been able to reproduce this issue you reported by only (re-)building in this module (directory)? E.g.:

cd raster/r.mapcalc
make clean
make -j1

I'm asking because I try figure out my inability to reproduce.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My tooling does 2 whole package builds from scratch via our spec file. Not that easy to adapt to test a partial build. My guess is that there are some cross-dependencies from outside that dir that caused the issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My tooling does 2 whole package builds from scratch via our spec file. Not that easy to adapt to test a partial build. My guess is that there are some cross-dependencies from outside that dir that caused the issue.

I did take a look at your tools, I'll see if I can make use of it on the Mac (definitely won't work as is).

Studying your log file, I realised the default GNU Make is quite old (3.81), but trying with 4.4.1 didn't make any difference.

Also I happened to notice:

 [   31s] configure: WARNING: unrecognized options: --enable-socket, --with-curses, --with-motif, --with-python, --with-wxwidgets

the listed options may all be removed from configure.

Thanks for your feedback!

@bmwiedemann bmwiedemann deleted the mapcaldeps branch February 15, 2024 09:36
jadenabrams100 pushed a commit to ncsu-csc472-spring2024/grass-CI-playground that referenced this pull request Feb 21, 2024
Add explicit dependency on mapcalc.tab.c to tell make that both .c and .h are needed
This allows for reproducible builds.

Without this change, r.mapcalc and r3.mapcalc
would be rebuilt a 2nd time in a make -j1 run
with slightly varied order of mapcalc.yy.o and mapcalc.tab.o

This might help improve OSGeo#3406

This patch was done while working on reproducible builds for openSUSE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module raster Related to raster data processing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants