* [PATCH] riscv: Pass -mno-relax only on lld < 15.0.0
@ 2022-07-10 7:11 Fangrui Song
2022-07-11 17:36 ` Nathan Chancellor
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Fangrui Song @ 2022-07-10 7:11 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, linux-riscv
Cc: Khem Raj, linux-kernel, llvm, Fangrui Song
lld since
https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
(milestone: 15.0.0) has implemented some RISC-V linker relaxation.
-mno-relax is no longer needed in KBUILD_CFLAGS/KBUILD_AFLAGS to
suppress R_RISCV_ALIGN which older lld can not handle:
ld.lld: error: capability.c:(.fixup+0x0): relocation R_RISCV_ALIGN requires unimplemented linker relaxation; recompile with -mno-relax but the .o is already compiled with -mno-relax
Signed-off-by: Fangrui Song <maskray@google.com>
---
arch/riscv/Makefile | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 34cf8a598617..7e4ceb2a0981 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -37,6 +37,7 @@ else
endif
ifeq ($(CONFIG_LD_IS_LLD),y)
+ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 150000; echo $$?),0)
KBUILD_CFLAGS += -mno-relax
KBUILD_AFLAGS += -mno-relax
ifndef CONFIG_AS_IS_LLVM
@@ -44,6 +45,7 @@ ifndef CONFIG_AS_IS_LLVM
KBUILD_AFLAGS += -Wa,-mno-relax
endif
endif
+endif
# ISA string setting
riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima
--
2.37.0.144.g8ac04bfd2-goog
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] riscv: Pass -mno-relax only on lld < 15.0.0
2022-07-10 7:11 [PATCH] riscv: Pass -mno-relax only on lld < 15.0.0 Fangrui Song
@ 2022-07-11 17:36 ` Nathan Chancellor
2022-07-11 17:38 ` Nick Desaulniers
2022-09-08 17:18 ` Nathan Chancellor
2 siblings, 0 replies; 7+ messages in thread
From: Nathan Chancellor @ 2022-07-11 17:36 UTC (permalink / raw)
To: Fangrui Song
Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, linux-riscv, Khem Raj,
linux-kernel, llvm
On Sun, Jul 10, 2022 at 12:11:17AM -0700, Fangrui Song wrote:
> lld since
> https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
> (milestone: 15.0.0) has implemented some RISC-V linker relaxation.
> -mno-relax is no longer needed in KBUILD_CFLAGS/KBUILD_AFLAGS to
> suppress R_RISCV_ALIGN which older lld can not handle:
>
> ld.lld: error: capability.c:(.fixup+0x0): relocation R_RISCV_ALIGN requires unimplemented linker relaxation; recompile with -mno-relax but the .o is already compiled with -mno-relax
>
> Signed-off-by: Fangrui Song <maskray@google.com>
ld.lld 14 and 15 both continue to link kernels and I have no issues
booting them in QEMU.
Tested-by: Nathan Chancellor <nathan@kernel.org>
> ---
> arch/riscv/Makefile | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> index 34cf8a598617..7e4ceb2a0981 100644
> --- a/arch/riscv/Makefile
> +++ b/arch/riscv/Makefile
> @@ -37,6 +37,7 @@ else
> endif
>
> ifeq ($(CONFIG_LD_IS_LLD),y)
> +ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 150000; echo $$?),0)
> KBUILD_CFLAGS += -mno-relax
> KBUILD_AFLAGS += -mno-relax
> ifndef CONFIG_AS_IS_LLVM
> @@ -44,6 +45,7 @@ ifndef CONFIG_AS_IS_LLVM
> KBUILD_AFLAGS += -Wa,-mno-relax
> endif
> endif
> +endif
>
> # ISA string setting
> riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima
> --
> 2.37.0.144.g8ac04bfd2-goog
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] riscv: Pass -mno-relax only on lld < 15.0.0
2022-07-10 7:11 [PATCH] riscv: Pass -mno-relax only on lld < 15.0.0 Fangrui Song
2022-07-11 17:36 ` Nathan Chancellor
@ 2022-07-11 17:38 ` Nick Desaulniers
2022-09-08 17:18 ` Nathan Chancellor
2 siblings, 0 replies; 7+ messages in thread
From: Nick Desaulniers @ 2022-07-11 17:38 UTC (permalink / raw)
To: Fangrui Song
Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, linux-riscv, Khem Raj,
linux-kernel, llvm
On Sun, Jul 10, 2022 at 12:11 AM Fangrui Song <maskray@google.com> wrote:
>
> lld since
> https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
> (milestone: 15.0.0) has implemented some RISC-V linker relaxation.
> -mno-relax is no longer needed in KBUILD_CFLAGS/KBUILD_AFLAGS to
> suppress R_RISCV_ALIGN which older lld can not handle:
>
> ld.lld: error: capability.c:(.fixup+0x0): relocation R_RISCV_ALIGN requires unimplemented linker relaxation; recompile with -mno-relax but the .o is already compiled with -mno-relax
>
> Signed-off-by: Fangrui Song <maskray@google.com>
Thanks for implementing relaxation in LLD for RISC-V!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
> arch/riscv/Makefile | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> index 34cf8a598617..7e4ceb2a0981 100644
> --- a/arch/riscv/Makefile
> +++ b/arch/riscv/Makefile
> @@ -37,6 +37,7 @@ else
> endif
>
> ifeq ($(CONFIG_LD_IS_LLD),y)
> +ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 150000; echo $$?),0)
> KBUILD_CFLAGS += -mno-relax
> KBUILD_AFLAGS += -mno-relax
> ifndef CONFIG_AS_IS_LLVM
> @@ -44,6 +45,7 @@ ifndef CONFIG_AS_IS_LLVM
> KBUILD_AFLAGS += -Wa,-mno-relax
> endif
> endif
> +endif
>
> # ISA string setting
> riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima
> --
> 2.37.0.144.g8ac04bfd2-goog
>
>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] riscv: Pass -mno-relax only on lld < 15.0.0
2022-07-10 7:11 [PATCH] riscv: Pass -mno-relax only on lld < 15.0.0 Fangrui Song
2022-07-11 17:36 ` Nathan Chancellor
2022-07-11 17:38 ` Nick Desaulniers
@ 2022-09-08 17:18 ` Nathan Chancellor
2 siblings, 0 replies; 7+ messages in thread
From: Nathan Chancellor @ 2022-09-08 17:18 UTC (permalink / raw)
To: Palmer Dabbelt
Cc: Paul Walmsley, Albert Ou, linux-riscv, Khem Raj, linux-kernel,
llvm, Fangrui Song
It does not look like this ever got picked up? Would it be possible to
pick it up for 6.1?
The original patch is at:
https://lore.kernel.org/20220710071117.446112-1-maskray@google.com/
Cheers,
Nathan
On Sun, Jul 10, 2022 at 12:11:17AM -0700, Fangrui Song wrote:
> lld since
> https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
> (milestone: 15.0.0) has implemented some RISC-V linker relaxation.
> -mno-relax is no longer needed in KBUILD_CFLAGS/KBUILD_AFLAGS to
> suppress R_RISCV_ALIGN which older lld can not handle:
>
> ld.lld: error: capability.c:(.fixup+0x0): relocation R_RISCV_ALIGN requires unimplemented linker relaxation; recompile with -mno-relax but the .o is already compiled with -mno-relax
>
> Signed-off-by: Fangrui Song <maskray@google.com>
> ---
> arch/riscv/Makefile | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> index 34cf8a598617..7e4ceb2a0981 100644
> --- a/arch/riscv/Makefile
> +++ b/arch/riscv/Makefile
> @@ -37,6 +37,7 @@ else
> endif
>
> ifeq ($(CONFIG_LD_IS_LLD),y)
> +ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 150000; echo $$?),0)
> KBUILD_CFLAGS += -mno-relax
> KBUILD_AFLAGS += -mno-relax
> ifndef CONFIG_AS_IS_LLVM
> @@ -44,6 +45,7 @@ ifndef CONFIG_AS_IS_LLVM
> KBUILD_AFLAGS += -Wa,-mno-relax
> endif
> endif
> +endif
>
> # ISA string setting
> riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima
> --
> 2.37.0.144.g8ac04bfd2-goog
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] riscv: Pass -mno-relax only on lld < 15.0.0
2022-07-13 5:48 ` Fangrui Song
@ 2022-07-13 7:19 ` Fangrui Song
0 siblings, 0 replies; 7+ messages in thread
From: Fangrui Song @ 2022-07-13 7:19 UTC (permalink / raw)
To: kernel test robot; +Cc: kbuild-all, llvm
On Tue, Jul 12, 2022 at 10:48 PM Fangrui Song <maskray@google.com> wrote:
>
> On Tue, Jul 12, 2022 at 9:16 PM kernel test robot <lkp@intel.com> wrote:
> >
> > BCC: lkp@intel.com
> > In-Reply-To: <20220710071117.446112-1-maskray@google.com>
> > References: <20220710071117.446112-1-maskray@google.com>
> > TO: Fangrui Song <maskray@google.com>
> > TO: Paul Walmsley <paul.walmsley@sifive.com>
> > TO: Palmer Dabbelt <palmer@dabbelt.com>
> > TO: Albert Ou <aou@eecs.berkeley.edu>
> > TO: linux-riscv@lists.infradead.org
> > CC: Khem Raj <raj.khem@gmail.com>
> > CC: linux-kernel@vger.kernel.org
> > CC: llvm@lists.linux.dev
> > CC: Fangrui Song <maskray@google.com>
> >
> > Hi Fangrui,
> >
> > Thank you for the patch! Yet something to improve:
> >
> > [auto build test ERROR on linus/master]
> > [also build test ERROR on v5.19-rc6 next-20220712]
> > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > And when submitting patch, we suggest to use '--base' as documented in
> > https://git-scm.com/docs/git-format-patch#_base_tree_information]
> >
> > url: https://github.com/intel-lab-lkp/linux/commits/Fangrui-Song/riscv-Pass-mno-relax-only-on-lld-15-0-0/20220710-151301
> > base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git b1c428b6c3684ee8ddf4137d68b3e8d51d2a700f
> > config: riscv-rv32_defconfig (https://download.01.org/0day-ci/archive/20220713/202207131251.9wFgtqfN-lkp@intel.com/config)
> > compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project e60b4fb2b777118c0ff664a6347851df14fcf75b)
> > reproduce (this is a W=1 build):
> > wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> > chmod +x ~/bin/make.cross
> > # install riscv cross compiling tool for clang build
> > # apt-get install binutils-riscv-linux-gnu
> > # https://github.com/intel-lab-lkp/linux/commit/9abe0b92e612c5b6c53d4658b46c60b75bbd39d3
> > git remote add linux-review https://github.com/intel-lab-lkp/linux
> > git fetch --no-tags linux-review Fangrui-Song/riscv-Pass-mno-relax-only-on-lld-15-0-0/20220710-151301
> > git checkout 9abe0b92e612c5b6c53d4658b46c60b75bbd39d3
> > # save the config file
> > mkdir build_dir && cp config build_dir/.config
> > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash
> >
> > If you fix the issue, kindly add following tag where applicable
> > Reported-by: kernel test robot <lkp@intel.com>
> >
> > All errors (new ones prefixed by >>):
> >
> > >> ld.lld: error: fs/built-in.a(nfs/nfs3xdr.o):(function decode_wcc_data: .text+0x2ec4): relocation R_RISCV_RVC_JUMP out of range: -1079 is not in [-1024, 1023]; references decode_fattr3
> > >>> referenced by nfs3xdr.c
> > >>> defined in fs/built-in.a(nfs/nfs3xdr.o)
> >
> > --
> > 0-DAY CI Kernel Test Service
> > https://01.org/lkp
> >
>
> This exposed an issue about imprecise branch distance computation when
> checking a call instruction referencing the same input section.
> I'll fix lld.
This was an issue in the R_RISCV_CALL lld patch. I just fixed it in
https://github.com/llvm/llvm-project/commit/6b1d151fe3dc530195d8802f1ecc247c8235dd3a
.
It's unnecessary to adjust the commit message since riscv32/riscv64
kernels should work with the very first R_RISCV_ALIGN lld patch.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] riscv: Pass -mno-relax only on lld < 15.0.0
2022-07-13 4:16 kernel test robot
@ 2022-07-13 5:48 ` Fangrui Song
2022-07-13 7:19 ` Fangrui Song
0 siblings, 1 reply; 7+ messages in thread
From: Fangrui Song @ 2022-07-13 5:48 UTC (permalink / raw)
To: kernel test robot; +Cc: kbuild-all, llvm
On Tue, Jul 12, 2022 at 9:16 PM kernel test robot <lkp@intel.com> wrote:
>
> BCC: lkp@intel.com
> In-Reply-To: <20220710071117.446112-1-maskray@google.com>
> References: <20220710071117.446112-1-maskray@google.com>
> TO: Fangrui Song <maskray@google.com>
> TO: Paul Walmsley <paul.walmsley@sifive.com>
> TO: Palmer Dabbelt <palmer@dabbelt.com>
> TO: Albert Ou <aou@eecs.berkeley.edu>
> TO: linux-riscv@lists.infradead.org
> CC: Khem Raj <raj.khem@gmail.com>
> CC: linux-kernel@vger.kernel.org
> CC: llvm@lists.linux.dev
> CC: Fangrui Song <maskray@google.com>
>
> Hi Fangrui,
>
> Thank you for the patch! Yet something to improve:
>
> [auto build test ERROR on linus/master]
> [also build test ERROR on v5.19-rc6 next-20220712]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Fangrui-Song/riscv-Pass-mno-relax-only-on-lld-15-0-0/20220710-151301
> base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git b1c428b6c3684ee8ddf4137d68b3e8d51d2a700f
> config: riscv-rv32_defconfig (https://download.01.org/0day-ci/archive/20220713/202207131251.9wFgtqfN-lkp@intel.com/config)
> compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project e60b4fb2b777118c0ff664a6347851df14fcf75b)
> reproduce (this is a W=1 build):
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # install riscv cross compiling tool for clang build
> # apt-get install binutils-riscv-linux-gnu
> # https://github.com/intel-lab-lkp/linux/commit/9abe0b92e612c5b6c53d4658b46c60b75bbd39d3
> git remote add linux-review https://github.com/intel-lab-lkp/linux
> git fetch --no-tags linux-review Fangrui-Song/riscv-Pass-mno-relax-only-on-lld-15-0-0/20220710-151301
> git checkout 9abe0b92e612c5b6c53d4658b46c60b75bbd39d3
> # save the config file
> mkdir build_dir && cp config build_dir/.config
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash
>
> If you fix the issue, kindly add following tag where applicable
> Reported-by: kernel test robot <lkp@intel.com>
>
> All errors (new ones prefixed by >>):
>
> >> ld.lld: error: fs/built-in.a(nfs/nfs3xdr.o):(function decode_wcc_data: .text+0x2ec4): relocation R_RISCV_RVC_JUMP out of range: -1079 is not in [-1024, 1023]; references decode_fattr3
> >>> referenced by nfs3xdr.c
> >>> defined in fs/built-in.a(nfs/nfs3xdr.o)
>
> --
> 0-DAY CI Kernel Test Service
> https://01.org/lkp
>
This exposed an issue about imprecise branch distance computation when
checking a call instruction referencing the same input section.
I'll fix lld.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] riscv: Pass -mno-relax only on lld < 15.0.0
@ 2022-07-13 4:16 kernel test robot
2022-07-13 5:48 ` Fangrui Song
0 siblings, 1 reply; 7+ messages in thread
From: kernel test robot @ 2022-07-13 4:16 UTC (permalink / raw)
Cc: kbuild-all, llvm
BCC: lkp@intel.com
In-Reply-To: <20220710071117.446112-1-maskray@google.com>
References: <20220710071117.446112-1-maskray@google.com>
TO: Fangrui Song <maskray@google.com>
TO: Paul Walmsley <paul.walmsley@sifive.com>
TO: Palmer Dabbelt <palmer@dabbelt.com>
TO: Albert Ou <aou@eecs.berkeley.edu>
TO: linux-riscv@lists.infradead.org
CC: Khem Raj <raj.khem@gmail.com>
CC: linux-kernel@vger.kernel.org
CC: llvm@lists.linux.dev
CC: Fangrui Song <maskray@google.com>
Hi Fangrui,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v5.19-rc6 next-20220712]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Fangrui-Song/riscv-Pass-mno-relax-only-on-lld-15-0-0/20220710-151301
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git b1c428b6c3684ee8ddf4137d68b3e8d51d2a700f
config: riscv-rv32_defconfig (https://download.01.org/0day-ci/archive/20220713/202207131251.9wFgtqfN-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project e60b4fb2b777118c0ff664a6347851df14fcf75b)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/9abe0b92e612c5b6c53d4658b46c60b75bbd39d3
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Fangrui-Song/riscv-Pass-mno-relax-only-on-lld-15-0-0/20220710-151301
git checkout 9abe0b92e612c5b6c53d4658b46c60b75bbd39d3
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
>> ld.lld: error: fs/built-in.a(nfs/nfs3xdr.o):(function decode_wcc_data: .text+0x2ec4): relocation R_RISCV_RVC_JUMP out of range: -1079 is not in [-1024, 1023]; references decode_fattr3
>>> referenced by nfs3xdr.c
>>> defined in fs/built-in.a(nfs/nfs3xdr.o)
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-09-08 17:18 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-10 7:11 [PATCH] riscv: Pass -mno-relax only on lld < 15.0.0 Fangrui Song
2022-07-11 17:36 ` Nathan Chancellor
2022-07-11 17:38 ` Nick Desaulniers
2022-09-08 17:18 ` Nathan Chancellor
2022-07-13 4:16 kernel test robot
2022-07-13 5:48 ` Fangrui Song
2022-07-13 7:19 ` Fangrui Song
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).