There is one other issue with the VPATH solution which I just realized while trying to make changes to the original patch: the order-only dependencies don't work with VPATH because the directories already exist the source directory, so we'd need to use the solution with .dirstamps. On Thu, Nov 12, 2015 at 6:50 AM Szabolcs Nagy wrote: > * Petr Hosek [2015-11-12 00:28:44 +0000]: > > On Wed, Nov 11, 2015 at 3:09 PM Rich Felker wrote: > > > On Wed, Nov 11, 2015 at 10:02:50PM +0000, Petr Hosek wrote: > > > > MEMOPS_SRCS = src/string/memcpy.c src/string/memmove.c > > > src/string/memcmp.c src/string/memset.c > > > > $(MEMOPS_SRCS:%.c=%.o) $(MEMOPS_SRCS:%.c=%.lo): CFLAGS_ALL += > > > $(CFLAGS_MEMOPS) > > > > @@ -119,34 +144,35 @@ $(CRT_LIBS:lib/%=crt/%): CFLAGS_ALL += -DCRT > > > > # force the corresponding object file to be rebuilt, even if the > > > implicit > > > > # rule below goes indirectly through a .sub file. > > > > define mkasmdep > > > > -$(dir $(patsubst %/,%,$(dir $(1))))$(notdir $(1:.s=.o)): $(1) > > > > +$(dir $(patsubst $(srcdir)/%/,%,$(dir $(1))))$(notdir $(1:.s=.o)): > $(1) > > > > +$(dir $(patsubst $(srcdir)/%/,%,$(dir $(1))))$(notdir $(1:.s=.lo)): > $(1) > > > > endef > > > > -$(foreach s,$(wildcard src/*/$(ARCH)*/*.s),$(eval $(call > > > mkasmdep,$(s)))) > > > > +$(foreach s,$(wildcard $(srcdir)/src/*/$(ARCH)*/*.s),$(eval $(call > > > mkasmdep,$(s)))) > > > > > > Was this missing the dep rules for .lo files? > > > > > > > I'm not sure how this worked before, I was getting build errors without > the > > explicit dep rule for .lo files. > > > > > > > > -%.o: $(ARCH)$(ASMSUBARCH)/%.sub > > > > +$(OBJS_SUB): %.o: > > > > $(CC) $(CFLAGS_ALL_STATIC) -c -o $@ $(dir $<)$(shell cat $<) > > > > > > > > -%.o: $(ARCH)/%.s > > > > +$(OBJS_S): %.o: > > > > $(AS_CMD) $(CFLAGS_ALL_STATIC) > > > > > > > > -%.o: %.c $(GENH) $(IMPH) > > > > +$(OBJS_C): %.o: $(srcdir)/%.c $(GENH) $(IMPH) > > > > $(CC) $(CFLAGS_ALL_STATIC) -c -o $@ $< > > > > > > > > -%.lo: $(ARCH)$(ASMSUBARCH)/%.sub > > > > +$(LOBJS_SUB): %.lo: > > > > $(CC) $(CFLAGS_ALL_SHARED) -c -o $@ $(dir $<)$(shell cat $<) > > > > > > > > -%.lo: $(ARCH)/%.s > > > > +$(LOBJS_S): %.lo: > > > > $(AS_CMD) $(CFLAGS_ALL_SHARED) > > > > > > > > -%.lo: %.c $(GENH) $(IMPH) > > > > +$(LOBJS_C): %.lo: $(srcdir)/%.c $(GENH) $(IMPH) > > > > $(CC) $(CFLAGS_ALL_SHARED) -c -o $@ $< > > > > > > I don't understand these rules with two :'s. I assume it's some trick > > > I don't yet know. But in the case of the %.s ones, the new rules have > > > no %.s in them... this looks wrong, no? > > > > > > > This is bit of hack which uses the static rules. I think we might be able > > to get rid of those if we remove the *.sub system as mentioned earlier, > but > > this is the only way I got it to work without having a per file rule in > the > > current setup. > > i'm fine with VPATH + a make time check that in/out is not mixed > > this second approach is ok if there is some solution for the > %.o: %.s rules (i guess AS_CMD only works without %.s because > mkasmdeps adds the deps). > > the .sub approach is not flexible and i don't see an easy way to > encode all configury bits in the directory tree > (e.g. if we ever want to allow musl to be compiled for sse4, > avx, or other more finegrained arch extensions.. maybe .S > with #ifdefs for subarch is more flexible) >