Build: Fix potential race condition - #8781
Conversation
|
I think you also need to remove the first line in the targets (the |
| # Eventually we will want to remove these target from building all the time. | ||
| main: examples/deprecation-warning/deprecation-warning.cpp | ||
| main: examples/deprecation-warning/deprecation-warning.o | ||
| $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<) |
There was a problem hiding this comment.
I think you should remove these $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<) in all legacy targets, as they will use the examples/deprecation-warning/deprecation-warning.o object, so there is no need to compile and overwrite it again
| main: examples/deprecation-warning/deprecation-warning.cpp | ||
| main: examples/deprecation-warning/deprecation-warning.o | ||
| $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<) | ||
| $(CXX) $(CXXFLAGS) $(filter-out $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS) |
There was a problem hiding this comment.
I think GET_OBJ_FILE is not needed here, you can directly use $< as it's the object file now.
| $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<) | ||
| $(CXX) $(CXXFLAGS) $(filter-out $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS) | ||
| main: examples/deprecation-warning/deprecation-warning.o | ||
| $(CXX) $(LDFLAGS) $< -o $@ |
There was a problem hiding this comment.
This is probably just being cautious, but I'd keep CXXFLAGS here at the front and LDFLAGS at the end of the command like it was before. It may matter when cross-compiling for some weird platform.
There was a problem hiding this comment.
Thank you for the help!
If you can't tell, I'm not the strongest with makefiles -- if you feel like you'd rather open the PR, I would not be offended!
There was a problem hiding this comment.
Naah, if you fix this one thing I think it will be good to go.
|
@fairydreaming Thank you for the repro case included here -- that helped a ton! That let me consistently reproduce the issue on Ubuntu, and it also gives us the data point that I was unable to get it to fail on OSX. Super helpful, thank you! |
fairydreaming
left a comment
There was a problem hiding this comment.
Looks good now, thank you!
|
|
||
| # Define the object file target | ||
| examples/deprecation-warning/deprecation-warning.o: examples/deprecation-warning/deprecation-warning.cpp | ||
| $(CXX) $(CXXFLAGS) -c $< -o $@ $(LDFLAGS) |
There was a problem hiding this comment.
Ugh I missed one. I think LDFLAGS is not needed here, it's only required when creating libraries or binaries, for object files CXXFLAGS is enough.
There was a problem hiding this comment.
Very helpful, thank you!!
|
For me this is ready to merge. @slaren do you see anything to improve? |
|
Thank you very much, @fairydreaming and @slaren ! |
* Fix potential race condition as pointed out by @fairydreaming in ggml-org#8776 * Reference the .o rather than rebuilding every time. * Adding in CXXFLAGS and LDFLAGS * Removing unnecessary linker flags.
* Fix potential race condition as pointed out by @fairydreaming in ggml-org#8776 * Reference the .o rather than rebuilding every time. * Adding in CXXFLAGS and LDFLAGS * Removing unnecessary linker flags.
* Fix potential race condition as pointed out by @fairydreaming in ggml-org#8776 * Reference the .o rather than rebuilding every time. * Adding in CXXFLAGS and LDFLAGS * Removing unnecessary linker flags.
* Fix potential race condition as pointed out by @fairydreaming in ggml-org#8776 * Reference the .o rather than rebuilding every time. * Adding in CXXFLAGS and LDFLAGS * Removing unnecessary linker flags.
* Fix potential race condition as pointed out by @fairydreaming in ggml-org#8776 * Reference the .o rather than rebuilding every time. * Adding in CXXFLAGS and LDFLAGS * Removing unnecessary linker flags.
* Fix potential race condition as pointed out by @fairydreaming in ggml-org#8776 * Reference the .o rather than rebuilding every time. * Adding in CXXFLAGS and LDFLAGS * Removing unnecessary linker flags.
* Fix potential race condition as pointed out by @fairydreaming in ggml-org#8776 * Reference the .o rather than rebuilding every time. * Adding in CXXFLAGS and LDFLAGS * Removing unnecessary linker flags.
This implements the fix suggested by @fairydreaming as reported in #8776.
So far I have not been able to reproduce the original issue as reported.