mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-03 18:20:25 +02:00 
			
		
		
		
	kbuild: check for wrong use of CFLAGS
External modules have in a few cases modifed gcc option by modifying CFLAGS. This has never been documented and was a bad practice. With the check to use KBUILD_CFLAGS it will no longer work so we better error out and tell what was wrong as a service to the external module users. This check can be overruled if KBUILD_NOPEDANTIC is set to something. Addid this possibility may allow older external module to build without any code modifications but potentially only loosing some un-important gcc options. Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
This commit is contained in:
		
							parent
							
								
									a0f97e06a4
								
							
						
					
					
						commit
						0c53c8e6eb
					
				
					 1 changed files with 11 additions and 1 deletions
				
			
		| 
						 | 
					@ -28,10 +28,20 @@ EXTRA_LDFLAGS  :=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
include scripts/Kbuild.include
 | 
					include scripts/Kbuild.include
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# For backward compatibility check that these variables does not change
 | 
				
			||||||
 | 
					save-cflags := $(CFLAGS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# The filename Kbuild has precedence over Makefile
 | 
					# The filename Kbuild has precedence over Makefile
 | 
				
			||||||
kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
 | 
					kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
 | 
				
			||||||
include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile)
 | 
					kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)
 | 
				
			||||||
 | 
					include $(kbuild-file)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# If the save-* variables changed error out
 | 
				
			||||||
 | 
					ifeq ($(KBUILD_NOPEDANTIC),)
 | 
				
			||||||
 | 
					        ifneq ("$(save-cflags)","$(CFLAGS)")
 | 
				
			||||||
 | 
					                $(error CFLAGS was changed in "$(kbuild-file)". Fix it to use EXTRA_CFLAGS)
 | 
				
			||||||
 | 
					        endif
 | 
				
			||||||
 | 
					endif
 | 
				
			||||||
include scripts/Makefile.lib
 | 
					include scripts/Makefile.lib
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ifdef host-progs
 | 
					ifdef host-progs
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue