Received: by 10.213.65.68 with SMTP id h4csp285140imn; Fri, 23 Mar 2018 04:44:33 -0700 (PDT) X-Google-Smtp-Source: AG47ELvLOF/NGbfBfvlFXnK1FkYAfuHKFemmkziR5t0BgrK+g15SeKIvkjuAfaPWq2RFPG5PB4FR X-Received: by 2002:a17:902:33c2:: with SMTP id b60-v6mr29476371plc.222.1521805473530; Fri, 23 Mar 2018 04:44:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521805473; cv=none; d=google.com; s=arc-20160816; b=ARjv6xvfTn+ZQL0gKuaIcjmFWD5SydN5hpoBeBiV8JrtBc/Xt7CS7mlDRgFJdwf0Ar 7Z7HEntSKgelq/tnqeCa5DABmHAfeQEA0z5qEnXbr68uwIYjvKGtqC03bGXUslsHZurZ gLMhbhnHenHJD4A2FpDqmeVTOuXx9ELJS3Y2FG/rOrrpN4UbDinVjzg+4QckpBfR53lU r5jlxezeSGJnKgG7UZGOTImJ+2Mw+GYno3FFBmAFHDUIYmsJO3x19RHFq00ZGS+ccf5t To27Va4KNQ6tcajUtZ1bRH+z+WU+w06vdEtwK49A4lgnCEZMID8b+KSh7YKi6tUTIicC mJWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=rUqkKCSn0Yq6yI4L9ugiygeog66JMeZJ0h0d/8jR/+Y=; b=s8bIF/G5Qp50xA/Zk3lO5k8a8Vfx8G7P7rGLdzbRgPREuVffhBBLlONTtxLb5bOVXd Gd7n2wwVpsx5xO2bZdUxD5FWy2I4vOa2Ky5CMqC21EyahSxIV3NtppDI9SutFirxewGH xeMa97P/Yja5j+E2AXxLO7SyTUp1NGqiHXLjmbRuE03VvnRW+rC2KAtc1JuCJekYRruh 0Qub991990RAnOo3kWZmyrKJEltq5GqoUMT/S6hk0AK7LidSZnMEdNTxBTN5G9d+JEhv S5gstlaWI+thsdF0Met/IJ4wM+NKfTFApBh2ZQRKqPEEvlVm1Wr3b09sRZ8n4nRNGyxk eEhA== ARC-Authentication-Results: i=1; mx.google.com; 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 h12-v6si9003022plt.571.2018.03.23.04.44.18; Fri, 23 Mar 2018 04:44:33 -0700 (PDT) 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; 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 S1754573AbeCWLnc (ORCPT + 99 others); Fri, 23 Mar 2018 07:43:32 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38840 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754488AbeCWKDg (ORCPT ); Fri, 23 Mar 2018 06:03:36 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C3730132F; Fri, 23 Mar 2018 10:03:35 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masahiro Yamada , Nick Desaulniers , Matthias Kaehlcke , Greg Hackmann Subject: [PATCH 4.14 76/77] kbuild: fix linker feature test macros when cross compiling with Clang Date: Fri, 23 Mar 2018 10:54:50 +0100 Message-Id: <20180323094147.376418597@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094142.260022880@linuxfoundation.org> References: <20180323094142.260022880@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-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 Signed-off-by: Greg Hackmann 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 @@ -160,12 +160,13 @@ cc-if-fullversion = $(shell [ $(cc-fullv # 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) $(CC_OPTION_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) $(CC_OPTION_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)