Skip to contentSkip to conversation

2.4.12 optionally prevent kbuild reading /usr/include

PATCH New Keith Owens 1 participant 1 message Oct 16, 2001

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.4.12 optionally prevent kbuild reading /usr/include

A few bits of kernel code are incorrectly reading from /usr/include, giving different results on different distributions. kbuild 2.5 will prevent this, all include files must be in the kernel tree. The patch below (for 2.4.12 but fits 2.4.13-pre3) defines kbuild_2_4_nostdinc. Linus, please add to 2.4.13-prex.

The various maintainers can optionally check that their code is not reading from outside the kernel, see the comments in the patch. I strongly recommend that maintainers check their code now, even if it is only on their own machine. There is no need to patch the sub Makefiles in Linus's tree, as long as the code has been tested.

Based on a suggestion by Christoph Hellwig.

Index: 12.1/Makefile

Makefile Tue, 16 Oct 2001 17:08:15 +1000 kaos (linux-2.4/T/c/50_Makefile 1.1.2.15.1.2.2.25.2.2.1.17.1.4.1.29.1.4 644) renamed from Makefile Thu, 11 Oct 2001 20:11:18 +1000 kaos (linux-2.4/T/c/50_Makefile 1.1.2.15.1.2.2.25.2.2.1.17.1.4.1.29.1.4 644) +10 -0
@@ -240,6 +240,16 @@ MRPROPER_DIRS = \
 
 include arch/$(ARCH)/Makefile
 
+# Optional cflags for kbuild 2.4, to prevent individual files or an entire
+# directory including files from outside the kernel.  To control an individual
+# file, use CFLAGS_foo.o += $(kbuild_2_4_nostdinc), to control an entire
+# directory use EXTRA_CFLAGS += $(kbuild_2_4_nostdinc).  In kbuild 2.5 the
+# default is to forbid includes from outside the kernel tree, you can use this
+# variable in kbuild 2.4 to ensure that your code is clean before 2.5.  KAO.
+
+kbuild_2_4_nostdinc     := -nostdinc $(shell $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp')
+export kbuild_2_4_nostdinc
+
 export	CPPFLAGS CFLAGS AFLAGS
 
 export	NETWORKS DRIVERS LIBS HEAD LDFLAGS LINKFLAGS MAKEBOOT ASFLAGS