Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Sun, 20 Aug 2017 13:30:33 -0700
From: Michael Forney <mforney@...rney.org>
To: musl@...ts.openwall.com
Subject: [musl-cross-make] [PATCH] Fix LINUX_ARCH for aarch64-* TARGET

'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

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.