From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752956AbdLKKRW (ORCPT ); Mon, 11 Dec 2017 05:17:22 -0500 Received: from mail-ot0-f195.google.com ([74.125.82.195]:35817 "EHLO mail-ot0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752433AbdLKKRR (ORCPT ); Mon, 11 Dec 2017 05:17:17 -0500 X-Google-Smtp-Source: AGs4zMYqjg/gBlZKSiNt5YJ2/HMk3JleKm8WU4GUs+vZjE9jRZ4ogQO5bAuZHrGZxJwsF3VEbY2z3SGzwLY/GL0JoBE= MIME-Version: 1.0 In-Reply-To: <20171106184756.24404-1-ndesaulniers@google.com> References: <20171106184756.24404-1-ndesaulniers@google.com> From: Arnd Bergmann Date: Mon, 11 Dec 2017 11:17:16 +0100 X-Google-Sender-Auth: GfwGTE-wwYJpZQN0nhU67KuzW0Y Message-ID: Subject: Re: [PATCH v3] kbuild: fix linker feature test macros when cross compiling with Clang To: Nick Desaulniers Cc: Linux Kbuild mailing list , Masahiro Yamada , Michael Davidson , Greg Hackmann , pirama@google.com, Matthias Kaehlcke , Ingo Molnar , Douglas Anderson , Cao jin , Josh Poimboeuf , Mark Charlebois , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 6, 2017 at 7:47 PM, Nick Desaulniers wrote: > 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 After this patch, I get the following warning in arm64 kernel builds with CONFIG_ARM64_ERRATUM_843419: arch/arm64/Makefile:27: ld does not support --fix-cortex-a53-843419; kernel may be susceptible to erratum This only happens on the first build though, when the cached variable is being set. On the second build we get the contents from the cache and the warning disappears. I've tried debugging it further but did not get anywhere with that. Arnd