Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5606782imu; Mon, 26 Nov 2018 02:55:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/XdrbKeYGY/Ui9h6aEoe1sB/xSlpGny9MW3gNynkmZ8IkRhnGJwZaudD8aAfMPL8ub0+WPe X-Received: by 2002:a17:902:c85:: with SMTP id 5-v6mr25943037plt.42.1543229741910; Mon, 26 Nov 2018 02:55:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543229741; cv=none; d=google.com; s=arc-20160816; b=kEWE2++an5F8KazsOlhvNZOPZ7JJGABVexssnjMznhTNwIFihXwO/+SrBigJF/Nx7H jnSVopVzAKXc+rZ83iQ2go3Q2uK+bsqdQMChL9hADrInNxw7mnnAFbqWbzwrCcnU5fUC YjEzsmGRVg2WwCxtLI2Dcn+W8X2MtYZc+WhzHjEws4xx4vCWu4E/ilQiSb+H96RITs3S R47ZQEMuZ8R6ayeuUlAhmJmObaqPjqhueCHFg7ucp83gF0i+0Um3lTHaYBPd4iILFzD5 p03ZYg1l1VeP27amaKO5AkOrSt82lntOWwxPML4AqdnI1qBfr2TAW614liVnXVUV9/W4 /adA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AGzoFRARZuFYI/zGjrS0ar6pyokI/4cdQ8kFE3wJPvc=; b=X+tKIEqe207YIQ3tE1a42Mg+W9+b/tjIbxPIR+PyfyzMVCkAmr8N2nUhmCrKcoUc7n 2+kTrnZCXFxjtWN2+A0Fo0i8pkUqoWogaVpZ/hxFhQjf248EMH2suRaNSt2Yg3YIq5KC k6M1LDg9p0aVMpVFPTvnYeB0u0xkodKIGARB+Th0rCN3HdH7jZAUrImmjlmYHKpEdOw1 u4yU8MkiIIVeI8HRtRmrsSnUz5bks5iSPDkNtAmgYxwEtWgCsKSdr+5r2qi8m6JukXMz LoiwZMMQiVSuXM1UKcQf2qbgYtXExKYe5zhJ8gq3EdYKFt0x4xDcT1JZamdVmP4DOu2i unsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iXHSoAns; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g7-v6si31286399plp.130.2018.11.26.02.55.26; Mon, 26 Nov 2018 02:55:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iXHSoAns; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727294AbeKZVrz (ORCPT + 99 others); Mon, 26 Nov 2018 16:47:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:56262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbeKZVrz (ORCPT ); Mon, 26 Nov 2018 16:47:55 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9149920817; Mon, 26 Nov 2018 10:54:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543229651; bh=77rtFgs82BiWNpE7TNqtEshHwHI04rzENm2iK2P/csI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iXHSoAnsa4jD0DmrVBFzRriI38Y0U+RQZ4/V4+v3DMw6fxTHgmEE039lpFilZTU6A YtuEiBVmPZ8o8/vIg8B/Wm7doiqSRTy3hvrHMSvK9ik4GuWU2GSisIuj6qXnjNjvdT 8vdq5JAuyb/kaktzZ0YlwlSJ3VwkSKmQg/LzXRVw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masahiro Yamada , Nick Desaulniers , Matthias Kaehlcke , Nathan Chancellor Subject: [PATCH 4.4 20/70] kbuild: fix linker feature test macros when cross compiling with Clang Date: Mon, 26 Nov 2018 11:50:35 +0100 Message-Id: <20181126105048.780330753@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181126105046.722096341@linuxfoundation.org> References: <20181126105046.722096341@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nick Desaulniers commit 86a9df597cdd564d2d29c65897bcad42519e3678 upstream. I was not seeing my linker flags getting added when using ld-option when cross compiling with Clang. Upon investigation, this seems to be due to a difference in how GCC vs Clang handle cross compilation. GCC is configured at build time to support one backend, that is implicit when compiling. Clang is explicit via the use of `-target ` and ships with all supported backends by default. GNU Make feature test macros that compile then link will always fail when cross compiling with Clang unless Clang's triple is passed along to the compiler. For example: $ clang -x c /dev/null -c -o temp.o $ aarch64-linux-android/bin/ld -E temp.o aarch64-linux-android/bin/ld: unknown architecture of input file `temp.o' is incompatible with aarch64 output aarch64-linux-android/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000400078 $ echo $? 1 $ clang -target aarch64-linux-android- -x c /dev/null -c -o temp.o $ aarch64-linux-android/bin/ld -E temp.o aarch64-linux-android/bin/ld: warning: cannot find entry symbol _start; defaulting to 00000000004002e4 $ echo $? 0 This causes conditional checks that invoke $(CC) without the target triple, then $(LD) on the result, to always fail. Suggested-by: Masahiro Yamada Signed-off-by: Nick Desaulniers Reviewed-by: Matthias Kaehlcke Signed-off-by: Masahiro Yamada [nc: Fix conflicts due to lack of commit 3298b690b21cd in linux-4.4.y Use KBUILD_CFLAGS instead of CC_OPTION_FLAGS because commit d26e94149276f that introduced that variable isn't in 4.4 either] Signed-off-by: Nathan Chancellor Signed-off-by: Greg Kroah-Hartman --- scripts/Kbuild.include | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -147,12 +147,13 @@ cc-ifversion = $(shell [ $(cc-version) $ # cc-ldoption # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) cc-ldoption = $(call try-run,\ - $(CC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2)) + $(CC) $(1) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2)) # ld-option # Usage: LDFLAGS += $(call ld-option, -X) ld-option = $(call try-run,\ - $(CC) -x c /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) + $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -x c /dev/null -c -o "$$TMPO"; \ + $(LD) $(LDFLAGS) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) # ar-option # Usage: KBUILD_ARFLAGS := $(call ar-option,D)