From nobody Sun Sep 14 00:00:45 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77234C27C76 for ; Sat, 28 Jan 2023 09:24:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231222AbjA1JYf (ORCPT ); Sat, 28 Jan 2023 04:24:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232296AbjA1JYe (ORCPT ); Sat, 28 Jan 2023 04:24:34 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60ADB79232; Sat, 28 Jan 2023 01:24:32 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1189EB80113; Sat, 28 Jan 2023 09:24:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D80A4C433EF; Sat, 28 Jan 2023 09:24:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674897869; bh=nGI8NjRBk355G52xy2altpSRn4gf5lig76qHJoACUMo=; h=From:To:Cc:Subject:Date:From; b=uFJJ0GOGmbnaeVLDdP7GZyqOfdPGbYTsic4MyxiT8+DgAqUHAvNnlloZ+Ja+PgDtd pVz6aMRg0cd2p/nubQAL29bEE4uft6aAzxL6/YclJ+cXZV/M/wuu8uo563x+uJcpIC 4Xdm8giSwLmOh7hZExr+O19G+C6Tvx16f5Kw3TF03XXgk8n2LtGqgNih5kL8wXLM3I 83ldRhW9+XECQBMZJTdhgaizBGzy6cx6sr8+cV9rxBeyYRgzcba0GquxMcxGaz2GZH cB1Kup36zeFyxH+3wiGlLbkTX/bEL/5zb1qv+sbpgerbsx1TywG3+Dc9aNww9SQRYD ny9foJbAEt7ZQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH] kbuild: remove --include-dir MAKEFLAG from top Makefile Date: Sat, 28 Jan 2023 18:24:23 +0900 Message-Id: <20230128092424.45105-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" I added $(srctree)/ to some included Makefiles in the following commits: - 3204a7fb98a3 ("kbuild: prefix $(srctree)/ to some included Makefiles") - d82856395505 ("kbuild: do not require sub-make for separate output tree = builds") Those were a preparation for removing --include-dir flag. I have never thought --include-dir useful, rather, it is harmful. For example, run the following commands: $ make -s ARCH=3Dx86 mrproper defconfig $ make ARCH=3Darm O=3Dfoo dtbs make[1]: Entering directory '/tmp/linux/foo' HOSTCC scripts/basic/fixdep Error: kernelrelease not valid - run 'make prepare' to update it UPD include/config/kernel.release make[1]: Leaving directory '/tmp/linux/foo' The first command configures the source tree for x86. The next command tries to build ARM device trees in the separate foo/ directory - this must stop because the directory foo/ has not been configured yet. However, due to --include-dir=3D$(abs_srctree), the top Makefile includes the wrong include/config/auto.conf from the source tree and continues building. Kbuild traverses the directory tree, but of course does not work correctly. The Error message is also pointless - 'make prepare' does not help at all for fixing the issue. This commit fixes more arch Makefile, and finally removes --include-dir from the top Makefile. There are more breakages under drivers/, but I do not volunteer to fix them all. I just moved --include-dir to drivers/Makefile. With this commit, the second command will stop with a sensible message. $ make -s ARCH=3Dx86 mrproper defconfig $ make ARCH=3Darm O=3Dfoo dtbs make[1]: Entering directory '/tmp/linux/foo' SYNC include/config/auto.conf.cmd *** *** The source tree is not clean, please run 'make ARCH=3Darm mrproper' *** in /tmp/linux *** make[2]: *** [../Makefile:646: outputmakefile] Error 1 /tmp/linux/Makefile:770: include/config/auto.conf.cmd: No such file or di= rectory make[1]: *** [/tmp/linux/Makefile:793: include/config/auto.conf.cmd] Erro= r 2 make[1]: Leaving directory '/tmp/linux/foo' make: *** [Makefile:226: __sub-make] Error 2 Signed-off-by: Masahiro Yamada --- Makefile | 8 -------- arch/arm/mach-s3c/Makefile | 4 ++-- arch/ia64/kernel/Makefile | 2 +- arch/mips/Kbuild | 2 +- arch/mips/Makefile.postlink | 2 +- arch/powerpc/Makefile.postlink | 2 +- arch/um/drivers/Makefile | 2 +- arch/um/kernel/Makefile | 2 +- arch/um/kernel/skas/Makefile | 2 +- arch/um/os-Linux/Makefile | 2 +- arch/um/os-Linux/drivers/Makefile | 2 +- arch/um/os-Linux/skas/Makefile | 2 +- arch/x86/Makefile.um | 2 +- arch/x86/um/Makefile | 2 +- arch/x86/um/os-Linux/Makefile | 2 +- drivers/Makefile | 5 +++++ fs/hostfs/Makefile | 2 +- 17 files changed, 21 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index cb1e188b1a91..339121558928 100644 --- a/Makefile +++ b/Makefile @@ -203,14 +203,6 @@ ifneq ($(words $(subst :, ,$(abs_srctree))), 1) $(error source directory cannot contain spaces or colons) endif =20 -ifneq ($(abs_srctree),$(abs_objtree)) -# Look for make include files relative to root of kernel src -# -# --included-dir is added for backward compatibility, but you should not r= ely on -# it. Please add $(srctree)/ prefix to include Makefiles in the source tre= e. -MAKEFLAGS +=3D --include-dir=3D$(abs_srctree) -endif - ifneq ($(filter 3.%,$(MAKE_VERSION)),) # 'MAKEFLAGS +=3D -rR' does not immediately become effective for GNU Make = 3.x # We need to invoke sub-make to avoid implicit rules in the top Makefile. diff --git a/arch/arm/mach-s3c/Makefile b/arch/arm/mach-s3c/Makefile index 7c7d3318fd61..deb44326b828 100644 --- a/arch/arm/mach-s3c/Makefile +++ b/arch/arm/mach-s3c/Makefile @@ -3,11 +3,11 @@ # Copyright 2009 Simtec Electronics =20 ifdef CONFIG_ARCH_S3C24XX -include $(src)/Makefile.s3c24xx +include $(srctree)/$(src)/Makefile.s3c24xx endif =20 ifdef CONFIG_ARCH_S3C64XX -include $(src)/Makefile.s3c64xx +include $(srctree)/$(src)/Makefile.s3c64xx endif =20 # Objects we always build independent of SoC choice diff --git a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile index ae9ff07de4ab..d7e1cabee2ec 100644 --- a/arch/ia64/kernel/Makefile +++ b/arch/ia64/kernel/Makefile @@ -43,4 +43,4 @@ obj-$(CONFIG_ELF_CORE) +=3D elfcore.o CFLAGS_traps.o +=3D -mfixed-range=3Df2-f5,f16-f31 =20 # The gate DSO image is built using a special linker script. -include $(src)/Makefile.gate +include $(srctree)/$(src)/Makefile.gate diff --git a/arch/mips/Kbuild b/arch/mips/Kbuild index 9e8071f0e58f..af2967bffb73 100644 --- a/arch/mips/Kbuild +++ b/arch/mips/Kbuild @@ -7,7 +7,7 @@ subdir-ccflags-y :=3D -Werror endif =20 # platform specific definitions -include arch/mips/Kbuild.platforms +include $(srctree)/arch/mips/Kbuild.platforms obj-y :=3D $(platform-y) =20 # make clean traverses $(obj-) without having included .config, so diff --git a/arch/mips/Makefile.postlink b/arch/mips/Makefile.postlink index 4b1d3ba3a8a2..34e3bd71f3b0 100644 --- a/arch/mips/Makefile.postlink +++ b/arch/mips/Makefile.postlink @@ -10,7 +10,7 @@ PHONY :=3D __archpost __archpost: =20 -include include/config/auto.conf -include scripts/Kbuild.include +include $(srctree)/scripts/Kbuild.include =20 CMD_LS3_LLSC =3D arch/mips/tools/loongson3-llsc-check quiet_cmd_ls3_llsc =3D LLSCCHK $@ diff --git a/arch/powerpc/Makefile.postlink b/arch/powerpc/Makefile.postlink index a6c77f4d32b2..1f860b3c9bec 100644 --- a/arch/powerpc/Makefile.postlink +++ b/arch/powerpc/Makefile.postlink @@ -9,7 +9,7 @@ PHONY :=3D __archpost __archpost: =20 -include include/config/auto.conf -include scripts/Kbuild.include +include $(srctree)/scripts/Kbuild.include =20 quiet_cmd_head_check =3D CHKHEAD $@ cmd_head_check =3D $(CONFIG_SHELL) $(srctree)/arch/powerpc/tools/hea= d_check.sh "$(NM)" "$@" diff --git a/arch/um/drivers/Makefile b/arch/um/drivers/Makefile index e1dc4292bd22..dee6f66353b3 100644 --- a/arch/um/drivers/Makefile +++ b/arch/um/drivers/Makefile @@ -72,4 +72,4 @@ CFLAGS_null.o =3D -DDEV_NULL=3D$(DEV_NULL_PATH) =20 CFLAGS_xterm.o +=3D '-DCONFIG_XTERM_CHAN_DEFAULT_EMULATOR=3D"$(CONFIG_XTER= M_CHAN_DEFAULT_EMULATOR)"' =20 -include arch/um/scripts/Makefile.rules +include $(srctree)/arch/um/scripts/Makefile.rules diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile index 1c2d4b29a3d4..811188be954c 100644 --- a/arch/um/kernel/Makefile +++ b/arch/um/kernel/Makefile @@ -29,7 +29,7 @@ obj-$(CONFIG_GENERIC_PCI_IOMAP) +=3D ioport.o =20 USER_OBJS :=3D config.o =20 -include arch/um/scripts/Makefile.rules +include $(srctree)/arch/um/scripts/Makefile.rules =20 targets :=3D config.c config.tmp capflags.c =20 diff --git a/arch/um/kernel/skas/Makefile b/arch/um/kernel/skas/Makefile index f3d494a4fd9b..f93972a25765 100644 --- a/arch/um/kernel/skas/Makefile +++ b/arch/um/kernel/skas/Makefile @@ -14,4 +14,4 @@ UNPROFILE_OBJS :=3D clone.o =20 KCOV_INSTRUMENT :=3D n =20 -include arch/um/scripts/Makefile.rules +include $(srctree)/arch/um/scripts/Makefile.rules diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile index 77ac50baa3f8..544e0b344c75 100644 --- a/arch/um/os-Linux/Makefile +++ b/arch/um/os-Linux/Makefile @@ -18,4 +18,4 @@ USER_OBJS :=3D $(user-objs-y) elf_aux.o execvp.o file.o h= elper.o irq.o \ main.o mem.o process.o registers.o sigio.o signal.o start_up.o time.o \ tty.o umid.o util.o =20 -include arch/um/scripts/Makefile.rules +include $(srctree)/arch/um/scripts/Makefile.rules diff --git a/arch/um/os-Linux/drivers/Makefile b/arch/um/os-Linux/drivers/M= akefile index d79e75f1b69a..cf2d75bb1884 100644 --- a/arch/um/os-Linux/drivers/Makefile +++ b/arch/um/os-Linux/drivers/Makefile @@ -10,4 +10,4 @@ obj-y =3D obj-$(CONFIG_UML_NET_ETHERTAP) +=3D ethertap.o obj-$(CONFIG_UML_NET_TUNTAP) +=3D tuntap.o =20 -include arch/um/scripts/Makefile.rules +include $(srctree)/arch/um/scripts/Makefile.rules diff --git a/arch/um/os-Linux/skas/Makefile b/arch/um/os-Linux/skas/Makefile index c4566e788815..75f11989d2e9 100644 --- a/arch/um/os-Linux/skas/Makefile +++ b/arch/um/os-Linux/skas/Makefile @@ -7,4 +7,4 @@ obj-y :=3D mem.o process.o =20 USER_OBJS :=3D $(obj-y) =20 -include arch/um/scripts/Makefile.rules +include $(srctree)/arch/um/scripts/Makefile.rules diff --git a/arch/x86/Makefile.um b/arch/x86/Makefile.um index b3c1ae084180..b89e2e0024c5 100644 --- a/arch/x86/Makefile.um +++ b/arch/x86/Makefile.um @@ -17,7 +17,7 @@ LDS_EXTRA :=3D -Ui386 export LDS_EXTRA =20 # First of all, tune CFLAGS for the specific CPU. This actually sets cflag= s-y. -include arch/x86/Makefile_32.cpu +include $(srctree)/arch/x86/Makefile_32.cpu =20 # prevent gcc from keeping the stack 16 byte aligned. Taken from i386. cflags-y +=3D $(call cc-option,-mpreferred-stack-boundary=3D2) diff --git a/arch/x86/um/Makefile b/arch/x86/um/Makefile index 3d5cd2e57820..ee89f6bb9242 100644 --- a/arch/x86/um/Makefile +++ b/arch/x86/um/Makefile @@ -48,4 +48,4 @@ include/generated/user_constants.h: $(obj)/user-offsets.s= FORCE UNPROFILE_OBJS :=3D stub_segv.o CFLAGS_stub_segv.o :=3D $(CFLAGS_NO_HARDENING) =20 -include arch/um/scripts/Makefile.rules +include $(srctree)/arch/um/scripts/Makefile.rules diff --git a/arch/x86/um/os-Linux/Makefile b/arch/x86/um/os-Linux/Makefile index 253bfb8cb702..ae169125d03f 100644 --- a/arch/x86/um/os-Linux/Makefile +++ b/arch/x86/um/os-Linux/Makefile @@ -10,4 +10,4 @@ obj-$(CONFIG_64BIT) +=3D prctl.o =20 USER_OBJS :=3D $(obj-y) =20 -include arch/um/scripts/Makefile.rules +include $(srctree)/arch/um/scripts/Makefile.rules diff --git a/drivers/Makefile b/drivers/Makefile index bdf1c66141c9..62a9cb403a1a 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -6,6 +6,11 @@ # Rewritten to use lists instead of if-statements. # =20 +# Some driver Makefiles miss $(srctree)/ for include directive. +ifdef building_out_of_srctree +MAKEFLAGS +=3D --include-dir=3D$(srctree) +endif + obj-y +=3D irqchip/ obj-y +=3D bus/ =20 diff --git a/fs/hostfs/Makefile b/fs/hostfs/Makefile index d5beaffad43b..587bcd6e50a3 100644 --- a/fs/hostfs/Makefile +++ b/fs/hostfs/Makefile @@ -8,4 +8,4 @@ hostfs-objs :=3D hostfs_kern.o hostfs_user.o obj-y :=3D obj-$(CONFIG_HOSTFS) +=3D hostfs.o =20 -include arch/um/scripts/Makefile.rules +include $(srctree)/arch/um/scripts/Makefile.rules --=20 2.34.1