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

Race condition in Makefile ? #9

Open
XavierRaynaud opened this issue Mar 10, 2021 · 3 comments
Open

Race condition in Makefile ? #9

XavierRaynaud opened this issue Mar 10, 2021 · 3 comments

Comments

@XavierRaynaud
Copy link

From time to time, when compiling with "make -j", we have a race condition in Makefile, with messages like:

Fatal error: can't create al/src/th_al.o: No such file or directory

It seems the following patch solves the issue:

diff --git a/mith/Makefile b/mith/Makefile
index faeaea1..71a6f9d 100644
--- a/mith/Makefile
+++ b/mith/Makefile
@@ -54,4 +54,4 @@ print-%:
        @echo $* = $($*)  
        @echo [Defined at $(origin $*)] 
 
-$(TH_OBJS) : $(TH_HDRS)        
\ No newline at end of file
+$(TH_OBJS) : $(TH_HDRS)        $(MYDIRS)

@petertorelli
Copy link
Member

@XavierRaynaud,
Very interesting, thanks for filing. I'd prefer to root out the problem rather than add a delay: adding a variable is not always the best way to solve a race. Let's understand the root cause in the build logic. However, since make is also used as the runner as well as the compilation manager, and since the code isn't particularly large, I'd rather just advise against using make -j. -Peter

@XavierRaynaud
Copy link
Author

$(TH_OBJS) contains "al/src/th_al.o"
$(MYDIRS) contains "al/src/"
"al/src/th_al.o" requires "al/src/" dir to be created (otherwise, it fails with given error above)

One thing is sure: the creation of $(MYDIRS) is not performed in the right place in the Makefile.

@petertorelli
Copy link
Member

Hmm. al/src isn't created, it is part of the repo. I'll keep an eye on this. If you can cause a failure repeatedly, that would help, but races are always hard to reproduce.

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