kcsan: select CONFIG_CONSTRUCTORS
authorArnd Bergmann <arnd@arndb.de>
Wed, 15 Feb 2023 09:14:48 +0000 (10:14 +0100)
committerPaul E. McKenney <paulmck@kernel.org>
Wed, 22 Feb 2023 18:28:20 +0000 (10:28 -0800)
commit6ba912f1c081448cf3d1fa9ada9115aae4594ac4
treecdf5111075c8761902e8f2d5a7e342558b693982
parent1b929c02afd37871d5afb9d498426f83432e71c2
kcsan: select CONFIG_CONSTRUCTORS

Building a kcsan enabled kernel for x86_64 with gcc-11 results in a lot
of build warnings or errors without CONFIG_CONSTRUCTORS:

x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/copy_mc.o'
x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/cpu.o'
x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/csum-partial_64.o'
x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/csum-wrappers_64.o'
x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/insn-eval.o'
x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/insn.o'
x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/misc.o'

The same thing has been reported for mips64. I can't reproduce it for
any other compiler version, so I don't know if constructors are always
required here or if this is a gcc-11 specific implementation detail.

I see no harm in always enabling constructors here, and this reliably
fixes the build warnings for me.

Link: https://lore.kernel.org/lkml/202204181801.r3MMkwJv-lkp@intel.com/T/
Cc: Kees Cook <keescook@chromium.org>
See-also: 3e6631485fae ("vmlinux.lds.h: Keep .ctors.* with .ctors")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Marco Elver <elver@google.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
lib/Kconfig.kcsan