Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [thomas-weissschuh:b4/module-hashes 9/9] llvm-objcopy: error: '.tmp_module_hashes.o': The file was not recognized as a valid object file
@ 2025-03-11 12:14 kernel test robot
  2025-03-11 19:49 ` Nathan Chancellor
  0 siblings, 1 reply; 4+ messages in thread
From: kernel test robot @ 2025-03-11 12:14 UTC (permalink / raw)
  To: Thomas Weißschuh; +Cc: llvm, oe-kbuild-all

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/thomas.weissschuh/linux.git b4/module-hashes
head:   8ab7849599f74e8492224b62d852cd9affecea7c
commit: 8ab7849599f74e8492224b62d852cd9affecea7c [9/9] module: Introduce hash-based integrity checking
config: x86_64-randconfig-005-20250311 (https://download.01.org/0day-ci/archive/20250311/202503112010.RsM1bgi6-lkp@intel.com/config)
compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250311/202503112010.RsM1bgi6-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503112010.RsM1bgi6-lkp@intel.com/

All errors (new ones prefixed by >>):

>> llvm-objcopy: error: '.tmp_module_hashes.o': The file was not recognized as a valid object file

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [thomas-weissschuh:b4/module-hashes 9/9] llvm-objcopy: error: '.tmp_module_hashes.o': The file was not recognized as a valid object file
  2025-03-11 12:14 [thomas-weissschuh:b4/module-hashes 9/9] llvm-objcopy: error: '.tmp_module_hashes.o': The file was not recognized as a valid object file kernel test robot
@ 2025-03-11 19:49 ` Nathan Chancellor
  2025-03-11 20:58   ` Thomas Weißschuh
  0 siblings, 1 reply; 4+ messages in thread
From: Nathan Chancellor @ 2025-03-11 19:49 UTC (permalink / raw)
  To: kernel test robot; +Cc: Thomas Weißschuh, llvm, oe-kbuild-all

On Tue, Mar 11, 2025 at 08:14:14PM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/thomas.weissschuh/linux.git b4/module-hashes
> head:   8ab7849599f74e8492224b62d852cd9affecea7c
> commit: 8ab7849599f74e8492224b62d852cd9affecea7c [9/9] module: Introduce hash-based integrity checking
> config: x86_64-randconfig-005-20250311 (https://download.01.org/0day-ci/archive/20250311/202503112010.RsM1bgi6-lkp@intel.com/config)
> compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250311/202503112010.RsM1bgi6-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202503112010.RsM1bgi6-lkp@intel.com/
> 
> All errors (new ones prefixed by >>):
> 
> >> llvm-objcopy: error: '.tmp_module_hashes.o': The file was not recognized as a valid object file

I suspect this happens because LTO is enabled for this configuration (so
-flto will be in KBUILD_CFLAGS), which generates an LLVM bitcode object
file instead of an ELF one.

Cheers,
Nathan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [thomas-weissschuh:b4/module-hashes 9/9] llvm-objcopy: error: '.tmp_module_hashes.o': The file was not recognized as a valid object file
  2025-03-11 19:49 ` Nathan Chancellor
@ 2025-03-11 20:58   ` Thomas Weißschuh
  2025-03-11 21:43     ` Nathan Chancellor
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Weißschuh @ 2025-03-11 20:58 UTC (permalink / raw)
  To: Nathan Chancellor; +Cc: kernel test robot, llvm, oe-kbuild-all

Hi Nathan,

On 2025-03-11 20:49:40+0100, Nathan Chancellor wrote:
> On Tue, Mar 11, 2025 at 08:14:14PM +0800, kernel test robot wrote:
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/thomas.weissschuh/linux.git b4/module-hashes
> > head:   8ab7849599f74e8492224b62d852cd9affecea7c
> > commit: 8ab7849599f74e8492224b62d852cd9affecea7c [9/9] module: Introduce hash-based integrity checking
> > config: x86_64-randconfig-005-20250311 (https://download.01.org/0day-ci/archive/20250311/202503112010.RsM1bgi6-lkp@intel.com/config)
> > compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250311/202503112010.RsM1bgi6-lkp@intel.com/reproduce)
> > 
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202503112010.RsM1bgi6-lkp@intel.com/
> > 
> > All errors (new ones prefixed by >>):
> > 
> > >> llvm-objcopy: error: '.tmp_module_hashes.o': The file was not recognized as a valid object file
> 
> I suspect this happens because LTO is enabled for this configuration (so
> -flto will be in KBUILD_CFLAGS), which generates an LLVM bitcode object
> file instead of an ELF one.

Thanks for the hint!

The following diff seems to fix the issue and quick testing indicates
that it should work with the different supported compilers.
Any objections?

diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index 2add7eb950a0..f8d87a2ae74b 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -324,7 +324,7 @@ if is_enabled CONFIG_MODULE_HASHES; then
        ${srctree}/scripts/module-hashes.sh > .tmp_module_hashes.c
        info CC ${module_hashes_o}
        ${CC} ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS} ${KBUILD_CFLAGS} \
-               ${KBUILD_CFLAGS_KERNEL} -c -o "${module_hashes_o}" ".tmp_module_hashes.c"
+               ${KBUILD_CFLAGS_KERNEL} -fno-lto -c -o "${module_hashes_o}" ".tmp_module_hashes.c"
        ${OBJCOPY} --dump-section .module_hashes=.tmp_module_hashes.bin ${module_hashes_o}
        ${OBJCOPY} --update-section .module_hashes=.tmp_module_hashes.bin vmlinux
 fi

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [thomas-weissschuh:b4/module-hashes 9/9] llvm-objcopy: error: '.tmp_module_hashes.o': The file was not recognized as a valid object file
  2025-03-11 20:58   ` Thomas Weißschuh
@ 2025-03-11 21:43     ` Nathan Chancellor
  0 siblings, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2025-03-11 21:43 UTC (permalink / raw)
  To: Thomas Weißschuh; +Cc: kernel test robot, llvm, oe-kbuild-all

On Tue, Mar 11, 2025 at 09:58:06PM +0100, Thomas Weißschuh wrote:
> Hi Nathan,
> 
> On 2025-03-11 20:49:40+0100, Nathan Chancellor wrote:
> > On Tue, Mar 11, 2025 at 08:14:14PM +0800, kernel test robot wrote:
> > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/thomas.weissschuh/linux.git b4/module-hashes
> > > head:   8ab7849599f74e8492224b62d852cd9affecea7c
> > > commit: 8ab7849599f74e8492224b62d852cd9affecea7c [9/9] module: Introduce hash-based integrity checking
> > > config: x86_64-randconfig-005-20250311 (https://download.01.org/0day-ci/archive/20250311/202503112010.RsM1bgi6-lkp@intel.com/config)
> > > compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
> > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250311/202503112010.RsM1bgi6-lkp@intel.com/reproduce)
> > > 
> > > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > > the same patch/commit), kindly add following tags
> > > | Reported-by: kernel test robot <lkp@intel.com>
> > > | Closes: https://lore.kernel.org/oe-kbuild-all/202503112010.RsM1bgi6-lkp@intel.com/
> > > 
> > > All errors (new ones prefixed by >>):
> > > 
> > > >> llvm-objcopy: error: '.tmp_module_hashes.o': The file was not recognized as a valid object file
> > 
> > I suspect this happens because LTO is enabled for this configuration (so
> > -flto will be in KBUILD_CFLAGS), which generates an LLVM bitcode object
> > file instead of an ELF one.
> 
> Thanks for the hint!
> 
> The following diff seems to fix the issue and quick testing indicates
> that it should work with the different supported compilers.
> Any objections?

Nope, I think that should work fine.

> diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
> index 2add7eb950a0..f8d87a2ae74b 100755
> --- a/scripts/link-vmlinux.sh
> +++ b/scripts/link-vmlinux.sh
> @@ -324,7 +324,7 @@ if is_enabled CONFIG_MODULE_HASHES; then
>         ${srctree}/scripts/module-hashes.sh > .tmp_module_hashes.c
>         info CC ${module_hashes_o}
>         ${CC} ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS} ${KBUILD_CFLAGS} \
> -               ${KBUILD_CFLAGS_KERNEL} -c -o "${module_hashes_o}" ".tmp_module_hashes.c"
> +               ${KBUILD_CFLAGS_KERNEL} -fno-lto -c -o "${module_hashes_o}" ".tmp_module_hashes.c"
>         ${OBJCOPY} --dump-section .module_hashes=.tmp_module_hashes.bin ${module_hashes_o}
>         ${OBJCOPY} --update-section .module_hashes=.tmp_module_hashes.bin vmlinux
>  fi

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-03-11 21:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-11 12:14 [thomas-weissschuh:b4/module-hashes 9/9] llvm-objcopy: error: '.tmp_module_hashes.o': The file was not recognized as a valid object file kernel test robot
2025-03-11 19:49 ` Nathan Chancellor
2025-03-11 20:58   ` Thomas Weißschuh
2025-03-11 21:43     ` Nathan Chancellor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox