From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12031 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Re: [musl-cross-make] [PATCH] Fix LINUX_ARCH for aarch64-* TARGET Date: Wed, 25 Oct 2017 16:08:58 -0400 Message-ID: <20171025200858.GZ1627@brightrain.aerifal.cx> References: <20170820203033.19393-1-mforney@mforney.org> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1508962150 32213 195.159.176.226 (25 Oct 2017 20:09:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 25 Oct 2017 20:09:10 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-12044-gllmg-musl=m.gmane.org@lists.openwall.com Wed Oct 25 22:09:06 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1e7Rz8-0007py-8R for gllmg-musl@m.gmane.org; Wed, 25 Oct 2017 22:09:06 +0200 Original-Received: (qmail 25710 invoked by uid 550); 25 Oct 2017 20:09:10 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 25686 invoked from network); 25 Oct 2017 20:09:10 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:12031 Archived-At: On Fri, Oct 20, 2017 at 12:23:41AM -0700, Michael Forney wrote: > On 2017-08-20, Michael Forney wrote: > > 'aarch64' is converted to 'arm64' in the TARGET_ARCH_MANGLED assignment, > > but then LINUX_ARCH is set the first to the first linux arch which > > appears in TARGET_ARCH_MANGLED. Since 'arm' is a substring of 'arm64' > > and appears ahead of 'arm64' in sorted order, it gets chosen > > incorrectly. > > > > To fix this, use 'lastword' instead of 'firstword'. This should work for > > all current linux architectures, but is still not perfect in the > > theoretical case where the substring match is not rooted at the > > beginning of TARGET_ARCH_MANGLED. So, also replace 'findstring' with an > > 'if' and 'filter'. > > --- > > litecross/Makefile | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/litecross/Makefile b/litecross/Makefile > > index 371affb..46584fd 100644 > > --- a/litecross/Makefile > > +++ b/litecross/Makefile > > @@ -206,7 +206,7 @@ ifneq ($(LINUX_SRCDIR),) > > TARGET_ARCH = $(firstword $(subst -, ,$(TARGET))) > > TARGET_ARCH_MANGLED = $(patsubst i%86,x86,$(patsubst > > aarch64%,arm64%,$(TARGET_ARCH))) > > LINUX_ARCH_LIST = $(sort $(notdir $(wildcard $(LINUX_SRCDIR)/arch/*))) > > -LINUX_ARCH = $(firstword $(foreach a,$(LINUX_ARCH_LIST),$(findstring > > $(a),$(TARGET_ARCH_MANGLED)))) > > +LINUX_ARCH = $(lastword $(foreach a,$(LINUX_ARCH_LIST),$(if $(filter > > $(a)%,$(TARGET_ARCH_MANGLED)),$(a)))) > > ifneq ($(LINUX_ARCH),) > > all: kernel-headers > > install: install-kernel-headers > > -- > > 2.14.0 > > Since some musl-cross-make patches are getting applied, I'm bumping > this so it doesn't get forgotten. I can also open a github PR if you > prefer. I think it looks right. Going to run a few smoke test builds before I push it. Rich