From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12018 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Forney Newsgroups: gmane.linux.lib.musl.general Subject: Re: [musl-cross-make] [PATCH] Fix LINUX_ARCH for aarch64-* TARGET Date: Fri, 20 Oct 2017 00:23:41 -0700 Message-ID: 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="UTF-8" X-Trace: blaine.gmane.org 1508484249 17435 195.159.176.226 (20 Oct 2017 07:24:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 20 Oct 2017 07:24:09 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-12031-gllmg-musl=m.gmane.org@lists.openwall.com Fri Oct 20 09:24:05 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 1e5Reo-0002RI-Gu for gllmg-musl@m.gmane.org; Fri, 20 Oct 2017 09:23:50 +0200 Original-Received: (qmail 27863 invoked by uid 550); 20 Oct 2017 07:23:55 -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 27822 invoked from network); 20 Oct 2017 07:23:54 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mforney-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=cJaPk34wcUMv+ZVkwcfVltoNWZkAuswAeIe7U0Bs3I8=; b=P7HuPfz1kG8KpRw6gQXlBLHOzPqi9wnXAAEQIaqnJsHYqSHrP6X9U28hTeVPPt1oe1 i//WG6EYwMi3zyFd50hgcRjpc6ZzfgicmovaK19zJsK2vV9MdYTblMujMHqHous8gFoK 4SLX5E+MoT2223BNua7nAFhtlm7C1MRIG3nsKdRu/ZH/bskbg+kmF+bRsYwDYjyt0Hvl Xjs10fTjLwmcUysTU+LssNoZLoDamtf0QxzSUCGbRrOn0eu3IgWT9hj2MDyhZjnb4rMw 75VLhKBudDUMsww3nSirkC1Jrn2bdEOp2VuNPUY9omg45dC4El8QAVSoBlQmezOPrTJy TgJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=cJaPk34wcUMv+ZVkwcfVltoNWZkAuswAeIe7U0Bs3I8=; b=OHHyDsGPjs2NY8SaL7xYmEztO1rRyvNdgB8ce0bHqDtYZqQxo5FGVIDlFko9OrFVMU yBN2Xx3ntiqXWfZKZPw7pie58Gg8c1hdWXGGryMfOtu/UM7BorUTjOXHfXcv32lxFUNG 5qBoJp6oDrFgRP1q7UBkiXapACfVTir47Aunwt+9dpND+uvgnBNVel8lbCMojdkBCJP8 9X6Tl+s1+mNXix3u5UbWzAOwPMvdv/vLjps36ygDo4nyjcvCHWvAhEJcwDXaUeLINe4u kW/f/oIC5t1amVr8POTVcuKW9dkZkJsKV+fU0IBPvpacBpkumMLHm71zDi3sVnO+oIiJ 0//A== X-Gm-Message-State: AMCzsaWZ4u+qkj08EapfRY1kFLzoBT7okGJPT5pOBDDsRroKuIYTSr7K pVjdHjGGehaJFWngMIOdIB6LVv99+R49VRNHbdx4XnIH X-Google-Smtp-Source: ABhQp+RPO/EEwvhQPZhjPqd23xreFeiuyl2gIln0SbvlE67wDBTqJC56+i4D6WmV5oa0deQ+DluRwic7L/dzE7U2yKQ= X-Received: by 10.157.88.141 with SMTP id x13mr2472878otg.176.1508484222242; Fri, 20 Oct 2017 00:23:42 -0700 (PDT) X-Originating-IP: [2601:647:5100:4a0:8a6:e1ff:fe64:a87d] In-Reply-To: <20170820203033.19393-1-mforney@mforney.org> Xref: news.gmane.org gmane.linux.lib.musl.general:12018 Archived-At: 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.