Re: Linux 4.9.180 build fails with gcc 9 and 'cleanup_module' specifies less restrictive attribute than its target …

Greg KH
2019-06-06T15:29:07Z

On Thu, Jun 06, 2019 at 05:27:46PM +0200, Greg KH wrote:
> On Thu, Jun 06, 2019 at 03:16:03PM +0200, Rolf Eike Beer wrote:
> > I have at least these 2 instances:
> >
> >
> > In file included from /tmp/e2/build/linux-4.9.180/include/drm/drm_vma_manager.h:28,
> > from /tmp/e2/build/linux-4.9.180/include/drm/drmP.h:78,
> > from /tmp/e2/build/linux-4.9.180/include/drm/drm_modeset_helper.h:26,
> > from /tmp/e2/build/linux-4.9.180/include/drm/drm_atomic_helper.h:33,
> > from /tmp/e2/build/linux-4.9.180/drivers/gpu/drm/tilcdc/tilcdc_drv.c:24:
> > /tmp/e2/build/linux-4.9.180/include/linux/module.h:138:7: error: 'cleanup_module' specifies less restrictive attribute than its target 'tilcdc_drm_fini': 'cold' [-Werror=missing-attributes]
> > 138 | void cleanup_module(void) __attribute__((alias(#exitfn)));
> > | ^~~~~~~~~~~~~~
> > /tmp/e2/build/linux-4.9.180/drivers/gpu/drm/tilcdc/tilcdc_drv.c:757:1: note: in expansion of macro 'module_exit'
> > 757 | module_exit(tilcdc_drm_fini);
> > | ^~~~~~~~~~~
> > /tmp/e2/build/linux-4.9.180/drivers/gpu/drm/tilcdc/tilcdc_drv.c:748:20: note: 'cleanup_module' target declared here
> > 748 | static void __exit tilcdc_drm_fini(void)
> > | ^~~~~~~~~~~~~~~
> > In file included from /tmp/e2/build/linux-4.9.180/include/drm/drm_vma_manager.h:28,
> > from /tmp/e2/build/linux-4.9.180/include/drm/drmP.h:78,
> > from /tmp/e2/build/linux-4.9.180/include/drm/drm_modeset_helper.h:26,
> > from /tmp/e2/build/linux-4.9.180/include/drm/drm_atomic_helper.h:33,
> > from /tmp/e2/build/linux-4.9.180/drivers/gpu/drm/tilcdc/tilcdc_drv.c:24:
> > /tmp/e2/build/linux-4.9.180/include/linux/module.h:132:6: error: 'init_module' specifies less restrictive attribute than its target 'tilcdc_drm_init': 'cold' [-Werror=missing-attributes]
> > 132 | int init_module(void) __attribute__((alias(#initfn)));
> > | ^~~~~~~~~~~
> > /tmp/e2/build/linux-4.9.180/drivers/gpu/drm/tilcdc/tilcdc_drv.c:756:1: note: in expansion of macro 'module_init'
> > 756 | module_init(tilcdc_drm_init);
> > | ^~~~~~~~~~~
> > /tmp/e2/build/linux-4.9.180/drivers/gpu/drm/tilcdc/tilcdc_drv.c:740:19: note: 'init_module' target declared here
> > 740 | static int __init tilcdc_drm_init(void)
> > | ^~~~~~~~~~~~~~~
> >
> >
> >
> > In file included from /tmp/e2/build/linux-4.9.180/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c:17:
> > /tmp/e2/build/linux-4.9.180/include/linux/module.h:138:7: error: 'cleanup_module' specifies less restrictive attribute than its target 'mpc52xx_lpbfifo_driver_exit': 'cold' [-Werror=missing-attributes]
> > 138 | void cleanup_module(void) __attribute__((alias(#exitfn)));
> > | ^~~~~~~~~~~~~~
> > /tmp/e2/build/linux-4.9.180/include/linux/device.h:1360:1: note: in expansion of macro 'module_exit'
> > 1360 | module_exit(__driver##_exit);
> > | ^~~~~~~~~~~
> > /tmp/e2/build/linux-4.9.180/include/linux/platform_device.h:228:2: note: in expansion of macro 'module_driver'
> > 228 | module_driver(__platform_driver, platform_driver_register, \
> > | ^~~~~~~~~~~~~
> > /tmp/e2/build/linux-4.9.180/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c:581:1: note: in expansion of macro 'module_platform_driver'
> > 581 | module_platform_driver(mpc52xx_lpbfifo_driver);
> > | ^~~~~~~~~~~~~~~~~~~~~~
> > In file included from /tmp/e2/build/linux-4.9.180/arch/powerpc/include/asm/io.h:27,
> > from /tmp/e2/build/linux-4.9.180/include/linux/io.h:25,
> > from /tmp/e2/build/linux-4.9.180/include/linux/irq.h:24,
> > from /tmp/e2/build/linux-4.9.180/arch/powerpc/include/asm/hardirq.h:5,
> > from /tmp/e2/build/linux-4.9.180/include/linux/hardirq.h:8,
> > from /tmp/e2/build/linux-4.9.180/include/linux/interrupt.h:12,
> > from /tmp/e2/build/linux-4.9.180/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c:12:
> > /tmp/e2/build/linux-4.9.180/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c:581:24: note: 'cleanup_module' target declared here
> > 581 | module_platform_driver(mpc52xx_lpbfifo_driver);
> > | ^~~~~~~~~~~~~~~~~~~~~~
> > /tmp/e2/build/linux-4.9.180/include/linux/device.h:1356:20: note: in definition of macro 'module_driver'
> > 1356 | static void __exit __driver##_exit(void) \
> > | ^~~~~~~~
> > /tmp/e2/build/linux-4.9.180/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c:581:1: note: in expansion of macro 'module_platform_driver'
> > 581 | module_platform_driver(mpc52xx_lpbfifo_driver);
> > | ^~~~~~~~~~~~~~~~~~~~~~
> > In file included from /tmp/e2/build/linux-4.9.180/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c:17:
> > /tmp/e2/build/linux-4.9.180/include/linux/module.h:132:6: error: 'init_module' specifies less restrictive attribute than its target 'mpc52xx_lpbfifo_driver_init': 'cold' [-Werror=missing-attributes]
> > 132 | int init_module(void) __attribute__((alias(#initfn)));
> > | ^~~~~~~~~~~
> > /tmp/e2/build/linux-4.9.180/include/linux/device.h:1355:1: note: in expansion of macro 'module_init'
> > 1355 | module_init(__driver##_init); \
> > | ^~~~~~~~~~~
> > /tmp/e2/build/linux-4.9.180/include/linux/platform_device.h:228:2: note: in expansion of macro 'module_driver'
> > 228 | module_driver(__platform_driver, platform_driver_register, \
> > | ^~~~~~~~~~~~~
> > /tmp/e2/build/linux-4.9.180/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c:581:1: note: in expansion of macro 'module_platform_driver'
> > 581 | module_platform_driver(mpc52xx_lpbfifo_driver);
> > | ^~~~~~~~~~~~~~~~~~~~~~
> > In file included from /tmp/e2/build/linux-4.9.180/arch/powerpc/include/asm/io.h:27,
> > from /tmp/e2/build/linux-4.9.180/include/linux/io.h:25,
> > from /tmp/e2/build/linux-4.9.180/include/linux/irq.h:24,
> > from /tmp/e2/build/linux-4.9.180/arch/powerpc/include/asm/hardirq.h:5,
> > from /tmp/e2/build/linux-4.9.180/include/linux/hardirq.h:8,
> > from /tmp/e2/build/linux-4.9.180/include/linux/interrupt.h:12,
> > from /tmp/e2/build/linux-4.9.180/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c:12:
> > /tmp/e2/build/linux-4.9.180/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c:581:24: note: 'init_module' target declared here
> > 581 | module_platform_driver(mpc52xx_lpbfifo_driver);
> > | ^~~~~~~~~~~~~~~~~~~~~~
> > /tmp/e2/build/linux-4.9.180/include/linux/device.h:1351:19: note: in definition of macro 'module_driver'
> > 1351 | static int __init __driver##_init(void) \
> > | ^~~~~~~~
> > /tmp/e2/build/linux-4.9.180/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c:581:1: note: in expansion of macro 'module_platform_driver'
> > 581 | module_platform_driver(mpc52xx_lpbfifo_driver);
> > | ^~~~~~~~~~~~~~~~~~~~~~
> >
> >
> > So this needs a6e60d84989fa0e91db7f236eda40453b0e44afa, which needs
> > c0d9782f5b6d7157635ae2fd782a4b27d55a6013, which can't be applied cleanly
> > because a3f8a30f3f0079c7edfc72e329eee8594fb3e3cb is missing in 4.9.
> >
> > I have applied a6e60d84989fa0e91db7f236eda40453b0e44afa and modified it to
> > directly use __attribute__((__copy__(initfn))) and (exitfn), which fixes the
> > build for me.
>
> I just added some patches for gcc9 to 4.14 and 4.19, are you really
> going to want to build it on 4.9?
>
> If so, I can try to fix this up...

And if you want this, you should look at how the backports to 4.14.y
worked, they did not include a3f8a30f3f00 ("Compiler Attributes: use
feature checks instead of version checks"), as that gets really messy...

thanks,

greg k-h