From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754704AbdKGDlv (ORCPT ); Mon, 6 Nov 2017 22:41:51 -0500 Received: from conssluserg-05.nifty.com ([210.131.2.90]:34470 "EHLO conssluserg-05.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754292AbdKGDlt (ORCPT ); Mon, 6 Nov 2017 22:41:49 -0500 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-05.nifty.com vA73ffG3008656 X-Nifty-SrcIP: [209.85.161.175] X-Google-Smtp-Source: ABhQp+QBsnwz/mI91yaigjA/MxAhovyCWiWdoEHaLV4K/O0INZFg8adHaARaczpwYlBI1WFRrbsQWCe1l3vBrwe77cM= MIME-Version: 1.0 In-Reply-To: <20171106184756.24404-1-ndesaulniers@google.com> References: <20171106184756.24404-1-ndesaulniers@google.com> From: Masahiro Yamada Date: Tue, 7 Nov 2017 12:41:00 +0900 X-Gmail-Original-Message-ID: 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 , Michael Davidson , Greg Hackmann , Pirama Arumuga Nainar , Matthias Kaehlcke , Arnd Bergmann , 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 2017-11-07 3:47 GMT+09:00 Nick Desaulniers : > 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 > --- > Changes since v2: > * Add LDFLAGS to ld-option, as per Masahiro, and spotted by 0-day bot: > https://lists.01.org/pipermail/lkp/2017-October/007427.html > > scripts/Kbuild.include | 5 +++-- Applied to linux-kbuild/kbuild. -- Best Regards Masahiro Yamada