mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	kbuild: rebuild GCC plugins when the compiler is upgraded
Linus reported a build error due to the GCC plugin incompatibility
when the compiler is upgraded. [1]
GCC plugins are tied to a particular GCC version. So, they must be
rebuilt when the compiler is upgraded.
This seems to be a long-standing flaw since the initial support of
GCC plugins.
Extend commit 8b59cd81dc ("kbuild: ensure full rebuild when the
compiler is updated"), so that GCC plugins are covered by the
compiler upgrade detection.
[1]: https://lore.kernel.org/lkml/CAHk-=wieoN5ttOy7SnsGwZv+Fni3R6m-Ut=oxih6bbZ28G+4dw@mail.gmail.com/
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
			
			
This commit is contained in:
		
							parent
							
								
									1f09af0625
								
							
						
					
					
						commit
						ce6ed1c4c9
					
				
					 5 changed files with 20 additions and 6 deletions
				
			
		
							
								
								
									
										1
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								Makefile
									
									
									
									
									
								
							| 
						 | 
					@ -479,6 +479,7 @@ USERINCLUDE    := \
 | 
				
			||||||
		-I$(objtree)/arch/$(SRCARCH)/include/generated/uapi \
 | 
							-I$(objtree)/arch/$(SRCARCH)/include/generated/uapi \
 | 
				
			||||||
		-I$(srctree)/include/uapi \
 | 
							-I$(srctree)/include/uapi \
 | 
				
			||||||
		-I$(objtree)/include/generated/uapi \
 | 
							-I$(objtree)/include/generated/uapi \
 | 
				
			||||||
 | 
					                -include $(srctree)/include/linux/compiler-version.h \
 | 
				
			||||||
                -include $(srctree)/include/linux/kconfig.h
 | 
					                -include $(srctree)/include/linux/kconfig.h
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Use LINUXINCLUDE when you must reference the include/ directory.
 | 
					# Use LINUXINCLUDE when you must reference the include/ directory.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										14
									
								
								include/linux/compiler-version.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								include/linux/compiler-version.h
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,14 @@
 | 
				
			||||||
 | 
					/* SPDX-License-Identifier: GPL-2.0-only */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef  __LINUX_COMPILER_VERSION_H
 | 
				
			||||||
 | 
					#error "Please do not include <linux/compiler-version.h>. This is done by the build system."
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#define __LINUX_COMPILER_VERSION_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * This header exists to force full rebuild when the compiler is upgraded.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * When fixdep scans this, it will find this string "CONFIG_CC_VERSION_TEXT"
 | 
				
			||||||
 | 
					 * and add dependency on include/config/cc/version/text.h, which is touched
 | 
				
			||||||
 | 
					 * by Kconfig when the version string from the compiler changes.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
| 
						 | 
					@ -2,8 +2,6 @@
 | 
				
			||||||
#ifndef __LINUX_KCONFIG_H
 | 
					#ifndef __LINUX_KCONFIG_H
 | 
				
			||||||
#define __LINUX_KCONFIG_H
 | 
					#define __LINUX_KCONFIG_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* CONFIG_CC_VERSION_TEXT (Do not delete this comment. See help in Kconfig) */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <generated/autoconf.h>
 | 
					#include <generated/autoconf.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_CPU_BIG_ENDIAN
 | 
					#ifdef CONFIG_CPU_BIG_ENDIAN
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,10 +20,10 @@ config CC_VERSION_TEXT
 | 
				
			||||||
	    When the compiler is updated, Kconfig will be invoked.
 | 
						    When the compiler is updated, Kconfig will be invoked.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  - Ensure full rebuild when the compiler is updated
 | 
						  - Ensure full rebuild when the compiler is updated
 | 
				
			||||||
	    include/linux/kconfig.h contains this option in the comment line so
 | 
						    include/linux/compiler-version.h contains this option in the comment
 | 
				
			||||||
	    fixdep adds include/config/cc/version/text.h into the auto-generated
 | 
						    line so fixdep adds include/config/cc/version/text.h into the
 | 
				
			||||||
	    dependency. When the compiler is updated, syncconfig will touch it
 | 
						    auto-generated dependency. When the compiler is updated, syncconfig
 | 
				
			||||||
	    and then every file will be rebuilt.
 | 
						    will touch it and then every file will be rebuilt.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
config CC_IS_GCC
 | 
					config CC_IS_GCC
 | 
				
			||||||
	def_bool $(success,test "$(cc-name)" = GCC)
 | 
						def_bool $(success,test "$(cc-name)" = GCC)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,6 +22,7 @@ always-y += $(GCC_PLUGIN)
 | 
				
			||||||
GCC_PLUGINS_DIR = $(shell $(CC) -print-file-name=plugin)
 | 
					GCC_PLUGINS_DIR = $(shell $(CC) -print-file-name=plugin)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
plugin_cxxflags	= -Wp,-MMD,$(depfile) $(KBUILD_HOSTCXXFLAGS) -fPIC \
 | 
					plugin_cxxflags	= -Wp,-MMD,$(depfile) $(KBUILD_HOSTCXXFLAGS) -fPIC \
 | 
				
			||||||
 | 
							  -include $(srctree)/include/linux/compiler-version.h \
 | 
				
			||||||
		   -I $(GCC_PLUGINS_DIR)/include -I $(obj) -std=gnu++11 \
 | 
							   -I $(GCC_PLUGINS_DIR)/include -I $(obj) -std=gnu++11 \
 | 
				
			||||||
		   -fno-rtti -fno-exceptions -fasynchronous-unwind-tables \
 | 
							   -fno-rtti -fno-exceptions -fasynchronous-unwind-tables \
 | 
				
			||||||
		   -ggdb -Wno-narrowing -Wno-unused-variable \
 | 
							   -ggdb -Wno-narrowing -Wno-unused-variable \
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue