-
-
Notifications
You must be signed in to change notification settings - Fork 619
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
Makefile target dependencies aren't correct #981
Comments
Does this occur with |
Yes, I'm using gmake 2 ;) It's just bugs effectively.. If I get around to it, I'll make a patch, just wanted to record the issue here. |
Fair enough. 👍 One day I should sit down and spend some time learning the ins and outs of Makefiles so I can actually give some input with these things.
FWIW, it was @bwhittle - I'm guessing what you're suggesting could speed up their build times, so I guess you might have additional devs looking into this with you? 😄 |
Is there anyone here that can comment on this: all: prebuild prelink $(TARGET) | $(TARGETDIR) $(OBJDIR)
@:
$(TARGET): $(GCH) $(OBJECTS) $(LDDEPS) | $(TARGETDIR)
@echo Linking Premake5
$(SILENT) $(LINKCMD)
$(POSTBUILDCMDS)
$(OBJECTS): $(GCH) $(PCH) | $(OBJDIR) $(PCH_PLACEHOLDER)
$(GCH): $(PCH) | $(OBJDIR)
@echo $(notdir $<)
$(SILENT) $(CC) -x c-header $(ALL_CFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<" This is just a fragment from a premake generated makefile, but there are a few questions I have:
|
This code has been touched by a lot of people over the years…I think your assessment is likely correct, and those dependencies ought to be untangled. |
Okay, so I feel like it should look something like this: all: $(TARGET)
@:
$(TARGET): prelink | $(TARGETDIR)
@echo Linking Premake5
$(SILENT) $(LINKCMD)
$(POSTBUILDCMDS)
prebuild:
$(PREBUILDCMDS)
prelink: $(OBJECTS) $(LDDEPS)
$(PRELINKCMDS)
$(OBJECTS): prebuild $(GCH) $(PCH) | $(OBJDIR) $(PCH_PLACEHOLDER)
$(GCH): $(PCH) | $(OBJDIR)
@echo $(notdir $<)
$(SILENT) $(CC) -x c-header $(ALL_CFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<" I actually think |
This looks reasonable to me (though my Makefile-fu is not particularly strong, especially when it comes to parallel builds). |
I'm looking at this; can anyone explain PCH_PLACEHOLDER? |
I've been working on this for the past 2 days, and the further I go, the more completely fubar I realise the existing make code is. It all falls apart on prebuild events, and I need to conclude how they should behave... This situation is particularly hard to express in make, since the conditions that will cause prebuild to re-run aren't easily expressed as make dependencies. Do we have any make experts floating around? Here's an example: .PHONY: all
SRCS := src/poo.x src/poo2.x src/poo3.x src/poo4.x
OBJS := $(SRCS:src/%.x=int/%.o)
all: out/poo.out
out/poo.out: $(OBJS) | out/
@echo prelink
touch $@
@echo postbuild
out/:
mkdir out
int/:
mkdir int
$(OBJS): int/prebuild | int/
@echo $@
@sleep 1
@touch $@
int/prebuild: $(SRCS)
@echo prebuild
@sleep 1
touch int/prebuild Use Challenge for the reader: consider the prebuild rule; it depends on $(SRCS) such that any change to src files (which triggers rebuild) will cause prebuild to re-run... problem is, this code rebuilds EVERYTHING in the event only a single source file changes. |
Okay, I think I've worked out a satisfactory solution. Can everyone tell me they agree this looks good? .PHONY: all
SRCS := src/poo.x src/poo2.x src/poo3.x src/poo4.x
OBJS := $(SRCS:src/%.x=int/%.o)
all: out/poo.out
out/poo.out: $(OBJS) | out/
@echo prelink
touch $@
@echo postbuild
out/:
mkdir out
int/:
mkdir int
int/poo.o: src/poo.x | int/prebuild
@echo $@
@sleep 1
@touch $@
int/poo2.o: src/poo2.x | int/prebuild
@echo $@
@sleep 1
@touch $@
int/poo3.o: src/poo3.x | int/prebuild
@echo $@
@sleep 1v
@touch $@
int/poo4.o: src/poo4.x | int/prebuild
@echo $@
@sleep 1
@touch $@
int/prebuild: $(SRCS) | int/
@echo prebuild
@sleep 1
touch int/prebuild |
Nope, I discovered a few issues...
Are these acceptable limitations for now? It's definitely better than what premake currently emits. |
I say yes, they are acceptable limitations, and someone else may be able to build out more from here. |
I've noticed that the make output has lots of errors with rule dependencies, and this leads to problems with multi-core builds (ie,
make -j2
or more)Consider:
What this says is that
all
depends onprebuild
prelink
and$(TARGET)
, but it misses the hierarchy of dependency.Truth is,
all
depends on$(TARGET)
, which depends onprelink
, which depends on$(OBJECTS)
, which may-or-may-not depend on$(PCH)
, which depends onprebuild
.We need to restructure the dependency resolution into the proper dependency structure, otherwise multi-threaded doesn't work.
Currently,
-j3
may causeprebuild
,prelink
, and$(TARGET)
to all be built at the same time in parallel, which is wrong, since each step may depend on successful completion of the prior steps.The text was updated successfully, but these errors were encountered: