From: Peter Smith <Peter.Smith@arm.com> To: Arnd Bergmann <arnd@kernel.org>, Nathan Chancellor <nathan@kernel.org> Cc: Catalin Marinas <Catalin.Marinas@arm.com>, Will Deacon <will@kernel.org>, Linux ARM <linux-arm-kernel@lists.infradead.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, clang-built-linux <clang-built-linux@googlegroups.com>, Arnd Bergmann <arnd@arndb.de> Subject: RE: [PATCH] arm64: Make CPU_BIG_ENDIAN depend on !LD_IS_LLD Date: Wed, 3 Feb 2021 10:08:24 +0000 [thread overview] Message-ID: <VI1PR08MB31986E54164FA3293AA737E1F8B49@VI1PR08MB3198.eurprd08.prod.outlook.com> (raw) In-Reply-To: <CAK8P3a19W2ejs8mtHrf6Nd6BVG8u5fM4BZB+neVEWdOmGCbLbw@mail.gmail.com> > -----Original Message----- > From: Arnd Bergmann <arnd@kernel.org> > Sent: 02 February 2021 20:44 > To: Nathan Chancellor <nathan@kernel.org> > Cc: Catalin Marinas <Catalin.Marinas@arm.com>; Will Deacon > <will@kernel.org>; Linux ARM <linux-arm-kernel@lists.infradead.org>; linux- > kernel@vger.kernel.org; Nick Desaulniers <ndesaulniers@google.com>; > clang-built-linux <clang-built-linux@googlegroups.com>; Arnd Bergmann > <arnd@arndb.de>; Peter Smith <Peter.Smith@arm.com> > Subject: Re: [PATCH] arm64: Make CPU_BIG_ENDIAN depend on !LD_IS_LLD > > On Tue, Feb 2, 2021 at 8:51 PM Nathan Chancellor <nathan@kernel.org> > wrote: > > On Tue, Feb 02, 2021 at 09:04:34AM +0100, Arnd Bergmann wrote: > > > On Tue, Feb 2, 2021 at 3:25 AM Nathan Chancellor <nathan@kernel.org> > wrote: > > > > > > > > Similar to commit 28187dc8ebd9 ("ARM: 9025/1: Kconfig: > > > > CPU_BIG_ENDIAN depends on !LD_IS_LLD"), ld.lld does not support > > > > aarch64 big endian, leading to the following build error when > > > > CONFIG_CPU_BIG_ENDIAN is > > > > selected: > > > > > > > > ld.lld: error: unknown emulation: aarch64linuxb > > > > > > While this is the original error message I reported, I think it > > > would be better to explain that lld actually does support linking > > > big-endian kernels but they don't boot, for unknown reasons. > > > > That statement seems to contradict what Peter Smith says: > > > > https://github.com/ClangBuiltLinux/linux/issues/1288#issuecomment-7706 > > 93582 > > > > https://reviews.llvm.org/D58655#1410282 > > Right, adding Peter to Cc for clarification. Peter, what I can tell from > experiments is that lld behaves just you describe it should, and (aside from > the command like flag handling) like ld.bfd, so I'm not sure if there are any > known deficiencies or just minor bugs when dealing with the kernel. > If an emulation (-m) is present then current LLD maps all known Arm and AArch emulations to little endian https://github.com/llvm/llvm-project/blob/main/lld/ELF/Driver.cpp#L147 In this case we'll get an error message with a big-endian object. ld.lld: error: be.o is incompatible with aarch64linux If there are no emulations present then LLD will auto-detect big-endian from the first object file. https://github.com/llvm/llvm-project/blob/main/lld/ELF/Driver.cpp#L1467 This will switch the generic LLD write functions to write big-endian. This will mean that any write to instructions will need to use explicit write32le and any data relocations will need to use write32/write64 as appropriate and not use the explicit le versions. The relocations for instructions look to be using explicit le writes as we'd want them to. I've spotted at least one case of using write64le for what looks like data https://github.com/llvm/llvm-project/blob/main/lld/ELF/Arch/AArch64.cpp#L198 I've not know anyone try LLD on big-endian before so there are no known deficiencies. I expect that without an active search and tests there will be some problems. I think every write will need looking at, if it is to instructions it needs to explicitly use le, if to data (that could be either little or big endian) it must not force little endian. Peter > FWIW, I have now built a big-endian musl C library and a helloworld binary, > which I linked with ld.lld and successfully tested using qemu-aarch64_be- > static > > Arnd > > > > I can send a patch to address the build error and mark big-endian as > > > "depends on !LD_IS_LLD || COMPILE_TEST" to reflect that and help > > > with randconfig testing. > > > > I have no strong opinion on handling this though.
WARNING: multiple messages have this Message-ID (diff)
From: Peter Smith <Peter.Smith@arm.com> To: Arnd Bergmann <arnd@kernel.org>, Nathan Chancellor <nathan@kernel.org> Cc: Arnd Bergmann <arnd@arndb.de>, Catalin Marinas <Catalin.Marinas@arm.com>, Nick Desaulniers <ndesaulniers@google.com>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, clang-built-linux <clang-built-linux@googlegroups.com>, Will Deacon <will@kernel.org>, Linux ARM <linux-arm-kernel@lists.infradead.org> Subject: RE: [PATCH] arm64: Make CPU_BIG_ENDIAN depend on !LD_IS_LLD Date: Wed, 3 Feb 2021 10:08:24 +0000 [thread overview] Message-ID: <VI1PR08MB31986E54164FA3293AA737E1F8B49@VI1PR08MB3198.eurprd08.prod.outlook.com> (raw) In-Reply-To: <CAK8P3a19W2ejs8mtHrf6Nd6BVG8u5fM4BZB+neVEWdOmGCbLbw@mail.gmail.com> > -----Original Message----- > From: Arnd Bergmann <arnd@kernel.org> > Sent: 02 February 2021 20:44 > To: Nathan Chancellor <nathan@kernel.org> > Cc: Catalin Marinas <Catalin.Marinas@arm.com>; Will Deacon > <will@kernel.org>; Linux ARM <linux-arm-kernel@lists.infradead.org>; linux- > kernel@vger.kernel.org; Nick Desaulniers <ndesaulniers@google.com>; > clang-built-linux <clang-built-linux@googlegroups.com>; Arnd Bergmann > <arnd@arndb.de>; Peter Smith <Peter.Smith@arm.com> > Subject: Re: [PATCH] arm64: Make CPU_BIG_ENDIAN depend on !LD_IS_LLD > > On Tue, Feb 2, 2021 at 8:51 PM Nathan Chancellor <nathan@kernel.org> > wrote: > > On Tue, Feb 02, 2021 at 09:04:34AM +0100, Arnd Bergmann wrote: > > > On Tue, Feb 2, 2021 at 3:25 AM Nathan Chancellor <nathan@kernel.org> > wrote: > > > > > > > > Similar to commit 28187dc8ebd9 ("ARM: 9025/1: Kconfig: > > > > CPU_BIG_ENDIAN depends on !LD_IS_LLD"), ld.lld does not support > > > > aarch64 big endian, leading to the following build error when > > > > CONFIG_CPU_BIG_ENDIAN is > > > > selected: > > > > > > > > ld.lld: error: unknown emulation: aarch64linuxb > > > > > > While this is the original error message I reported, I think it > > > would be better to explain that lld actually does support linking > > > big-endian kernels but they don't boot, for unknown reasons. > > > > That statement seems to contradict what Peter Smith says: > > > > https://github.com/ClangBuiltLinux/linux/issues/1288#issuecomment-7706 > > 93582 > > > > https://reviews.llvm.org/D58655#1410282 > > Right, adding Peter to Cc for clarification. Peter, what I can tell from > experiments is that lld behaves just you describe it should, and (aside from > the command like flag handling) like ld.bfd, so I'm not sure if there are any > known deficiencies or just minor bugs when dealing with the kernel. > If an emulation (-m) is present then current LLD maps all known Arm and AArch emulations to little endian https://github.com/llvm/llvm-project/blob/main/lld/ELF/Driver.cpp#L147 In this case we'll get an error message with a big-endian object. ld.lld: error: be.o is incompatible with aarch64linux If there are no emulations present then LLD will auto-detect big-endian from the first object file. https://github.com/llvm/llvm-project/blob/main/lld/ELF/Driver.cpp#L1467 This will switch the generic LLD write functions to write big-endian. This will mean that any write to instructions will need to use explicit write32le and any data relocations will need to use write32/write64 as appropriate and not use the explicit le versions. The relocations for instructions look to be using explicit le writes as we'd want them to. I've spotted at least one case of using write64le for what looks like data https://github.com/llvm/llvm-project/blob/main/lld/ELF/Arch/AArch64.cpp#L198 I've not know anyone try LLD on big-endian before so there are no known deficiencies. I expect that without an active search and tests there will be some problems. I think every write will need looking at, if it is to instructions it needs to explicitly use le, if to data (that could be either little or big endian) it must not force little endian. Peter > FWIW, I have now built a big-endian musl C library and a helloworld binary, > which I linked with ld.lld and successfully tested using qemu-aarch64_be- > static > > Arnd > > > > I can send a patch to address the build error and mark big-endian as > > > "depends on !LD_IS_LLD || COMPILE_TEST" to reflect that and help > > > with randconfig testing. > > > > I have no strong opinion on handling this though. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-02-03 10:09 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-02-02 2:24 [PATCH] arm64: Make CPU_BIG_ENDIAN depend on !LD_IS_LLD Nathan Chancellor 2021-02-02 2:24 ` Nathan Chancellor 2021-02-02 8:04 ` Arnd Bergmann 2021-02-02 8:04 ` Arnd Bergmann 2021-02-02 19:51 ` Nathan Chancellor 2021-02-02 19:51 ` Nathan Chancellor 2021-02-02 20:43 ` Arnd Bergmann 2021-02-02 20:43 ` Arnd Bergmann 2021-02-03 10:08 ` Peter Smith [this message] 2021-02-03 10:08 ` Peter Smith 2021-02-07 2:30 ` Nathan Chancellor 2021-02-07 2:30 ` Nathan Chancellor 2021-02-09 0:57 ` [PATCH v2] arm64: Make CPU_BIG_ENDIAN depend on ld.bfd or ld.lld 13.0.0+ Nathan Chancellor 2021-02-09 0:57 ` Nathan Chancellor 2021-02-09 1:39 ` Nick Desaulniers 2021-02-09 1:39 ` Nick Desaulniers 2021-02-09 14:35 ` Will Deacon 2021-02-09 14:35 ` Will Deacon
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=VI1PR08MB31986E54164FA3293AA737E1F8B49@VI1PR08MB3198.eurprd08.prod.outlook.com \ --to=peter.smith@arm.com \ --cc=Catalin.Marinas@arm.com \ --cc=arnd@arndb.de \ --cc=arnd@kernel.org \ --cc=clang-built-linux@googlegroups.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=nathan@kernel.org \ --cc=ndesaulniers@google.com \ --cc=will@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.