-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Build: Fix potential race condition #8781
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
Conversation
I think you also need to remove the first line in the targets (the |
Makefile
Outdated
# NOTE: We currently will always build the deprecation-warning `main` and `server` binaries to help users migrate. | ||
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Makefile
Outdated
# NOTE: We currently will always build the deprecation-warning `main` and `server` binaries to help users migrate. | ||
# 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, $<) | ||
$(CXX) $(CXXFLAGS) $(filter-out $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think GET_OBJ_FILE is not needed here, you can directly use $< as it's the object file now.
Makefile
Outdated
$(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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now, thank you!
Makefile
Outdated
@@ -1605,42 +1605,41 @@ llama-q8dot: pocs/vdot/q8dot.cpp ggml/src/ggml.o \ | |||
# Mark legacy binary targets as .PHONY so that they are always checked. | |||
.PHONY: main quantize perplexity embedding server | |||
|
|||
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very helpful, thank you!!
For me this is ready to merge. @slaren do you see anything to improve? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
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.
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.