diff mbox series

ARM: Allow pre-ARMv5 builds with ld.lld 16.0.0 and newer

Message ID 20230118-v4-v4t-lld-16-v1-1-e3d9a00ae47c@kernel.org (mailing list archive)
State New, archived
Headers show
Series ARM: Allow pre-ARMv5 builds with ld.lld 16.0.0 and newer | expand

Commit Message

Nathan Chancellor Jan. 18, 2023, 7:22 p.m. UTC
Commit 6a7ee50f8f56 ("ARM: disallow pre-ARMv5 builds with ld.lld")
prevented v4 or v4t kernels when ld.lld will link the kernel due to
inserting unsupported blx instructions.

ld.lld has been fixed in current main (16.0.0) to avoid inserting these
instructions by inserting position independent thunks instead. Allow
these configurations to be enabled when ld.lld 16.0.0 is used to link
the kernel.

Additionally, add a link to the upstream LLVM issue so that the reason
for this dependency is clearly documented.

Link: https://github.com/ClangBuiltLinux/linux/issues/964
Link: https://github.com/llvm/llvm-project/commit/6f9ff1beee9d12aca0c9caa9ae0051dc6d0a718c
Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
I just build tested:

- multi_v4t_defconfig without 6a7ee50f8f56 with LLVM 15: warning
- multi_v4t_defconfig with this patch with LLVM 16: no warning

and the configuration cannot be selected under the old and new conditions
still.
---
 arch/arm/Kconfig | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)


---
base-commit: 5dc4c995db9eb45f6373a956eb1f69460e69e6d4
change-id: 20230118-v4-v4t-lld-16-96d5d5cc36c2

Best regards,

Comments

Arnd Bergmann Jan. 27, 2023, 9:56 p.m. UTC | #1
On Wed, Jan 18, 2023, at 20:22, Nathan Chancellor wrote:
> Commit 6a7ee50f8f56 ("ARM: disallow pre-ARMv5 builds with ld.lld")
> prevented v4 or v4t kernels when ld.lld will link the kernel due to
> inserting unsupported blx instructions.
>
> ld.lld has been fixed in current main (16.0.0) to avoid inserting these
> instructions by inserting position independent thunks instead. Allow
> these configurations to be enabled when ld.lld 16.0.0 is used to link
> the kernel.
>
> Additionally, add a link to the upstream LLVM issue so that the reason
> for this dependency is clearly documented.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/964
> Link: 
> https://github.com/llvm/llvm-project/commit/6f9ff1beee9d12aca0c9caa9ae0051dc6d0a718c
> Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>

Thanks a lot for getting this fixed!

I gave this a spin on my randconfig build setup, which showed
nothing unusual.

Tested-by: Arnd Bergmann <arnd@arndb.de>

Please add this to Russell's patch tracker.

      Arnd
Nathan Chancellor Jan. 29, 2023, 2:51 p.m. UTC | #2
On Fri, Jan 27, 2023 at 10:56:06PM +0100, Arnd Bergmann wrote:
> On Wed, Jan 18, 2023, at 20:22, Nathan Chancellor wrote:
> > Commit 6a7ee50f8f56 ("ARM: disallow pre-ARMv5 builds with ld.lld")
> > prevented v4 or v4t kernels when ld.lld will link the kernel due to
> > inserting unsupported blx instructions.
> >
> > ld.lld has been fixed in current main (16.0.0) to avoid inserting these
> > instructions by inserting position independent thunks instead. Allow
> > these configurations to be enabled when ld.lld 16.0.0 is used to link
> > the kernel.
> >
> > Additionally, add a link to the upstream LLVM issue so that the reason
> > for this dependency is clearly documented.
> >
> > Link: https://github.com/ClangBuiltLinux/linux/issues/964
> > Link: 
> > https://github.com/llvm/llvm-project/commit/6f9ff1beee9d12aca0c9caa9ae0051dc6d0a718c
> > Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> 
> Thanks a lot for getting this fixed!
> 
> I gave this a spin on my randconfig build setup, which showed
> nothing unusual.
> 
> Tested-by: Arnd Bergmann <arnd@arndb.de>
> 
> Please add this to Russell's patch tracker.

Done, thanks for testing!

https://www.armlinux.org.uk/developer/patches/viewpatch.php?id=9289/1

Cheers,
Nathan
kernel test robot Jan. 30, 2023, 6:10 p.m. UTC | #3
Hi Nathan,

I love your patch! Perhaps something to improve:

[auto build test WARNING on 5dc4c995db9eb45f6373a956eb1f69460e69e6d4]

url:    https://github.com/intel-lab-lkp/linux/commits/Nathan-Chancellor/ARM-Allow-pre-ARMv5-builds-with-ld-lld-16-0-0-and-newer/20230119-032402
base:   5dc4c995db9eb45f6373a956eb1f69460e69e6d4
patch link:    https://lore.kernel.org/r/20230118-v4-v4t-lld-16-v1-1-e3d9a00ae47c%40kernel.org
patch subject: [PATCH] ARM: Allow pre-ARMv5 builds with ld.lld 16.0.0 and newer
config: arm-shannon_defconfig (https://download.01.org/0day-ci/archive/20230131/202301310149.euWWUSrD-lkp@intel.com/config)
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 4196ca3278f78c6e19246e54ab0ecb364e37d66a)
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 arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://github.com/intel-lab-lkp/linux/commit/197c1476db190ad6d2afe14bc0f90de0e82f63b6
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Nathan-Chancellor/ARM-Allow-pre-ARMv5-builds-with-ld-lld-16-0-0-and-newer/20230119-032402
        git checkout 197c1476db190ad6d2afe14bc0f90de0e82f63b6
        # 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=arm olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash arch/arm/mach-sa1100/ drivers/gpio/ drivers/video/fbdev/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> arch/arm/mach-sa1100/pm.c:122:12: warning: no previous prototype for function 'sa11x0_pm_init' [-Wmissing-prototypes]
   int __init sa11x0_pm_init(void)
              ^
   arch/arm/mach-sa1100/pm.c:122:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int __init sa11x0_pm_init(void)
   ^
   static 
   1 warning generated.
--
>> drivers/gpio/gpio-sa1100.c:309:13: warning: no previous prototype for function 'sa1100_init_gpio' [-Wmissing-prototypes]
   void __init sa1100_init_gpio(void)
               ^
   drivers/gpio/gpio-sa1100.c:309:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __init sa1100_init_gpio(void)
   ^
   static 
   1 warning generated.
--
>> drivers/video/fbdev/sa1100fb.c:1219:12: warning: no previous prototype for function 'sa1100fb_init' [-Wmissing-prototypes]
   int __init sa1100fb_init(void)
              ^
   drivers/video/fbdev/sa1100fb.c:1219:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int __init sa1100fb_init(void)
   ^
   static 
   1 warning generated.


vim +/sa11x0_pm_init +122 arch/arm/mach-sa1100/pm.c

^1da177e4c3f41 Linus Torvalds 2005-04-16  121  
7fea1ba58e61c1 Shawn Guo      2012-04-26 @122  int __init sa11x0_pm_init(void)
Arnd Bergmann Jan. 30, 2023, 6:19 p.m. UTC | #4
On Mon, Jan 30, 2023, at 19:10, kernel test robot wrote:
> Hi Nathan,
>
> I love your patch! Perhaps something to improve:
>
> [auto build test WARNING on 5dc4c995db9eb45f6373a956eb1f69460e69e6d4]
>
> url:    
> https://github.com/intel-lab-lkp/linux/commits/Nathan-Chancellor/ARM-Allow-pre-ARMv5-builds-with-ld-lld-16-0-0-and-newer/20230119-032402
> base:   5dc4c995db9eb45f6373a956eb1f69460e69e6d4
>>> arch/arm/mach-sa1100/pm.c:122:12: warning: no previous prototype for function 'sa11x0_pm_init' [-Wmissing-prototypes]
>    int __init sa11x0_pm_init(void)
>               ^
>    arch/arm/mach-sa1100/pm.c:122:1: note: declare 'static' if the 
> function is not intended to be used outside of this translation unit
>    int __init sa11x0_pm_init(void)
>    ^
>    static 
>    1 warning generated.
> --


For refernece, these are all known problems, the patch just allowed
the code to be built by clang/lld when that was previously not
possible.

After the 6.3 merge window, we can probably go through the much
smaller set of board files are address most of the W=1 warnings that
were previously overwhelming.

      Arnd
Nick Desaulniers Jan. 30, 2023, 10:03 p.m. UTC | #5
On Mon, Jan 30, 2023 at 10:19 AM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Mon, Jan 30, 2023, at 19:10, kernel test robot wrote:
> > Hi Nathan,
> >
> > I love your patch! Perhaps something to improve:
> >
> > [auto build test WARNING on 5dc4c995db9eb45f6373a956eb1f69460e69e6d4]
> >
> > url:
> > https://github.com/intel-lab-lkp/linux/commits/Nathan-Chancellor/ARM-Allow-pre-ARMv5-builds-with-ld-lld-16-0-0-and-newer/20230119-032402
> > base:   5dc4c995db9eb45f6373a956eb1f69460e69e6d4
> >>> arch/arm/mach-sa1100/pm.c:122:12: warning: no previous prototype for function 'sa11x0_pm_init' [-Wmissing-prototypes]
> >    int __init sa11x0_pm_init(void)
> >               ^
> >    arch/arm/mach-sa1100/pm.c:122:1: note: declare 'static' if the
> > function is not intended to be used outside of this translation unit
> >    int __init sa11x0_pm_init(void)
> >    ^
> >    static
> >    1 warning generated.
> > --
>
>
> For refernece, these are all known problems, the patch just allowed
> the code to be built by clang/lld when that was previously not
> possible.
>
> After the 6.3 merge window, we can probably go through the much
> smaller set of board files are address most of the W=1 warnings that
> were previously overwhelming.

Yeah! I've filed
https://github.com/ClangBuiltLinux/continuous-integration2/issues/509
too so that we can wire up an ARMv4 test in our CI as well.

>
>       Arnd
diff mbox series

Patch

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 43c7773b89ae..874c5b56cf9a 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -345,14 +345,16 @@  comment "CPU Core family selection"
 config ARCH_MULTI_V4
 	bool "ARMv4 based platforms (FA526, StrongARM)"
 	depends on !ARCH_MULTI_V6_V7
-	depends on !LD_IS_LLD
+	# https://github.com/llvm/llvm-project/issues/50764
+	depends on !LD_IS_LLD || LLD_VERSION >= 160000
 	select ARCH_MULTI_V4_V5
 	select CPU_FA526 if !(CPU_SA110 || CPU_SA1100)
 
 config ARCH_MULTI_V4T
 	bool "ARMv4T based platforms (ARM720T, ARM920T, ...)"
 	depends on !ARCH_MULTI_V6_V7
-	depends on !LD_IS_LLD
+	# https://github.com/llvm/llvm-project/issues/50764
+	depends on !LD_IS_LLD || LLD_VERSION >= 160000
 	select ARCH_MULTI_V4_V5
 	select CPU_ARM920T if !(CPU_ARM7TDMI || CPU_ARM720T || \
 		CPU_ARM740T || CPU_ARM9TDMI || CPU_ARM922T || \