From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8846 Path: news.gmane.org!not-for-mail From: Petr Hosek Newsgroups: gmane.linux.lib.musl.general Subject: Re: Support for out-of-tree build Date: Thu, 12 Nov 2015 20:17:05 +0000 Message-ID: References: <20151107130537.GC8500@port70.net> <20151108004323.GE3818@brightrain.aerifal.cx> <20151108021630.GG8500@port70.net> <20151108022920.GL3818@brightrain.aerifal.cx> <20151111230848.GZ3818@brightrain.aerifal.cx> <20151112145026.GB18372@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a114ddb1200d1e505245da1ff X-Trace: ger.gmane.org 1447359456 6108 80.91.229.3 (12 Nov 2015 20:17:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 12 Nov 2015 20:17:36 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-8859-gllmg-musl=m.gmane.org@lists.openwall.com Thu Nov 12 21:17:32 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1ZwyJH-0000Vh-MZ for gllmg-musl@m.gmane.org; Thu, 12 Nov 2015 21:17:31 +0100 Original-Received: (qmail 24539 invoked by uid 550); 12 Nov 2015 20:17:28 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 24521 invoked from network); 12 Nov 2015 20:17:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-type; bh=1BHv+qJ+xmPYapUCFuvw79VmwsG8PoUvIczktNZ9YQ0=; b=n8H7A2UViaqfM2Wr0yBomZdndQ1vavLEvigM2Wk4ZyulHEFfmVaZ4auz+bPIqOI+5E 3ZEa4WtIautoedPa4AmrAiE4DN2VXIDIcCZO3jwP9MMtTgGH7BdPSG8e446ymwuNoDbV dPW2Sa7qi7Icxxq7W14mY86eEf34cuKpsxMms= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-type; bh=1BHv+qJ+xmPYapUCFuvw79VmwsG8PoUvIczktNZ9YQ0=; b=eU3xb9KiOlpXnH1qa9MZDIvmjcfN2hHoGtCMjXQQi3bKeBOy1qqCpdOYw9eGxc6dCN Cm9r9zJONiOZWtusRt4Ef9csuAuJpMAsoTCy6ZToaU6I50KfAO8RGMzS2IxU4Uhxf5dN 7dnEcMPN+yZh2wzAiIRrn3yFNtIONoh/lOqPrz4xlIhxg9MyMXWm2EamZNtdGlW++2YO 8IhKed9faagLDDFXJ2OZa74gEgbOdaC+S/aSANkovzq19OnaVzBXFiugC2rxylyKSTb7 Au047Ug6nc2mgmXPiA2DPSZm8YkADd+zxZZjHrwiVyXyTaCFbK6XpUCR2dS8GlXGA02i DrXQ== X-Gm-Message-State: ALoCoQkrjxy8EsVd7SxK8ZqzrQZdEa0v8pV6jsZ6YFdYgghg0iOMQvc+ca+ACR/vrOIs2v2QxHee X-Received: by 10.129.108.195 with SMTP id h186mr16761007ywc.75.1447359435271; Thu, 12 Nov 2015 12:17:15 -0800 (PST) In-Reply-To: <20151112145026.GB18372@port70.net> Xref: news.gmane.org gmane.linux.lib.musl.general:8846 Archived-At: --001a114ddb1200d1e505245da1ff Content-Type: text/plain; charset=UTF-8 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) > --001a114ddb1200d1e505245da1ff Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
There is one other issue with the VPATH solution which I j= ust 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 .dir= stamps.

On Thu, Nov 12, = 2015 at 6:50 AM Szabolcs Nagy <nsz@por= t70.net> wrote:
* Petr Hosek= <phosek@chromi= um.org> [2015-11-12 00:28:44 +0000]:
> On Wed, Nov 11, 2015 at 3:09 PM Rich Felker <dalias@libc.org> wrote:
> > On Wed, Nov 11, 2015 at 10:02:50PM +0000, Petr Hosek wrote:
> > >=C2=A0 MEMOPS_SRCS =3D src/string/memcpy.c src/string/memmove= .c
> > src/string/memcmp.c src/string/memset.c
> > >=C2=A0 $(MEMOPS_SRCS:%.c=3D%.o) $(MEMOPS_SRCS:%.c=3D%.lo): CF= LAGS_ALL +=3D
> > $(CFLAGS_MEMOPS)
> > > @@ -119,34 +144,35 @@ $(CRT_LIBS:lib/%=3Dcrt/%): CFLAGS_ALL = +=3D -DCRT
> > >=C2=A0 # force the corresponding object file to be rebuilt, e= ven if the
> > implicit
> > >=C2=A0 # rule below goes indirectly through a .sub file.
> > >=C2=A0 define mkasmdep
> > > -$(dir $(patsubst %/,%,$(dir $(1))))$(notdir $(1:.s=3D.o)): = $(1)
> > > +$(dir $(patsubst $(srcdir)/%/,%,$(dir $(1))))$(notdir $(1:.= s=3D.o)): $(1)
> > > +$(dir $(patsubst $(srcdir)/%/,%,$(dir $(1))))$(notdir $(1:.= s=3D.lo)): $(1)
> > >=C2=A0 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 wi= thout the
> explicit dep rule for .lo files.
>
>
> > > -%.o: $(ARCH)$(ASMSUBARCH)/%.sub
> > > +$(OBJS_SUB): %.o:
> > >=C2=A0 =C2=A0 =C2=A0 =C2=A0$(CC) $(CFLAGS_ALL_STATIC) -c -o $= @ $(dir $<)$(shell cat $<)
> > >
> > > -%.o: $(ARCH)/%.s
> > > +$(OBJS_S): %.o:
> > >=C2=A0 =C2=A0 =C2=A0 =C2=A0$(AS_CMD) $(CFLAGS_ALL_STATIC)
> > >
> > > -%.o: %.c $(GENH) $(IMPH)
> > > +$(OBJS_C): %.o: $(srcdir)/%.c $(GENH) $(IMPH)
> > >=C2=A0 =C2=A0 =C2=A0 =C2=A0$(CC) $(CFLAGS_ALL_STATIC) -c -o $= @ $<
> > >
> > > -%.lo: $(ARCH)$(ASMSUBARCH)/%.sub
> > > +$(LOBJS_SUB): %.lo:
> > >=C2=A0 =C2=A0 =C2=A0 =C2=A0$(CC) $(CFLAGS_ALL_SHARED) -c -o $= @ $(dir $<)$(shell cat $<)
> > >
> > > -%.lo: $(ARCH)/%.s
> > > +$(LOBJS_S): %.lo:
> > >=C2=A0 =C2=A0 =C2=A0 =C2=A0$(AS_CMD) $(CFLAGS_ALL_SHARED)
> > >
> > > -%.lo: %.c $(GENH) $(IMPH)
> > > +$(LOBJS_C): %.lo: $(srcdir)/%.c $(GENH) $(IMPH)
> > >=C2=A0 =C2=A0 =C2=A0 =C2=A0$(CC) $(CFLAGS_ALL_SHARED) -c -o $= @ $<
> >
> > I don't understand these rules with two :'s. I assume it&= #39;s some trick
> > I don't yet know. But in the case of the %.s ones, the new ru= les have
> > no %.s in them... this looks wrong, no?
> >
>
> This is bit of hack which uses the static rules. I think we might be a= ble
> 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 i= n 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)
--001a114ddb1200d1e505245da1ff--