Re: [PATCH 20/21] Kbuild, lto: Add Link Time Optimization support

Arnd Bergmann
2018-01-27T00:15:50Z

On Mon, Nov 27, 2017 at 10:34 PM, Andi Kleen <andi@firstfloor.org> wrote:
> From: Andi Kleen <ak@linux.intel.com>
> - Add a new LDFINAL variable that controls the final link
> for vmlinux or module. In this case we call gcc-ld instead
> of ld, to run the LTO step.

When I tried this out on allmodconfig (following the lwn article), I ran into
a number of warnings:

WARNING: modpost: missing MODULE_LICENSE() in
drivers/isdn/hardware/eicon/diva_mnt.o
see include/linux/module.h for more information
WARNING: modpost: missing MODULE_LICENSE() in drivers/isdn/hysdn/hysdn.o
see include/linux/module.h for more information
WARNING: modpost: missing MODULE_LICENSE() in drivers/vhost/vhost_scsi.o
see include/linux/module.h for more information
WARNING: modpost: missing MODULE_LICENSE() in drivers/scsi/pcmcia/qlogic_cs.o
see include/linux/module.h for more information
WARNING: modpost: missing MODULE_LICENSE() in drivers/scsi/pcmcia/fdomain_cs.o
...

These are apparently all compound modules that do have a valid
license, and modinfo
shows it correctly:

modinfo build/tmp/drivers/isdn/hardware/eicon/diva_mnt.ko
filename:
/home/arnd/arm-soc/build/tmp/drivers/isdn/hardware/eicon/diva_mnt.ko
license: GPL
author: Cytronics & Melware, Eicon Networks
description: Maint driver for Eicon DIVA Server cards
...

but something in the LTO build conuses modpost to the point that it doesn't
see it.

I also get 131 errors in x86 allmodconfig along the lines of

/git/arm-soc/include/linux/slab.h:298:0: error: type of
'kmalloc_caches' does not match original declaration
[-Werror=lto-type-mismatch]
extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
/git/arm-soc/mm/slab_common.c:958:1: note: 'kmalloc_caches' was
previously declared here
EXPORT_SYMBOL(kmalloc_caches);

/git/arm-soc/include/linux/seq_file.h:109:5: error: type of 'seq_open'
does not match original declaration [-Werror=lto-type-mismatc
h]
int seq_open(struct file *, const struct seq_operations *);
^
/git/arm-soc/fs/seq_file.c:48:0: note: 'seq_open' was previously declared here
int seq_open(struct file *file, const struct seq_operations *op)

I found a fix for some of these issues attached to
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83954
but am still doing more randconfig build testing.

Arnd