From patchwork Fri Feb 16 18:38:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128625 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp870267ljc; Fri, 16 Feb 2018 10:49:05 -0800 (PST) X-Google-Smtp-Source: AH8x2269enpJAJnalnVY2K3eMe8RfEtIFhccH1+6zNAC8OQIJfBrz/biegMsMtu8k3/8AAUve/+a X-Received: by 2002:a17:902:5814:: with SMTP id m20-v6mr6669616pli.389.1518806945079; Fri, 16 Feb 2018 10:49:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806945; cv=none; d=google.com; s=arc-20160816; b=HLnLBYptarvnjJe5GBCETDbMWI0K0N420qTi+RQiX7RdRH93mZaFtOLBOao8e4jhcV IWBuBFwtPeahVDwFDsnrAy6i44Xo896yQHqQCl4Odb0DZoE1H3dDvAQa6OzZE/A79IED tF8PSed6pnTGcbLOqsTtfpV/iL1Ir2uerEEsAAiCn59tcTlJ3DSmcvN3hQRQ232JLabf BYL7PapUM8u0fwlNuxHRlEIqbNdrm8I0b3Y8qrndbT2q/DpgmXptfPhMM/n7JWDGr6YU JX82CngFEEwIXcwyfiTtbKtIdf6VyQx51kdO7W2pIy4MNHfKDxWymBz90/35APfp/Iip 6cDA== 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 :arc-authentication-results; bh=e6tkaYf8zFapXNO1isT86zDxZTxiqkGFf30Hn4plGx4=; b=DOC+RisnhFe9Sy2ACxuL+XvY5kUnTUXf7NriqYm77B45UhM5rk+vzjoq4pLE88fOfx 5unCKB+p3SezKb6jEbydexw45MuDAeWvrl/TGyvEuFbM6qrNFmGZ+1k91Un1WAWXHVA3 IETr0iBZoWUMYiE++aCaR2eyI0NZE5nr0/xFsFok0vu/OEKMhK7INqnsn2gW7SeXbq/f K+K/IeJnyz8RM/OyWWwijYSv5i3S5Kk4MKvMKZWznMy05pwvt2lJSvWQpueNsCqc1W+E MWg+pbYCf1TZNbGIVgPUvlNfMWeW3oBtr+YydvKDtDNlEA5oc4Je9z98Z6N+EoKlq1c0 fflw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=JLQvGyo/; 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 n66si3573643pfb.213.2018.02.16.10.49.04; Fri, 16 Feb 2018 10:49:05 -0800 (PST) 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=JLQvGyo/; 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 S1752306AbeBPSsH (ORCPT + 28 others); Fri, 16 Feb 2018 13:48:07 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:57764 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752635AbeBPSlS (ORCPT ); Fri, 16 Feb 2018 13:41:18 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBT4013418; Sat, 17 Feb 2018 03:39:13 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBT4013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806354; bh=e6tkaYf8zFapXNO1isT86zDxZTxiqkGFf30Hn4plGx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JLQvGyo/FN7iLJgRcJScK5E0silTeAcQ94y7mf7q/QD/n0A+mTdf3bTDmTAvFoDZ3 605gNaKFEeGdXaTkpTzwYIfMwz0NEF4HW6CjOVCgCbfpaeMin/uGk6a5s4b4slXpXI kaOOwfJiOU2gaBm83lPFbiZCmq2cfRmZ0WJc3cl5BDpwMJvALXEpps9SPWHP6Xr5Ha S4SxctT7CuS2dLs6xQY67jEplBUvgDUAUdX9lxcYkZxp+t0M2JErZZ6+V6d27DeY0y 7yXOarjlekb5JjtQyiRs93krcsM9hjQXHngMHwynoS5kYvSTJf6W+YvrwZmtgOysMB yBAJvm71ZSd0g== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 01/23] kbuild: remove kbuild cache Date: Sat, 17 Feb 2018 03:38:29 +0900 Message-Id: <1518806331-7101-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The kbuild cache was introduced to remember the result of shell commands, some of which are expensive to compute, such as $(call cc-option,...). However, this turned out not so clear as I had first expected. Actually, it is problematic. For example, "$(CC) -print-file-name" is cached. If the compiler is updated, the stale search path causes build error, which is difficult to figure out. Another problem scenario is cache files could be touched while install targets are running under the root permission. We can patch them if desired, but the build infrastructure is getting uglier and uglier. Now, we are going to move compiler flag tests to the configuration phase. If this is completed, the result of compiler tests will be naturally cached in the .config file. We will not have performance issues of incremental building since this testing only happens at Kconfig time. To start this work with a cleaner code base, remove the kbuild cache first. Revert the following commits: Commit 9a234a2e384349 ("kbuild: create directory for make cache only when necessary") Commit e17c400ae194945ee ("kbuild: shrink .cache.mk when it exceeds 1000 lines") Commit 4e56207130eda9 ("kbuild: Cache a few more calls to the compiler") Commit 3298b690b21cdb ("kbuild: Add a cache for generated variables") Signed-off-by: Masahiro Yamada --- Makefile | 5 +-- scripts/Kbuild.include | 101 +++++++------------------------------------------ 2 files changed, 16 insertions(+), 90 deletions(-) -- 2.7.4 diff --git a/Makefile b/Makefile index 79ad2bf..a27e6d8 100644 --- a/Makefile +++ b/Makefile @@ -655,7 +655,7 @@ KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \ KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) # check for 'asm goto' -ifeq ($(call shell-cached,$(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y) +ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y) KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO endif @@ -810,7 +810,7 @@ KBUILD_CFLAGS += $(call cc-option,-fdata-sections,) endif # arch Makefile may override CC so keep this after arch Makefile is included -NOSTDINC_FLAGS += -nostdinc -isystem $(call shell-cached,$(CC) -print-file-name=include) +NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) CHECKFLAGS += $(NOSTDINC_FLAGS) # warn about C99 declaration after statement @@ -1601,7 +1601,6 @@ clean: $(clean-dirs) -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ -o -name '*.symtypes' -o -name 'modules.order' \ -o -name modules.builtin -o -name '.tmp_*.o.*' \ - -o -name .cache.mk \ -o -name '*.c.[012]*.*' \ -o -name '*.ll' \ -o -name '*.gcno' \) -type f -print | xargs rm -f diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 065324a..9776946 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -8,8 +8,6 @@ squote := ' empty := space := $(empty) $(empty) space_escape := _-_SPACE_-_ -right_paren := ) -left_paren := ( ### # Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o @@ -82,71 +80,6 @@ cc-cross-prefix = \ echo $(c); \ fi))) -# Tools for caching Makefile variables that are "expensive" to compute. -# -# Here we want to help deal with variables that take a long time to compute -# by making it easy to store these variables in a cache. -# -# The canonical example here is testing for compiler flags. On a simple system -# each call to the compiler takes 10 ms, but on a system with a compiler that's -# called through various wrappers it can take upwards of 100 ms. If we have -# 100 calls to the compiler this can take 1 second (on a simple system) or 10 -# seconds (on a complicated system). -# -# The "cache" will be in Makefile syntax and can be directly included. -# Any time we try to reference a variable that's not in the cache we'll -# calculate it and store it in the cache for next time. - -# Include values from last time -make-cache := $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/,$(if $(obj),$(obj)/)).cache.mk -$(make-cache): ; --include $(make-cache) - -cached-data := $(filter __cached_%, $(.VARIABLES)) - -# If cache exceeds 1000 lines, shrink it down to 500. -ifneq ($(word 1000,$(cached-data)),) -$(shell tail -n 500 $(make-cache) > $(make-cache).tmp; \ - mv $(make-cache).tmp $(make-cache)) -endif - -create-cache-dir := $(if $(KBUILD_SRC),$(if $(cache-data),,1)) - -# Usage: $(call __sanitize-opt,Hello=Hola$(comma)Goodbye Adios) -# -# Convert all '$', ')', '(', '\', '=', ' ', ',', ':' to '_' -__sanitize-opt = $(subst $$,_,$(subst $(right_paren),_,$(subst $(left_paren),_,$(subst \,_,$(subst =,_,$(subst $(space),_,$(subst $(comma),_,$(subst :,_,$(1))))))))) - -# Usage: $(call shell-cached,shell_command) -# Example: $(call shell-cached,md5sum /usr/bin/gcc) -# -# If we've already seen a call to this exact shell command (even in a -# previous invocation of make!) we'll return the value. If not, we'll -# compute it and store the result for future runs. -# -# This is a bit of voodoo, but basic explanation is that if the variable -# was undefined then we'll evaluate the shell command and store the result -# into the variable. We'll then store that value in the cache and finally -# output the value. -# -# NOTE: The $$(2) here isn't actually a parameter to __run-and-store. We -# happen to know that the caller will have their shell command in $(2) so the -# result of "call"ing this will produce a reference to that $(2). The reason -# for this strangeness is to avoid an extra level of eval (and escaping) of -# $(2). -define __run-and-store -ifeq ($(origin $(1)),undefined) - $$(eval $(1) := $$(shell $$(2))) -ifeq ($(create-cache-dir),1) - $$(shell mkdir -p $(dir $(make-cache))) - $$(eval create-cache-dir :=) -endif - $$(shell echo '$(1) := $$($(1))' >> $(make-cache)) -endif -endef -__shell-cached = $(eval $(call __run-and-store,$(1)))$($(1)) -shell-cached = $(call __shell-cached,__cached_$(call __sanitize-opt,$(1)),$(1)) - # output directory for tests below TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/) @@ -154,36 +87,30 @@ TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/) # Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise) # Exit code chooses option. "$$TMP" serves as a temporary file and is # automatically cleaned up. -__try-run = set -e; \ +try-run = $(shell set -e; \ TMP="$(TMPOUT).$$$$.tmp"; \ TMPO="$(TMPOUT).$$$$.o"; \ if ($(1)) >/dev/null 2>&1; \ then echo "$(2)"; \ else echo "$(3)"; \ fi; \ - rm -f "$$TMP" "$$TMPO" - -try-run = $(shell $(__try-run)) - -# try-run-cached -# This works like try-run, but the result is cached. -try-run-cached = $(call shell-cached,$(__try-run)) + rm -f "$$TMP" "$$TMPO") # as-option # Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,) -as-option = $(call try-run-cached,\ +as-option = $(call try-run,\ $(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2)) # as-instr # Usage: cflags-y += $(call as-instr,instr,option1,option2) -as-instr = $(call try-run-cached,\ +as-instr = $(call try-run,\ printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3)) # __cc-option # Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586) -__cc-option = $(call try-run-cached,\ +__cc-option = $(call try-run,\ $(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4)) # Do not attempt to build with gcc plugins during cc-option tests. @@ -203,23 +130,23 @@ hostcc-option = $(call __cc-option, $(HOSTCC),\ # cc-option-yn # Usage: flag := $(call cc-option-yn,-march=winchip-c6) -cc-option-yn = $(call try-run-cached,\ +cc-option-yn = $(call try-run,\ $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) # cc-disable-warning # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable) -cc-disable-warning = $(call try-run-cached,\ +cc-disable-warning = $(call try-run,\ $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) # cc-name # Expands to either gcc or clang -cc-name = $(call shell-cached,$(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc) +cc-name = $(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc) # cc-version -cc-version = $(call shell-cached,$(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) +cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) # cc-fullversion -cc-fullversion = $(call shell-cached,$(CONFIG_SHELL) \ +cc-fullversion = $(shell $(CONFIG_SHELL) \ $(srctree)/scripts/gcc-version.sh -p $(CC)) # cc-ifversion @@ -232,23 +159,23 @@ cc-if-fullversion = $(shell [ $(cc-fullversion) $(1) $(2) ] && echo $(3) || echo # cc-ldoption # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) -cc-ldoption = $(call try-run-cached,\ +cc-ldoption = $(call try-run,\ $(CC) $(1) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2)) # ld-option # Usage: LDFLAGS += $(call ld-option, -X) -ld-option = $(call try-run-cached,\ +ld-option = $(call try-run,\ $(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -x c /dev/null -c -o "$$TMPO"; \ $(LD) $(LDFLAGS) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) # ar-option # Usage: KBUILD_ARFLAGS := $(call ar-option,D) # Important: no spaces around options -ar-option = $(call try-run-cached, $(AR) rc$(1) "$$TMP",$(1),$(2)) +ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2)) # ld-version # Note this is mainly for HJ Lu's 3 number binutil versions -ld-version = $(call shell-cached,$(LD) --version | $(srctree)/scripts/ld-version.sh) +ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh) # ld-ifversion # Usage: $(call ld-ifversion, -ge, 22252, y) From patchwork Fri Feb 16 18:38:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128618 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp867844ljc; Fri, 16 Feb 2018 10:45:54 -0800 (PST) X-Google-Smtp-Source: AH8x227u9qYz0xOxxeovtNqO4YNsQVI1BkgPyb213H5EV5qvzGfZvyEuTqqEzqsTeuZjLqhseMvY X-Received: by 10.98.238.2 with SMTP id e2mr7016021pfi.206.1518806754539; Fri, 16 Feb 2018 10:45:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806754; cv=none; d=google.com; s=arc-20160816; b=Vbhe7rN02YzBUXpH209lWdjMmV0d73FUQ70uQiNSN8XEx25sTJYiEtb9J/CBQ7ioQF xm0QMk+JFNkq0M/ZuqbU+AXr0NFk+JnlNWaxn0kwy1FR0zp2uT4aq2Z2dlMwfuPh9FkM sUV8udyqO92fLwhjI2V4CQO0Qi0JLpYrBOrawyCcHYWRtxCHWU814LsxDrxdF35/Vkzm HVxZbNKaN7OnC1SvtgyWVEul64eOFxrMZxtX6fGgrdVuV8COlflTUEipRXN+2jTRMaX+ yy/wTxgb0MBf0TCMW98vDyUBbvGHHdrlbrnEOuK+pXkMZeBr6Aorw0w4Hh+5WqULY3g9 S41w== 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 :arc-authentication-results; bh=TcwbpsyunP2zGuqv8JQctkwE0xC6/BHmB73ouAOs6XY=; b=MWqYwP0y7dWZLEqNslfw9tr+sv/Lo8P8UQgWIB1DCN3tkly1CnJa2f5fkzcNwUg720 bFNdIzdTn1jbIu2l+8YReCw3tRVawc5a1XmfQjOhdsElWIa+Gdy/II6GfoKaIGyoWRtL y1j9D6vFn4QocL8bFaEdAIRH0cQIIcPFc8t2D1uDzGzAyTWhcTESiQsir38a17//D2Ki qgWA9fr4nNuip++eOB7WecU9hHXa8thuW7vKNj0QurXSofetsAoQziU5njciAWgbFDhi E0sOVD5670osk/Iv6S43SB0/YV4NHmyEw3/w9hQlATYbMX6IadDSzUROIsRYseSSRZQ+ K2Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=lDEQnHgg; 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 16si1807107pge.448.2018.02.16.10.45.54; Fri, 16 Feb 2018 10:45:54 -0800 (PST) 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=lDEQnHgg; 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 S1753724AbeBPSpW (ORCPT + 28 others); Fri, 16 Feb 2018 13:45:22 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:57775 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752689AbeBPSlT (ORCPT ); Fri, 16 Feb 2018 13:41:19 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBT5013418; Sat, 17 Feb 2018 03:39:14 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBT5013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806354; bh=TcwbpsyunP2zGuqv8JQctkwE0xC6/BHmB73ouAOs6XY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lDEQnHggJBLUc1YBu+aKVBgIbTe3EvBypOFig7n9R3jw83O2HiD7ep6RekRmfNAnk X4cb2sTw/eqDZBtTO15kYAzenXm4A/fzZ/kJgUe7pbbOGlAX2XXZeRQ5KJKJ033ep3 bToYWtaY/GCFj/UbUgc5du7nYFmY5GSapuBIJym6xSYSCzW299QRQWM6ktHAUZIKW4 UZmxa8x9z6/ZZI9fRdBMeapfppR6FmJyDTHvj4i6/EMjzqVfAgiP+Gz91hgXhutDQS Kra2RN5A8wIO/Fl6fJuOkxDikOYSrOi854nT2TwhMTUsyVrBQM+F1meDpsvKsXILNu rvNa5ezaQFNgQ== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 02/23] kbuild: remove CONFIG_CROSS_COMPILE support Date: Sat, 17 Feb 2018 03:38:30 +0900 Message-Id: <1518806331-7101-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Kbuild provides a couple of ways to specify CROSS_COMPILE: [1] Command line [2] Environment [3] arch/*/Makefile (only some architectures) [4] CONFIG_CROSS_COMPILE [4] is problematic for the compiler capability tests in Kconfig. CONFIG_CROSS_COMPILE allows users to change the compiler prefix from 'make menuconfig', etc. It means, the compiler options would have to be all re-calculated everytime CONFIG_CROSS_COMPILE is changed. To avoid complexity and performance issues, I'd like to evaluate the shell commands statically, i.e. only parsing Kconfig files. I guess the majority is [1] or [2]. Currently, there are only 4 defconfig files that specify CONFIG_CROSS_COMPILE. arch/arm/configs/lpc18xx_defconfig arch/hexagon/configs/comet_defconfig arch/openrisc/configs/or1ksim_defconfig arch/openrisc/configs/simple_smp_defconfig Signed-off-by: Masahiro Yamada --- Makefile | 3 --- init/Kconfig | 9 --------- 2 files changed, 12 deletions(-) -- 2.7.4 diff --git a/Makefile b/Makefile index a27e6d8..94a957e 100644 --- a/Makefile +++ b/Makefile @@ -307,12 +307,9 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ # CROSS_COMPILE can be set on the command line # make CROSS_COMPILE=ia64-linux- # Alternatively CROSS_COMPILE can be set in the environment. -# A third alternative is to store a setting in .config so that plain -# "make" in the configured kernel build directory always uses that. # Default value for CROSS_COMPILE is not to prefix executables # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile ARCH ?= $(SUBARCH) -CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%) # Architecture as present in compile.h UTS_MACHINE := $(ARCH) diff --git a/init/Kconfig b/init/Kconfig index e37f4b2..df18492 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -54,15 +54,6 @@ config INIT_ENV_ARG_LIMIT Maximum of each of the number of arguments and environment variables passed to init from the kernel command line. - -config CROSS_COMPILE - string "Cross-compiler tool prefix" - help - Same as running 'make CROSS_COMPILE=prefix-' but stored for - default make runs in this kernel build directory. You don't - need to set this unless you want the configured kernel build - directory to select the cross-compiler automatically. - config COMPILE_TEST bool "Compile also drivers which will not load" depends on !UML From patchwork Fri Feb 16 18:38:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128606 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp864186ljc; Fri, 16 Feb 2018 10:41:30 -0800 (PST) X-Google-Smtp-Source: AH8x224mMtBmKWqgnjRLvJnsk38JbimngcaxFWvAEOByIdmZdgcj7RJ2wJsKYbAJMYrHm2cYqB+N X-Received: by 10.99.168.75 with SMTP id i11mr5806222pgp.420.1518806490464; Fri, 16 Feb 2018 10:41:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806490; cv=none; d=google.com; s=arc-20160816; b=FFhWUjDoTS+Y4zZ0p4g57DOeG/hUfh/DxDzu5QkpqsyyPYgbWnfkZObIdY4kvD4/gS sGyYSI8OECBx6XNGxns6J3kgm640WdqSDZOgT0205FLfLq1n3aRpFPoD3/7VS0hmP5fA ZK8xGjM9PQUTc/6Lc4ic/UNWgGo1x+6WnJ3hrG1XCQj3g3yrjTAWXYq3gykQiH4nGGwE Us6bT/6zeibH91tz44d2pc6FWha/L7RWTOua2r79og3Amy9X1myAaFpsdug0h9563aVA 4BVub2FSol+YAq/y4Fwsgj8z0ATqgQWvh+NTtjutvjsJ/jp5RMbmxtZAeLyUGM9aPagg Su+w== 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 :arc-authentication-results; bh=x37G/JrybxXhVfsvSRijeqSjd9Vmal2cBfU3vCqzxWI=; b=n5Ldv5D5fRcZN9zJolofLjw9hOBEEEmllHk1HJj/n01Pr3DnkDksFWAo5AJTIbzV3b 1l//YztSBZuW+l0mtT2KeY/Q+DH8yThWMPwuLQZR5wqZUElXXfEWaWpIEl85LnUP3HyI N9queCSL0McVPHJc/maPymoSmBiARfJOfpF+6s/txxp8+1JVHXGCuzW9yLn0y2jN/XlY kCUPt7N21LbTTwrqQTvuCvEKycQ4hCs0fpaWpBiH+uh2Qes56wZGaHC6vnygekfCQ73h V+HAFq7xRm/0umFj/Eqsf5Tf+WE7a+SQwN0YnUsz5adpa8Q38Jh1Cb7z6yel6YUuqlWy 1t/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=ZAEzv6Vt; 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 l12si851327pfg.404.2018.02.16.10.41.30; Fri, 16 Feb 2018 10:41:30 -0800 (PST) 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=ZAEzv6Vt; 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 S1752882AbeBPSlY (ORCPT + 28 others); Fri, 16 Feb 2018 13:41:24 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:57763 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752622AbeBPSlS (ORCPT ); Fri, 16 Feb 2018 13:41:18 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBT6013418; Sat, 17 Feb 2018 03:39:15 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBT6013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806355; bh=x37G/JrybxXhVfsvSRijeqSjd9Vmal2cBfU3vCqzxWI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZAEzv6VtrCoKX3v0tpsSlIRB45IBre4UrlcyyD2uVh7B6vmW7YNoxxNpD18eGwYL0 JVsIO+2t6EDzuDbfaQ3ui86L56yNCFwtl1XE8m9eKdJ/NeeoLKPIeeRxCPDTY6KzEn LWCrbuyp3xshYynZG7Fp4gZuCK8DRFKU2T9ZW4k2KxK0Muba+JbzMNcUZ0GU5MHpU2 50f2pAkUwmLlplME0IdUXmu3BV9rd7It9crE0ZAyaj598xn32iMQegLncnmSQpYtWn WT+0cF4DwrzYewfn2x4hSe+Mdnv1jP63T27wLpYtQa+g10IkgGZsmKIBt0/VUULbyC RBDS0SE2yJxcg== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 03/23] kconfig: add xstrdup() helper Date: Sat, 17 Feb 2018 03:38:31 +0900 Message-Id: <1518806331-7101-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We already have xmalloc(), xcalloc(), and xrealloc((). Add xstrdup() as well to save tedious error handling. Signed-off-by: Masahiro Yamada --- scripts/kconfig/confdata.c | 2 +- scripts/kconfig/kxgettext.c | 2 +- scripts/kconfig/lkc.h | 1 + scripts/kconfig/symbol.c | 4 ++-- scripts/kconfig/util.c | 11 +++++++++++ scripts/kconfig/zconf.y | 2 +- 6 files changed, 17 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 5c12dc9..df26c7b 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -178,7 +178,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) case S_HEX: done: if (sym_string_valid(sym, p)) { - sym->def[def].val = strdup(p); + sym->def[def].val = xstrdup(p); sym->flags |= def_flags; } else { if (def != S_DEF_AUTO) diff --git a/scripts/kconfig/kxgettext.c b/scripts/kconfig/kxgettext.c index 2858738..240880a 100644 --- a/scripts/kconfig/kxgettext.c +++ b/scripts/kconfig/kxgettext.c @@ -101,7 +101,7 @@ static struct message *message__new(const char *msg, char *option, if (self->files == NULL) goto out_fail; - self->msg = strdup(msg); + self->msg = xstrdup(msg); if (self->msg == NULL) goto out_fail_msg; diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 4e23feb..2d5ec2d 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -115,6 +115,7 @@ int file_write_dep(const char *name); void *xmalloc(size_t size); void *xcalloc(size_t nmemb, size_t size); void *xrealloc(void *p, size_t size); +char *xstrdup(const char *s); struct gstr { size_t len; diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index cca9663..2220bc4 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -183,7 +183,7 @@ static void sym_validate_range(struct symbol *sym) sprintf(str, "%lld", val2); else sprintf(str, "0x%llx", val2); - sym->curr.val = strdup(str); + sym->curr.val = xstrdup(str); } static void sym_set_changed(struct symbol *sym) @@ -849,7 +849,7 @@ struct symbol *sym_lookup(const char *name, int flags) : !(symbol->flags & (SYMBOL_CONST|SYMBOL_CHOICE)))) return symbol; } - new_name = strdup(name); + new_name = xstrdup(name); } else { new_name = NULL; hash = 0; diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index b98a79e..c6f6e21 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -154,3 +154,14 @@ void *xrealloc(void *p, size_t size) fprintf(stderr, "Out of memory.\n"); exit(1); } + +char *xstrdup(const char *s) +{ + char *p; + + p = strdup(s); + if (p) + return p; + fprintf(stderr, "Out of memory.\n"); + exit(1); +} diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 4893676..ad6305b 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -127,7 +127,7 @@ no_mainmenu_stmt: /* empty */ * later regardless of whether it comes from the 'prompt' in * mainmenu_stmt or here */ - menu_add_prompt(P_MENU, strdup("Linux Kernel Configuration"), NULL); + menu_add_prompt(P_MENU, xstrdup("Linux Kernel Configuration"), NULL); }; From patchwork Fri Feb 16 18:38:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128627 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp870567ljc; Fri, 16 Feb 2018 10:49:31 -0800 (PST) X-Google-Smtp-Source: AH8x226AVLJMAN7jHX+Q5TwhXYEyMyVeL+NAQATz76Qa2ddYBvrz0e9dFazxliOdtMr+AUtxf1+j X-Received: by 10.98.253.17 with SMTP id p17mr2208364pfh.105.1518806971528; Fri, 16 Feb 2018 10:49:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806971; cv=none; d=google.com; s=arc-20160816; b=K967ffg02PsLPZNd8jp3Q9eQv9VCbvXkekokCczVoetsSCAy0D/+abP1NPu4AgxWzZ 7kUo2mXhvBlctSDc+0STdKAiBfaMysqini0hQ001kt+uYQmUVkwOWhnoizdeKDcQ+dFc ksUCmuyxFXBuEEIleMgj/O9Cj0jjentBrZe/w4HpI/b8uYwm07w4DpNe6Nrn8MMp8LCV HDn6UrNBjiMQC29GN+NCGLjp6BmisaS1XS3kBWOL8fhK9wci3zQw5kNwi3KBvUwdaoKV iWd29Ed6KRJiRGaG8rozM+6uoUuzzgiqGNHGJKHoqrKepfEnKIiHe3fDFdW7ewzFqXbv ceIw== 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 :arc-authentication-results; bh=5v0/HrzAJlD9iSgCxrOCACm9vCZI9W7j1VzmKYbwL2Y=; b=qXgVWgX9TaZFyo+9V+oU8gAQed2kE/SzAhhqMVziHcn9/8gGaPsTqOmx5VfaMptTNB 7t9kKQ7LWeiccNSvpV5GbJdzGmHT9Ak6RX1X63on0MZBycrYmgNNYqxwfc0sAXZ+vhQp icgLcotiEaG3Mh79pqMnwrCRNAtyPKtms980CJ+m5/GEQgBcy0lFDBA1Y2Z6toIu5pO1 B4dRzhejxoLPCIk5j2rbO1+98oNrPXeXnQowWtiOVT4qAQH51wP8v6IzJLbRV4ms9Qpy xCYsrN+JVRZCZKyKw4x9OtsSTkrcQwaIzZMTNVKrmC4fHjsCZo3SfY3MAAcJ6tLHxbYD iNnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=jgNgpdo1; 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 f5si12574pgr.235.2018.02.16.10.49.31; Fri, 16 Feb 2018 10:49:31 -0800 (PST) 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=jgNgpdo1; 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 S1752003AbeBPSsA (ORCPT + 28 others); Fri, 16 Feb 2018 13:48:00 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:57766 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752657AbeBPSlS (ORCPT ); Fri, 16 Feb 2018 13:41:18 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBT7013418; Sat, 17 Feb 2018 03:39:16 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBT7013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806356; bh=5v0/HrzAJlD9iSgCxrOCACm9vCZI9W7j1VzmKYbwL2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jgNgpdo15pK7YCpwxKoWxUm00nyR5hItRvmC3oe9rT/yci83X39iW//SRa6VwbIuo kRFleu1DuHAilsgoIN4dX6uVdbw0aUWK6Lr23Augg7JKK8/XOTMeNbW+rSTtsyK8Od G7No9F/4cZzwxZOQGr9PCy4jLZ9yRsiD1iAh15eVu/meC1U/zoF2FmlhogGDq7LpBn 0ooIFAiHVEaHx5tIbbRhItynv+3CfmtXgkdI11+KO6plBVkc8ACkmF+BnF5aHCzhSz JLQsagApZQ0MoLO902pKr4nx5rwhIoyslaXSaeri7aKXnzq18c3qfGTWWbl8Oai2Bp FR1TdLg0qUJIA== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 04/23] kconfig: set SYMBOL_AUTO to the symbol marked with defconfig_list Date: Sat, 17 Feb 2018 03:38:32 +0900 Message-Id: <1518806331-7101-5-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The 'defconfig_list' is a weird attribute. If the '.config' is missing, conf_read_simple() iterates over all visible defaults, then it uses the first one for which fopen() succeeds. config DEFCONFIG_LIST string depends on !UML option defconfig_list default "/lib/modules/$UNAME_RELEASE/.config" default "/etc/kernel-config" default "/boot/config-$UNAME_RELEASE" default "$ARCH_DEFCONFIG" default "arch/$ARCH/defconfig" However, like other symbols, the first visible default is always written out to the .config file. This might be different from what has been actually used. For example, on my machine, the third one "/boot/config-$UNAME_RELEASE" is opened, like follows: $ rm .config $ make oldconfig 2>/dev/null scripts/kconfig/conf --oldconfig Kconfig # # using defaults found in /boot/config-4.4.0-112-generic # * * Restart config... * * * IRQ subsystem * Expose irq internals in debugfs (GENERIC_IRQ_DEBUGFS) [N/y/?] (NEW) However, the resulted .config file contains the first one since it is visible: $ grep CONFIG_DEFCONFIG_LIST .config CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" In order to stop confusing people, prevent this CONFIG option from being written to the .config file. Signed-off-by: Masahiro Yamada --- I'd like to fix the root case of this weirdness later. (and other 'option' attributes as well) But, this series is focusing a more important work in a bigger picture. For now, I decided to just hide CONFIG_DEFCONFIG_LIST from the .config file. scripts/kconfig/menu.c | 1 + 1 file changed, 1 insertion(+) -- 2.7.4 Reviewed-by: Ulf Magnusson diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 9922285..36cd3e1 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -212,6 +212,7 @@ void menu_add_option(int token, char *arg) sym_defconfig_list = current_entry->sym; else if (sym_defconfig_list != current_entry->sym) zconf_error("trying to redefine defconfig symbol"); + sym_defconfig_list->flags |= SYMBOL_AUTO; break; case T_OPT_ENV: prop_add_env(arg); From patchwork Fri Feb 16 18:38:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128623 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp869617ljc; Fri, 16 Feb 2018 10:48:16 -0800 (PST) X-Google-Smtp-Source: AH8x225+C17WUht6+ubqHYusSbnsPr53UcDgb1INae/8FftQSdQciE2/Hm6xWjR8mlZOmOmVePT5 X-Received: by 2002:a17:902:848b:: with SMTP id c11-v6mr3143484plo.372.1518806896661; Fri, 16 Feb 2018 10:48:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806896; cv=none; d=google.com; s=arc-20160816; b=ZQ+AIsrhhNpZP8Q/ygjyz6ECLEwXSqwy6uwD4MHYbm4VX8mvHBBOQbGto2TYczz6uO 7SHjf9S7iU+vcRcQWKRdtwco5TwFZllT9GgQa8IYDdRmbuEmZ984qOXtEk8OH4hWHkBG DCOuF2/UOMkgk3Ep0V0Nzc/0xKixtpxCTiQHhAr4NYcqJiQzZHYu2Ury3kNL7UCHp+RZ NsORWjIarb6FmPZCXaDg/oBR/cDIj11GDggguaFzKChkAEvgkRDRS5SEshFFYoCZvgHi qslvbWhgbZKZbiimFCn2Q/h64Ip4hKuvQC9C4wZdat80h6tXcr771/77npp3S/nxHQ7I pUdg== 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 :arc-authentication-results; bh=6bDWmuezbI5Hm+gjpVvP4x2GJkY1+VLq+ILtVxXeZbM=; b=iXVAFO2uzQBl/jw0QuUpAWa1ox9nSZJnS2+64NwfvmnViG5os7RnU3acNuJnudKAwV Myt1heewFjSsS3OJyKHMY5VcyMvccP62cZHFIma/2ERGroFgFmghxPgup9aVpHl/IxJk FpHODBXlFu6Wo8x6aNrwc4DYqyidCa73msgJOBeNrQ2+h62oKkIKntJu5AJba6r9AkcL w6FoMlhZak1eGdLFWRBLYTezs1XSWlInF/wtNQL7LdptvRF59aJa4A9+DaOhCZlUNi0T UY0/2GWGC1bsJ8iLiQef7T0VXQa38IOSjP9mFMih2o/fBHNFJcoHe1fYfWaSf46nzz3f J52Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=2nv9Jg/J; 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 p33-v6si2408561pld.310.2018.02.16.10.48.16; Fri, 16 Feb 2018 10:48:16 -0800 (PST) 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=2nv9Jg/J; 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 S1752517AbeBPSsM (ORCPT + 28 others); Fri, 16 Feb 2018 13:48:12 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:57758 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752623AbeBPSlS (ORCPT ); Fri, 16 Feb 2018 13:41:18 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBT8013418; Sat, 17 Feb 2018 03:39:16 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBT8013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806357; bh=6bDWmuezbI5Hm+gjpVvP4x2GJkY1+VLq+ILtVxXeZbM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2nv9Jg/JLTu1f+2uFHUqFKdVbN5hSZhImE14eOpzWiF0YbaeKazAxh9vz/y3G7edy sfvoo3Wm46M3qDlie9ty6hjb5E3tezXhCHf0Nsb2uL/9wFLrEU/uIVzoR4B/DRb5Gw AZUkHC36Wb/ZhKpJfvcSseJhEeOX47FLZhL33CGAJYBEmEiFvXtzqVwMdspppb/ieE DtEUcl+aj7vfEg3uponlYc4amoxso4J/WhZB9uTcb/Ege+ExdVYekoOdkO1Bba8tJu ew3CUvF9gG0I01RI6C0lWCwhmwS0oID6vl1HST4VYjBw6nxkRTr/4Dhn5R+WkAlTgU tsj06LU4gFPiQ== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 05/23] kconfig: move and rename sym_expand_string_value() Date: Sat, 17 Feb 2018 03:38:33 +0900 Message-Id: <1518806331-7101-6-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This helper expands symbols contained in a string. I am about to change it to expand environments instead of symbols. Also, I will add function expansion later. Rename it to expand_string_value(), and move it to util.c, which is a more suitable place. Signed-off-by: Masahiro Yamada --- scripts/kconfig/lkc.h | 1 + scripts/kconfig/lkc_proto.h | 1 - scripts/kconfig/symbol.c | 53 ------------------------------------------- scripts/kconfig/util.c | 55 ++++++++++++++++++++++++++++++++++++++++++++- scripts/kconfig/zconf.y | 2 +- 5 files changed, 56 insertions(+), 56 deletions(-) -- 2.7.4 diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 2d5ec2d..fb2503a 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -110,6 +110,7 @@ void menu_finalize(struct menu *parent); void menu_set_type(int type); /* util.c */ +char *expand_string_value(const char *in); struct file *file_lookup(const char *name); int file_write_dep(const char *name); void *xmalloc(size_t size); diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index 9dc8abf..9884adc 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -31,7 +31,6 @@ extern struct symbol * symbol_hash[SYMBOL_HASHSIZE]; struct symbol * sym_lookup(const char *name, int flags); struct symbol * sym_find(const char *name); -char *sym_expand_string_value(const char *in); const char * sym_escape_string_value(const char *in); struct symbol ** sym_re_search(const char *pattern); const char * sym_type_name(enum symbol_type type); diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 2220bc4..e4ccf56 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -894,59 +894,6 @@ struct symbol *sym_find(const char *name) return symbol; } -/* - * Expand symbol's names embedded in the string given in argument. Symbols' - * name to be expanded shall be prefixed by a '$'. Unknown symbol expands to - * the empty string. - */ -char *sym_expand_string_value(const char *in) -{ - const char *src; - char *res; - size_t reslen; - - /* - * Note: 'in' might come from a token that's about to be - * freed, so make sure to always allocate a new string - */ - reslen = strlen(in) + 1; - res = xmalloc(reslen); - res[0] = '\0'; - - while ((src = strchr(in, '$'))) { - char *p, name[SYMBOL_MAXLENGTH]; - const char *symval = ""; - struct symbol *sym; - size_t newlen; - - strncat(res, in, src - in); - src++; - - p = name; - while (isalnum(*src) || *src == '_') - *p++ = *src++; - *p = '\0'; - - sym = sym_find(name); - if (sym != NULL) { - sym_calc_value(sym); - symval = sym_get_string_value(sym); - } - - newlen = strlen(res) + strlen(symval) + strlen(src) + 1; - if (newlen > reslen) { - reslen = newlen; - res = xrealloc(res, reslen); - } - - strcat(res, symval); - in = src; - } - strcat(res, in); - - return res; -} - const char *sym_escape_string_value(const char *in) { const char *p; diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index c6f6e21..22201a4 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -10,11 +10,64 @@ #include #include "lkc.h" +/* + * Expand symbol's names embedded in the string given in argument. Symbols' + * name to be expanded shall be prefixed by a '$'. Unknown symbol expands to + * the empty string. + */ +char *expand_string_value(const char *in) +{ + const char *src; + char *res; + size_t reslen; + + /* + * Note: 'in' might come from a token that's about to be + * freed, so make sure to always allocate a new string + */ + reslen = strlen(in) + 1; + res = xmalloc(reslen); + res[0] = '\0'; + + while ((src = strchr(in, '$'))) { + char *p, name[SYMBOL_MAXLENGTH]; + const char *symval = ""; + struct symbol *sym; + size_t newlen; + + strncat(res, in, src - in); + src++; + + p = name; + while (isalnum(*src) || *src == '_') + *p++ = *src++; + *p = '\0'; + + sym = sym_find(name); + if (sym != NULL) { + sym_calc_value(sym); + symval = sym_get_string_value(sym); + } + + newlen = strlen(res) + strlen(symval) + strlen(src) + 1; + if (newlen > reslen) { + reslen = newlen; + res = xrealloc(res, reslen); + } + + strcat(res, symval); + in = src; + } + strcat(res, in); + + return res; +} + /* file already present in list? If not add it */ struct file *file_lookup(const char *name) { struct file *file; - char *file_name = sym_expand_string_value(name); + char *file_name = expand_string_value(name); for (file = file_list; file; file = file->next) { if (!strcmp(name, file->name)) { diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index ad6305b..262c464 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -547,7 +547,7 @@ void conf_parse(const char *name) tmp = rootmenu.prompt->text; rootmenu.prompt->text = _(rootmenu.prompt->text); - rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text); + rootmenu.prompt->text = expand_string_value(rootmenu.prompt->text); free((char*)tmp); menu_finalize(&rootmenu); From patchwork Fri Feb 16 18:38:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128613 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp865218ljc; Fri, 16 Feb 2018 10:42:44 -0800 (PST) X-Google-Smtp-Source: AH8x224axRiCKcaPaucr+gaSYRlRbgwNnsE2rJq5uj0SuMX9+fbyGWLkCUO5ZXlqAWkOUh/vyYyj X-Received: by 10.99.4.197 with SMTP id 188mr5719807pge.359.1518806564777; Fri, 16 Feb 2018 10:42:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806564; cv=none; d=google.com; s=arc-20160816; b=etYUb19e5acDqVnurjzkNyb136OZJNWvXXKfzp7GPO3ZPRUwxIytDttcVJp0YixBiW UV9IVVRp0xxovSDm+4LS1TacHZ5Psfju/fbr2XZuJ4PdIRx6m9TNKueBV8iKrKiodiJS 3sTX63Ag3AA2e0nn6Y4kHvy5a8BXCy2WrZ1DXzY6+2arqXvGYshl/khbhbT5BcA/JwsK LoYu8V2F8ZjSCcJvXx427XcgUvmNqdSdAJhPuw/QiQMx8o9v7V1ZDMqbhAIiq1X/t2iI Eyi1vU2G6du3eG/JggTw7+Sq04oVlEsCWGUkO5K4Pk7e+N735nNeqCSsSZgYPN/RlC77 O8uA== 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 :arc-authentication-results; bh=v/ny6VJzm2Ll1c4GNuLdzJpeFvQuhQcfHoQxEj3r8ng=; b=iRfoQhrtt8+m5g22IUlHIWp9Hn2uIQkv0ThB/CZaZW+7ImpRbCJRZbOli0Ly2zxzS9 lRVvVvqoyMYhDedeF2v6sXONAQAnNZDZvPUus8fylBnkh2oMCVKYeuYV4lWpO6y9ShE/ EEb8u43L0UD6urTabAIxPB8Un7weWylfUfLnNE2Foi1UeZ2bJik+Kk8GL8cItxGZ7D6e nE6pDTfoBp5atJncQ9MDfGyL+xFnlLAEgR1Nqn1wHtgXWjiuLQzSYrsITqweI2s/VLtp p7LxxBYNJBDdlMqL/KgK/kacMB46LoLh2VYfeFGazV+txAVVij2OGmskLqKj3vY5gCqj 3u/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=s3DRY770; 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 z25si1783654pfi.39.2018.02.16.10.42.44; Fri, 16 Feb 2018 10:42:44 -0800 (PST) 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=s3DRY770; 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 S1753415AbeBPSml (ORCPT + 28 others); Fri, 16 Feb 2018 13:42:41 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:59098 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753280AbeBPSmh (ORCPT ); Fri, 16 Feb 2018 13:42:37 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBT9013418; Sat, 17 Feb 2018 03:39:17 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBT9013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806359; bh=v/ny6VJzm2Ll1c4GNuLdzJpeFvQuhQcfHoQxEj3r8ng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s3DRY770F/iLzBqeD4QTJpmy8Tk4IPagy0oGapcg7uUgGk45plUXBU+XccRpp1GLa 9MXJ1RB7KpGSfKKYmLxLTWGDzgx1OC105xjZvt0+u1xsrNVqfCPzHw0LOROZdnpJsy lMkLtBQhYpYLG0sea+A50M5vthhQLbrsHMf64UDBvz50o9xygB6OyOPyUzFN5btwsr wUiyHlpQGqyl4jNWiK5VpVDtTmHPodfqWBynCKdJzh9HhznieNehRex2I8c3CDlKab B0Uii5uoHfYP2U45B5FEtbio+sq2X05Grry2f2zwaembIOEfuCEPmUEIBcPnXo71HS rbkla93GH6ktg== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , "H. Peter Anvin" , "David S. Miller" , Yoshinori Sato , x86@kernel.org, linux-doc@vger.kernel.org, Jonathan Corbet , Thomas Gleixner , linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org, linux-sh@vger.kernel.org, Richard Weinberger , user-mode-linux-user@lists.sourceforge.net, user-mode-linux-devel@lists.sourceforge.net, Rich Felker , Ingo Molnar , Jeff Dike Subject: [PATCH 06/23] kconfig: reference environments directly and remove 'option env=' syntax Date: Sat, 17 Feb 2018 03:38:34 +0900 Message-Id: <1518806331-7101-7-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To get an environment value, Kconfig needs to define a symbol using "option env=" syntax. It is tedious to add a config entry for each environment given that we need more environments such as 'CC', 'AS', 'srctree' etc. to evaluate the compiler capability in Kconfig. Adding '$' to symbols is weird. Kconfig can reference symbols directly like this: config FOO string default BAR So, I want to use the following syntax to get environment 'BAR' from the system: config FOO string default $BAR Looking at the code, the symbols prefixed with 'S' are expanded by: - conf_expand_value() This is used to expand 'arch/$ARCH/defconfig' and 'defconfig_list' - expand_string_value() This is used to expand strings in 'source' and 'mainmenu' All of them are independent of user configuration, i.e. fixed values. So, this kind of syntax should be moved to simply take the environment. This change makes the code much cleaner. The bounce symbols 'SRCARCH', 'ARCH', 'SUBARCH', 'KERNELVERSION' are gone. sym_init() hard-coding 'UNAME_RELEASE' is also gone. 'UNAME_RELEASE' should be be given from the environment. ARCH_DEFCONFIG is a normal symbol, so it should be simply referenced by 'default ARCH_DEFCONFIG'. An environment can appear anywhere a symbol reference can appear. (It is expanded by sym_lookup().) If an expression (which is derived from symbols) is a string, environments in the string are also expanded. For example, the following code works. Example code: config TOOLCHAIN_LIST string default "My tools: CC=$CC, AS=$AS, CPP=$CPP" Result: $ make -s alldefconfig && tail -n 1 .config CONFIG_TOOLCHAIN_LIST="My tools: CC=gcc, AS=as, CPP=gcc -E" Signed-off-by: Masahiro Yamada --- I tested all 'make *config' for arch architectures. I confirmed this commit still produced the same result. Documentation/kbuild/kconfig-language.txt | 8 -- Kconfig | 4 - Makefile | 3 +- arch/sh/Kconfig | 4 +- arch/sparc/Kconfig | 4 +- arch/tile/Kconfig | 2 +- arch/um/Kconfig.common | 4 - arch/x86/Kconfig | 4 +- arch/x86/um/Kconfig | 4 +- init/Kconfig | 10 +- scripts/kconfig/confdata.c | 31 +----- scripts/kconfig/kconf_id.c | 1 - scripts/kconfig/lkc.h | 4 - scripts/kconfig/menu.c | 3 - scripts/kconfig/symbol.c | 84 ++++------------ scripts/kconfig/util.c | 156 +++++++++++++++++++++--------- scripts/kconfig/zconf.l | 2 +- scripts/kconfig/zconf.y | 1 - 18 files changed, 144 insertions(+), 185 deletions(-) -- 2.7.4 diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt index f5b9493..0e966e8 100644 --- a/Documentation/kbuild/kconfig-language.txt +++ b/Documentation/kbuild/kconfig-language.txt @@ -198,14 +198,6 @@ applicable everywhere (see syntax). enables the third modular state for all config symbols. At most one symbol may have the "modules" option set. - - "env"= - This imports the environment variable into Kconfig. It behaves like - a default, except that the value comes from the environment, this - also means that the behaviour when mixing it with normal defaults is - undefined at this point. The symbol is currently not exported back - to the build environment (if this is desired, it can be done via - another symbol). - - "allnoconfig_y" This declares the symbol as one that should have the value y when using "allnoconfig". Used for symbols that hide other symbols. diff --git a/Kconfig b/Kconfig index 8c4c1cb..e6ece5b 100644 --- a/Kconfig +++ b/Kconfig @@ -5,8 +5,4 @@ # mainmenu "Linux/$ARCH $KERNELVERSION Kernel Configuration" -config SRCARCH - string - option env="SRCARCH" - source "arch/$SRCARCH/Kconfig" diff --git a/Makefile b/Makefile index 94a957e..9a8c689 100644 --- a/Makefile +++ b/Makefile @@ -275,7 +275,8 @@ include scripts/Kbuild.include # Read KERNELRELEASE from include/config/kernel.release (if it exists) KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) -export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION +UNAME_RELEASE := $(shell uname --release) +export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION UNAME_RELEASE # SUBARCH tells the usermode build what the underlying arch is. That is set # first, and if a usermode build is happening, the "ARCH=um" on the command diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 97fe293..89fc2f6 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -57,7 +57,7 @@ config SUPERH . config SUPERH32 - def_bool ARCH = "sh" + def_bool $ARCH = "sh" select HAVE_KPROBES select HAVE_KRETPROBES select HAVE_IOREMAP_PROT if MMU && !X2TLB @@ -76,7 +76,7 @@ config SUPERH32 select HAVE_CC_STACKPROTECTOR config SUPERH64 - def_bool ARCH = "sh64" + def_bool $ARCH = "sh64" select HAVE_EXIT_THREAD select KALLSYMS diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 6bf594a..fed3d82 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -1,6 +1,6 @@ config 64BIT - bool "64-bit kernel" if ARCH = "sparc" - default ARCH = "sparc64" + bool "64-bit kernel" if $ARCH = "sparc" + default $ARCH = "sparc64" help SPARC is a family of RISC microprocessors designed and marketed by Sun Microsystems, incorporated. They are very widely found in Sun diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig index ef9d403..fed372e 100644 --- a/arch/tile/Kconfig +++ b/arch/tile/Kconfig @@ -119,7 +119,7 @@ config HVC_TILE # Building with ARCH=tilegx (or ARCH=tile) implies using the # 64-bit TILE-Gx toolchain, so force CONFIG_TILEGX on. config TILEGX - def_bool ARCH != "tilepro" + def_bool $ARCH != "tilepro" select ARCH_SUPPORTS_ATOMIC_RMW select GENERIC_IRQ_LEGACY_ALLOC_HWIRQ select HAVE_ARCH_JUMP_LABEL diff --git a/arch/um/Kconfig.common b/arch/um/Kconfig.common index c68add8..07f84c8 100644 --- a/arch/um/Kconfig.common +++ b/arch/um/Kconfig.common @@ -54,10 +54,6 @@ config HZ int default 100 -config SUBARCH - string - option env="SUBARCH" - config NR_CPUS int range 1 1 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index a528c14..54d943a 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1,8 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 # Select 32 or 64 bit config 64BIT - bool "64-bit kernel" if ARCH = "x86" - default ARCH != "i386" + bool "64-bit kernel" if $ARCH = "x86" + default $ARCH != "i386" ---help--- Say yes to build a 64-bit kernel - formerly known as x86_64 Say no to build a 32-bit kernel - formerly known as i386 diff --git a/arch/x86/um/Kconfig b/arch/x86/um/Kconfig index 13ed827..d355413 100644 --- a/arch/x86/um/Kconfig +++ b/arch/x86/um/Kconfig @@ -16,8 +16,8 @@ config UML_X86 select GENERIC_FIND_FIRST_BIT config 64BIT - bool "64-bit kernel" if SUBARCH = "x86" - default SUBARCH != "i386" + bool "64-bit kernel" if $SUBARCH = "x86" + default $SUBARCH != "i386" config X86_32 def_bool !64BIT diff --git a/init/Kconfig b/init/Kconfig index df18492..b4814e6 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1,11 +1,3 @@ -config ARCH - string - option env="ARCH" - -config KERNELVERSION - string - option env="KERNELVERSION" - config DEFCONFIG_LIST string depends on !UML @@ -13,7 +5,7 @@ config DEFCONFIG_LIST default "/lib/modules/$UNAME_RELEASE/.config" default "/etc/kernel-config" default "/boot/config-$UNAME_RELEASE" - default "$ARCH_DEFCONFIG" + default ARCH_DEFCONFIG default "arch/$ARCH/defconfig" config CONSTRUCTORS diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index df26c7b..98c2014 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -81,39 +81,13 @@ const char *conf_get_autoconfig_name(void) return name ? name : "include/config/auto.conf"; } -static char *conf_expand_value(const char *in) -{ - struct symbol *sym; - const char *src; - static char res_value[SYMBOL_MAXLENGTH]; - char *dst, name[SYMBOL_MAXLENGTH]; - - res_value[0] = 0; - dst = name; - while ((src = strchr(in, '$'))) { - strncat(res_value, in, src - in); - src++; - dst = name; - while (isalnum(*src) || *src == '_') - *dst++ = *src++; - *dst = 0; - sym = sym_lookup(name, 0); - sym_calc_value(sym); - strcat(res_value, sym_get_string_value(sym)); - in = src; - } - strcat(res_value, in); - - return res_value; -} - char *conf_get_default_confname(void) { struct stat buf; static char fullname[PATH_MAX+1]; char *env, *name; - name = conf_expand_value(conf_defname); + name = expand_string_value(conf_defname); env = getenv(SRCTREE); if (env) { sprintf(fullname, "%s/%s", env, name); @@ -274,7 +248,8 @@ int conf_read_simple(const char *name, int def) if (expr_calc_value(prop->visible.expr) == no || prop->expr->type != E_SYMBOL) continue; - name = conf_expand_value(prop->expr->left.sym->name); + sym_calc_value(prop->expr->left.sym); + name = sym_get_string_value(prop->expr->left.sym); in = zconf_fopen(name); if (in) { conf_message(_("using defaults found in %s"), diff --git a/scripts/kconfig/kconf_id.c b/scripts/kconfig/kconf_id.c index 3ea9c5f..b3e0ea0 100644 --- a/scripts/kconfig/kconf_id.c +++ b/scripts/kconfig/kconf_id.c @@ -32,7 +32,6 @@ static struct kconf_id kconf_id_array[] = { { "on", T_ON, TF_PARAM }, { "modules", T_OPT_MODULES, TF_OPTION }, { "defconfig_list", T_OPT_DEFCONFIG_LIST, TF_OPTION }, - { "env", T_OPT_ENV, TF_OPTION }, { "allnoconfig_y", T_OPT_ALLNOCONFIG_Y, TF_OPTION }, }; diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index fb2503a..0ff3256 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -58,7 +58,6 @@ enum conf_def_mode { #define T_OPT_MODULES 1 #define T_OPT_DEFCONFIG_LIST 2 -#define T_OPT_ENV 3 #define T_OPT_ALLNOCONFIG_Y 4 struct kconf_id { @@ -134,9 +133,6 @@ void str_printf(struct gstr *gs, const char *fmt, ...); const char *str_get(struct gstr *gs); /* symbol.c */ -extern struct expr *sym_env_list; - -void sym_init(void); void sym_clear_all_valid(void); struct symbol *sym_choice_default(struct symbol *sym); const char *sym_get_string_default(struct symbol *sym); diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 36cd3e1..a9d0ccc 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -214,9 +214,6 @@ void menu_add_option(int token, char *arg) zconf_error("trying to redefine defconfig symbol"); sym_defconfig_list->flags |= SYMBOL_AUTO; break; - case T_OPT_ENV: - prop_add_env(arg); - break; case T_OPT_ALLNOCONFIG_Y: current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y; break; diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index e4ccf56..96ea8a9 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -33,33 +33,6 @@ struct symbol *sym_defconfig_list; struct symbol *modules_sym; tristate modules_val; -struct expr *sym_env_list; - -static void sym_add_default(struct symbol *sym, const char *def) -{ - struct property *prop = prop_alloc(P_DEFAULT, sym); - - prop->expr = expr_alloc_symbol(sym_lookup(def, SYMBOL_CONST)); -} - -void sym_init(void) -{ - struct symbol *sym; - struct utsname uts; - static bool inited = false; - - if (inited) - return; - inited = true; - - uname(&uts); - - sym = sym_lookup("UNAME_RELEASE", 0); - sym->type = S_STRING; - sym->flags |= SYMBOL_AUTO; - sym_add_default(sym, uts.release); -} - enum symbol_type sym_get_type(struct symbol *sym) { enum symbol_type type = sym->type; @@ -828,28 +801,38 @@ static unsigned strhash(const char *s) struct symbol *sym_lookup(const char *name, int flags) { - struct symbol *symbol; + struct symbol *symbol = NULL; char *new_name; int hash; if (name) { - if (name[0] && !name[1]) { - switch (name[0]) { - case 'y': return &symbol_yes; - case 'm': return &symbol_mod; - case 'n': return &symbol_no; + new_name = expand_string_value(name); + if (new_name[0] && !new_name[1]) { + switch (new_name[0]) { + case 'y': + symbol = &symbol_yes; + break; + case 'm': + symbol = &symbol_mod; + break; + case 'n': + symbol = &symbol_no; + break; + } + if (symbol) { + free(new_name); + return symbol; } } - hash = strhash(name) % SYMBOL_HASHSIZE; + hash = strhash(new_name) % SYMBOL_HASHSIZE; for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) { if (symbol->name && - !strcmp(symbol->name, name) && + !strcmp(symbol->name, new_name) && (flags ? symbol->flags & flags : !(symbol->flags & (SYMBOL_CONST|SYMBOL_CHOICE)))) return symbol; } - new_name = xstrdup(name); } else { new_name = NULL; hash = 0; @@ -1336,32 +1319,3 @@ const char *prop_get_type_name(enum prop_type type) } return "unknown"; } - -static void prop_add_env(const char *env) -{ - struct symbol *sym, *sym2; - struct property *prop; - char *p; - - sym = current_entry->sym; - sym->flags |= SYMBOL_AUTO; - for_all_properties(sym, prop, P_ENV) { - sym2 = prop_get_symbol(prop); - if (strcmp(sym2->name, env)) - menu_warn(current_entry, "redefining environment symbol from %s", - sym2->name); - return; - } - - prop = prop_alloc(P_ENV, sym); - prop->expr = expr_alloc_symbol(sym_lookup(env, SYMBOL_CONST)); - - sym_env_list = expr_alloc_one(E_LIST, sym_env_list); - sym_env_list->right.sym = sym; - - p = getenv(env); - if (p) - sym_add_default(sym, p); - else - menu_warn(current_entry, "environment variable %s undefined", env); -} diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index 22201a4..dddf85b 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -8,16 +8,98 @@ #include #include #include + +#include "list.h" #include "lkc.h" +static LIST_HEAD(env_list); + +struct env { + char *name; + char *value; + struct list_head node; +}; + +static struct env *env_list_lookup(const char *name) +{ + struct env *e; + + list_for_each_entry(e, &env_list, node) { + if (!strcmp(name, e->name)) + return e; + } + + return NULL; +} + +static void env_list_add(const char *name, const char *value) +{ + struct env *e; + + e = xmalloc(sizeof(*e)); + e->name = xstrdup(name); + e->value = xstrdup(value); + + list_add_tail(&e->node, &env_list); +} + +static void env_list_del(struct env *e) +{ + list_del(&e->node); + free(e->name); + free(e->value); + free(e); +} + +/* the returned pointer must be freed when done */ +static char *env_expand(const char *name) +{ + struct env *e; + const char *value; + + e = env_list_lookup(name); + if (e) + return xstrdup(e->value); + + value = getenv(name); + if (!value) { + fprintf(stderr, "environment variable \"%s\" undefined\n", name); + value = ""; + } + + /* + * we need to remember all referenced environments. + * They will be written out to include/config/auto.conf.cmd + */ + env_list_add(name, value); + + return xstrdup(value); +} + +/* works like env_expand, but 'name' does not need to be null-terminated */ +static char *env_expand_n(const char *name, size_t n) +{ + char *tmp, *res; + + tmp = xmalloc(n + 1); + memcpy(tmp, name, n); + *(tmp + n) = '\0'; + + res = env_expand(tmp); + + free(tmp); + + return res; +} + /* - * Expand symbol's names embedded in the string given in argument. Symbols' - * name to be expanded shall be prefixed by a '$'. Unknown symbol expands to + * Expand environments embedded in the string given in argument. Environments + * to be expanded shall be prefixed by a '$'. Unknown environment expands to * the empty string. */ char *expand_string_value(const char *in) { - const char *src; + const char *p, *q; char *res; size_t reslen; @@ -25,39 +107,28 @@ char *expand_string_value(const char *in) * Note: 'in' might come from a token that's about to be * freed, so make sure to always allocate a new string */ - reslen = strlen(in) + 1; - res = xmalloc(reslen); - res[0] = '\0'; - - while ((src = strchr(in, '$'))) { - char *p, name[SYMBOL_MAXLENGTH]; - const char *symval = ""; - struct symbol *sym; - size_t newlen; - - strncat(res, in, src - in); - src++; - - p = name; - while (isalnum(*src) || *src == '_') - *p++ = *src++; - *p = '\0'; - - sym = sym_find(name); - if (sym != NULL) { - sym_calc_value(sym); - symval = sym_get_string_value(sym); - } + res = xmalloc(1); + *res = '\0'; - newlen = strlen(res) + strlen(symval) + strlen(src) + 1; - if (newlen > reslen) { - reslen = newlen; - res = xrealloc(res, reslen); - } + while ((p = strchr(in, '$'))) { + char *new; + + q = p + 1; + while (isalnum(*q) || *q == '_') + q++; - strcat(res, symval); - in = src; + new = env_expand_n(p + 1, q - p - 1); + + reslen = strlen(res) + (p - in) + strlen(new) + 1; + res = xrealloc(res, reslen); + strncat(res, in, p - in); + strcat(res, new); + free(new); + in = q; } + + reslen = strlen(res) + strlen(in) + 1; + res = xrealloc(res, reslen); strcat(res, in); return res; @@ -87,8 +158,7 @@ struct file *file_lookup(const char *name) /* write a dependency file as used by kbuild to track dependencies */ int file_write_dep(const char *name) { - struct symbol *sym, *env_sym; - struct expr *e; + struct env *env, *tmp; struct file *file; FILE *out; @@ -107,20 +177,12 @@ int file_write_dep(const char *name) fprintf(out, "\n%s: \\\n" "\t$(deps_config)\n\n", conf_get_autoconfig_name()); - expr_list_for_each_sym(sym_env_list, e, sym) { - struct property *prop; - const char *value; - - prop = sym_get_env_prop(sym); - env_sym = prop_get_symbol(prop); - if (!env_sym) - continue; - value = getenv(env_sym->name); - if (!value) - value = ""; - fprintf(out, "ifneq \"$(%s)\" \"%s\"\n", env_sym->name, value); + list_for_each_entry_safe(env, tmp, &env_list, node) { + fprintf(out, "ifneq \"$(%s)\" \"%s\"\n", + env->name, getenv(env->name) ?: ""); fprintf(out, "%s: FORCE\n", conf_get_autoconfig_name()); fprintf(out, "endif\n"); + env_list_del(env); } fprintf(out, "\n$(deps_config): ;\n"); diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 02de6fe..0d89ea6 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -75,7 +75,7 @@ static void warn_ignored_character(char chr) } %} -n [A-Za-z0-9_-] +n [$A-Za-z0-9_-] %% int str = 0; diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 262c464..784083d 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -534,7 +534,6 @@ void conf_parse(const char *name) zconf_initscan(name); - sym_init(); _menu_init(); if (getenv("ZCONF_DEBUG")) From patchwork Fri Feb 16 18:38:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128607 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp864303ljc; Fri, 16 Feb 2018 10:41:40 -0800 (PST) X-Google-Smtp-Source: AH8x226JP7f0SNAJoqCzep9No2HKiX3dEf677eYeRUUa5qp6DeH7DDLY4f74O5PP5gY5yLyiHNzK X-Received: by 2002:a17:902:a607:: with SMTP id u7-v6mr6636951plq.71.1518806500009; Fri, 16 Feb 2018 10:41:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806500; cv=none; d=google.com; s=arc-20160816; b=taLsonbIBUDcNPYAvuprImgyyBFkAzq0LNSPPfFsqalrGjIy7W62A9QaCbdG7xSiBr luZRBFdsLQf7kRO9yj6mIDOqRjp0Ay7yvSmjx+vm+gK1qW1eReGAzHKaBK2qW5I4qFjJ QJPtaH3Gsn+jT+HdoLmri3+RG2Or3utyulMwGBAiQcZwavGhxcP4esh3X4RFjkR3VULl bBEe929xIJyNM69Ffybh1YnB4KW0G3XRYwBGeaJuH6UZDawt6kKj2pxyYz6vauRrbeMm ud230ze7OZVoS9ZQjqbfjb9J/IYD4aKXg0HjPktsDLkGMjx8QB/jzBBuEyJLLgOrE0Hm F79g== 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 :arc-authentication-results; bh=BFV7tpwgyTEsSRyQedUPFLKAzO55hNEeU6iegJTYxjI=; b=K+WLhjXaeVYXYWT9h11KTJ8G8kHenLm1BVaXPoAeCeAQ/Dxz5/bO6A5bYOMwA3No/2 /vNOUOffr9d4XtaanGF22XNIkrcxDjH2RL7SltJXTbdbFrP8gSaz+tHslc5OJGQ9BTus 8UHU9bkzCBwQ7bbsBngfzQifIOWNdDyObPJcZ5UcF8yU/LSvlSnTrBi3YTRcKfPVD9J5 Je4gNpp9PrPgg3F8nXGCoX7efG2M6ytD4jg+T+0ErhsYDoGm5pZgUqIbPf9mKIIv2Aru 6C9Y+kA8kHg2/DeLPUqMmx9ibdP1XHhd+cHqRWbN0F7DwKpj9XnpzNNEbPswUP0MEUus NnSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=KuqKp2ZZ; 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 l12si851327pfg.404.2018.02.16.10.41.39; Fri, 16 Feb 2018 10:41:39 -0800 (PST) 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=KuqKp2ZZ; 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 S1752798AbeBPSlW (ORCPT + 28 others); Fri, 16 Feb 2018 13:41:22 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:57762 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752521AbeBPSlS (ORCPT ); Fri, 16 Feb 2018 13:41:18 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBTA013418; Sat, 17 Feb 2018 03:39:19 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBTA013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806360; bh=BFV7tpwgyTEsSRyQedUPFLKAzO55hNEeU6iegJTYxjI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KuqKp2ZZchCXXLv+B/nim5UNeYXRSCu23oX5x2/k95dYeJJuwRqGIYzNp1K2yOgju yedX0fwakSe09IkLf/lDZRMCIdeD+phS66rIyjNB3jSY9gSFiC9AHcPX4m8cDv8a1n XIyihjq++yr/ApmLwKmOnJ+3dcCtj9xmBhnwrq5X9BB/9WnzVib8tgUEvYy1rt6N2+ O3jrkQdgabvKiciBF209Pxjsj6jtqkrjkAgfSJWua7LvI/N3k0WK0YiYCvKk7xpb0J h0Nu8ciVW/Q1xwZwyn2Nu+KtBHaNN9sNVmVEsOLrxH7ezi4fEsm/cWTqICHS9XHFz7 M8JtBtBjbPpaA== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 07/23] kconfig: add function support and implement 'shell' function Date: Sat, 17 Feb 2018 03:38:35 +0900 Message-Id: <1518806331-7101-8-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This commit adds a new concept 'function' to Kconfig. A function call resembles a variable reference with arguments, and looks like this: $(function arg1, arg2, arg3, ...) (Actually, this syntax was inspired by Makefile.) Real examples will look like this: $(shell true) $(cc-option -fstackprotector) This commit adds the basic infrastructure to add, delete, evaluate functions. Also, add the first built-in function $(shell ...). This evaluates to 'y' if the given command exits with 0, 'n' otherwise. I am also planning to support user-defined functions (a.k.a 'macro') for cases where hard-coding is not preferred. If you want to try this feature, the hello-world code is someting below. Example code: config CC_IS_GCC bool default $(shell $CC --version | grep -q gcc) config CC_IS_CLANG bool default $(shell $CC --version | grep -q clang) config CC_HAS_OZ bool default $(shell $CC -Werror -Oz -c -x c /dev/null -o /dev/null) Result: $ make -s alldefconfig && tail -n 3 .config CONFIG_CC_IS_GCC=y # CONFIG_CC_IS_CLANG is not set # CONFIG_CC_HAS_OZ is not set $ make CC=clang -s alldefconfig && tail -n 3 .config # CONFIG_CC_IS_GCC is not set CONFIG_CC_IS_CLANG=y CONFIG_CC_HAS_OZ=y A function call can appear anywhere a symbol reference can appear. So, the following code is possible. Example code: config CC_NAME string default "gcc" if $(shell $CC --version | grep -q gcc) default "clang" if $(shell $CC --version | grep -q clang) default "unknown compiler" Result: $ make -s alldefconfig && tail -n 1 .config CONFIG_CC_NAME="gcc" $ make CC=clang -s alldefconfig && tail -n 1 .config CONFIG_CC_NAME="clang" Signed-off-by: Masahiro Yamada --- Reminder for myself: Update Documentation/kbuild/kconfig-language.txt scripts/kconfig/function.c | 149 ++++++++++++++++++++++++++++++++++++++++++++ scripts/kconfig/lkc_proto.h | 5 ++ scripts/kconfig/util.c | 46 +++++++++++--- scripts/kconfig/zconf.l | 38 ++++++++++- scripts/kconfig/zconf.y | 9 +++ 5 files changed, 238 insertions(+), 9 deletions(-) create mode 100644 scripts/kconfig/function.c -- 2.7.4 diff --git a/scripts/kconfig/function.c b/scripts/kconfig/function.c new file mode 100644 index 0000000..60e59be --- /dev/null +++ b/scripts/kconfig/function.c @@ -0,0 +1,149 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright (C) 2018 Masahiro Yamada + +#include +#include +#include + +#include "list.h" + +#define FUNCTION_MAX_ARGS 10 + +static LIST_HEAD(function_list); + +struct function { + const char *name; + char *(*func)(int argc, char *argv[]); + struct list_head node; +}; + +static struct function *func_lookup(const char *name) +{ + struct function *f; + + list_for_each_entry(f, &function_list, node) { + if (!strcmp(name, f->name)) + return f; + } + + return NULL; +} + +static void func_add(const char *name, char *(*func)(int argc, char *argv[])) +{ + struct function *f; + + f = func_lookup(name); + if (f) { + fprintf(stderr, "%s: function already exists. ignored.\n", name); + return; + } + + f = xmalloc(sizeof(*f)); + f->name = name; + f->func = func; + + list_add_tail(&f->node, &function_list); +} + +static void func_del(struct function *f) +{ + list_del(&f->node); + free(f); +} + +static char *func_call(int argc, char *argv[]) +{ + struct function *f; + + f = func_lookup(argv[0]); + if (!f) { + fprintf(stderr, "%s: function not found\n", argv[0]); + return NULL; + } + + return f->func(argc, argv); +} + +static char *func_eval(const char *func) +{ + char *expanded, *saveptr, *str, *token, *res; + const char *delim; + int argc = 0; + char *argv[FUNCTION_MAX_ARGS]; + + expanded = expand_string_value(func); + + str = expanded; + delim = " "; + + while ((token = strtok_r(str, delim, &saveptr))) { + argv[argc++] = token; + str = NULL; + delim = ","; + } + + res = func_call(argc, argv); + + free(expanded); + + return res ?: xstrdup(""); +} + +char *func_eval_n(const char *func, size_t n) +{ + char *tmp, *res; + + tmp = xmalloc(n + 1); + memcpy(tmp, func, n); + *(tmp + n) = '\0'; + + res = func_eval(tmp); + + free(tmp); + + return res; +} + +/* built-in functions */ +static char *do_shell(int argc, char *argv[]) +{ + static const char *pre = "("; + static const char *post = ") >/dev/null 2>&1"; + char *cmd; + int ret; + + if (argc != 2) + return NULL; + + /* + * Surround the command with ( ) in case it is piped commands. + * Also, redirect stdout and stderr to /dev/null. + */ + cmd = xmalloc(strlen(pre) + strlen(argv[1]) + strlen(post) + 1); + strcpy(cmd, pre); + strcat(cmd, argv[1]); + strcat(cmd, post); + + ret = system(cmd); + + free(cmd); + + return xstrdup(ret == 0 ? "y" : "n"); +} + +void func_init(void) +{ + /* register built-in functions */ + func_add("shell", do_shell); +} + +void func_exit(void) +{ + struct function *f, *tmp; + + /* unregister all functions */ + list_for_each_entry_safe(f, tmp, &function_list, node) + func_del(f); +} diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index 9884adc..09a4f53 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -48,5 +48,10 @@ const char * sym_get_string_value(struct symbol *sym); const char * prop_get_type_name(enum prop_type type); +/* function.c */ +char *func_eval_n(const char *func, size_t n); +void func_init(void); +void func_exit(void); + /* expr.c */ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken); diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index dddf85b..ed89fb9 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -93,9 +93,10 @@ static char *env_expand_n(const char *name, size_t n) } /* - * Expand environments embedded in the string given in argument. Environments - * to be expanded shall be prefixed by a '$'. Unknown environment expands to - * the empty string. + * Expand environments and functions embedded in the string given in argument. + * Environments to be expanded shall be prefixed by a '$'. Functions to be + * evaluated shall be surrounded by $(). Unknown environment/function expands + * to the empty string. */ char *expand_string_value(const char *in) { @@ -113,11 +114,40 @@ char *expand_string_value(const char *in) while ((p = strchr(in, '$'))) { char *new; - q = p + 1; - while (isalnum(*q) || *q == '_') - q++; - - new = env_expand_n(p + 1, q - p - 1); + /* + * If the next character is '(', it is a function. + * Otherwise, environment. + */ + if (*(p + 1) == '(') { + int nest = 0; + + q = p + 2; + while (1) { + if (*q == '\0') { + fprintf(stderr, + "unterminated function: %s\n", + p); + new = xstrdup(""); + break; + } else if (*q == '(') { + nest++; + } else if (*q == ')') { + if (nest-- == 0) { + new = func_eval_n(p + 2, + q - p - 2); + q++; + break; + } + } + q++; + } + } else { + q = p + 1; + while (isalnum(*q) || *q == '_') + q++; + + new = env_expand_n(p + 1, q - p - 1); + } reslen = strlen(res) + (p - in) + strlen(new) + 1; res = xrealloc(res, reslen); diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 0d89ea6..f433ab0 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -1,7 +1,7 @@ %option nostdinit noyywrap never-interactive full ecs %option 8bit nodefault perf-report perf-report %option noinput -%x COMMAND HELP STRING PARAM +%x COMMAND HELP STRING PARAM FUNCTION %{ /* * Copyright (C) 2002 Roman Zippel @@ -25,6 +25,7 @@ static struct { static char *text; static int text_size, text_asize; +static int function_nest; struct buffer { struct buffer *parent; @@ -138,6 +139,12 @@ n [$A-Za-z0-9_-] new_string(); BEGIN(STRING); } + "$(" { + new_string(); + append_string(yytext, yyleng); + function_nest = 0; + BEGIN(FUNCTION); + } \n BEGIN(INITIAL); current_file->lineno++; return T_EOL; ({n}|[/.])+ { const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); @@ -196,6 +203,35 @@ n [$A-Za-z0-9_-] } } +{ + [^()\n]* { + append_string(yytext, yyleng); + } + "(" { + append_string(yytext, yyleng); + function_nest++; + } + ")" { + append_string(yytext, yyleng); + if (function_nest-- == 0) { + BEGIN(PARAM); + yylval.string = text; + return T_WORD; + } + } + \n { + fprintf(stderr, + "%s:%d:warning: multi-line function not supported\n", + zconf_curname(), zconf_lineno()); + current_file->lineno++; + BEGIN(INITIAL); + return T_EOL; + } + <> { + BEGIN(INITIAL); + } +} + { [ \t]+ { ts = 0; diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 784083d..d9977de 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -534,11 +534,19 @@ void conf_parse(const char *name) zconf_initscan(name); + func_init(); _menu_init(); if (getenv("ZCONF_DEBUG")) yydebug = 1; yyparse(); + + /* + * Currently, functions are evaluated only when Kconfig files are + * parsed. We can free functions here. + */ + func_exit(); + if (yynerrs) exit(1); if (!modules_sym) @@ -778,4 +786,5 @@ void zconfdump(FILE *out) #include "confdata.c" #include "expr.c" #include "symbol.c" +#include "function.c" #include "menu.c" From patchwork Fri Feb 16 18:38:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128626 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp870440ljc; Fri, 16 Feb 2018 10:49:21 -0800 (PST) X-Google-Smtp-Source: AH8x227U3FnUUcx2+Hui93sTBDyEsaRfHF8/q79hdnzKo7mxqjLavKuKILL3cDPgvPwFNlgY1rez X-Received: by 10.98.253.17 with SMTP id p17mr2208017pfh.105.1518806961067; Fri, 16 Feb 2018 10:49:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806961; cv=none; d=google.com; s=arc-20160816; b=wGzicr4D5za4zZ7smtHXnGfO1A+6WZvz/mWlr72EsXstEl4+MI8brBKmeYe4oXHsvk FKe5+lqN1ep4TjzRPRmwlwckXQeMjbmoNRP1S3WBxeSiqvyz9Gd6aF4icIlgNEtZglfG ltUQAYDiaZ9xXIvWkG1qraKPMjQxwC6rj515LZm3Wl62CsSKZ3ZCi9GH4mVvGCilcq+n K4ClJD5FClFXZ/2xyWN+Pcx1rqDBSCqfa1F+tDYC3MY2RWZ/5T9KOabGW9bdRSxTGTLU BQb0isLF4g2/k3xZLbixedigE9jCfjI68DOEnMzX0PTL0Jgv2f1s1Qd9/xUg7RsKCink Aujw== 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 :arc-authentication-results; bh=eB+H8YnayIo+d4ZLnZL2bVOcxIArXroK9M7Ad0zqD0Q=; b=VXl/KJRO3KjjgF7B+sif7VvGmn6NSgg95h2CTaIUMbFO9VQMLofFXyUAl/1udB8lCY SPLyQ2hhZocRNbBaiSpqeIfLUV7m5+bSa4s6XJKUXf45mW9g5o3BBBF/Osoc1fD381nz Yt2GnThDiSCY03SOlPP45nU08tM8//Zly7bBsuXoBadrLpLAT/5baYGmlMGMOjU4qkOX ewIUyb47aiyyT9Gk57fLgMAfMf3gF4ZFN4QBRKuJATElrmHCykGYsCpQVlap+szNxslK AXxeAaxj0Sh3Rsoc6KYTzsltiivZ7PGOxfdIGeysk+4JM7pfuKamWiN3GEZwY6/7wYE3 OPMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=QlYvZbjk; 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 f5si12574pgr.235.2018.02.16.10.49.20; Fri, 16 Feb 2018 10:49:21 -0800 (PST) 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=QlYvZbjk; 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 S1752212AbeBPSsF (ORCPT + 28 others); Fri, 16 Feb 2018 13:48:05 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:57759 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752637AbeBPSlS (ORCPT ); Fri, 16 Feb 2018 13:41:18 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBTB013418; Sat, 17 Feb 2018 03:39:20 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBTB013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806361; bh=eB+H8YnayIo+d4ZLnZL2bVOcxIArXroK9M7Ad0zqD0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QlYvZbjkUoWuYzns9y5a2Nen6oqVhUux31SEX3xP+qqd7QYzmU3z5NnNepI7R8kuj NATfvcKkboNdOxcd/qTA5C1Sk7GXqxL1dcVtTXQPCSid8cZCZO0EeX2qfo8k5n0OLh PSSzEdCJKjBZKRevAzxo8vPgJ9Z2N4VD6NrG6rXGOce8q4X5B2IDQnbplI2aWT3ecT o71iCVGsNzVnA2BnWLmpI+6ZtJV/YvmhRXfU3cVYzGkIzWQqVG4oburUHvxULOrs2+ HKmVdQZebzITC5Emj4Jd6cGCIUy4fk+wZ3TuwS+913yLXAd3ZIxoVlt3gQf7rLrtWJ iMJQVNu2LAUag== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 08/23] kconfig: add 'macro' keyword to support user-defined function Date: Sat, 17 Feb 2018 03:38:36 +0900 Message-Id: <1518806331-7101-9-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now, we got a basic ability to test compiler capability in Kconfig. config CC_HAS_STACKPROTECTOR bool default $(shell $CC -Werror -fstack-protector -c -x c /dev/null -o /dev/null) This works, but it is ugly to repeat this long boilerplate. We want to describe like this: config CC_HAS_STACKPROTECTOR bool default $(cc-option -fstack-protector) It is straight-forward to implement a new function, but I do not like to hard-code specialized functions like this. Hence, here is another feature to add functions from Kconfig files. A user-defined function can be defined as a string type symbol with a special keyword 'macro'. It can be referenced in the same way as built-in functions. This feature was also inspired by Makefile where user-defined functions are referenced by $(call func-name, args...), but I omitted the 'call' to makes it shorter. The macro definition can contain $(1), $(2), ... which will be replaced with arguments from the caller. Example code: config cc-option string macro $(shell $CC -Werror $(1) -c -x c /dev/null -o /dev/null) config CC_HAS_STACKPROTECTOR bool default $(cc-option -fstack-protector) Signed-off-by: Masahiro Yamada --- Reminder for myself: Update Documentation/kbuild/kconfig-language.txt scripts/kconfig/function.c | 66 +++++++++++++++++++++++++++++++++++++++++---- scripts/kconfig/kconf_id.c | 1 + scripts/kconfig/lkc_proto.h | 1 + scripts/kconfig/zconf.y | 8 ++++++ 4 files changed, 71 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/scripts/kconfig/function.c b/scripts/kconfig/function.c index 60e59be..f7f154d 100644 --- a/scripts/kconfig/function.c +++ b/scripts/kconfig/function.c @@ -14,7 +14,8 @@ static LIST_HEAD(function_list); struct function { const char *name; - char *(*func)(int argc, char *argv[]); + char *(*func)(struct function *f, int argc, char *argv[]); + void *priv; struct list_head node; }; @@ -30,7 +31,9 @@ static struct function *func_lookup(const char *name) return NULL; } -static void func_add(const char *name, char *(*func)(int argc, char *argv[])) +static void func_add(const char *name, + char *(*func)(struct function *f, int argc, char *argv[]), + void *priv) { struct function *f; @@ -43,6 +46,7 @@ static void func_add(const char *name, char *(*func)(int argc, char *argv[])) f = xmalloc(sizeof(*f)); f->name = name; f->func = func; + f->priv = priv; list_add_tail(&f->node, &function_list); } @@ -50,6 +54,7 @@ static void func_add(const char *name, char *(*func)(int argc, char *argv[])) static void func_del(struct function *f) { list_del(&f->node); + free(f->priv); free(f); } @@ -63,7 +68,7 @@ static char *func_call(int argc, char *argv[]) return NULL; } - return f->func(argc, argv); + return f->func(f, argc, argv); } static char *func_eval(const char *func) @@ -106,8 +111,59 @@ char *func_eval_n(const char *func, size_t n) return res; } +/* run user-defined function */ +static char *do_macro(struct function *f, int argc, char *argv[]) +{ + char *new; + char *src, *p, *res; + size_t newlen; + int n; + + new = xmalloc(1); + *new = 0; + + /* + * This is a format string. $(1), $(2), ... must be replaced with + * function arguments. + */ + src = f->priv; + p = src; + + while ((p = strstr(p, "$("))) { + if (isdigit(p[2]) && p[3] == ')') { + n = p[2] - '0'; + if (n < argc) { + newlen = strlen(new) + (p - src) + + strlen(argv[n]) + 1; + new = xrealloc(new, newlen); + strncat(new, src, p - src); + strcat(new, argv[n]); + src = p + 4; + } + p += 2; + } + p += 2; + } + + newlen = strlen(new) + strlen(src) + 1; + new = xrealloc(new, newlen); + strcat(new, src); + + res = expand_string_value(new); + + free(new); + + return res; +} + +/* add user-defined function (macro) */ +void func_add_macro(const char *name, char *macro) +{ + func_add(name, do_macro, macro); +} + /* built-in functions */ -static char *do_shell(int argc, char *argv[]) +static char *do_shell(struct function *f, int argc, char *argv[]) { static const char *pre = "("; static const char *post = ") >/dev/null 2>&1"; @@ -136,7 +192,7 @@ static char *do_shell(int argc, char *argv[]) void func_init(void) { /* register built-in functions */ - func_add("shell", do_shell); + func_add("shell", do_shell, NULL); } void func_exit(void) diff --git a/scripts/kconfig/kconf_id.c b/scripts/kconfig/kconf_id.c index b3e0ea0..5a1357d 100644 --- a/scripts/kconfig/kconf_id.c +++ b/scripts/kconfig/kconf_id.c @@ -28,6 +28,7 @@ static struct kconf_id kconf_id_array[] = { { "imply", T_IMPLY, TF_COMMAND }, { "range", T_RANGE, TF_COMMAND }, { "visible", T_VISIBLE, TF_COMMAND }, + { "macro", T_MACRO, TF_COMMAND }, { "option", T_OPTION, TF_COMMAND }, { "on", T_ON, TF_PARAM }, { "modules", T_OPT_MODULES, TF_OPTION }, diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index 09a4f53..25caca3 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -50,6 +50,7 @@ const char * prop_get_type_name(enum prop_type type); /* function.c */ char *func_eval_n(const char *func, size_t n); +void func_add_macro(const char *name, char *macro); void func_init(void); void func_exit(void); diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index d9977de..19452b6 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -65,6 +65,7 @@ static struct menu *current_menu, *current_entry; %token T_IMPLY %token T_RANGE %token T_VISIBLE +%token T_MACRO %token T_OPTION %token T_ON %token T_WORD @@ -199,6 +200,7 @@ config_option_list: | config_option_list config_option | config_option_list symbol_option | config_option_list depends + | config_option_list macro | config_option_list help | config_option_list option_error | config_option_list T_EOL @@ -246,6 +248,12 @@ config_option: T_RANGE symbol symbol if_expr T_EOL printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); }; +macro: T_MACRO T_WORD T_EOL +{ + current_entry->sym->flags |= SYMBOL_AUTO; + func_add_macro(current_entry->sym->name, $2); +} + symbol_option: T_OPTION symbol_option_list T_EOL ; From patchwork Fri Feb 16 18:38:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128629 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp871241ljc; Fri, 16 Feb 2018 10:50:11 -0800 (PST) X-Google-Smtp-Source: AH8x225xEeFVeWh1wUE4JOh5UlogDbVyyUejGpUyr/IL72DYAgnktU0D224+rXP3R9hfD6Y54LFs X-Received: by 10.98.18.65 with SMTP id a62mr7000912pfj.115.1518807011036; Fri, 16 Feb 2018 10:50:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518807011; cv=none; d=google.com; s=arc-20160816; b=zFfz4EByuvofUTIZPwPVAjL5kD6uQ1daNMPjMQXXOZ3m3mQYjl4l9adG8LFqD/gPWA 3HwR8CaCxANENib+Kh2M+Tp3Ic4iUyxU/sNeP7jjwNyKN7mejezrhNG1KLYRdp88/CBB vgXKol/JiMhglYj/IIL0HtU5MS7LTDxjRyqxqeC5v2zwgEabKDJlv6pEn8ZihrIzVN/U tfxSKHkAkIMhob0hoWr0woOFZ/hjHFpdO47WLfZdpSpvberR3QjwkURuT8i7UQ+VydZZ dvJCN9FP5gXN5i2/8Fu/s65GNtrMafG4ybxwOeXbGEK4hWbfH8HLio2iV13RrvcvJHT9 dgfw== 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 :arc-authentication-results; bh=G5hsOF43iRoT1pN7d/9mibt7V26nz0plYRyEv44rmrM=; b=eQkuUHsQcyyTnQ+o0xF/Mo/ZvYKe6WjhMDww1rILIQSD+VkzXEnf5Xe0pdQDbmUMDA i48HtwZBh+rkh5V0b6K9nmD9VzhxBluJJ2Za8HcqyLi3CzaFEqhAauQDRdZ8bdm9e52j gLyuh0KHnX+vppw2nqmQyuuyPr/IcDCVlIK/QNVttq2Jkjn+w2slfHnr5FY0B3G3yrhj sYuQerMYpz4YUCgw3gLG8wDmGUOu4oWwEa5g8fB1rJd+8hqh8yocQWTNFaVlyDBE6u// jimqeqcjVBNctPPlRqt13CsRCB7kHjEvN/qx6okW2KD5fuAE7D72Vz395PDoPjxYp9PM Mm+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=2QEWDR4H; 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 w9-v6si1158173plp.425.2018.02.16.10.50.10; Fri, 16 Feb 2018 10:50:11 -0800 (PST) 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=2QEWDR4H; 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 S1751623AbeBPSry (ORCPT + 28 others); Fri, 16 Feb 2018 13:47:54 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:57772 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752659AbeBPSlS (ORCPT ); Fri, 16 Feb 2018 13:41:18 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBTC013418; Sat, 17 Feb 2018 03:39:21 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBTC013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806361; bh=G5hsOF43iRoT1pN7d/9mibt7V26nz0plYRyEv44rmrM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2QEWDR4Hlr3QilxioYCpCSsx43ONaaJmInvWTXXUmE304l4lAMavOHPfAeA0T96gl AXKGQJOHHYwTFzyyf6xFcHDTAB/hG32I5n7NDEbux7IdeGTEV19T7dPMAWINmZ5Xsc n8TGz3q2v3Mk3WadW/wvNhMfgI4/zg8nlhffc1mvkQ+6cGWMRRSFFfcj7f7X/naLJ4 73fvUX8b4gX0kAjjgmsh5iK3Sh+aF6RZzt9fBS88p9pp++UNxaRsaMEIBNI6+P3rwh qrvOzQwf37NJ5VqnbGw8QJi94bHXwB/307gwrmuQyqSDDgVsqs3htVB0qtPEQswd+t /+r4sXsBGUqfQ== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 09/23] kconfig: add 'cc-option' macro Date: Sat, 17 Feb 2018 03:38:37 +0900 Message-Id: <1518806331-7101-10-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This will be the most frequently used macro. It evaluates to 'y' if the given argument is supported by the compiler, or 'n' otherwise. Signed-off-by: Masahiro Yamada --- init/Kconfig | 4 ++++ 1 file changed, 4 insertions(+) -- 2.7.4 diff --git a/init/Kconfig b/init/Kconfig index b4814e6..f026a62 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -8,6 +8,10 @@ config DEFCONFIG_LIST default ARCH_DEFCONFIG default "arch/$ARCH/defconfig" +config cc-option + string + macro $(shell $CC -Werror $(1) -c -x c /dev/null -o /dev/null) + config CONSTRUCTORS bool depends on !UML From patchwork Fri Feb 16 18:38:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128612 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp865131ljc; Fri, 16 Feb 2018 10:42:38 -0800 (PST) X-Google-Smtp-Source: AH8x224HoDETa9wpIjLRgC35bxUlAwwsSqMvdGk6ZxaLydcwbrMhcmi7i5i01QcnVS2wm0HD/VIM X-Received: by 10.98.144.213 with SMTP id q82mr6981669pfk.37.1518806558282; Fri, 16 Feb 2018 10:42:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806558; cv=none; d=google.com; s=arc-20160816; b=ArqJfWl+EvOqJMuh9r76L9Lr0El+lkc19xiIwSqUGhnO7gEUd5mzKQul9vy5f2LZSF hxAjukn2X828CXPyqn1scsDZMOIsRPeIdM5mNJfmFnQt7pzQ+5FPbZK2Bmjrv+gJYvl0 XkfDZYgj1srV4MG1Czmj1X0NqECPDPa4FHXi/dQryyjH7sFoy4tR8gzApaGDV8xW0nZS XZg849ZOdzM2hWaJ6P72Fq3ujqccwBUSKYVbn4et/Ru54PFPisd1/HQIHn17XM8xq9+A y2Iw3LEF0ipOlbPQO4Fufixx189oqlmPUHpSR6s6aSolsuK/K3Kw8AR9gWkSUq2MGnjp /Nyw== 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 :arc-authentication-results; bh=YofhUX8RoPoVMr1fDLpFqcWzGOIs9n0RgRDX86OQxhA=; b=YeatPSCp8bK4jSNLrQ3zR0TGJNo1Vmse1oA0Z2qs7TN/VLreGdRawRUgYDfbuI1NbZ scQmSkiGHY1LK2WYoPCkbWwwsVZObWS3WkjqhtLTFRu2R4uJiZEi/IFBfQsjWdNj9PPd j3/P7VwKFV4nJaM19L455nDImHBgVk5VEYEZXcPiyyEB5OxvbZdL5JySwd2lWvAh9QgN sOo/zEr1M3HVmm3DnvprQlpXtR+Fk8FtBwhHyQ1o71/uQE1UB2kutMqIEBaG0JqKo+jj sK0+EYDMj6xuOLm7WHiTV/OLFjbCoDGVCmg7Ng0hKNjO+iOr2oSjiUITCfA6O1YNcIVy wWgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=RwzKdsEr; 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 m13si7068458pfh.118.2018.02.16.10.42.38; Fri, 16 Feb 2018 10:42:38 -0800 (PST) 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=RwzKdsEr; 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 S1753361AbeBPSmc (ORCPT + 28 others); Fri, 16 Feb 2018 13:42:32 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:58925 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753280AbeBPSm0 (ORCPT ); Fri, 16 Feb 2018 13:42:26 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBTD013418; Sat, 17 Feb 2018 03:39:22 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBTD013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806363; bh=YofhUX8RoPoVMr1fDLpFqcWzGOIs9n0RgRDX86OQxhA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RwzKdsEr1LaoEDCLmxrK/GItbhQazAS9Shbv+z2Bcwz9jN8wcZ8N65IdfhIUTtXJQ IE8BI/NlsdB1iciW5s8FphFfSb1kMaF64TWU6nHXo0bTZVOiUoplgh3k1Ytbg1PbjS p2U5qF/Gs49agOWR8JZb2/Dbr5sUMK4R3NAmC0QvlAxoMwZIoY/tbqevDQjS6EEhQ0 CzSNJk0L4D+kr/3GnJz9MaOVV+AHATP9RFb7S9bODmUFFr5ypol32KYXpyD4Sau7i2 2JoYDMTGZJydPVg6GcgNxAuTu70nXKliQqe6TpeYwVtgQDNNlUdJPY40wTWZEtYntE MyYc6EArO0HIA== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar Subject: [PATCH 10/23] stack-protector: test compiler capability in Kconfig and drop AUTO mode Date: Sat, 17 Feb 2018 03:38:38 +0900 Message-Id: <1518806331-7101-11-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add CC_HAS_STACKPROTECTOR(_STRONG) to test if the compiler supports -fstack-protector(-strong) option. X86 has additional shell scripts in case the compiler supports the option, but generates broken code. I added CC_HAS_SANE_STACKPROTECTOR to test this. I had to add -m32 to gcc-x86_32-has-stack-protector.sh to make it work correctly. If the compiler does not support the option, the menu is automatically hidden. If _STRONG is not supported, it will fall back to _REGULAR. This means, _AUTO is implicitly supported in the dependency solver of Kconfig, hence removed. I also turned the 'choice' into only two boolean symbols. The use of 'choice' is not a good idea here, because all of all{yes,mod,no}config would choose the first visible value, while we want allnoconfig to disable as many features as possible. I did not add CC_HAS_STACKPROTECTOR_NONE in the hope that GCC versions we support will recognize -fno-stack-protector. If this turns out to be a problem, it will be possible to do this: stackp-flags-$(CONFIG_CC_HAS_STACKPROTECTOR_NONE) := -fno-stack-protector stackp-flags-$(CONFIG_CC_STACKPROTECTOR) := -fstack-protector stackp-flags-$(CONFIG_CC_STACKPROTECTOR_STRONG) := -fstack-protector-strong Signed-off-by: Masahiro Yamada --- Makefile | 93 ++----------------------------- arch/Kconfig | 37 ++++++------ arch/x86/Kconfig | 8 ++- scripts/gcc-x86_32-has-stack-protector.sh | 7 +-- scripts/gcc-x86_64-has-stack-protector.sh | 5 -- 5 files changed, 30 insertions(+), 120 deletions(-) -- 2.7.4 diff --git a/Makefile b/Makefile index 9a8c689..e9fc7c9 100644 --- a/Makefile +++ b/Makefile @@ -675,55 +675,11 @@ ifneq ($(CONFIG_FRAME_WARN),0) KBUILD_CFLAGS += $(call cc-option,-Wframe-larger-than=${CONFIG_FRAME_WARN}) endif -# This selects the stack protector compiler flag. Testing it is delayed -# until after .config has been reprocessed, in the prepare-compiler-check -# target. -ifdef CONFIG_CC_STACKPROTECTOR_AUTO - stackp-flag := $(call cc-option,-fstack-protector-strong,$(call cc-option,-fstack-protector)) - stackp-name := AUTO -else -ifdef CONFIG_CC_STACKPROTECTOR_REGULAR - stackp-flag := -fstack-protector - stackp-name := REGULAR -else -ifdef CONFIG_CC_STACKPROTECTOR_STRONG - stackp-flag := -fstack-protector-strong - stackp-name := STRONG -else - # If either there is no stack protector for this architecture or - # CONFIG_CC_STACKPROTECTOR_NONE is selected, we're done, and $(stackp-name) - # is empty, skipping all remaining stack protector tests. - # - # Force off for distro compilers that enable stack protector by default. - KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector) -endif -endif -endif -# Find arch-specific stack protector compiler sanity-checking script. -ifdef stackp-name -ifneq ($(stackp-flag),) - stackp-path := $(srctree)/scripts/gcc-$(SRCARCH)_$(BITS)-has-stack-protector.sh - stackp-check := $(wildcard $(stackp-path)) - # If the wildcard test matches a test script, run it to check functionality. - ifdef stackp-check - ifneq ($(shell $(CONFIG_SHELL) $(stackp-check) $(CC) $(KBUILD_CPPFLAGS) $(biarch)),y) - stackp-broken := y - endif - endif - ifndef stackp-broken - # If the stack protector is functional, enable code that depends on it. - KBUILD_CPPFLAGS += -DCONFIG_CC_STACKPROTECTOR - # Either we've already detected the flag (for AUTO) or we'll fail the - # build in the prepare-compiler-check rule (for specific flag). - KBUILD_CFLAGS += $(stackp-flag) - else - # We have to make sure stack protector is unconditionally disabled if - # the compiler is broken (in case we're going to continue the build in - # AUTO mode). - KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector) - endif -endif -endif +stackp-flags-y := -fno-stack-protector +stackp-flags-$(CONFIG_CC_STACKPROTECTOR) := -fstack-protector +stackp-flags-$(CONFIG_CC_STACKPROTECTOR_STRONG) := -fstack-protector-strong + +KBUILD_CFLAGS += $(stackp-flags-y) ifeq ($(cc-name),clang) KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,) @@ -1079,7 +1035,7 @@ endif # prepare2 creates a makefile if using a separate output directory. # From this point forward, .config has been reprocessed, so any rules # that need to depend on updated CONFIG_* values can be checked here. -prepare2: prepare3 prepare-compiler-check outputmakefile asm-generic +prepare2: prepare3 outputmakefile asm-generic prepare1: prepare2 $(version_h) include/generated/utsrelease.h \ include/config/auto.conf @@ -1105,43 +1061,6 @@ uapi-asm-generic: PHONY += prepare-objtool prepare-objtool: $(objtool_target) -# Check for CONFIG flags that require compiler support. Abort the build -# after .config has been processed, but before the kernel build starts. -# -# For security-sensitive CONFIG options, we don't want to fallback and/or -# silently change which compiler flags will be used, since that leads to -# producing kernels with different security feature characteristics -# depending on the compiler used. (For example, "But I selected -# CC_STACKPROTECTOR_STRONG! Why did it build with _REGULAR?!") -PHONY += prepare-compiler-check -prepare-compiler-check: FORCE -# Make sure compiler supports requested stack protector flag. -ifdef stackp-name - # Warn about CONFIG_CC_STACKPROTECTOR_AUTO having found no option. - ifeq ($(stackp-flag),) - @echo CONFIG_CC_STACKPROTECTOR_$(stackp-name): \ - Compiler does not support any known stack-protector >&2 - else - # Fail if specifically requested stack protector is missing. - ifeq ($(call cc-option, $(stackp-flag)),) - @echo Cannot use CONFIG_CC_STACKPROTECTOR_$(stackp-name): \ - $(stackp-flag) not supported by compiler >&2 && exit 1 - endif - endif -endif -# Make sure compiler does not have buggy stack-protector support. If a -# specific stack-protector was requested, fail the build, otherwise warn. -ifdef stackp-broken - ifeq ($(stackp-name),AUTO) - @echo CONFIG_CC_STACKPROTECTOR_$(stackp-name): \ - $(stackp-flag) available but compiler is broken: disabling >&2 - else - @echo Cannot use CONFIG_CC_STACKPROTECTOR_$(stackp-name): \ - $(stackp-flag) available but compiler is broken >&2 && exit 1 - endif -endif - @: - # Generate some files # --------------------------------------------------------------------------- diff --git a/arch/Kconfig b/arch/Kconfig index 76c0b54..9b7a628 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -535,13 +535,21 @@ config HAVE_CC_STACKPROTECTOR bool help An arch should select this symbol if: - - its compiler supports the -fstack-protector option - it has implemented a stack canary (e.g. __stack_chk_guard) -choice - prompt "Stack Protector buffer overflow detection" +config CC_HAS_STACKPROTECTOR + bool + default $(cc-option -fstack-protector) + +config CC_HAS_STACKPROTECTOR_STRONG + bool + default $(cc-option -fstack-protector-strong) + +config CC_STACKPROTECTOR + bool "Stack Protector buffer overflow detection" depends on HAVE_CC_STACKPROTECTOR - default CC_STACKPROTECTOR_AUTO + depends on CC_HAS_STACKPROTECTOR + default y help This option turns on the "stack-protector" GCC feature. This feature puts, at the beginning of functions, a canary value on @@ -551,14 +559,6 @@ choice overwrite the canary, which gets detected and the attack is then neutralized via a kernel panic. -config CC_STACKPROTECTOR_NONE - bool "None" - help - Disable "stack-protector" GCC feature. - -config CC_STACKPROTECTOR_REGULAR - bool "Regular" - help Functions will have the stack-protector canary logic added if they have an 8-byte or larger character array on the stack. @@ -570,7 +570,10 @@ config CC_STACKPROTECTOR_REGULAR by about 0.3%. config CC_STACKPROTECTOR_STRONG - bool "Strong" + bool "Strong Stack Protector" + depends on CC_HAS_STACKPROTECTOR_STRONG + depends on CC_STACKPROTECTOR + default y help Functions will have the stack-protector canary logic added in any of the following conditions: @@ -588,14 +591,6 @@ config CC_STACKPROTECTOR_STRONG about 20% of all kernel functions, which increases the kernel code size by about 2%. -config CC_STACKPROTECTOR_AUTO - bool "Automatic" - help - If the compiler supports it, the best available stack-protector - option will be chosen. - -endchoice - config THIN_ARCHIVES def_bool y help diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 54d943a..498694d 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -124,7 +124,6 @@ config X86 select HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD if X86_64 select HAVE_ARCH_VMAP_STACK if X86_64 select HAVE_ARCH_WITHIN_STACK_FRAMES - select HAVE_CC_STACKPROTECTOR select HAVE_CMPXCHG_DOUBLE select HAVE_CMPXCHG_LOCAL select HAVE_CONTEXT_TRACKING if X86_64 @@ -340,6 +339,13 @@ config PGTABLE_LEVELS default 2 source "init/Kconfig" + +config CC_HAS_SANE_STACKPROTECTOR + bool + default $(shell $srctree/scripts/gcc-x86_64-has-stack-protector.sh $CC) if 64BIT + default $(shell $srctree/scripts/gcc-x86_32-has-stack-protector.sh $CC) + select HAVE_CC_STACKPROTECTOR + source "kernel/Kconfig.freezer" menu "Processor type and features" diff --git a/scripts/gcc-x86_32-has-stack-protector.sh b/scripts/gcc-x86_32-has-stack-protector.sh index 6b2aeef..f5c1194 100755 --- a/scripts/gcc-x86_32-has-stack-protector.sh +++ b/scripts/gcc-x86_32-has-stack-protector.sh @@ -1,9 +1,4 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 -echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -fstack-protector - -o - 2> /dev/null | grep -q "%gs" -if [ "$?" -eq "0" ] ; then - echo y -else - echo n -fi +echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -m32 -O0 -fstack-protector - -o - 2> /dev/null | grep -q "%gs" diff --git a/scripts/gcc-x86_64-has-stack-protector.sh b/scripts/gcc-x86_64-has-stack-protector.sh index 4a48bdc..3755af0 100755 --- a/scripts/gcc-x86_64-has-stack-protector.sh +++ b/scripts/gcc-x86_64-has-stack-protector.sh @@ -2,8 +2,3 @@ # SPDX-License-Identifier: GPL-2.0 echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -mcmodel=kernel -fno-PIE -fstack-protector - -o - 2> /dev/null | grep -q "%gs" -if [ "$?" -eq "0" ] ; then - echo y -else - echo n -fi From patchwork Fri Feb 16 18:38:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128617 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp867509ljc; Fri, 16 Feb 2018 10:45:31 -0800 (PST) X-Google-Smtp-Source: AH8x225S1LpobXFEtFdV732Ebf5CAga2m9TboBRIsSyWafUIUulqOtZzXvjdMTkTJ7HqkdNUrzk7 X-Received: by 10.98.17.15 with SMTP id z15mr7030260pfi.116.1518806731809; Fri, 16 Feb 2018 10:45:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806731; cv=none; d=google.com; s=arc-20160816; b=C0yioGytr4a3HjLkAS92UWlVpdCPHAyWSoYuwJyvyJpLhyQ6lWZkZXuTNL3rdQeIkl D+7QDL0wT6FjypZF8tjeNNEmv5o22CzLuMueTDHHYIsnT9h3GQ61kRChBgbeKaRI/afz kSfygPcw4Fb2EhvwXzWesE8JEDqO/5QghXXBkuFmko7sKMG8UQZ7CAftVbZ6lW93hhVr wwNoW1UOeWLCL7BuZrG2jfp62gnsozAR2qw7tZjFPj5jxIKWhy9az0BfZE7G1s92xn+/ xoTxAMNolABTkqiRZ63fQzVkOO5BJzSMFpkbL9wfjLqKH5RggvWrK/tuPvjtoZW4l+F8 +skA== 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 :arc-authentication-results; bh=6/IoqUTGHai0Czf36phhQJ7Uyzpz6vT0GEH8DaNw/3g=; b=wbIXZBHF76NxUT8umv4lbZs2jdNStA8YbE8/OjiWht1m7eqBTNaA5ov33OWqg0EM4X kgnY9YkAN0z13bgnC88+nVanLG8VdMlp7jRT/a5wh5+FWSDuCtR0XxfMZ+8q+BG0u+wt z1EjP7Nw5G8XjCXjzcifpbezDhiIQrJ3whbMnkqP+tVn8B+M5ChohJFR1igUqcb4BZUt UAunLN9/nsP+XANNtJ/F39NaSTlDWZkc6YM1wcMzEZRexM+WFhN+kxAYryvngW0Xcgxo tv1nQxO8unLzIbSpWdz4FR61VkWNsD6LMX1E6Gx90otRgdL8S1BpHo+/SZ0+XVxwy5hv IEGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=QV6T0K0+; 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 y12-v6si4889566plt.1.2018.02.16.10.45.31; Fri, 16 Feb 2018 10:45:31 -0800 (PST) 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=QV6T0K0+; 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 S1753728AbeBPSp0 (ORCPT + 28 others); Fri, 16 Feb 2018 13:45:26 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:57765 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752658AbeBPSlS (ORCPT ); Fri, 16 Feb 2018 13:41:18 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBTE013418; Sat, 17 Feb 2018 03:39:23 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBTE013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806363; bh=6/IoqUTGHai0Czf36phhQJ7Uyzpz6vT0GEH8DaNw/3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QV6T0K0+Jzg4vHnXjGJv3bKHiP6jTezf1u5g068P9oib0rEugu3lBkSnawvMe+/SI FsfbsV0dn0vBjN9tDLWZq9wcWeSJdRlXnRxHf480HzEr1BYUYdgMLNfM9BjGlXOlVc lJIZ/thtEJIgVB7KlIyQ6BMokwuxgHoZ5WW+2RPJrWE+ngwjpzr8iyDTIgSreXmRUO Qe51ZpW9OLCKbQfuyPrMNTreW0upKK3sLr0W42Yon2BdHdQEGmFrMqbtDqZw5iUMxi VU0+/mXTrGoqP4xKrMcIlKysMEBV4PAEv4yyzw9YpL0PXQgE+xKFuoUyzp+EPIJhgO b7g29fgpDo9gA== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 11/23] kconfig: add 'shell-stdout' function Date: Sat, 17 Feb 2018 03:38:39 +0900 Message-Id: <1518806331-7101-12-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is the second built-in function, which retrieves the first line of stdout from the given shell command. Example code: config CC_IS_GCC bool default $(shell $CC --version | grep -q gcc) config GCC_VERSION int default $(shell-stdout $srctree/scripts/gcc-version.sh $CC | sed 's/^0*//') if CC_IS_GCC default 0 Result: $ make -s alldefconfig && tail -n 2 .config CONFIG_CC_IS_GCC=y CONFIG_GCC_VERSION=504 $ make CC=clang -s alldefconfig && tail -n 2 .config # CONFIG_CC_IS_GCC is not set CONFIG_GCC_VERSION=0 By the way, function calls can be nested, so the following works. Example code: config FOO bool default $(shell $(shell-stdout echo $COMMAND_IN_CAPITAL | tr [A-Z] [a-z])) Result: $ make -s COMMAND=TRUE alldefconfig && tail -n 1 .config CONFIG_FOO=y $ make -s COMMAND=FALSE alldefconfig && tail -n 1 .config # CONFIG_FOO is not set Signed-off-by: Masahiro Yamada --- scripts/kconfig/function.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) -- 2.7.4 diff --git a/scripts/kconfig/function.c b/scripts/kconfig/function.c index f7f154d..266f4ec 100644 --- a/scripts/kconfig/function.c +++ b/scripts/kconfig/function.c @@ -189,10 +189,56 @@ static char *do_shell(struct function *f, int argc, char *argv[]) return xstrdup(ret == 0 ? "y" : "n"); } +static char *do_shell_stdout(struct function *f, int argc, char *argv[]) +{ + static const char *pre = "("; + static const char *post = ") 2>/dev/null"; + FILE *p; + char buf[256]; + char *cmd; + int ret; + + if (argc != 2) + return NULL; + + /* + * Surround the command with ( ) in case it is piped commands. + * Also, redirect stderr to /dev/null. + */ + cmd = xmalloc(strlen(pre) + strlen(argv[1]) + strlen(post) + 1); + strcpy(cmd, pre); + strcat(cmd, argv[1]); + strcat(cmd, post); + + p = popen(cmd, "r"); + if (!p) { + perror(cmd); + goto free; + } + if (fgets(buf, sizeof(buf), p)) { + size_t len = strlen(buf); + + if (buf[len - 1] == '\n') + buf[len - 1] = '\0'; + } else { + buf[0] = '\0'; + } + + ret = pclose(p); + if (ret == -1) + perror(cmd); + +free: + free(cmd); + + return xstrdup(buf); +} + void func_init(void) { /* register built-in functions */ func_add("shell", do_shell, NULL); + func_add("shell-stdout", do_shell_stdout, NULL); } void func_exit(void) From patchwork Fri Feb 16 18:38:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128624 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp869852ljc; Fri, 16 Feb 2018 10:48:34 -0800 (PST) X-Google-Smtp-Source: AH8x226u0gAfoBdOj59SMaaUXgN5Jjxn0EtPFP2ArHrsmG7/xazXsdTL1Ns8Pn/W1NS9DVMozMx4 X-Received: by 10.98.7.214 with SMTP id 83mr6878907pfh.130.1518806914626; Fri, 16 Feb 2018 10:48:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806914; cv=none; d=google.com; s=arc-20160816; b=KIkwnHAT0FnTImyb2G9vOPqR1N2MklcmGKTOPzoboM0DAWFd9A5f8dB+SoiT7Mr4TE fVgc1jmMRoS+j59Zts7LqTKFA4FttkDoL3X26lp+z+WT260ElOkgB0WLsYdQhDq/GX2v +fdeMEu7ZDcoSjUKJp+YprOdt9MKID+GYSdIoAR7MJ93R2VDy9bwXr/cod2X20fxo8+w o0VSENNp+1zDVwo/qG4W5AzhlpdvmHAn5vqRF/0yPm+fFE/cI5x7TtC4U8RCGe5KmKzU B4ucEoUaGjjD1K1hV9YseR20Ygaq1zx2vkHuasgJqB84BSj+EX93zwfUisizkxAjaTeB InzA== 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 :arc-authentication-results; bh=uohe4JbWTsHxXCz7M2tIVXCUW+oWNRx1k6t+Og+uw9s=; b=QHtuRO+qYWd0hnqM6KLrn4i9NKgKg0AvPi7vNzMQuay98/vGFJ9/oUi+n5OknLppy5 h3rROhaQFpi0ZzgPUVQJ4R7MrJzlQILCYCJqHIgBaflwgjMuKXcE5DlJujyw2pXHRgno W8N44mKkezPSjuQSHmeWV2BPN4US3t6W9/RJEE6I8CGjQfgkwvjoRIwGSby4fUEBXe7F jt8Lq5C/kwamYdJGMLiNbAGg41fnuKijIGSFcZ7WD3F3h1m6CitOoIMZgW0tncRhrZVp Mbbq59ajYJohduOIRWgBG17lCFswDSZUX4PMUxGlE/vZ/BNUY9MV2vOUAgBD+i0UPol5 FWHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=xEiTufgI; 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 p33-v6si2408561pld.310.2018.02.16.10.48.34; Fri, 16 Feb 2018 10:48:34 -0800 (PST) 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=xEiTufgI; 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 S1752442AbeBPSsJ (ORCPT + 28 others); Fri, 16 Feb 2018 13:48:09 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:57761 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752633AbeBPSlS (ORCPT ); Fri, 16 Feb 2018 13:41:18 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBTF013418; Sat, 17 Feb 2018 03:39:24 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBTF013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806364; bh=uohe4JbWTsHxXCz7M2tIVXCUW+oWNRx1k6t+Og+uw9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xEiTufgINRL5SPe22riEdAN2jhTl058etg5OcI0tVtrpYonAT02vBjEgG0TB+7HzF kf6oJQZx8OUxPUaOJ38K9/2kBoB7SnonuVT1nyI0yh17PSM9eoJYUCH2vuMg+Aa/78 fawYXVbJoNQ+9/rKEq7DpYoru7PwxkXo7BjENhguAa3+Ig7PPWVlccxvgMB8e1dTI9 okPMppBlio4V7s4tg4L43IIa0szXEpstSDOQeWcLYvzz1GkyZcMdXoRHbcqAmqaM+H 6VFmgyfrkXAgyoW0oPsVJWe7kCVgndlRyYN0jHOPnurxf2HWJWiebsZnnacJ2YOs5u Ni2zxsnovEmBA== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 12/23] kconfig: replace $UNAME_RELEASE with function call Date: Sat, 17 Feb 2018 03:38:40 +0900 Message-Id: <1518806331-7101-13-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With 'shell-stdout' supported, we can make it self-contained in Kconfig. Signed-off-by: Masahiro Yamada --- Makefile | 3 +-- init/Kconfig | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/Makefile b/Makefile index e9fc7c9..6491404 100644 --- a/Makefile +++ b/Makefile @@ -275,8 +275,7 @@ include scripts/Kbuild.include # Read KERNELRELEASE from include/config/kernel.release (if it exists) KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) -UNAME_RELEASE := $(shell uname --release) -export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION UNAME_RELEASE +export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION # SUBARCH tells the usermode build what the underlying arch is. That is set # first, and if a usermode build is happening, the "ARCH=um" on the command diff --git a/init/Kconfig b/init/Kconfig index f026a62..837a584 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -2,9 +2,9 @@ config DEFCONFIG_LIST string depends on !UML option defconfig_list - default "/lib/modules/$UNAME_RELEASE/.config" + default "/lib/modules/$(shell-stdout uname --release)/.config" default "/etc/kernel-config" - default "/boot/config-$UNAME_RELEASE" + default "/boot/config-$(shell-stdout uname --release)" default ARCH_DEFCONFIG default "arch/$ARCH/defconfig" From patchwork Fri Feb 16 18:38:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128619 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp868032ljc; Fri, 16 Feb 2018 10:46:08 -0800 (PST) X-Google-Smtp-Source: AH8x224MWlhu0mBblb1vLW45wI5WI+Su5ZOUWjtpjuDB+VVUvdubS8hjLDzaiWjdl6Jy8yYxQMBi X-Received: by 2002:a17:902:7008:: with SMTP id y8-v6mr6624885plk.358.1518806768594; Fri, 16 Feb 2018 10:46:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806768; cv=none; d=google.com; s=arc-20160816; b=AYlQZBDJCkCTYsKvOs8khjNz4+zqKkCRcz2CSQCfmr+8AvnZOADZ6XuzzbmCX53x0P fsvQo/n1BwYH/YA+5qdPOpg4BQeA9PZ16cj+uXjY8WRjEGogJeVAmDy3JBdfyncDpmh4 Sc1KW8vmDQa2s08os8hCVkinbJenA8141hfq19nVCh/hAqSg5rBAsY16NZVv78bO1Fnh YqVGeKuH0ZliQtsEi696HVlCeGO2Pa8Qq3wM2SE5d4ZrnCCcLxlaPF17hCYB4OhKVv6f TSrjMPNZKttZzcgrjmgfO6aX/LNaHtdWjALlTzhfRithn9KzZt/NOQg/DLnbZuSpt9E4 WFKA== 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 :arc-authentication-results; bh=6ZKZUGrGKtv5i28aZcukMehAO6Ar8s8CMYxI7ksDKCU=; b=DSR7oAoyLffSTeodSaXjq+ZnTNllLoUZYDyV237GbkO4Tq/iaak3opHp0OTBrR/cv4 lcRkxRgxjNM10ljnhDznspMTNXGj44AoUWyQ265fzrWGoQgdvckwBXWokt7hnD0z4WoU BrHCC5OfuC0V/BFggusTlkaz+Vt2zcYsfwwLOOjA/S8p9/a9WRulg2oGRwrxlUSB6DWF pcyLLNodrvg3uT1c5qj4md9d0ZqbbaVdUn+TO9BgZ0EGyTIjlG8ebBzPEs9AD+aqf9F3 keR0LvQ8CwGeVCqzalSe31YpHWmwUt/e6SWFzNp+7Rk1/eKHxYMhJirrq01zxie1HNmn ENjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=JcgYXRTI; 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 126si2374670pfd.48.2018.02.16.10.46.08; Fri, 16 Feb 2018 10:46:08 -0800 (PST) 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=JcgYXRTI; 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 S1753677AbeBPSpT (ORCPT + 28 others); Fri, 16 Feb 2018 13:45:19 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:57777 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752694AbeBPSlT (ORCPT ); Fri, 16 Feb 2018 13:41:19 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBTG013418; Sat, 17 Feb 2018 03:39:25 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBTG013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806365; bh=6ZKZUGrGKtv5i28aZcukMehAO6Ar8s8CMYxI7ksDKCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JcgYXRTIPxugz1or4Pb3XhIBHdnssIOxB6d9rp1yBZxo6Bs2EYjln4XMK1Ppna0Y7 uR5HfWMtykmkarYJ4LqXhxHlwfYdevmTM2WicLScwo5ZFCh+85JwM2QtRoepLntglQ 7bC8aOjfnqXeME/Awsk96O/bONvwe9VkmRPlYTOUKQtspug6dON3Wd5ifIAW1B2PUs ml4qhWXTyUdoDecllqocICvBc0YRUD1SCc9iZ4QOXdB4cJGJrdCdDcDhZ5SB1u8Ter 6SbVM8M/VecHm/HpYDqjgWiXgY477Zu3ywquy9XyeZ1VBtAHaTNtV56piIEtDsdB2N zwpDM6O8s0EfA== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 13/23] kconfig: expand environments/functions in (main)menu, comment, prompt Date: Sat, 17 Feb 2018 03:38:41 +0900 Message-Id: <1518806331-7101-14-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Expand the prompt passed to menu_add_prompt(). This affects 'mainmenu', 'menu', 'prompt', 'comment'. Another good thing is, I am fixing the memory leak for the case without mainmenu. The 'mainmenu' should be independent of user configuration. So, its prompt can be expanded in the first parse phase. The ugly hack for no_mainmenu_stmt is gone. Signed-off-by: Masahiro Yamada --- scripts/kconfig/menu.c | 2 +- scripts/kconfig/zconf.y | 30 +++++++++++------------------- 2 files changed, 12 insertions(+), 20 deletions(-) -- 2.7.4 diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index a9d0ccc..462b995 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -176,7 +176,7 @@ static struct property *menu_add_prop(enum prop_type type, char *prompt, struct struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep) { - return menu_add_prop(type, prompt, NULL, dep); + return menu_add_prop(type, expand_string_value(prompt), NULL, dep); } void menu_add_visibility(struct expr *expr) diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 19452b6..ef006be 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -110,28 +110,16 @@ static struct menu *current_menu, *current_entry; %% input: nl start | start; -start: mainmenu_stmt stmt_list | no_mainmenu_stmt stmt_list; +start: mainmenu_stmt stmt_list | stmt_list; /* mainmenu entry */ mainmenu_stmt: T_MAINMENU prompt nl { menu_add_prompt(P_MENU, $2, NULL); + free($2); }; -/* Default main menu, if there's no mainmenu entry */ - -no_mainmenu_stmt: /* empty */ -{ - /* - * Hack: Keep the main menu title on the heap so we can safely free it - * later regardless of whether it comes from the 'prompt' in - * mainmenu_stmt or here - */ - menu_add_prompt(P_MENU, xstrdup("Linux Kernel Configuration"), NULL); -}; - - stmt_list: /* empty */ | stmt_list common_stmt @@ -217,6 +205,7 @@ config_option: T_TYPE prompt_stmt_opt T_EOL config_option: T_PROMPT prompt if_expr T_EOL { menu_add_prompt(P_PROMPT, $2, $3); + free($2); printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); }; @@ -316,6 +305,7 @@ choice_option_list: choice_option: T_PROMPT prompt if_expr T_EOL { menu_add_prompt(P_PROMPT, $2, $3); + free($2); printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); }; @@ -385,6 +375,7 @@ menu: T_MENU prompt T_EOL { menu_add_entry(NULL); menu_add_prompt(P_MENU, $2, NULL); + free($2); printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); }; @@ -424,6 +415,7 @@ comment: T_COMMENT prompt T_EOL { menu_add_entry(NULL); menu_add_prompt(P_COMMENT, $2, NULL); + free($2); printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); }; @@ -489,6 +481,7 @@ prompt_stmt_opt: | prompt if_expr { menu_add_prompt(P_PROMPT, $1, $2); + free($1); }; prompt: T_WORD @@ -536,7 +529,6 @@ word_opt: /* empty */ { $$ = NULL; } void conf_parse(const char *name) { - const char *tmp; struct symbol *sym; int i; @@ -560,10 +552,10 @@ void conf_parse(const char *name) if (!modules_sym) modules_sym = sym_find( "n" ); - tmp = rootmenu.prompt->text; - rootmenu.prompt->text = _(rootmenu.prompt->text); - rootmenu.prompt->text = expand_string_value(rootmenu.prompt->text); - free((char*)tmp); + if (!menu_has_prompt(&rootmenu)) { + current_entry = &rootmenu; + menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); + } menu_finalize(&rootmenu); for_all_symbols(i, sym) { From patchwork Fri Feb 16 18:38:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128616 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp866694ljc; Fri, 16 Feb 2018 10:44:37 -0800 (PST) X-Google-Smtp-Source: AH8x226iQjVuq0Ut8tj0n+gVyK54zkM7aApdyknEFO6b0TIF+bqPGsctXAxHomVmntRUZwQItqXX X-Received: by 2002:a17:902:365:: with SMTP id 92-v6mr6729536pld.127.1518806677237; Fri, 16 Feb 2018 10:44:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806677; cv=none; d=google.com; s=arc-20160816; b=DzbS0cZEuIk/eeZdPm3C0eK6YBgD6Xvvo4cJtRFzMDFUfpPHAracuUrgCqSIUvH9AT Nql0xXs0acBukvWfpR1FfnONghg6aj9lcXJPWcabsXW5jOh1errP1mFEEzSYhxV4WvZc D8I2LoSCpKRCo015GFPaUGgwK+3MsnXzQH2TkkZILhfh3OQRUVVTKKIG6UCekYZ5k4zF kJvfAx/Vvk2P4VCbZcK8FBTYc7woUKYugEiR8B4cQH7RM9plXrTgVlNlC3AO0kD7YJCj w0KvV4Sqb+MhbAUbsE6FHRs+6wWd1se1fmzD4M15MGkrRBFrDLNM+U02XWNHAM4Jn/tl uv9A== 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 :arc-authentication-results; bh=EiehZoLPDaIFPIKHmPipZDDhu3qP0WJWAhF2I/M1qZI=; b=N5yxiJIIx7GJqGY9zDIUeLE6UlyW0smMMKuqgtGrR2TNDEbZ0BVuOC3FMhfvEOGbSq 7WukeWNWbrWMXdPfzlotUu1O0oQKjYpbzdx4U//SpuDq9F7nLQqgJHTD0hHNWppd5PNo LJgUMyDXQ90uYUVpeY/FeHDUttu0DOqMlBFYi5akdTaw0eUFG4Ck9jksVmtGf/jVh08g 5nlEpm3irn8H9PqsqMwXJRCbiX8FW9F6qrNC01dFGXH2BDOgJK+K4ijGB1jWjLHULSLB 6OBWPYZ9yl+/9BJEFD7dCOJlEB4ZIkd9ddWB58vTlusveYTedr70kxd3RVeHJQXpT+O+ ikOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=juhLG5ru; 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 k20-v6si3577959pll.606.2018.02.16.10.44.36; Fri, 16 Feb 2018 10:44:37 -0800 (PST) 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=juhLG5ru; 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 S1753096AbeBPSod (ORCPT + 28 others); Fri, 16 Feb 2018 13:44:33 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:58323 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752921AbeBPSlr (ORCPT ); Fri, 16 Feb 2018 13:41:47 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBTH013418; Sat, 17 Feb 2018 03:39:25 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBTH013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806366; bh=EiehZoLPDaIFPIKHmPipZDDhu3qP0WJWAhF2I/M1qZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=juhLG5ru4zGFLcuTiNnOPbRAF6RCbpFcGoZykom96Y5XvnIzbxoaWrJDoUXg0MCyo 8SKu6kM8h3XjEZsXUTzes+X7FL/ToLcqQy5h1mBHYPfYpP7tulx7wJWMJVmDKepxeT egtrpTfI3tH7K4Hv7CdCll3ndHSYKMOZtWykqilFs56vIXN7tG7gHnZ+pRa5ltxuqi ISkc8C7YhlWrEiu9PY32NgDOpOCvLpMnZXGEAF/AiaQnxCasS5AY5S+vzzDS49E/GV RXAQfgdGEEq62hw6BmZXil8YvmfENQ/WYxvbBdxjgBIgEvH0V3EEhIpx6hk19rkrJk 0kWka76UerI+Q== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 14/23] kconfig: show compiler version text in the top comment Date: Sat, 17 Feb 2018 03:38:42 +0900 Message-Id: <1518806331-7101-15-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The kernel configuration phase is now tightly coupled with the compiler in use. It will be nice to show the compiler information in Kconfig. The compiler information will be displayed like this: $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- config scripts/kconfig/conf --oldaskconfig Kconfig * * Linux/arm64 4.16.0-rc1 Kernel Configuration * * * Compiler: aarch64-linux-gnu-gcc (Linaro GCC 7.2-2017.11) 7.2.1 20171011 * * * General setup * Compile also drivers which will not load (COMPILE_TEST) [N/y/?] If you use GUI methods such as menuconfig, it will be displayed in the top menu. This is simply implemented by using 'comment'. So, it will be saved into the .config file as well. This commit has a very important meaning. If the compile is upgraded, Kconfig must be re-run since different compilers have different sets of supported options. All referenced environments are written to include/config/auto.conf.cmd so that any environment change triggers silentoldconfig, and prompt the user to input new values if needed. With this commit, something like follows will be added to include/config/auto.conf.cmd ifneq "$(CC_VERSION_TEXT)" "aarch64-linux-gnu-gcc (Linaro GCC 7.2-2017.11) 7.2.1 20171011" include/config/auto.conf: FORCE endif Signed-off-by: Masahiro Yamada --- Kconfig | 2 ++ Makefile | 2 ++ 2 files changed, 4 insertions(+) -- 2.7.4 diff --git a/Kconfig b/Kconfig index e6ece5b..99ed4b8 100644 --- a/Kconfig +++ b/Kconfig @@ -5,4 +5,6 @@ # mainmenu "Linux/$ARCH $KERNELVERSION Kernel Configuration" +comment "Compiler: $CC_VERSION_TEXT" + source "arch/$SRCARCH/Kconfig" diff --git a/Makefile b/Makefile index 6491404..b8df04b 100644 --- a/Makefile +++ b/Makefile @@ -438,6 +438,8 @@ export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL export KBUILD_ARFLAGS +export CC_VERSION_TEXT := $(shell $(CC) --version | head -n 1) + # When compiling out-of-tree modules, put MODVERDIR in the module # tree rather than in the kernel tree. The kernel tree might # even be read-only. From patchwork Fri Feb 16 18:38:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128628 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp870844ljc; Fri, 16 Feb 2018 10:49:43 -0800 (PST) X-Google-Smtp-Source: AH8x226snhxQ+HEMD2/0Lcso0oTRdaGCdUl120zDD1RNxJkAS0/LiZHNS/v0v1MqTAQPxnG8c/3g X-Received: by 10.98.223.93 with SMTP id u90mr1963121pfg.13.1518806983746; Fri, 16 Feb 2018 10:49:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806983; cv=none; d=google.com; s=arc-20160816; b=P3Nz0rLVnmk7MKxVtdY+N9jYRWt1jDr1W45cwBrd4Efm3LQTBCKzoaIXCOSKWlZEV6 K4r/gRfrPC4GuS+KsFwvQiRP2EqkJ1mkptw0yDUeYBGZkO2TVbOog/AVn9QTlsoxDddj oBaOZMPll+13fj8UUooTB8W3TFL4CeQl782ZiJuPCCUw7i0SeuDDLAHui13WzpTLw197 QwBAm+RKda68ijyn+gG+OKzys/ZkDm7viDWWe83ZKjHNZTCy2uslPt0H2kEIelQrpDfd /XIUaQ8orh+c1PwoVU7+4eOY7ZlP9o9uEbxrhKCWJ6/P1/7kBpdbu+ETwKD7gf6x7lzs eOJQ== 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 :arc-authentication-results; bh=WqMC/J/ZklNycTvQVm5mFpJGFmWJQ7pZGdtACgEPnzo=; b=dmGMjCxHqtXzkz0YbxCrHsfa9h2h5UxG9UmJGX9ozWIKnP+6yCsPoUe8yoiq0VO4Yv uQBLjpC5Nw2S6fvKN+vtHwkF/Ee+hzCIfLEHu7howYDos/cSKugWkHcrHjOJiDMwoq1K PiILMrMqPUbgvv6DWPoI0GxEUiv8hCF5XWlZAzc487ubMSaXuHVBXAFr5qEjhPaJ1uUH hp2GIQPG+HNqIJ1xDAjYRsGTEf9UbgofQdELFax23BXya/A5TPYJN68g5/ebMydtKuA2 zqtNOuRon9BZ/avtwMRhgp/0o3vUBjqFyHMbuJ9SqPUmQ4DexvuPCbXubYXh9fCt6vyo BfFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=RpwtBOh3; 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 f5si12574pgr.235.2018.02.16.10.49.43; Fri, 16 Feb 2018 10:49:43 -0800 (PST) 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=RpwtBOh3; 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 S1751862AbeBPSr6 (ORCPT + 28 others); Fri, 16 Feb 2018 13:47:58 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:57773 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752671AbeBPSlS (ORCPT ); Fri, 16 Feb 2018 13:41:18 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBTI013418; Sat, 17 Feb 2018 03:39:26 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBTI013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806367; bh=WqMC/J/ZklNycTvQVm5mFpJGFmWJQ7pZGdtACgEPnzo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RpwtBOh33Agt9ZKHvyEquggMIqXrQpHtZ9JjdzB9YLlGxIBCaflbp8OrVKeHX5X2A GWivO+Nkwp/h2D/p4Q+RNiS934RWXKKP87Qy6OrqcJKt8anno0fuNnNFsbPbLZkMDn t/mq/dmdpvUl2OT4zLK+IQ+8+IzsQgODR3Jb+xoovhq9I//rHElqFdxWb3CzR+Di4O YbwX0xPx6GzGsIiwEeIXXoTiMFoek2GXnW2G/6lNeiaYzLCWGfTuO0hx6616LFP4Gh 1+oDynqXTiFXk0iOMsjCY5MqlfhXoPyM7ah4KgjSk8gowhFHDEmNej3ydksuOTi4bM Pq66aLgAhEgOQ== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 15/23] kconfig: add CC_IS_GCC and GCC_VERSION Date: Sat, 17 Feb 2018 03:38:43 +0900 Message-Id: <1518806331-7101-16-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This will be useful to specify the required compiler version, like this: config FOO bool "Use Foo" depends on GCC_VERSION >= 408000 help This feature requires GCC 4.8 or newer. Signed-off-by: Masahiro Yamada --- init/Kconfig | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.7.4 diff --git a/init/Kconfig b/init/Kconfig index 837a584..f2da5e9 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -12,6 +12,15 @@ config cc-option string macro $(shell $CC -Werror $(1) -c -x c /dev/null -o /dev/null) +config CC_IS_GCC + bool + default $(shell $CC --version | grep -q gcc) + +config GCC_VERSION + int + default $(shell-stdout $srctree/scripts/gcc-version.sh -p $CC | sed 's/^0*//') if CC_IS_GCC + default 0 + config CONSTRUCTORS bool depends on !UML From patchwork Fri Feb 16 18:38:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128621 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp868529ljc; Fri, 16 Feb 2018 10:46:47 -0800 (PST) X-Google-Smtp-Source: AH8x224kWlvV4/m02As7pa4wh8n65u8fuSdTuYiE5Md6l9ksV7T4uugzC8miA8zPEtpiUOr7Qf34 X-Received: by 2002:a17:902:1746:: with SMTP id i64-v6mr6615504pli.53.1518806807547; Fri, 16 Feb 2018 10:46:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806807; cv=none; d=google.com; s=arc-20160816; b=M5ZSewuLZkrtzpMzmm6qiKZnbLL9hI/Z7dNnkUAItwtogTNduACf59OsiDHkaBUreE TCQkwA/idBVStjcDCu1FP0d2Li98PeBEbxJg4SKt+5iWj0IMpHIh6tBI+usBunmxThBg +rdlskBybzR9yVKT/e3q1T2ZeyiSEGc/OFYL9sNHcqsRfnmL8ynLc8t1U9/wO6FK1Yjo LjblkM198t0YqWOPKphkSwFVGBjRZbQD6n9LyJaX/Z7qxQYgTT3U+BTHpx+3ADE9hxPp UPLpvevx/uGg0Q1nM8hMIEAXNMVhS2g0v7L9lB9NTqzhilY6F1Xf2idYxu+lbaKwQgFt Ghew== 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 :arc-authentication-results; bh=g4jr7p8+pSavXrVBxgeLhmsF9gTgnd5dakNfR8FDu8k=; b=WSXwz/EKKUVIvGloizirUKK0hpNlmZwYVNCCS82iEAfF5HLgik3c5ZBVdtOpHf6Y04 6aoamjs0u7jJnvPb9ZIQNGQHhEmsonqberH3rQCcTtLJBd/hSieI5SRnvSwSNimi8Dy1 ZFf3wszeJCLZA1DaMZ16n7ZCtybbjsrmG42iSwrhbjV7phBl/1+PfDjZ4X4mqxb+m0QW ow7DWUU+tHTcqzYolqlJoLsUsP9HkLXB687/Z+MpjgYehagIRi6daxbrkYyjMG3WicLt FwDblXkSLzBc2Uira5vY1gwQec0CqLoi4qYeTwH5dbY6hqdzI7B1T/krESNF6aL4CAK4 7LBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Zv2WgPoR; 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 126si2374670pfd.48.2018.02.16.10.46.47; Fri, 16 Feb 2018 10:46:47 -0800 (PST) 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=Zv2WgPoR; 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 S1752184AbeBPSpM (ORCPT + 28 others); Fri, 16 Feb 2018 13:45:12 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:57780 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752718AbeBPSlT (ORCPT ); Fri, 16 Feb 2018 13:41:19 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBTJ013418; Sat, 17 Feb 2018 03:39:27 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBTJ013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806368; bh=g4jr7p8+pSavXrVBxgeLhmsF9gTgnd5dakNfR8FDu8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zv2WgPoRD5elvY50ieLvOVEDup3dPLbKRWyua+EoBAHVZMB83ZvVv7rna0Zef36PA 9/88wiMWHeEg56GF5wMZy8r89tuBB6ZmvX0dR25uFosurZe33DJiiD+G+mVWiwXNj8 gupHLKUw72v/82pQ3/vksS4CMIzEgA2KpMVNWzMV7RSpHJtrfIX1jdK876nnal4qeA 80vi65YuGXDHyY+vht/IpVFm6pSgzT3hxUNgaQyYNmviz3EEy6ewNPVF0fcLBYPjcP mObrh4I6tw5KFl4ao5wiP7+05FYazKjRaMf+0bfUnc7hCpK1molhuMms95c1plcGsm XetrjKOXE1DGg== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Sami Tolvanen , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 16/23] kbuild: add clang-version.sh Date: Sat, 17 Feb 2018 03:38:44 +0900 Message-Id: <1518806331-7101-17-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sami Tolvanen Based on gcc-version.sh, clang-version.sh prints out the correct version of clang. Signed-off-by: Sami Tolvanen Tested-by: Nick Desaulniers Signed-off-by: Masahiro Yamada --- scripts/clang-version.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 scripts/clang-version.sh -- 2.7.4 diff --git a/scripts/clang-version.sh b/scripts/clang-version.sh new file mode 100755 index 0000000..9780efa --- /dev/null +++ b/scripts/clang-version.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# +# clang-version [-p] clang-command +# +# Prints the compiler version of `clang-command' in a canonical 4-digit form +# such as `0500' for clang-5.0 etc. +# +# With the -p option, prints the patchlevel as well, for example `050001' for +# clang-5.0.1 etc. +# + +if [ "$1" = "-p" ] ; then + with_patchlevel=1; + shift; +fi + +compiler="$*" + +if [ ${#compiler} -eq 0 ]; then + echo "Error: No compiler specified." + printf "Usage:\n\t$0 \n" + exit 1 +fi + +MAJOR=$(echo __clang_major__ | $compiler -E -x c - | tail -n 1) +MINOR=$(echo __clang_minor__ | $compiler -E -x c - | tail -n 1) +if [ "x$with_patchlevel" != "x" ] ; then + PATCHLEVEL=$(echo __clang_patchlevel__ | $compiler -E -x c - | tail -n 1) + printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL +else + printf "%02d%02d\\n" $MAJOR $MINOR +fi From patchwork Fri Feb 16 18:38:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128622 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp869041ljc; Fri, 16 Feb 2018 10:47:29 -0800 (PST) X-Google-Smtp-Source: AH8x226JnEs4U+cgucQsNRRkCvKVML4g9Xjbstcdn2TViMH+NZvjWMl56Y7rFLwzsYFb30GIMDKB X-Received: by 2002:a17:902:c81:: with SMTP id 1-v6mr6692188plt.281.1518806849812; Fri, 16 Feb 2018 10:47:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806849; cv=none; d=google.com; s=arc-20160816; b=BQg3E/zTatuSVoK/C+jj+5sYL0tOXVOmIFalg4fIl7dVdgSlIS+0twenMgGd7AydrC 2t6ukbdTR8FBbmgZSO+4TnXUFhMwBBWgfu0CbHyja9kJNRx+Hifqwwlm+szm/a5p/Btr zBm0Vi0RewiTje4srIrXt6z72XanGZSxw/pbOLuynEbxNJx37WYHm+4dNkAeECfKM3x6 wg71B+k8P4F9JpqwOEvdL2ju9Kh45D4zmbA7smeCZGRTMC2IFPpuYG1TzlKfVfNYpR7I fwH13AynYRfW9qYX+4agzXxQ2/VkSfCjQCqYm9NqrzHrCVTGtUH5Tm1YfwimgcgZtcyz kUEw== 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 :arc-authentication-results; bh=D0SFCGOFIy+/Nth0+l6GLQfAxw29uEAyFnvGWq1jc7A=; b=o9JQH4FH/jp1Y0SMVDEFEkUnFx4WWwIAGbVp5KFFFlCP6UIArNdaXfJJ0Qj4MmuyMr bCd9KkwDodkvW2i665VshHmRXdwRehVZH/1VzE4N69ad3ezpOsfT5J7awW6aRWjpi6lY 8mEU/EQHfTNKISf7kxpiTLidvQGELa0apUUBYxt3YOrPz0oa7sYHHocTaaKeBw14f7eN XkgAhfyVQBdc4fBz2Z0DB00XfTY+1ePnvqELe2zgmCU1WowSO2lyQNB4urmZJcujOAMZ MW8PDtwrCj8c+Zj+lbuHtYoMeTqoP/XfCqh8V3dzZhHiraIchaSeb3TDvAk1OV5bzFxV 2FnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Yt/IrWbd; 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 n7si4324240pga.670.2018.02.16.10.47.29; Fri, 16 Feb 2018 10:47:29 -0800 (PST) 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=Yt/IrWbd; 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 S1751267AbeBPSpJ (ORCPT + 28 others); Fri, 16 Feb 2018 13:45:09 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:57776 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752697AbeBPSlT (ORCPT ); Fri, 16 Feb 2018 13:41:19 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBTK013418; Sat, 17 Feb 2018 03:39:28 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBTK013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806369; bh=D0SFCGOFIy+/Nth0+l6GLQfAxw29uEAyFnvGWq1jc7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yt/IrWbdovkVWI/a78BtJWddlbKNgIUK/X7Pg1FPaDZF2qREBkb3f0DXby7H6nQSe n1qUCg0CcjikdlFyYupOaFEqeDpV/Tgyq60WhiLZZSz7zkWKGJ4QV62UIZ/fij+djo /kLG3XIApBgaNFiStipjmatrieAJNbs6+xApfztQzvrlHTVI8C3PP6QpxyN6RyWH5G ZlkM8lKVctTnz1ABk0pKM51qJ7vZncjI8xhH24RRHxtFsLFDKmYiLr8GJLpgOiFOe6 RndGUJYN2Cv+PszpFIKvVL+P1W3i1M/HiPiCXB1hRS0r5XcwTXWAng7wuwrWMghdH/ CQwAu19/q6UOQ== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 17/23] kconfig: add CC_IS_CLANG and CLANG_VERSION Date: Sat, 17 Feb 2018 03:38:45 +0900 Message-Id: <1518806331-7101-18-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This will be useful to describe the clang version dependency. Signed-off-by: Masahiro Yamada --- init/Kconfig | 8 ++++++++ scripts/clang-version.sh | 24 +++++++++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) -- 2.7.4 diff --git a/init/Kconfig b/init/Kconfig index f2da5e9..1b751bc 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -21,6 +21,14 @@ config GCC_VERSION default $(shell-stdout $srctree/scripts/gcc-version.sh -p $CC | sed 's/^0*//') if CC_IS_GCC default 0 +config CC_IS_CLANG + bool + default $(shell $CC --version | grep -q clang) + +config CLANG_VERSION + int + default $(shell-stdout $srctree/scripts/clang-version.sh $CC) + config CONSTRUCTORS bool depends on !UML diff --git a/scripts/clang-version.sh b/scripts/clang-version.sh index 9780efa..d8002d2 100755 --- a/scripts/clang-version.sh +++ b/scripts/clang-version.sh @@ -10,24 +10,22 @@ # clang-5.0.1 etc. # -if [ "$1" = "-p" ] ; then - with_patchlevel=1; - shift; -fi - compiler="$*" if [ ${#compiler} -eq 0 ]; then - echo "Error: No compiler specified." - printf "Usage:\n\t$0 \n" + echo "Error: No compiler specified." >&2 + printf "Usage:\n\t$0 \n" >&2 + echo 0 + exit 1 +fi + +if !( $compiler --version | grep -q clang) ; then + echo "This is not clang." >&2 + echo 0 exit 1 fi MAJOR=$(echo __clang_major__ | $compiler -E -x c - | tail -n 1) MINOR=$(echo __clang_minor__ | $compiler -E -x c - | tail -n 1) -if [ "x$with_patchlevel" != "x" ] ; then - PATCHLEVEL=$(echo __clang_patchlevel__ | $compiler -E -x c - | tail -n 1) - printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL -else - printf "%02d%02d\\n" $MAJOR $MINOR -fi +PATCHLEVEL=$(echo __clang_patchlevel__ | $compiler -E -x c - | tail -n 1) +printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL From patchwork Fri Feb 16 18:38:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128608 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp864490ljc; Fri, 16 Feb 2018 10:41:52 -0800 (PST) X-Google-Smtp-Source: AH8x227sXfT+dreU5Cc7kHIZK1QpotL+fVWKGPUrKil0zsdv+6jMazJ5gkqsCEfKE5kZeSuOkyMy X-Received: by 10.101.69.9 with SMTP id n9mr6046272pgq.317.1518806512391; Fri, 16 Feb 2018 10:41:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806512; cv=none; d=google.com; s=arc-20160816; b=yxiPhglHx5z0v+MZ22LMWEMLcv9ED5rRh7KqGIdTgv8325xiqLR3+9NHHhvOzKtqSe wMxHwyk56M5+vmjFplQKkfc8MXxDWNG/akMo427/qcQA28NrJqNQBJ+ljR8GKXpstegP qLQGZQUBFP60SuNiGzDf/BNtRyQjQaWZ/JK8VoWLLF+kCzV6VsEoXm7wVqSFC84UQLrm 1oqUl3cGir24A2lKs0tgAGU53eC0is7NQzvRSOqbMWf1oPxzxZAhEiVNX8JLswKbFPTP 82RtWJ0Wp7F6PIxJD3rLSIdWWspH27ERa1d3lJBn4y5g2gsCSwzup5VrmAHinj3qR91v icnQ== 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 :arc-authentication-results; bh=5E3V+lniGkXthizHMXYirjjRQ8c47R+TtsbPm2hC14Y=; b=RdFEQ91E5S/i4wCQ4V9WJEsSpWWsaBi1Bkv7V3u58SKhP1oAxbnpTO8zFAvc0YqkBS uGS1PPMyySjGZirtX7Twfw/6isiqSWyuiWZx4t6yOgU8+zGMJsL+kY19TJGBxxgjoWYE WpBq43XiaOraY6YWWsv077DNUGnjuvCkACXP7YG7/PxOYIPpyn1yvHWX23WmvmU+KLXN KsUNLw6pWrEn0PaYzOnWFM+Rb9/L8ucwqfNt/6TmIwR0PaLigeBuW3iwmp3Z8OAIdjns kSBchldOyyGUxlExltYbCOB9gJEiL8sl0GOGdbG4rZfCbBrr4MQFD4g5ShxvTed29Lyl 0GMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=oJRN23ux; 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 o1si4429669pfh.238.2018.02.16.10.41.52; Fri, 16 Feb 2018 10:41:52 -0800 (PST) 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=oJRN23ux; 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 S1752985AbeBPSls (ORCPT + 28 others); Fri, 16 Feb 2018 13:41:48 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:57824 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752719AbeBPSlU (ORCPT ); Fri, 16 Feb 2018 13:41:20 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBTL013418; Sat, 17 Feb 2018 03:39:29 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBTL013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806370; bh=5E3V+lniGkXthizHMXYirjjRQ8c47R+TtsbPm2hC14Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oJRN23ux3B0UQd2L3uUo5l471O4o0PGGEd/jSN8TZr9AYmboOsaPxOGtAahLq/C1i 4hiVj3VfBNrBW+7U4fUk1RNiplWjFs94BeRh4I6sEIR8y1+iAS2JwD7wdt0A8fooye 4EqMB1wbdE0mmm8H0j/4ct1a//RAIKFbvVsGe0pbio7kghfAK6G23vjKsROVhSF67N G9f96uCdFb7Bo/622KHfDs+TMJCKlCIaSSTFaEdPxd2jNUhBRAMgeDfltejp9KrulY +r2d8eoNb28Tz4Y8GocuvxQ4oU6/Hk1hVoXK7HsxwIhaXF6xtTJVLveFKRN+ovmprg 5NiX/LVkV9Ibg== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , Peter Oberparleiter , linux-kernel@vger.kernel.org Subject: [PATCH 18/23] gcov: remove CONFIG_GCOV_FORMAT_AUTODETECT Date: Sat, 17 Feb 2018 03:38:46 +0900 Message-Id: <1518806331-7101-19-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org CONFIG_GCOV_FORMAT_AUTODETECT compiles either gcc_3_4.c or gcc_4_7.c according to your GCC version. We can achieve the equivalent behavior by setting reasonable default in the 'choice' with the knowledge of the compiler version. Users are still allowed to change it if they need to do so. Signed-off-by: Masahiro Yamada --- kernel/gcov/Kconfig | 18 ++++++------------ kernel/gcov/Makefile | 2 -- 2 files changed, 6 insertions(+), 14 deletions(-) -- 2.7.4 diff --git a/kernel/gcov/Kconfig b/kernel/gcov/Kconfig index 1276aab..c56bee7 100644 --- a/kernel/gcov/Kconfig +++ b/kernel/gcov/Kconfig @@ -53,20 +53,14 @@ config GCOV_PROFILE_ALL choice prompt "Specify GCOV format" depends on GCOV_KERNEL - default GCOV_FORMAT_AUTODETECT + default GCOV_FORMAT_3_4 if CC_IS_GCC && GCC_VERSION < 40700 + default GCOV_FORMAT_4_7 ---help--- - The gcov format is usually determined by the GCC version, but there are + The gcov format is usually determined by the GCC version, and the + default is chosen according to your GCC version. However, there are exceptions where format changes are integrated in lower-version GCCs. - In such a case use this option to adjust the format used in the kernel - accordingly. - - If unsure, choose "Autodetect". - -config GCOV_FORMAT_AUTODETECT - bool "Autodetect" - ---help--- - Select this option to use the format that corresponds to your GCC - version. + In such a case, change this option to adjust the format used in the + kernel accordingly. config GCOV_FORMAT_3_4 bool "GCC 3.4 format" diff --git a/kernel/gcov/Makefile b/kernel/gcov/Makefile index c6c50e5..ff06d64 100644 --- a/kernel/gcov/Makefile +++ b/kernel/gcov/Makefile @@ -4,5 +4,3 @@ ccflags-y := -DSRCTREE='"$(srctree)"' -DOBJTREE='"$(objtree)"' obj-y := base.o fs.o obj-$(CONFIG_GCOV_FORMAT_3_4) += gcc_3_4.o obj-$(CONFIG_GCOV_FORMAT_4_7) += gcc_4_7.o -obj-$(CONFIG_GCOV_FORMAT_AUTODETECT) += $(call cc-ifversion, -lt, 0407, \ - gcc_3_4.o, gcc_4_7.o) From patchwork Fri Feb 16 18:38:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128620 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp868255ljc; Fri, 16 Feb 2018 10:46:26 -0800 (PST) X-Google-Smtp-Source: AH8x224D8oyuOgZcehZcrbHZ/TKLbUo5yR+sYJbxrx6ameeJSg0+QFURqBKxbfpbnsn5rzGy2E/3 X-Received: by 2002:a17:902:6c41:: with SMTP id h1-v6mr6572029pln.25.1518806786027; Fri, 16 Feb 2018 10:46:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806786; cv=none; d=google.com; s=arc-20160816; b=Z9s5E1MlBUPoJXPEeu9Nf2A9BhxbeS1znmpsBhy7qqyYRTkmeR33VKkgvusGb5lnvr 5p6RIRFiQoNucM1QG10vuKKxaihPtb9E5UEMwoNNGuaZdNBZ311b2zjL3sSgmS/rXgvk Kguunlg9IUFTzkXhix4aWceuJpWPW49j/6SOSifGrvhSvtkmDpCgz85KP2bQ6BIpRnR+ Wh0ivgHitgi6gWjuZdZyRWv1gk9Qavi69FDf8uyAV99NZW8bGFDATKsUK+Oh+csMGYgR KU4g2zifmnWDOvFZ9NzKWB+WrBRHo/2LtivTQ7758EJr+vHp/QD0d/3viLqLpOPrSQfR 5xZQ== 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 :arc-authentication-results; bh=NNUronc0b0DxbhAtpAXfRP7LuUaytEfPMCerNrVvsRI=; b=TddiPralABl7H8dgN6c28Nl1svXXySzAuRANuJVEdCqyRzZUmQ/lE4lIWNWtBiWvUC wRyqgI4Gn54EsJK9WvwhddKkSTzuAQFhW6fiwNhAGISgYa5EwEtIy9R7MRwPtA/Q1xRC IJD0pYazNMZAQ3CwXS3pXqwav/sleRA3beufXlHrUZGQ7M6E/s3quHORq3S3NKkMBziN B7qyirISULhaZD9HFSN1g3nUhVit2+5QMcIJ3Dx/qDjw/kKKQ6SQK2NQ7w8HeFevHPIP sxJosDWiH3id8tKE+Iay4V/Url7ncyy2qjWnka+AyLqPZVTrkbeIbc4Qz+zn85aGa+ky hlNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=c1puTWxM; 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 126si2374670pfd.48.2018.02.16.10.46.25; Fri, 16 Feb 2018 10:46:26 -0800 (PST) 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=c1puTWxM; 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 S1753568AbeBPSpP (ORCPT + 28 others); Fri, 16 Feb 2018 13:45:15 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:57779 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752696AbeBPSlT (ORCPT ); Fri, 16 Feb 2018 13:41:19 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBTM013418; Sat, 17 Feb 2018 03:39:30 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBTM013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806370; bh=NNUronc0b0DxbhAtpAXfRP7LuUaytEfPMCerNrVvsRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c1puTWxMB8foCOL8AnvAnR43Xew+G3qCSfx3UlFvqoqGb9RTflHT4AB5+KHdhNxDv ShU0lwSrmFF951Zhcnz03u/0u2u9p8duLbCp9YPf7ZxycuCwEeHYyPlzbRP4Zvb2IN cjguVqLP2uZWO8tBn3lUwDiEbAoYvQ/xBBHeZKoYQIu4B+K8Vm0yYjfp+MqsSYJM1h Gj3zjy7n+wNASruivcmIMxqJTkeu/JqeT6Zcu2ZxJzjRb/QJ/BChlcQ94Vj82eyn/3 cJkAw0FzyW9JLfiF9e0x6DeIw/o4G8CNqxXpdgryrmDwpUteH/MhBlgNtj1QEccFTV kWW5oUATERAXw== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 19/23] kcov: imply GCC_PLUGINS and GCC_PLUGIN_SANCOV instead of select'ing them Date: Sat, 17 Feb 2018 03:38:47 +0900 Message-Id: <1518806331-7101-20-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As Documentation/kbuild/kconfig-language.txt notes, 'select' should be used with care - it forces a lower limit of another symbol, ignoring the dependency. In this case, KCOV can select GCC_PLUGINS even if 'depends on HAVE_GCC_PLUGINS' is unmet. 'imply' is modest enough to observe the dependency, and this makes sense. If you enable KCOV, you will probably want to enable GCC_PLUGIN_SANCOV, but it should not break the dependency. I also remove unneeded code, I just happened to notice. Signed-off-by: Masahiro Yamada --- lib/Kconfig.debug | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 6088408..1216ce6 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -743,8 +743,8 @@ config KCOV bool "Code coverage for fuzzing" depends on ARCH_HAS_KCOV select DEBUG_FS - select GCC_PLUGINS if !COMPILE_TEST - select GCC_PLUGIN_SANCOV if !COMPILE_TEST + imply GCC_PLUGINS + imply GCC_PLUGIN_SANCOV help KCOV exposes kernel code coverage information in a form suitable for coverage-guided fuzzing (randomized testing). @@ -758,7 +758,6 @@ config KCOV config KCOV_ENABLE_COMPARISONS bool "Enable comparison operands collection by KCOV" depends on KCOV - default n help KCOV also exposes operands of every comparison in the instrumented code along with operand sizes and PCs of the comparison instructions. @@ -768,7 +767,7 @@ config KCOV_ENABLE_COMPARISONS config KCOV_INSTRUMENT_ALL bool "Instrument all code by default" depends on KCOV - default y if KCOV + default y help If you are doing generic system call fuzzing (like e.g. syzkaller), then you will want to instrument the whole kernel and you should From patchwork Fri Feb 16 18:38:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128610 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp864760ljc; Fri, 16 Feb 2018 10:42:14 -0800 (PST) X-Google-Smtp-Source: AH8x22605oIWRvcJ98ethN4+ZdUL2PO3rc8m1dnPXYKNCReNzRitUhArhCOqdjOD1WelvzDhtTQx X-Received: by 10.98.178.218 with SMTP id z87mr6924912pfl.88.1518806534060; Fri, 16 Feb 2018 10:42:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806534; cv=none; d=google.com; s=arc-20160816; b=ANVLsoqctwsoHDa/YgKgAiJBN+SIOL4+Lt2KCliIi/Tlf1noXrqsR9Y5cx72a8HkN8 6uRCoICX/0dT0F+1hSzVPc6/ZmR6PSruU6Lz083zvEfizmCWxsdNXpX0v6sghDybErxV lAvrbGdicM7RuTcS8iUrMVrgobif2GO/Hq0crbr2zWoAU7uRGcPeOKrZZZkeXbIZB6Yy oCRCQ+zS9elcJoOQtEhZnoB5K0PV1xgZrNOoYfgne7hgUiq+DutUD4+oTjjqH2rD1r1N tOA06wuCLa0yepVleQeOR6dHi/2nXAxoT5p/thPyrIYEr464C95AXf1bROdoN2H/Xrxc BUCg== 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 :arc-authentication-results; bh=BPc6z7jaBi5hs6EsHJx7v6rdWK5aF1kXWi0zXb2tz0w=; b=EhEWyYPMFrNkSMlBGbKAQWPIsyMMBCfMl627j0sny2Aqbo3HReUJQGPuSodZVuvOQ5 j2XxDT9LI+oSnwwtdeXZ6yxvIVg9GV5NclAOLCifirpxmLIk7g8CNhe96x4WUbi20HHL xuwqDYtpsm8XZ0fgbSJbn/V5FgSbjcDZoeoFznykkIvFP5OanZZyFjnrmWzqyOIphMYL p3oAfcQaXxyjM2PN8C+t3YrLUBe1Ppik7y47bjhN4IqPcGxY8DhBTdolq58O3Mk6OJOs mnrJ9Jitp9VVtQpgAUUQ+TXySSyP4V/ELlFItsBLvU/DSpSn3uAfCCjciHaAUHqDB9DS RPGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=QiTU1ykl; 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 g1-v6si1631408pld.236.2018.02.16.10.42.13; Fri, 16 Feb 2018 10:42:14 -0800 (PST) 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=QiTU1ykl; 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 S1753088AbeBPSly (ORCPT + 28 others); Fri, 16 Feb 2018 13:41:54 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:58376 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753034AbeBPSlv (ORCPT ); Fri, 16 Feb 2018 13:41:51 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBTN013418; Sat, 17 Feb 2018 03:39:31 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBTN013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806371; bh=BPc6z7jaBi5hs6EsHJx7v6rdWK5aF1kXWi0zXb2tz0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QiTU1yklr9qYYyEZvQiotuZx1gd6GCOp5UNwwd3GAPGHDPoutuEZflnynvOuTAn+B ZN9pZKA4YRnATOA0tuF4qkUKccThrsNoBqWsaKt7f2oWRX9aXF0XdFEgZRxoEbVU4T 2B6gmOxsznRYR8PKz3Mdsa0R0AvkE1rnieg3FQG9Mao7eEcC8NqWKDrlBAEnEiuRBS mddYfzj7Rv96IOHdaXfxZCVTUK4kgHVk87D/Z1/jSLf9kwsz/FjeiQspgBwsgbITKV lTTcQ2INhnLN4JSugXCMMWMnOZWdg+KaRVW+TfILBthdnF7hSTx0GNNFD1fFyQR0tk bUzIIzAIP2UzQ== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , kernel-hardening@lists.openwall.com, linux-kernel@vger.kernel.org, Emese Revfy Subject: [PATCH 20/23] gcc-plugins: always build plugins with C++ Date: Sat, 17 Feb 2018 03:38:48 +0900 Message-Id: <1518806331-7101-21-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the target compiler is GCC 4.8 or newer, plugins are compiled with HOSTCXX. Otherwise, gcc-plugin.sh will select HOSTCC or HOSTCXX. To simpily things, let's decide GCC 4.8 is the requirement for GCC pulgins. With this, plugins are always built with HOSTCXX. This is a feature of advanced users, so this requirement whould not be not a big issue. Add 'depends on GCC_VERSION >= 40800' to GCC_PLUGINS, and remove the code that was needed to build plugins with HOSTCC. Signed-off-by: Masahiro Yamada --- arch/Kconfig | 1 + scripts/Makefile.gcc-plugins | 11 +++-------- scripts/gcc-plugin.sh | 38 +++----------------------------------- scripts/gcc-plugins/Makefile | 15 ++++----------- 4 files changed, 11 insertions(+), 54 deletions(-) -- 2.7.4 diff --git a/arch/Kconfig b/arch/Kconfig index 9b7a628..9bd4e1f 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -410,6 +410,7 @@ config HAVE_GCC_PLUGINS menuconfig GCC_PLUGINS bool "GCC plugins" depends on HAVE_GCC_PLUGINS + depends on GCC_VERSION >= 40800 depends on !COMPILE_TEST help GCC plugins are loadable modules that provide extra features to the diff --git a/scripts/Makefile.gcc-plugins b/scripts/Makefile.gcc-plugins index b2a95af..b0f9108 100644 --- a/scripts/Makefile.gcc-plugins +++ b/scripts/Makefile.gcc-plugins @@ -1,7 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 ifdef CONFIG_GCC_PLUGINS - __PLUGINCC := $(call cc-ifversion, -ge, 0408, $(HOSTCXX), $(HOSTCC)) - PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)") + PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh $(HOSTCXX) $(CC)) SANCOV_PLUGIN := -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so @@ -65,12 +64,8 @@ ifdef CONFIG_GCC_PLUGINS @echo "Cannot use CONFIG_GCC_PLUGINS: plugin support on gcc <= 5.1 is buggy on powerpc, please upgrade to gcc 5.2 or newer" >&2 && exit 1 endif endif - ifeq ($(call cc-ifversion, -ge, 0405, y), y) - $(Q)$(srctree)/scripts/gcc-plugin.sh --show-error "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)" || true - @echo "Cannot use CONFIG_GCC_PLUGINS: your gcc installation does not support plugins, perhaps the necessary headers are missing?" >&2 && exit 1 - else - @echo "Cannot use CONFIG_GCC_PLUGINS: your gcc version does not support plugins, you should upgrade it to at least gcc 4.5" >&2 && exit 1 - endif + $(Q)$(srctree)/scripts/gcc-plugin.sh --show-error $(HOSTCXX) $(CC) || true + @echo "Cannot use CONFIG_GCC_PLUGINS: your gcc installation does not support plugins, perhaps the necessary headers are missing?" >&2 && exit 1 endif endif endif diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh index d3caefe..0edbdae 100755 --- a/scripts/gcc-plugin.sh +++ b/scripts/gcc-plugin.sh @@ -8,42 +8,10 @@ if [ "$1" = "--show-error" ] ; then shift || true fi -gccplugins_dir=$($3 -print-file-name=plugin) -plugincc=$($1 -E -x c++ - -o /dev/null -I"${srctree}"/gcc-plugins -I"${gccplugins_dir}"/include 2>&1 <= 4008 || defined(ENABLE_BUILD_WITH_CXX) -#warning $2 CXX -#else -#warning $1 CC -#endif -EOF -) - -if [ $? -ne 0 ] -then - if [ -n "$SHOW_ERROR" ] ; then - echo "${plugincc}" >&2 - fi - exit 1 -fi - -case "$plugincc" in - *"$1 CC"*) - echo "$1" - exit 0 - ;; - - *"$2 CXX"*) - # the c++ compiler needs another test, see below - ;; - - *) - exit 1 - ;; -esac +gccplugins_dir=$($2 -print-file-name=plugin) # we need a c++ compiler that supports the designated initializer GNU extension -plugincc=$($2 -c -x c++ -std=gnu++98 - -fsyntax-only -I"${srctree}"/gcc-plugins -I"${gccplugins_dir}"/include 2>&1 <&1 < X-Patchwork-Id: 128614 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp865545ljc; Fri, 16 Feb 2018 10:43:11 -0800 (PST) X-Google-Smtp-Source: AH8x227woBG9UzMai0ZPLK+l+2VIxu5zA1YmV+MkgM4EX1/FMlVtHEYHz6hbqtMageMeoqxguMgR X-Received: by 10.101.66.129 with SMTP id j1mr5745087pgp.56.1518806591440; Fri, 16 Feb 2018 10:43:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806591; cv=none; d=google.com; s=arc-20160816; b=Rz3IYdnPLsGNwFKRbcmtfnEJXIZii2OKOD0BGz+21UR5zLTRrhnXECsesZotizQQW6 smzvQLzJCPKI4rPi2D0c85KY0/ekNVKZ2dknbZ/8sElBJjY2SHw5ZNG9ZVO2CIDJ6M3c iFRsiE5FNUlFHvWqYV/s59tPnBJp7oi4HXW0VFpEZD5/ZXVPpuROb/NClDAjTBs2Vvfq L3kjKeuPaHMK8ZJ20/LorwI84BgSshv8euUslgPTiUXA/mGuwQ2xMYLFrKHCT/SRMnmS wP7rqTKt6l0T8ZL6jL0z5p/GthZtvIyg5sMZVniquwlIx/1lvOj5JBX2BfEIq29lJO7p MgWw== 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 :arc-authentication-results; bh=3HaRTIPTfu2Ud13Hd7mnMb61C3Dpjxmhm9k9d1jW2xQ=; b=ju5x+8HdmI79p8VdbA139Ed0HzaUl3LFqwBMy3uVhZrZb+sLeRC3YZGvOUPY9DHIFT LSn7QZpsRFNql1qI/1YAGpx8iryvN9e5gelD+CAnxEax5koXsCXzk3vz3bL6t/X4xoth zJv3jLU0xVvEyAUNZwwtS522QyRrx1XPINqaF0uuubN1IM6fQflgQPcDWmgh05m/jTx4 SdZR4lHRYEvJfU9Hfu/JBDB0Jf3vk4FxrAU/YZgEu5Ok+T8MnZPyctWspPlPk/v4gAlO /bURkDVNRJ312VTE8hA+mUnPhmO3x+nFv4tFAOF7mtHoTHYsvJ85YtV9/3bTzvEJD4KY hpcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=cE5poFrQ; 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 h70si4807313pfh.181.2018.02.16.10.43.11; Fri, 16 Feb 2018 10:43:11 -0800 (PST) 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=cE5poFrQ; 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 S1753517AbeBPSnI (ORCPT + 28 others); Fri, 16 Feb 2018 13:43:08 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:59556 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753280AbeBPSnF (ORCPT ); Fri, 16 Feb 2018 13:43:05 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBTO013418; Sat, 17 Feb 2018 03:39:32 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBTO013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806373; bh=3HaRTIPTfu2Ud13Hd7mnMb61C3Dpjxmhm9k9d1jW2xQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cE5poFrQ7gWR8lRI/On8FoVrFTuA9fDngRc2g/1h6Qei64yEkmPlsbj/kO37o2T9p GQl2TRSbqac5Xdt+zAn4hJZK1vtuzcvxYi4EjBaZQQjffRfIVabjbrDasIM+usJEbw G64PkGliTFWWCWUQ6XGyA2Rd9RcfQI33xEwcIL//LltwLlMFaRWdoKteiPhFgFy4MH pxV4WmJUJFJhUkLn2W5cLodzC7Xc0AbuPK6KNgWTmn6kG/n5vyhRNX8/doeV1sLE+8 KYV1bhS2BeHakpjc9/BgX9Nd6PeKK1CHTkaqj+F808Fiuux03akBDu3acPeLbWKyu3 I5ed7LnxzYfdQ== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , Michael Ellerman , Benjamin Herrenschmidt , linux-kernel@vger.kernel.org, Paul Mackerras , kernel-hardening@lists.openwall.com, linuxppc-dev@lists.ozlabs.org, Emese Revfy Subject: [PATCH 21/23] gcc-plugins: move GCC version check for PowerPC to Kconfig Date: Sat, 17 Feb 2018 03:38:49 +0900 Message-Id: <1518806331-7101-22-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For PowerPC, GCC 5.2 is the requirement for GCC plugins. Move the version check to Kconfig, and remove the ugly checker. Signed-off-by: Masahiro Yamada --- arch/powerpc/Kconfig | 2 +- scripts/Makefile.gcc-plugins | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) -- 2.7.4 Acked-by: Andrew Donnellan diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 73ce5dd..b8474c2 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -195,7 +195,7 @@ config PPC select HAVE_FTRACE_MCOUNT_RECORD select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FUNCTION_TRACER - select HAVE_GCC_PLUGINS + select HAVE_GCC_PLUGINS if GCC_VERSION >= 50200 select HAVE_GENERIC_GUP select HAVE_HW_BREAKPOINT if PERF_EVENTS && (PPC_BOOK3S || PPC_8xx) select HAVE_IDE diff --git a/scripts/Makefile.gcc-plugins b/scripts/Makefile.gcc-plugins index b0f9108..25da4c0 100644 --- a/scripts/Makefile.gcc-plugins +++ b/scripts/Makefile.gcc-plugins @@ -56,14 +56,6 @@ gcc-plugins-check: FORCE ifdef CONFIG_GCC_PLUGINS ifeq ($(PLUGINCC),) ifneq ($(GCC_PLUGINS_CFLAGS),) - # Various gccs between 4.5 and 5.1 have bugs on powerpc due to missing - # header files. gcc <= 4.6 doesn't work at all, gccs from 4.8 to 5.1 have - # issues with 64-bit targets. - ifeq ($(ARCH),powerpc) - ifeq ($(call cc-ifversion, -le, 0501, y), y) - @echo "Cannot use CONFIG_GCC_PLUGINS: plugin support on gcc <= 5.1 is buggy on powerpc, please upgrade to gcc 5.2 or newer" >&2 && exit 1 - endif - endif $(Q)$(srctree)/scripts/gcc-plugin.sh --show-error $(HOSTCXX) $(CC) || true @echo "Cannot use CONFIG_GCC_PLUGINS: your gcc installation does not support plugins, perhaps the necessary headers are missing?" >&2 && exit 1 endif From patchwork Fri Feb 16 18:38:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128611 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp864987ljc; Fri, 16 Feb 2018 10:42:29 -0800 (PST) X-Google-Smtp-Source: AH8x22559TiPvwGJeiv/OgC3ahnsT3lg2wxB03AvKEIjVzEeqrtX+lGfT2A4HPMc34VVquFrB0Xk X-Received: by 10.99.117.89 with SMTP id f25mr5773781pgn.18.1518806549449; Fri, 16 Feb 2018 10:42:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806549; cv=none; d=google.com; s=arc-20160816; b=i6Z97PkNuZ7gIKhML1Nd2d76xBrRzxMwveZYEG6EabQ7FCixonzD1/g/pMsiGcm0iE 1suhPBr8f/xYvPPJOD1jIhTbzcmlBB8XKY5ttq7rHCkFMWBAy2WOu5vLjiK/2EOnW6oa J1PZX7rOmmrLXiH5lEPMYodAYerpBC1+jaUfL0c4gMY1ytx9G7hKvTofmO4hE03hQKjY ItFdGJcL3MoZsCjCKi4K1pG8e73Y2Hg4S8xLRVBzDXvI4rcaft3SFIntUyQRA/p4u8TA Tz4EcEhN8rXIHPXai48UDS0uwnwDyo1rF0LrtgEQjK5IX9dRYvHY+vL9fMRqYIWv/eb+ cFCw== 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 :arc-authentication-results; bh=F/qDuC0sT0NIAbx2z1/ZZbN6D538cPMbWTiUtETtWrE=; b=ug7ppZ9RtBmB0x3TL30j7q4jVJlMpy6GfTCPwK6QD5vbdU9JDzo9X+rkFueErO0Ej9 /VFdsRNjA70aJqsyfYPXZNoUtMgONQ69J52oUe+QovfUDeux8PGE+Pwy1EaFF49PKn6O 5/exA0x8FF5a+wfGiIYObGXyLOLBUDSMesDeosXr/vPAGR6/DpXU3SloVoxJ2OHbwXxw VZh+IyRXP/bDHXBn0l+LRGbj4Yy1nzsuVEA04JVDk/ogEzNrKCi/s0SVyWCIXaUq7s+M M4+IyRPX33C5Ko4xb45wZ0JzQdqqrjBCUfEjsx1XkCeilMkCF5SNogruP/Jeio3FniAH VopQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=y9fPigkA; 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 o10si1222056pgf.102.2018.02.16.10.42.29; Fri, 16 Feb 2018 10:42:29 -0800 (PST) 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=y9fPigkA; 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 S1753306AbeBPSm0 (ORCPT + 28 others); Fri, 16 Feb 2018 13:42:26 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:58880 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753234AbeBPSmX (ORCPT ); Fri, 16 Feb 2018 13:42:23 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBTP013418; Sat, 17 Feb 2018 03:39:33 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBTP013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806374; bh=F/qDuC0sT0NIAbx2z1/ZZbN6D538cPMbWTiUtETtWrE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y9fPigkAysB4TQRVK3YWb4H/vypAjHEwkQpAZm/CrvOcs3J4EqM1QiPkZIQvHw/ms faa4bC9Djp2kHvsvb9+u8QHakO883XY85m98hyj9+WR9ucPYiTgaElxwI5XCfbHNvp 9QJ2ZDdRfvrqhx2yaOPFaXUAKSiOQn5TCu/J3uJ/Kp+7FZlJLMQzGtYWrwgS4ZO99i uhsuL/UKP9GEGbi4M9Zs0uIJ9xBO5El0iu6nk50qlWTppIxc1CyhkQkN9HT4m8MrI6 H+yHfKB/KkCN+AmK1ByK93fPDHGE+Qswtg/ssfvlUa9Xlp7/Nwofu57eE/vv9LAqYY lfNDgj45wukDg== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , kernel-hardening@lists.openwall.com, linux-kernel@vger.kernel.org, Emese Revfy Subject: [PATCH 22/23] gcc-plugins: test GCC plugin support in Kconfig Date: Sat, 17 Feb 2018 03:38:50 +0900 Message-Id: <1518806331-7101-23-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Run scripts/gcc-plugin.sh from Kconfig. Users can enable GCC_PLUGINS only when it is supported. I dropped 'depends on GCC_VERSION >= 40800'. I guess gcc-plugin.sh will not pass with GCC 4.7 or older. Signed-off-by: Masahiro Yamada --- arch/Kconfig | 6 +++- scripts/Makefile.gcc-plugins | 82 ++++++++++++++++---------------------------- scripts/gcc-plugin.sh | 1 - 3 files changed, 34 insertions(+), 55 deletions(-) -- 2.7.4 diff --git a/arch/Kconfig b/arch/Kconfig index 9bd4e1f..d567bd1 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -407,10 +407,14 @@ config HAVE_GCC_PLUGINS An arch should select this symbol if it supports building with GCC plugins. +config CC_HAS_GCC_PLUGINS + bool + default $(shell $srctree/scripts/gcc-plugin.sh $HOSTCXX $CC) + menuconfig GCC_PLUGINS bool "GCC plugins" depends on HAVE_GCC_PLUGINS - depends on GCC_VERSION >= 40800 + depends on CC_HAS_GCC_PLUGINS depends on !COMPILE_TEST help GCC plugins are loadable modules that provide extra features to the diff --git a/scripts/Makefile.gcc-plugins b/scripts/Makefile.gcc-plugins index 25da4c0..19d0d5b 100644 --- a/scripts/Makefile.gcc-plugins +++ b/scripts/Makefile.gcc-plugins @@ -1,71 +1,47 @@ # SPDX-License-Identifier: GPL-2.0 -ifdef CONFIG_GCC_PLUGINS - PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh $(HOSTCXX) $(CC)) - - SANCOV_PLUGIN := -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so +SANCOV_PLUGIN := -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so - gcc-plugin-$(CONFIG_GCC_PLUGIN_CYC_COMPLEXITY) += cyc_complexity_plugin.so +gcc-plugin-$(CONFIG_GCC_PLUGIN_CYC_COMPLEXITY) += cyc_complexity_plugin.so - gcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += latent_entropy_plugin.so - gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += -DLATENT_ENTROPY_PLUGIN - ifdef CONFIG_GCC_PLUGIN_LATENT_ENTROPY - DISABLE_LATENT_ENTROPY_PLUGIN += -fplugin-arg-latent_entropy_plugin-disable - endif +gcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += latent_entropy_plugin.so +gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += -DLATENT_ENTROPY_PLUGIN +ifdef CONFIG_GCC_PLUGIN_LATENT_ENTROPY + DISABLE_LATENT_ENTROPY_PLUGIN += -fplugin-arg-latent_entropy_plugin-disable +endif - ifdef CONFIG_GCC_PLUGIN_SANCOV - ifeq ($(CFLAGS_KCOV),) - # It is needed because of the gcc-plugin.sh and gcc version checks. - gcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV) += sancov_plugin.so +ifdef CONFIG_GCC_PLUGIN_SANCOV + ifeq ($(CFLAGS_KCOV),) + # It is needed because of the gcc-plugin.sh and gcc version checks. + gcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV) += sancov_plugin.so - ifneq ($(PLUGINCC),) - CFLAGS_KCOV := $(SANCOV_PLUGIN) - else - $(warning warning: cannot use CONFIG_KCOV: -fsanitize-coverage=trace-pc is not supported by compiler) - endif - endif + CFLAGS_KCOV := $(SANCOV_PLUGIN) endif +endif - gcc-plugin-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) += structleak_plugin.so - gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE) += -fplugin-arg-structleak_plugin-verbose - gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL) += -fplugin-arg-structleak_plugin-byref-all - gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) += -DSTRUCTLEAK_PLUGIN - - gcc-plugin-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += randomize_layout_plugin.so - gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += -DRANDSTRUCT_PLUGIN - gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE) += -fplugin-arg-randomize_layout_plugin-performance-mode +gcc-plugin-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) += structleak_plugin.so +gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE) += -fplugin-arg-structleak_plugin-verbose +gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL) += -fplugin-arg-structleak_plugin-byref-all +gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) += -DSTRUCTLEAK_PLUGIN - GCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y)) +gcc-plugin-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += randomize_layout_plugin.so +gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += -DRANDSTRUCT_PLUGIN +gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE) += -fplugin-arg-randomize_layout_plugin-performance-mode - export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGIN GCC_PLUGIN_SUBDIR - export SANCOV_PLUGIN DISABLE_LATENT_ENTROPY_PLUGIN +GCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y)) - ifneq ($(PLUGINCC),) - # SANCOV_PLUGIN can be only in CFLAGS_KCOV because avoid duplication. - GCC_PLUGINS_CFLAGS := $(filter-out $(SANCOV_PLUGIN), $(GCC_PLUGINS_CFLAGS)) - endif +export GCC_PLUGINS_CFLAGS GCC_PLUGIN GCC_PLUGIN_SUBDIR +export SANCOV_PLUGIN DISABLE_LATENT_ENTROPY_PLUGIN - KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS) - GCC_PLUGIN := $(gcc-plugin-y) - GCC_PLUGIN_SUBDIR := $(gcc-plugin-subdir-y) -endif +# SANCOV_PLUGIN can be only in CFLAGS_KCOV because avoid duplication. +GCC_PLUGINS_CFLAGS := $(filter-out $(SANCOV_PLUGIN), $(GCC_PLUGINS_CFLAGS)) -# If plugins aren't supported, abort the build before hard-to-read compiler -# errors start getting spewed by the main build. -PHONY += gcc-plugins-check -gcc-plugins-check: FORCE -ifdef CONFIG_GCC_PLUGINS - ifeq ($(PLUGINCC),) - ifneq ($(GCC_PLUGINS_CFLAGS),) - $(Q)$(srctree)/scripts/gcc-plugin.sh --show-error $(HOSTCXX) $(CC) || true - @echo "Cannot use CONFIG_GCC_PLUGINS: your gcc installation does not support plugins, perhaps the necessary headers are missing?" >&2 && exit 1 - endif - endif -endif - @: +KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS) +GCC_PLUGIN := $(gcc-plugin-y) +GCC_PLUGIN_SUBDIR := $(gcc-plugin-subdir-y) # Actually do the build, if requested. PHONY += gcc-plugins -gcc-plugins: scripts_basic gcc-plugins-check +gcc-plugins: scripts_basic ifdef CONFIG_GCC_PLUGINS $(Q)$(MAKE) $(build)=scripts/gcc-plugins endif diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh index 0edbdae..b18c69c 100755 --- a/scripts/gcc-plugin.sh +++ b/scripts/gcc-plugin.sh @@ -24,7 +24,6 @@ EOF if [ $? -eq 0 ] then - echo "$1" exit 0 fi From patchwork Fri Feb 16 18:38:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128609 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp864651ljc; Fri, 16 Feb 2018 10:42:03 -0800 (PST) X-Google-Smtp-Source: AH8x226sgWgKUyYnop7zPzkaXUK7JAC0376jK9b47kGEyPk8Ipva6OcNKScHWtvU/+IVLVgiZeSL X-Received: by 2002:a17:902:7042:: with SMTP id h2-v6mr6721912plt.217.1518806523235; Fri, 16 Feb 2018 10:42:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806523; cv=none; d=google.com; s=arc-20160816; b=V8wK3igXnYBjkIa1bxl2RplVt1uEM/TicZ9zgZSvnWazYHDADmVI02ZIsq2uNRBCfg Gudzxst1DbwgedQiVAvMdQsHdNkWdjKDYUGoZMiYyCLcLgoYJutzJfa/0C7But68C/Dd I9livPDQKLb2DuQo6zdV/pzyGgkqIZ42y3v1GwYV/NN9FPtTrhVp01Y21ft+nNlqITdR QtU9xM5V55/rdJFNZFkWaw5b4m8xO2VsL2gbMzw7pyKlArgTOGT0nftl+AC9HKHFQloi BOytOg/FvuEvI21kB+gzJwod0efy3ggOzs+0TlldpLbXSWFdirKPRapqsBPY8syxEFin /43Q== 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 :arc-authentication-results; bh=Lau+sX5Xfd97pBT4xPSqZK1OIR5DgA12mp5Ps116g7M=; b=wscLRvSM0P0Tc1phzN4X9ZCRO9ID40S1JCeEi82/SWDUTSSBjdrBx0gqkdma3wJOvd w1M9a6Ib6saGBlBNG6lnVhRZkM+3RzKjfqLeeSAO7/1m5YFJBgfI3NTMKknSYeLCnh3U Wyadpp6nbk57mK39DV3L5PWEhgUFH1SBfJ8WbK4tWtt8ZtoB/dC59316CyYJ1Z64pfuq H5rShlSYHvotkaH4cBQHIdvYUXVYy14QKuoASChOSOycgz8EzGmnCOWfrLVS7paHsnKC EF97OxTtBlKKouVhkAeABU4FZIKqChW/8vJy26iLqXccjSqYHKdX337dYfheviX4PCWV 2A0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=YxRw0GLl; 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 g1-v6si1631408pld.236.2018.02.16.10.42.02; Fri, 16 Feb 2018 10:42:03 -0800 (PST) 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=YxRw0GLl; 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 S1753160AbeBPSl7 (ORCPT + 28 others); Fri, 16 Feb 2018 13:41:59 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:58419 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753064AbeBPSly (ORCPT ); Fri, 16 Feb 2018 13:41:54 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBTQ013418; Sat, 17 Feb 2018 03:39:34 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBTQ013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806375; bh=Lau+sX5Xfd97pBT4xPSqZK1OIR5DgA12mp5Ps116g7M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YxRw0GLldbSA59vjgSk0HJw4r3/UowX7FxNOF4F1ZlN0jCbeP/lJd2R4DDzCGuiDZ V7ax+hgZIb7AG4MFotX8eIpUtDE8c4IeE1ZH9EoRj4Tf3Vi+yBcNdROQ1QWKWxnDff 5qXNsmc/gjZNchgQTlWhIj0e8hG9BUNnLA4CSCzrOrtX3xu8MyIj0YhadZ3GyeGkde qV2EuLMEDn+30XrCTc1GWfewab0yIcR4XR6JW+T+RvM8qUmge6DusJYyg3K8DBlEbT pVbKm58/09KJi/z3PV+HvtsrGFb+1bsn2QFylh3jfg8xMwN4LO32oAMm2o7oF3yJXq Fq00u6SQO9uUA== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 23/23] gcc-plugins: enable GCC_PLUGINS for COMPILE_TEST Date: Sat, 17 Feb 2018 03:38:51 +0900 Message-Id: <1518806331-7101-24-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The plugin availability is checked in Kconfig, so all{yes,mod}config will not be bothered. Remove 'depends on !COMPILE_TEST'. Signed-off-by: Masahiro Yamada --- arch/Kconfig | 1 - 1 file changed, 1 deletion(-) -- 2.7.4 diff --git a/arch/Kconfig b/arch/Kconfig index d567bd1..5b5610b 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -415,7 +415,6 @@ menuconfig GCC_PLUGINS bool "GCC plugins" depends on HAVE_GCC_PLUGINS depends on CC_HAS_GCC_PLUGINS - depends on !COMPILE_TEST help GCC plugins are loadable modules that provide extra features to the compiler. They are useful for runtime instrumentation and static analysis.