From patchwork Mon Jul 1 00:58:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 168194 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2264160ilk; Sun, 30 Jun 2019 18:01:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyw35GzYwjtlxJhVV7YnfQS8jJQiEmROc4kHF0poVyHPcDNuPKHEJ+jgaYxGRpNl8bVmgOG X-Received: by 2002:a17:90a:37ac:: with SMTP id v41mr26467299pjb.6.1561942860380; Sun, 30 Jun 2019 18:01:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561942860; cv=none; d=google.com; s=arc-20160816; b=ZRM+Vbxhk136c3vDu/VqTnUNhhoVNkeaUpICKzgI3KkE3sMCJrTQgOI/FLLkkqyVWt ERTHVZPDk2qGqWjTECF6CvpBut0VQ6cnTvfxFkxOe12DRi/ZlimBix54I3X+xwPPUiQH osX2qqNSe2XPvP4Oaul2gj7OzIt/cdMtAla+P05sJPq9Rnw0V7Mmw1rh/sLk9ETV+E10 7McDfdEF4HNgR1gRvAgTZUcggVy7RAdwZdc/Fu1P7BkoHfIPqxS37e/YnCO+bhQJguAx NPgDJNMoGH87gtKP1j3PAYa+AIgCFWPTOsJFflGTR1KE1nyAEr/pmxsEY8sOjUNwBG+5 e7qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=oooXViC9T86N1kehUCLZdnfYF06+I/OFxyRd+VRUuLY=; b=kTNKwrWnKSFyuAd/VsTv/CZYS2R/2oeiU8mqLp9rpND9KnQYyI543VFHz7luj6x+WT WvFUSjCy6A1HTgOpaTSmzzVcapuAttQQLdNXm3DE6dOu/v3tFmID2mBC/3kJmCaqBJRk ppNZTzZYW6tJwzpUjIqKdl6LTUvoCwK9unSe2B7S1W0yBtRH8yBH1MpBTrf8d1YEkbdo vpdnas2BOFRpFG0CMxYdxXcIkzvxQiir0utqTs9aiebDnxneB1Je55qVUyEUEamJoyY4 xTTGtZhAP1phvfdIEkwsMTQhqRBxYrMVVEFPhWlqehNAu0rMxSG/kJTJukBF565Ua2kl 6zXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=ggO1KhAu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g7si8967925plb.29.2019.06.30.18.01.00; Sun, 30 Jun 2019 18:01:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=ggO1KhAu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727102AbfGABA6 (ORCPT + 30 others); Sun, 30 Jun 2019 21:00:58 -0400 Received: from conuserg-12.nifty.com ([210.131.2.79]:61398 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726040AbfGABA6 (ORCPT ); Sun, 30 Jun 2019 21:00:58 -0400 Received: from grover.flets-west.jp (softbank126125154139.bbtec.net [126.125.154.139]) (authenticated) by conuserg-12.nifty.com with ESMTP id x610x4fs000634; Mon, 1 Jul 2019 09:59:06 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com x610x4fs000634 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1561942747; bh=oooXViC9T86N1kehUCLZdnfYF06+I/OFxyRd+VRUuLY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ggO1KhAuF+Nehk+KyS4QRMj0B08P+J7jfF5cmz0EDGcz93utHNiduH2qvMY9Yto6q 8/8ceCQiq04MtWkng9ByWDTZzTQAdwv1azeeA9+fDDsAkPRmxhIdUzNDLOwLt0pgqw OeIYQh9Hh1HBHgW2VrPzEQNXTAsN/qGX5sYXWUSVJuL66Xpe4D3w1tpS1HgzmTgLxV 7ZBfSW3v7jSdkeYemHkv/P2vDOdZhI1j8QXqbvz2Z4Uc1W/YQ4S7WHuYXLjZH1XLOn mGU2UgfjiOCMsbAbahCqhQjLY55blB0RGnxiuotFQKfK68tOhGR+ftVWS+kQSLQ8Pw jB+D0zrHWlh4g== X-Nifty-SrcIP: [126.125.154.139] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Joel Fernandes , Masahiro Yamada , Song Liu , "David S. Miller" , Alexei Starovoitov , netdev@vger.kernel.org, Yonghong Song , linux-kernel@vger.kernel.org, Martin KaFai Lau , bpf@vger.kernel.org, Daniel Borkmann Subject: [PATCH 1/7] init/Kconfig: add CONFIG_CC_CAN_LINK Date: Mon, 1 Jul 2019 09:58:39 +0900 Message-Id: <20190701005845.12475-2-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190701005845.12475-1-yamada.masahiro@socionext.com> References: <20190701005845.12475-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, scripts/cc-can-link.sh is run just for BPFILTER_UMH, but defining CC_CAN_LINK will be useful in other places. Signed-off-by: Masahiro Yamada --- Changes in v4: - New patch Changes in v3: None Changes in v2: None init/Kconfig | 3 +++ net/bpfilter/Kconfig | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/init/Kconfig b/init/Kconfig index df5bba27e3fe..2e9813daa2c1 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -24,6 +24,9 @@ config CLANG_VERSION int default $(shell,$(srctree)/scripts/clang-version.sh $(CC)) +config CC_CAN_LINK + def_bool $(success,$(srctree)/scripts/cc-can-link.sh $(CC)) + config CC_HAS_ASM_GOTO def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC)) diff --git a/net/bpfilter/Kconfig b/net/bpfilter/Kconfig index 91f9d878165e..fed9290e3b41 100644 --- a/net/bpfilter/Kconfig +++ b/net/bpfilter/Kconfig @@ -9,7 +9,7 @@ menuconfig BPFILTER if BPFILTER config BPFILTER_UMH tristate "bpfilter kernel module with user mode helper" - depends on $(success,$(srctree)/scripts/cc-can-link.sh $(CC)) + depends on CC_CAN_LINK default m help This builds bpfilter kernel module with embedded user mode helper From patchwork Mon Jul 1 00:58:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 168195 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2264716ilk; Sun, 30 Jun 2019 18:01:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqyk5U1HbrmmNVOWt58AshZo46hzWJz7xTEECrPYyEGDbCo5UGwKpDMYqwISdU/dYy6jJ/b1 X-Received: by 2002:a63:130f:: with SMTP id i15mr17620608pgl.158.1561942891293; Sun, 30 Jun 2019 18:01:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561942891; cv=none; d=google.com; s=arc-20160816; b=PQeX7MOWB2/bwBosKPKAgbss5fhvuC08/oNbCZMZMPqmBVX845ggdXodmuWkadx1dJ uDW9kSBiDtxO1ms931s7J3jNPImrmWhBGbUkzo1H+rDJKC3RXtFDsok9g+3Tx8IjTinW 0MKgX/+nZ5YMRD8uyyIpU5OKgFCnOTCgPmTNPwIXFCzhPr5SPwYaSP3gcfpT7lp0QHtn 5e+hiu7f3XOhSpCuombmslPr0hc0EYR0JmQkqrKJ2QQYBuJ2KJ2semNZdAjT7+YANJsR Dy5UsEwRsOcMyFMCkDeRGrvKXL5vEjte5lx7wpO1TQ+Mohg3ds1jejfHn+4MYpYyRZmJ oBXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=MKeZdTTRfl86Y7P6MzXWSAuIsFqD3wq5RLZjRa1I1Lw=; b=unLiI6E+sTPeVXQDP/1W3wyu8PtBXXmn3Qp+W83TdO+h3V8D6JLRUJjBkOUEY63ICG 0fx6OsWjTs8cUcpnGglEX5DhgfEafoUcpASCr5cGmPm8lfARX1TjbuQa14RYI0fucqVi j3qbuN5Fz+/rhJrzhNCS2TOQBfSnlKpN0X6ojzMRBeHM3aQ27I5dsal1fgX9qxaEnO8X 77GkSTs2Jn5kQDDwhjBvqyKz22Y9kRbasWYeG0wtDSBO84J+kyzh7xF2W7ueq2s0Bjsi 4/0+YjMcqE0+1UZK3GVha5tYWXV5AqZFLu9CyrYrxYbjZ+XE0FyaNY8sJDEs55OWKkah l1Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=ziU+h4rJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t191si4182989pgd.370.2019.06.30.18.01.30; Sun, 30 Jun 2019 18:01:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=ziU+h4rJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727168AbfGABB3 (ORCPT + 30 others); Sun, 30 Jun 2019 21:01:29 -0400 Received: from conuserg-12.nifty.com ([210.131.2.79]:62385 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726040AbfGABB3 (ORCPT ); Sun, 30 Jun 2019 21:01:29 -0400 Received: from grover.flets-west.jp (softbank126125154139.bbtec.net [126.125.154.139]) (authenticated) by conuserg-12.nifty.com with ESMTP id x610x4ft000634; Mon, 1 Jul 2019 09:59:07 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com x610x4ft000634 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1561942748; bh=MKeZdTTRfl86Y7P6MzXWSAuIsFqD3wq5RLZjRa1I1Lw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ziU+h4rJWJvBru7ZdtTN3A5VNXFG3Pr048ghe0KATQ698wjk2Wpz6/MYAs4RIoTl6 ZXHX62tCknYKHXGyyw4obJDCVa3hg97aj5/o1K9TAlaIxoZcpM/J7aJ6XgLG9U2eeK FBJ/VCvX3UyrMSrjBISljHjV29nWC20Kzd24DcAJ+jmSqHOYk6hmrtNRCG8cHPyYRL /j1kdEWCNn544fJdrVlL4pOib4nOeVcTWIakaIQ3ejmP0bf1alUm93sVrwLpzTkvgq UNXzuM3OCm5oqkHte62It2zBAnQBPqr4PuJbzuiC6w2k+t9EA+aEojhWXDewuQ4iTI 84kvLpsw2RyZw== X-Nifty-SrcIP: [126.125.154.139] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Joel Fernandes , Masahiro Yamada , Song Liu , Alexei Starovoitov , netdev@vger.kernel.org, Yonghong Song , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Michal Marek , Martin KaFai Lau , Palmer Dabbelt , bpf@vger.kernel.org, Daniel Borkmann , Albert Ou Subject: [PATCH 2/7] kbuild: compile-test exported headers to ensure they are self-contained Date: Mon, 1 Jul 2019 09:58:40 +0900 Message-Id: <20190701005845.12475-3-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190701005845.12475-1-yamada.masahiro@socionext.com> References: <20190701005845.12475-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Multiple people have suggested compile-testing UAPI headers to ensure they can be really included from user-space. "make headers_check" is obviously not enough to catch bugs, and we often leak unresolved references to user-space. Use the new header-test-y syntax to implement it. Please note exported headers are compile-tested with a completely different set of compiler flags. The header search path is set to $(objtree)/usr/include since exported headers should not include unexported ones. We use -std=gnu89 for the kernel space since the kernel code highly depends on GNU extensions. On the other hand, UAPI headers should be written in more standardized C, so they are compiled with -std=c90. This will emit errors if C++ style comments, the keyword 'inline', etc. are used. Please use C style comments (/* ... */), '__inline__', etc. in UAPI headers. There is additional compiler requirement to enable this test because many of UAPI headers include , , , etc. directly or indirectly. You cannot use kernel.org pre-built toolchains [1] since they lack . I reused CONFIG_CC_CAN_LINK to check the system header availability. The intention is slightly different, but a compiler that can link userspace programs provide system headers. For now, a lot of headers need to be excluded because they cannot be compiled standalone, but this is a good start point. [1] https://mirrors.edge.kernel.org/pub/tools/crosstool/index.html Signed-off-by: Masahiro Yamada Reviewed-by: Sam Ravnborg --- Changes in v4: - Sort the blacklist alphabetically - Add a little more comments - Remove scripts/cc-system-headers.sh and reuse CC_CAN_LINK Changes in v3: None Changes in v2: - Add CONFIG_CPU_{BIG,LITTLE}_ENDIAN guard to avoid build error - Use 'header-test-' instead of 'no-header-test' - Avoid weird 'find' warning when cleaning Makefile | 2 +- init/Kconfig | 10 ++++ usr/.gitignore | 1 - usr/Makefile | 2 + usr/include/.gitignore | 3 + usr/include/Makefile | 131 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 usr/include/.gitignore create mode 100644 usr/include/Makefile -- 2.17.1 diff --git a/Makefile b/Makefile index 1f35aca4fe05..f23516980796 100644 --- a/Makefile +++ b/Makefile @@ -1363,7 +1363,7 @@ CLEAN_DIRS += $(MODVERDIR) include/ksym CLEAN_FILES += modules.builtin.modinfo # Directories & files removed with 'make mrproper' -MRPROPER_DIRS += include/config usr/include include/generated \ +MRPROPER_DIRS += include/config include/generated \ arch/$(SRCARCH)/include/generated .tmp_objdiff MRPROPER_FILES += .config .config.old .version \ Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \ diff --git a/init/Kconfig b/init/Kconfig index 2e9813daa2c1..74192de8ada6 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -108,6 +108,16 @@ config HEADER_TEST If you are a developer or tester and want to ensure the requested headers are self-contained, say Y here. Otherwise, choose N. +config UAPI_HEADER_TEST + bool "Compile test UAPI headers" + depends on HEADER_TEST && HEADERS_INSTALL && CC_CAN_LINK + help + Compile test headers exported to user-space to ensure they are + self-contained, i.e. compilable as standalone units. + + If you are a developer or tester and want to ensure the exported + headers are self-contained, say Y here. Otherwise, choose N. + config LOCALVERSION string "Local version - append to kernel release" help diff --git a/usr/.gitignore b/usr/.gitignore index 8e48117a3f3d..be5eae1df7eb 100644 --- a/usr/.gitignore +++ b/usr/.gitignore @@ -7,4 +7,3 @@ initramfs_data.cpio.gz initramfs_data.cpio.bz2 initramfs_data.cpio.lzma initramfs_list -include diff --git a/usr/Makefile b/usr/Makefile index 4a70ae43c9cb..6a89eb019275 100644 --- a/usr/Makefile +++ b/usr/Makefile @@ -56,3 +56,5 @@ $(deps_initramfs): klibcdirs $(obj)/$(datafile_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/$(datafile_d_y) $(call if_changed,initfs) + +subdir-$(CONFIG_UAPI_HEADER_TEST) += include diff --git a/usr/include/.gitignore b/usr/include/.gitignore new file mode 100644 index 000000000000..a0991ff4402b --- /dev/null +++ b/usr/include/.gitignore @@ -0,0 +1,3 @@ +* +!.gitignore +!Makefile diff --git a/usr/include/Makefile b/usr/include/Makefile new file mode 100644 index 000000000000..0f9f92c6016a --- /dev/null +++ b/usr/include/Makefile @@ -0,0 +1,131 @@ +# SPDX-License-Identifier: GPL-2.0-only + +# Unlike the kernel space, exported headers are written in standard C. +# - Forbid C++ style comments +# - Use '__inline__', '__asm__' instead of 'inline', 'asm' +# +# -std=c90 (equivalent to -ansi) catches the violation of those. +# We cannot go as far as adding -Wpedantic since it emits too many warnings. +UAPI_CFLAGS := -std=c90 -Wall -Werror=implicit-function-declaration + +override c_flags = $(UAPI_CFLAGS) -Wp,-MD,$(depfile) -I$(objtree)/usr/include + +# The following are excluded for now because they fail to build. +# +# Do not add a new header to the blacklist without legitimate reason. +# Please consider to fix the header first. +# +# Sorted alphabetically. +header-test- += asm/ipcbuf.h +header-test- += asm/msgbuf.h +header-test- += asm/sembuf.h +header-test- += asm/shmbuf.h +header-test- += asm/signal.h +header-test- += asm/ucontext.h +header-test- += drm/vmwgfx_drm.h +header-test- += linux/am437x-vpfe.h +header-test- += linux/android/binder.h +header-test- += linux/android/binderfs.h +header-test-$(CONFIG_CPU_BIG_ENDIAN) += linux/byteorder/big_endian.h +header-test-$(CONFIG_CPU_LITTLE_ENDIAN) += linux/byteorder/little_endian.h +header-test- += linux/coda.h +header-test- += linux/coda_psdev.h +header-test- += linux/dvb/audio.h +header-test- += linux/dvb/osd.h +header-test- += linux/elfcore.h +header-test- += linux/errqueue.h +header-test- += linux/fsmap.h +header-test- += linux/hdlc/ioctl.h +header-test- += linux/ivtv.h +header-test- += linux/jffs2.h +header-test- += linux/kexec.h +header-test- += linux/matroxfb.h +header-test- += linux/netfilter_bridge/ebtables.h +header-test- += linux/netfilter_ipv4/ipt_LOG.h +header-test- += linux/netfilter_ipv6/ip6t_LOG.h +header-test- += linux/nfc.h +header-test- += linux/nilfs2_ondisk.h +header-test- += linux/omap3isp.h +header-test- += linux/omapfb.h +header-test- += linux/patchkey.h +header-test- += linux/phonet.h +header-test- += linux/reiserfs_xattr.h +header-test- += linux/scc.h +header-test- += linux/sctp.h +header-test- += linux/signal.h +header-test- += linux/sysctl.h +header-test- += linux/usb/audio.h +header-test- += linux/v4l2-mediabus.h +header-test- += linux/v4l2-subdev.h +header-test- += linux/videodev2.h +header-test- += linux/vm_sockets.h +header-test- += misc/ocxl.h +header-test- += mtd/mtd-abi.h +header-test- += scsi/scsi_bsg_fc.h +header-test- += scsi/scsi_netlink.h +header-test- += scsi/scsi_netlink_fc.h +header-test- += sound/asequencer.h +header-test- += sound/asoc.h +header-test- += sound/asound.h +header-test- += sound/compress_offload.h +header-test- += sound/emu10k1.h +header-test- += sound/sfnt_info.h +header-test- += sound/sof/eq.h +header-test- += sound/sof/fw.h +header-test- += sound/sof/header.h +header-test- += sound/sof/manifest.h +header-test- += sound/sof/trace.h +header-test- += xen/evtchn.h +header-test- += xen/gntdev.h +header-test- += xen/privcmd.h + +# More headers are broken in some architectures + +ifeq ($(SRCARCH),arc) +header-test- += linux/bpf_perf_event.h +endif + +ifeq ($(SRCARCH),ia64) +header-test- += asm/setup.h +header-test- += asm/sigcontext.h +header-test- += asm/perfmon.h +header-test- += asm/perfmon_default_smpl.h +header-test- += linux/if_bonding.h +endif + +ifeq ($(SRCARCH),mips) +header-test- += asm/stat.h +endif + +ifeq ($(SRCARCH),powerpc) +header-test- += asm/stat.h +header-test- += linux/bpf_perf_event.h +endif + +ifeq ($(SRCARCH),riscv) +header-test- += linux/bpf_perf_event.h +endif + +ifeq ($(SRCARCH),s390) +header-test- += asm/runtime_instr.h +header-test- += asm/zcrypt.h +endif + +ifeq ($(SRCARCH),sparc) +header-test- += asm/stat.h +header-test- += asm/uctx.h +header-test- += asm/fbio.h +header-test- += asm/openpromio.h +endif + +# asm-generic/*.h is used by asm/*.h, and should not be included directly +header-test- += asm-generic/% + +# The rest are compile-tested +header-test-y += $(filter-out $(header-test-), \ + $(patsubst $(obj)/%,%, $(wildcard \ + $(addprefix $(obj)/, *.h */*.h */*/*.h */*/*/*.h)))) + +# For GNU Make <= 4.2.1, $(wildcard $(obj)/*/) matches to not only directories +# but also regular files. Use $(filter %/, ...) just in case. +clean-dirs += $(patsubst $(obj)/%/,%,$(filter %/, $(wildcard $(obj)/*/))) From patchwork Mon Jul 1 00:58:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 168193 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2263762ilk; Sun, 30 Jun 2019 18:00:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHA66cREFLoJE6irm2bX74u9l2NChNU7vK/B7RQDv8N8PQg/r7jGiDZliFEGQBNkhx87JD X-Received: by 2002:a63:ab08:: with SMTP id p8mr4103202pgf.340.1561942833218; Sun, 30 Jun 2019 18:00:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561942833; cv=none; d=google.com; s=arc-20160816; b=o4cx466SZXdtPvl9h82ldSp9juy3+plDO2zOO0jFw6qOagpKAjc1xSpKg4drsWAu59 Q/h8xQ8GOk93wkoSTQfZij5J8ozoENkkEqUtKDlrPQA69cm6J7WlqOs2VZTK8Bmj3fs6 ugpaid2p+dsyrWf76u4uqyeOSHLHfEtaGdAt95pWxg/0PVqm2mcqg4/2WXTvBt0ILIm4 pAIZ5puMngTXYhU7kSDSiBQ0rigy1yi+GYPR6agWemh+PujwjZFJVdd9mIizD9Gf/+N6 GF7NXNbaHBjQaat6XiuuzC43bM0qiZB+67yFT3Tjr992TsxU4jS9yTVC4fCTNpn6LcHX hfiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=rM1OWC0NYjNzccPK//0F4tGu6ozRHQZMCkGhKTcJdWI=; b=hcY4xJjIekg30wPmvDeSUQER0630vIVWrbSlP/qlE5tY3uCQfNAw9Vaf7XkYKcZkyj 55xfY+XcQzJe0UnxZwrjzkBXQEOFeJa2oJetCOOsXXhf/VUH7k+jry4rD3CcWMCYQzdR fR5ojJ2p+ED/BgeghrqL5VlzJE/n2lBaUcC61ied2DBdPSZIv5UM8AV99JN33BoUMt7p diclBARJIxer5Bnn3D/RMIeTPQ348xbBcwKBjWku2jeQDOZm7SZhMIsV4/VIeHcw9XhR vtNlp2it6OsnAONnu56ZntQMmXb2hIL+qBXHbYi1Z6ReMBJjphI++opkoenbhb5/6SBz g2gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=oXq9dvO3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t2si8479736ply.133.2019.06.30.18.00.32; Sun, 30 Jun 2019 18:00:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=oXq9dvO3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727036AbfGABAZ (ORCPT + 30 others); Sun, 30 Jun 2019 21:00:25 -0400 Received: from conuserg-12.nifty.com ([210.131.2.79]:60232 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726563AbfGABAX (ORCPT ); Sun, 30 Jun 2019 21:00:23 -0400 Received: from grover.flets-west.jp (softbank126125154139.bbtec.net [126.125.154.139]) (authenticated) by conuserg-12.nifty.com with ESMTP id x610x4fu000634; Mon, 1 Jul 2019 09:59:09 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com x610x4fu000634 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1561942749; bh=rM1OWC0NYjNzccPK//0F4tGu6ozRHQZMCkGhKTcJdWI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oXq9dvO3uZ/pRTSUNd0h3q4yicM3BbqFnLQVqEjcb7HmyXctmNJ2nn+yl2Ty+1Uov ImA9EKvIFO/neA8oRXsMtqtXZC1PC1cmt5YhrSxQUQOKcFO+dHjLvl5Iuq3x4TWPX1 YRYVx4D/vyv9kmWHdIXq3xhJZ3daUIuCfShIftHuqVbeciPIfGqBow1mxLO6k39jLg LB92YfjcbrmQ0HUTCtKm/IRC6SoOE5OsiL9wgm9QfoRTzMGzbp7Cxte6u0yK23M0JD IXJohMaxWWrs2IPIk+LyFQfcdeQHGiaFWbXjMv5RrCBrjy8D3QrXwshn3xFKsY9m8I JCa5bGO45B+RQ== X-Nifty-SrcIP: [126.125.154.139] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Joel Fernandes , Masahiro Yamada , linux-doc@vger.kernel.org, Jonathan Corbet , linux-kernel@vger.kernel.org, Michal Marek Subject: [PATCH 3/7] kbuild: do not create wrappers for header-test-y Date: Mon, 1 Jul 2019 09:58:41 +0900 Message-Id: <20190701005845.12475-4-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190701005845.12475-1-yamada.masahiro@socionext.com> References: <20190701005845.12475-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org header-test-y does not work with headers in sub-directories. For example, you may want to write a Makefile, like this: include/linux/Kbuild: header-test-y += mtd/nand.h This entry will create a wrapper include/linux/mtd/nand.hdrtest.c with the following content: #include "mtd/nand.h" To make this work, we need to add $(srctree)/include/linux to the header search path. It would be tedious to add ccflags-y. Instead, we could change the *.hdrtest.c rule to wrap: #include "nand.h" This works for in-tree build since #include "..." searches in the relative path from the header with this directive. For O=... build, we need to add $(srctree)/include/linux/mtd to the header search path, which will be even more tedious. After all, I thought it would be handier to compile headers directly without creating wrappers. I added a new build rule to compile %.h into %.h.s The target is %.h.s instead of %.h.o because it is slightly faster. Also, as for GCC, an empty assembly is smaller than an empty object. I wrote the build rule: $(CC) $(c_flags) -S -o $@ -x c /dev/null -include $< instead of: $(CC) $(c_flags) -S -o $@ -x c $< Both work fine with GCC, but the latter is bad for Clang. This comes down to the difference in the -Wunused-function policy. GCC does not warn about unused 'static inline' functions at all. Clang does not warn about the ones in included headers, but does about the ones in the source. So, we should handle headers as headers, not as source files. In fact, this has been hidden since commit abb2ea7dfd82 ("compiler, clang: suppress warning for unused static inline functions"), but we should not rely on that. Signed-off-by: Masahiro Yamada Acked-by: Jani Nikula Tested-by: Jani Nikula --- Changes in v4: None Changes in v3: None Changes in v2: - New patch .gitignore | 1 - Documentation/dontdiff | 1 - Documentation/kbuild/makefiles.txt | 3 +-- Makefile | 1 - scripts/Makefile.build | 10 +++++----- scripts/Makefile.lib | 2 +- 6 files changed, 7 insertions(+), 11 deletions(-) -- 2.17.1 diff --git a/.gitignore b/.gitignore index 4bb60f0fa23b..7587ef56b92d 100644 --- a/.gitignore +++ b/.gitignore @@ -22,7 +22,6 @@ *.elf *.gcno *.gz -*.hdrtest.c *.i *.ko *.lex.c diff --git a/Documentation/dontdiff b/Documentation/dontdiff index 554dfe4883d2..5eba889ea84d 100644 --- a/Documentation/dontdiff +++ b/Documentation/dontdiff @@ -19,7 +19,6 @@ *.grep *.grp *.gz -*.hdrtest.c *.html *.i *.jpeg diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index ca4b24ec0399..5080fec34609 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -1023,8 +1023,7 @@ When kbuild executes, the following steps are followed (roughly): header-test-y specifies headers (*.h) in the current directory that should be compile tested to ensure they are self-contained, i.e. compilable as standalone units. If CONFIG_HEADER_TEST is enabled, - this autogenerates dummy sources to include the headers, and builds them - as part of extra-y. + this builds them as part of extra-y. --- 6.7 Commands useful for building a boot image diff --git a/Makefile b/Makefile index f23516980796..7f293b0431fe 100644 --- a/Makefile +++ b/Makefile @@ -1648,7 +1648,6 @@ clean: $(clean-dirs) -o -name '*.dwo' -o -name '*.lst' \ -o -name '*.su' \ -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ - -o -name '*.hdrtest.c' \ -o -name '*.lex.c' -o -name '*.tab.[ch]' \ -o -name '*.asn1.[ch]' \ -o -name '*.symtypes' -o -name 'modules.order' \ diff --git a/scripts/Makefile.build b/scripts/Makefile.build index ee0319560513..776842b7e6a3 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -294,14 +294,14 @@ quiet_cmd_cc_lst_c = MKLST $@ $(obj)/%.lst: $(src)/%.c FORCE $(call if_changed_dep,cc_lst_c) -# Dummy C sources for header test (header-test-y target) +# header test (header-test-y target) # --------------------------------------------------------------------------- -quiet_cmd_header_test = HDRTEST $@ - cmd_header_test = echo "\#include \"$*.h\"" > $@ +quiet_cmd_cc_s_h = CC $@ + cmd_cc_s_h = $(CC) $(c_flags) -S -o $@ -x c /dev/null -include $< -$(obj)/%.hdrtest.c: - $(call cmd,header_test) +$(obj)/%.h.s: $(src)/%.h FORCE + $(call if_changed_dep,cc_s_h) # Compile assembler sources (.S) # --------------------------------------------------------------------------- diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 3e630fcaffd1..55ae1ec65342 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -67,7 +67,7 @@ extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-)) endif # Test self-contained headers -extra-$(CONFIG_HEADER_TEST) += $(patsubst %.h,%.hdrtest.o,$(header-test-y)) +extra-$(CONFIG_HEADER_TEST) += $(addsuffix .s, $(header-test-y)) # Add subdir path From patchwork Mon Jul 1 00:58:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 168192 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2263756ilk; Sun, 30 Jun 2019 18:00:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzcRo3HxNUDknerFKaZVSb8Rzbcc07JRgT83P8zmi0026916ndRoOW9i6ieRMp0yV9w75re X-Received: by 2002:a17:902:1e9:: with SMTP id b96mr25735820plb.277.1561942832844; Sun, 30 Jun 2019 18:00:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561942832; cv=none; d=google.com; s=arc-20160816; b=lm2Zae9IYORCU8rnoib3NorjmmLVYUO/j7hZS3ZiEigQfTjQRT3xlVFSIwNkM8Gczy 2JiqClHz2w0t34CkH7s7lmQX1MqElulIpJFEiSBshTVHa+p/+4+rhJz7/+iOdEqk2yK2 OYVhWqv/QKez9oZmswSdEbAt1jW3dp/8Ij1odA/AE47lHVJOjtL6IQOwPufpXq/1JMaT fRqpFY6D01qhc3IZ0Is2BEmZ3eG91cn0GRo+a3wLorljOFn+sGwCdRu8hAH9ZvYPN0yP uTI6SX9mrmJj5NErmrgWEgRyjCd59/xjkeT2P6yuKjwaOFHcdIjy7ybhPpeYHZTKkTWO /N+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=1HcjEC7wLR2+UWOsM11fHQgnI022Sfeb8n0eROHz6Dw=; b=ziKsiF5fVOnf9I24ZintQBA1Jpt6X/xBD7DbJsxbXzF8NiPAOOpW3vKeGNt2Odiwpn O0A89MVK0xtB9QFmTBmIGjBQ5CsDj2FxPlbK54F6MricnDrq9aqROQIm6JvGq2F3Kx8P 63YZ+UePIXK3e3Sn69z8cnUernaQaF2tFkFAHxe57YOZ/sBbObI5Af+RIubAaoxZrN5v +cliMYUUFjNmoHC8aCZ89Q5BZwyhIUQt5YHXEC7Q+wBhbaMaSCZYicyoSgyd8wL28ZTV Z4HLWkCbD40YiItBo70WpNkoa4ejjTZjUJxCz42KY9KeIxoaBZEoFGQfJwR5U9OmeFnr 2C4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=DLEkV7w0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t2si8479736ply.133.2019.06.30.18.00.32; Sun, 30 Jun 2019 18:00:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=DLEkV7w0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726985AbfGABAY (ORCPT + 30 others); Sun, 30 Jun 2019 21:00:24 -0400 Received: from conuserg-12.nifty.com ([210.131.2.79]:60237 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726896AbfGABAW (ORCPT ); Sun, 30 Jun 2019 21:00:22 -0400 Received: from grover.flets-west.jp (softbank126125154139.bbtec.net [126.125.154.139]) (authenticated) by conuserg-12.nifty.com with ESMTP id x610x4fv000634; Mon, 1 Jul 2019 09:59:09 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com x610x4fv000634 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1561942750; bh=1HcjEC7wLR2+UWOsM11fHQgnI022Sfeb8n0eROHz6Dw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DLEkV7w0not3hRjNOpSRVgM8jLvb2EBRfxQUh0olJzWpK6eUm9EGNPUlreEq8tRPO e1MoyrbgT7Bn135uJgldXUPf9oHzqClPpEk7y578D5OBYaOhTwzHSrMwU+5HNxm6cP 77YaiaHL9X1hYqj7zHyT7XSjC+lQTb4IGS2BpLqcX+irOHFObhpPFzDABaSgkOJYBj S/cVbafWaWaCp5knXhwsgxaeDhjXFKoQfTv9DPMBKxckEVcx+MOPnoApQ5jKyc+x+S 5kg2rijkRp5cW8ETcthjRVEUiUH0AoI2rdLr/5f+ZAsc0GFo1fiYav/xVO8hsuE4Vr 5F1k6FlUG22/Q== X-Nifty-SrcIP: [126.125.154.139] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Joel Fernandes , Masahiro Yamada , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Corbet , Michal Marek Subject: [PATCH 4/7] kbuild: support header-test-pattern-y Date: Mon, 1 Jul 2019 09:58:42 +0900 Message-Id: <20190701005845.12475-5-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190701005845.12475-1-yamada.masahiro@socionext.com> References: <20190701005845.12475-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In my view, most of headers can be self-contained. So, it would be tedious to add every header to header-test-y explicitly. We usually end up with "all headers with some exceptions". There are two types in exceptions: [1] headers that are never compiled as standalone units For examples, include/linux/compiler-gcc.h is not intended for direct inclusion. We should always exclude such ones. [2] headers that are conditionally compiled as standalone units Some headers can be compiled only for particular architectures. For example, include/linux/arm-cci.h can be compiled only for arm/arm64 because it requires to exist. Clang can compile include/soc/nps/mtm.h only for arc because it contains an arch-specific register in inline assembler. So, you can write Makefile like this: header-test- += linux/compiler-gcc.h header-test-$(CONFIG_ARM) += linux/arm-cci.h header-test-$(CONFIG_ARM64) += linux/arm-cci.h header-test-$(CONFIG_ARC) += soc/nps/mtm.h The new syntax header-test-pattern-y will be useful to specify "the rest". The typical usage is like this: header-test-pattern-y += */*.h This will add all the headers in sub-directories to the test coverage, excluding $(header-test-). In this regards, header-test-pattern-y behaves like a weaker variant of header-test-y. Caveat: The patterns in header-test-pattern-y are prefixed with $(srctree)/$(src)/ but not $(objtree)/$(obj)/. Stale generated headers are often left over when you traverse the git history without cleaning. Wildcard patterns for $(objtree) may match to stale headers, which could fail to compile. One pitfall is $(srctree)/$(src)/ and $(objtree)/$(obj)/ point to the same directory for in-tree building. So, header-test-pattern-y should be used with care since it can potentially match to stale headers. Caveat2: You could use wildcard for header-test-. For example, header-test- += asm-generic/% ... will exclude headers in asm-generic directory. Unfortunately, the wildcard character is '%' instead of '*' here because this is evaluated by $(filter-out ...) whereas header-test-pattern-y is evaluated by $(wildcard ...). This is a kludge, but seems useful in some places... Signed-off-by: Masahiro Yamada Tested-by: Jani Nikula --- Changes in v4: None Changes in v3: None Changes in v2: - New patch Documentation/kbuild/makefiles.txt | 10 ++++++++++ scripts/Makefile.lib | 11 +++++++++++ 2 files changed, 21 insertions(+) -- 2.17.1 diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index 5080fec34609..b817e6cefb77 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -1025,6 +1025,16 @@ When kbuild executes, the following steps are followed (roughly): i.e. compilable as standalone units. If CONFIG_HEADER_TEST is enabled, this builds them as part of extra-y. + header-test-pattern-y + + This works as a weaker version of header-test-y, and accepts wildcard + patterns. The typical usage is: + + header-test-pattern-y += *.h + + This specifies all the files that matches to '*.h' in the current + directory, but the files in 'header-test-' are excluded. + --- 6.7 Commands useful for building a boot image Kbuild provides a few macros that are useful when building a diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 55ae1ec65342..281864fcf0fe 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -67,6 +67,17 @@ extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-)) endif # Test self-contained headers + +# Wildcard searches in $(srctree)/$(src)/, but not in $(objtree)/$(obj)/. +# Stale generated headers are often left over, so pattern matching should +# be avoided. Please notice $(srctree)/$(src)/ and $(objtree)/$(obj) point +# to the same location for in-tree building. So, header-test-pattern-y should +# be used with care. +header-test-y += $(filter-out $(header-test-), \ + $(patsubst $(srctree)/$(src)/%, %, \ + $(wildcard $(addprefix $(srctree)/$(src)/, \ + $(header-test-pattern-y))))) + extra-$(CONFIG_HEADER_TEST) += $(addsuffix .s, $(header-test-y)) # Add subdir path From patchwork Mon Jul 1 00:58:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 168190 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2263539ilk; Sun, 30 Jun 2019 18:00:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7yLsuD1tR9XnV7IPRSpzXcxVB0jclBJ1jBI7WiLMXd/HvPB7an4OdHs8by5fayRmU8iIg X-Received: by 2002:a65:5a42:: with SMTP id z2mr22129716pgs.421.1561942817060; Sun, 30 Jun 2019 18:00:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561942817; cv=none; d=google.com; s=arc-20160816; b=Efjho+l5yUYoU0C1Z/dH1WJPDxftOdPHnAWdoXtQNcfsonxgL86vJE1XQ3X4+Hv92M RaqqAyLgRJbhQDen6uuFqRWqDZhdezvISdzHVxCma34Qav/spV/MV6Sen0RyPFWV6Lfh LwxA5KBgDiPuqGyVJMvEikmHqYPVG+457GKgWk63y0gYfeQXAXMl52MmAM3tLtUN8pfr 13shu/FRFER6XtjwpKD67mf2jI6MRqVj1gvsj+3q3BVbX5vIhZ+rGNrnl8FlJXF2Yh/2 +40jZGCQhUT7cZR3o4BGfzokXyyhF3LTZTQqRNwJ1/mT6Tk9Ql5J8RW8VF6k/U7+zcdD 1VpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=rpeL0VIy/UIykKSqi/KZPVDb8+AGL27FhHoeS6eYDfM=; b=Kh9wvTodzA4sRAGC51FohjU2h68gaZZR9bOnlplWi9H426+di3Aqtz3jmKWrf4Bs9C viPuJHl6+X0Ys1FMshiYZr8dDxS2klI7Kj7UBktAKkJFZ7xItUURMFtkBMGtxvEJ2lrH i7ukZjyr+rLf6HYdodx5fYBc3WU4lRpE7whKUpa9ZhU55hZWzc16PB/yx/673pnODCVH eMoQS00To/B6LDxr49FtZcH2AkfAToJDeo8ipcXKcgfhvmGhXOpa4QYOcptiTK+oxZ0O un+Wf7yIc7Fikc3hvW/R7MWIP/trgKaz/5QbjGzrTUtE3bvDwWGCg1TOaLbT3E6rUNoz pmRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=A208QQas; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x18si8652423pjq.71.2019.06.30.18.00.16; Sun, 30 Jun 2019 18:00:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=A208QQas; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726695AbfGABAP (ORCPT + 30 others); Sun, 30 Jun 2019 21:00:15 -0400 Received: from conuserg-12.nifty.com ([210.131.2.79]:59957 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726086AbfGABAO (ORCPT ); Sun, 30 Jun 2019 21:00:14 -0400 Received: from grover.flets-west.jp (softbank126125154139.bbtec.net [126.125.154.139]) (authenticated) by conuserg-12.nifty.com with ESMTP id x610x4fw000634; Mon, 1 Jul 2019 09:59:10 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com x610x4fw000634 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1561942750; bh=rpeL0VIy/UIykKSqi/KZPVDb8+AGL27FhHoeS6eYDfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A208QQaso4Ua3Xv5StoEy7N1uTKOr3ov4gE6NKkSxARIu7tAZuEmCkclp9x8NjcJp oFY/qVU3caS+6bbgTVAj1iLPi8Y0ETnU/wEhwR6cx00EaltEeEZqVP7L17Ey/gix/8 H5KfHmHVxPgj4gQl6bjXByCEHWvb2XPRyNCWXZC73o196m4uBTVEEGQONivak15yub K6rBITpjIYIfyEOilus6E8Uq/6r8QTNOV/w3ODQ8twMeQOBt/m8AfzBi7LKY8OWTAO hCxWp+9RySYVpeHTnBnhYbuBBfv1zIwep96sIk44AB135uXBgMD1Fr8Ij+99jgGtES 9kIQAx5rBMxXQ== X-Nifty-SrcIP: [126.125.154.139] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Joel Fernandes , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 5/7] kheaders: remove meaningless -R option of 'ls' Date: Mon, 1 Jul 2019 09:58:43 +0900 Message-Id: <20190701005845.12475-6-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190701005845.12475-1-yamada.masahiro@socionext.com> References: <20190701005845.12475-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The -R option of 'ls' is supposed to be used for directories. -R, --recursive list subdirectories recursively Since 'find ... -type f' only matches to regular files, we do not expect directories passed to the 'ls' command here. Giving -R is harmless at least, but unneeded. Signed-off-by: Masahiro Yamada --- Changes in v4: - New patch Changes in v3: None Changes in v2: None kernel/gen_kheaders.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.17.1 Reviewed-by: Joel Fernandes (Google) diff --git a/kernel/gen_kheaders.sh b/kernel/gen_kheaders.sh index 9a34e1d9bd7f..86a666f5cb17 100755 --- a/kernel/gen_kheaders.sh +++ b/kernel/gen_kheaders.sh @@ -33,8 +33,8 @@ arch/$SRCARCH/include/ # Uncomment it for debugging. # if [ ! -f /tmp/iter ]; then iter=1; echo 1 > /tmp/iter; # else iter=$(($(cat /tmp/iter) + 1)); echo $iter > /tmp/iter; fi -# find $src_file_list -type f | xargs ls -lR > /tmp/src-ls-$iter -# find $obj_file_list -type f | xargs ls -lR > /tmp/obj-ls-$iter +# find $src_file_list -type f | xargs ls -l > /tmp/src-ls-$iter +# find $obj_file_list -type f | xargs ls -l > /tmp/obj-ls-$iter # include/generated/compile.h is ignored because it is touched even when none # of the source files changed. This causes pointless regeneration, so let us @@ -46,7 +46,7 @@ src_files_md5="$(find $src_file_list -type f | grep -v "include/config/auto.conf" | grep -v "include/config/auto.conf.cmd" | grep -v "include/config/tristate.conf" | - xargs ls -lR | md5sum | cut -d ' ' -f1)" + xargs ls -l | md5sum | cut -d ' ' -f1)" popd > /dev/null obj_files_md5="$(find $obj_file_list -type f | grep -v "include/generated/compile.h" | @@ -54,7 +54,7 @@ obj_files_md5="$(find $obj_file_list -type f | grep -v "include/config/auto.conf" | grep -v "include/config/auto.conf.cmd" | grep -v "include/config/tristate.conf" | - xargs ls -lR | md5sum | cut -d ' ' -f1)" + xargs ls -l | md5sum | cut -d ' ' -f1)" if [ -f $tarfile ]; then tarfile_md5="$(md5sum $tarfile | cut -d ' ' -f1)"; fi if [ -f kernel/kheaders.md5 ] && From patchwork Mon Jul 1 00:58:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 168191 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2263548ilk; Sun, 30 Jun 2019 18:00:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMp6tvgQftXK8IGWl9hNPq0s0mEmnkfd2v0u+RKJcSXLZzHGub1U/PKEJnm9vth8cIIVR2 X-Received: by 2002:a17:90a:bb8b:: with SMTP id v11mr27266561pjr.64.1561942817936; Sun, 30 Jun 2019 18:00:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561942817; cv=none; d=google.com; s=arc-20160816; b=kEFyhg72Rj7lhhqdlOO0AXRZwhbZ289HN6TtyzLG9Lvi2+Eml6WVVU55tID6xQPzu0 2cISdGjDt4HmWBSdIyNMl7gt/ueW0cQfn3qgJ6Quyd3s8/amhUzk2xjvQGw4GjOOpUja 8A08ppW/jInHWF3RLkg0TdXldVG5E6+5IbjkOSKTSi79JZiTU0sBUnktmOvMXJ+d/uEV VCuqUvTvWkhV6TtNMy/eD63x3YDYlG/Ue+ZkPFrZmTgBkBq4KTAuRSqnnJnKYua9FdVU qbAOgItDOUUZrkIcAyKF/8G+WXFLcGxRT3EsEfBzKdLKMzF/1owaPj7P2JtT5ytTsb1G dbKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=+UpIu10WCEZP6+HNL9px3zwBEqpAxSsMePRRBKj3x4o=; b=YMiR50AV/uPd+XiQUbuICv18E8iID0mifZCSzBh4PP8+U0W1c6OnoEejeBNewdnxcq n2lv9J1GZlXzZ/W2f4DFeqoz2W8pbMErk4qZuocRfnMWi4y+51lMHvMtZxllKuyx//8B 6nqwxIOcx0htweYY5YIGnyxqT6ZZhigggFBy+PjgRWgINhDjM6YasN75aLtBkpgzCfIJ tjNA1+O4D9KcsZdTM/v2P0iGNsQiBOfNrKb/diAXh72EOoUYlpyU1vLl0ivQ3bewdZ7V sGicvzjA1uiNxbXLevcDzb0V7Vbaq3pBCJfJaAo9VR93sZPFSF6FsrMeM7DSP6bDm4hJ sljw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=nki3gYfh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x18si8652423pjq.71.2019.06.30.18.00.17; Sun, 30 Jun 2019 18:00:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=nki3gYfh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726866AbfGABAQ (ORCPT + 30 others); Sun, 30 Jun 2019 21:00:16 -0400 Received: from conuserg-12.nifty.com ([210.131.2.79]:60031 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726563AbfGABAP (ORCPT ); Sun, 30 Jun 2019 21:00:15 -0400 Received: from grover.flets-west.jp (softbank126125154139.bbtec.net [126.125.154.139]) (authenticated) by conuserg-12.nifty.com with ESMTP id x610x4fx000634; Mon, 1 Jul 2019 09:59:10 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com x610x4fx000634 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1561942751; bh=+UpIu10WCEZP6+HNL9px3zwBEqpAxSsMePRRBKj3x4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nki3gYfhvgkiXFwtL93SL+mwz10BSbkHJh9srmQUWGFUs3hKu+t5Q+dToCV/smjlE QvgrZuo5HqN4B5WFWSSIQGBgYPRDsO0dfWdAHrbYAO8qC9lz2U1GfzhVfQSq+Vh5oz hlUMFO0543qoGvAQcojYv/tbgFOtNbiFkDB/H2NlMBCSYvZKj1j/HzxIXGqPs2T8Sn T0mmsPNHPq0Byd5rN9VT5mdqh1FJbmxjM3qlGBHlQwn7FpQXFI7STuPiFAgdQrA4kT UBk/0HMAPGtcnLe9iTFZ5rENISHkbc6uM+mhmLXMxtfLt4N+QivaJNMvs3KI8SPaSF EQJsEcpBFtpNA== X-Nifty-SrcIP: [126.125.154.139] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Joel Fernandes , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 6/7] kheaders: include only headers into kheaders_data.tar.xz Date: Mon, 1 Jul 2019 09:58:44 +0900 Message-Id: <20190701005845.12475-7-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190701005845.12475-1-yamada.masahiro@socionext.com> References: <20190701005845.12475-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, kheaders_data.tar.xz contains some build scripts as well as headers. None of them is needed in the header archive. For ARCH=x86, this commit excludes the following from the archive: arch/x86/include/asm/Kbuild arch/x86/include/uapi/asm/Kbuild include/asm-generic/Kbuild include/config/auto.conf include/config/kernel.release include/config/tristate.conf include/uapi/asm-generic/Kbuild include/uapi/Kbuild kernel/gen_kheaders.sh This change is actually motivated for the planned header compile-testing because it will generate more build artifacts, which should not be included in the archive. Signed-off-by: Masahiro Yamada --- Changes in v4: - New patch Changes in v3: None Changes in v2: None kernel/gen_kheaders.sh | 47 ++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 31 deletions(-) -- 2.17.1 diff --git a/kernel/gen_kheaders.sh b/kernel/gen_kheaders.sh index 86a666f5cb17..9ff449888d9c 100755 --- a/kernel/gen_kheaders.sh +++ b/kernel/gen_kheaders.sh @@ -4,24 +4,12 @@ # This script generates an archive consisting of kernel headers # for CONFIG_IKHEADERS. set -e -spath="$(dirname "$(readlink -f "$0")")" -kroot="$spath/.." +sfile="$(readlink -f "$0")" outdir="$(pwd)" tarfile=$1 cpio_dir=$outdir/$tarfile.tmp -# Script filename relative to the kernel source root -# We add it to the archive because it is small and any changes -# to this script will also cause a rebuild of the archive. -sfile="$(realpath --relative-to $kroot "$(readlink -f "$0")")" - -src_file_list=" -include/ -arch/$SRCARCH/include/ -$sfile -" - -obj_file_list=" +dir_list=" include/ arch/$SRCARCH/include/ " @@ -33,33 +21,29 @@ arch/$SRCARCH/include/ # Uncomment it for debugging. # if [ ! -f /tmp/iter ]; then iter=1; echo 1 > /tmp/iter; # else iter=$(($(cat /tmp/iter) + 1)); echo $iter > /tmp/iter; fi -# find $src_file_list -type f | xargs ls -l > /tmp/src-ls-$iter -# find $obj_file_list -type f | xargs ls -l > /tmp/obj-ls-$iter +# find $src_file_list -name "*.h" | xargs ls -l > /tmp/src-ls-$iter +# find $obj_file_list -name "*.h" | xargs ls -l > /tmp/obj-ls-$iter # include/generated/compile.h is ignored because it is touched even when none # of the source files changed. This causes pointless regeneration, so let us # ignore them for md5 calculation. -pushd $kroot > /dev/null -src_files_md5="$(find $src_file_list -type f | +pushd $srctree > /dev/null +src_files_md5="$(find $dir_list -name "*.h" | grep -v "include/generated/compile.h" | grep -v "include/generated/autoconf.h" | - grep -v "include/config/auto.conf" | - grep -v "include/config/auto.conf.cmd" | - grep -v "include/config/tristate.conf" | xargs ls -l | md5sum | cut -d ' ' -f1)" popd > /dev/null -obj_files_md5="$(find $obj_file_list -type f | +obj_files_md5="$(find $dir_list -name "*.h" | grep -v "include/generated/compile.h" | grep -v "include/generated/autoconf.h" | - grep -v "include/config/auto.conf" | - grep -v "include/config/auto.conf.cmd" | - grep -v "include/config/tristate.conf" | xargs ls -l | md5sum | cut -d ' ' -f1)" - +# Any changes to this script will also cause a rebuild of the archive. +this_file_md5="$(ls -l $sfile | md5sum | cut -d ' ' -f1)" if [ -f $tarfile ]; then tarfile_md5="$(md5sum $tarfile | cut -d ' ' -f1)"; fi if [ -f kernel/kheaders.md5 ] && [ "$(cat kernel/kheaders.md5|head -1)" == "$src_files_md5" ] && [ "$(cat kernel/kheaders.md5|head -2|tail -1)" == "$obj_files_md5" ] && + [ "$(cat kernel/kheaders.md5|head -3|tail -1)" == "$this_file_md5" ] && [ "$(cat kernel/kheaders.md5|tail -1)" == "$tarfile_md5" ]; then exit fi @@ -71,16 +55,16 @@ fi rm -rf $cpio_dir mkdir $cpio_dir -pushd $kroot > /dev/null -for f in $src_file_list; - do find "$f" ! -name "*.cmd" ! -name ".*"; +pushd $srctree > /dev/null +for f in $dir_list; + do find "$f" -name "*.h"; done | cpio --quiet -pd $cpio_dir popd > /dev/null # The second CPIO can complain if files already exist which can # happen with out of tree builds. Just silence CPIO for now. -for f in $obj_file_list; - do find "$f" ! -name "*.cmd" ! -name ".*"; +for f in $dir_list; + do find "$f" -name "*.h"; done | cpio --quiet -pd $cpio_dir >/dev/null 2>&1 # Remove comments except SDPX lines @@ -91,6 +75,7 @@ tar -Jcf $tarfile -C $cpio_dir/ . > /dev/null echo "$src_files_md5" > kernel/kheaders.md5 echo "$obj_files_md5" >> kernel/kheaders.md5 +echo "$this_file_md5" >> kernel/kheaders.md5 echo "$(md5sum $tarfile | cut -d ' ' -f1)" >> kernel/kheaders.md5 rm -rf $cpio_dir