Re: [PATCH] kbuild: builddeb: always make modules_install, to install modules.builtin*

2023-06-25 Thread Masahiro Yamada
On Fri, Jun 23, 2023 at 4:20 AM Josh Triplett  wrote:
>
> Even for a non-modular kernel, the kernel builds modules.builtin and
> modules.builtin.modinfo, with information about the built-in modules.
> Tools such as initramfs-tools need these files to build a working
> initramfs on some systems, such as those requiring firmware.
>
> Now that `make modules_install` works even in non-modular kernels and
> installs these files, unconditionally invoke it when building a Debian
> package.
>
> Signed-off-by: Josh Triplett 
> ---


Applied to linux-kbuild. Thanks.

What I meant in my previous reply was
to remove "if is_enabled CONFIG_MODULES; then"

Anyway, I did it by myself in a follow-up patch.

https://lore.kernel.org/linux-kbuild/20230625181623.2473308-1-masahi...@kernel.org/T/#u





-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH] kbuild: make modules_install copy modules.builtin(.modinfo)

2023-06-15 Thread Masahiro Yamada
Josh Triplett reports that initramfs-tools needs modules.builtin and
modules.builtin.modinfo to create a working initramfs for a non-modular
kernel.

If this is a general tooling issue not limited to Debian, I think it
makes sense to change modules_install.

This commit changes the targets as follows when CONFIG_MODULES=n.

In-tree builds:
  make modules  -> no-op
  make modules_install  -> install modules.builtin(.modinfo)

External module builds:
  make modules  -> show error message like before
  make modules_install  -> show error message like before

Link: 
https://lore.kernel.org/lkml/36a4014c73a52af27d930d3ca31d362b60f4461c.1686356364.git.j...@joshtriplett.org/
Reported-by: Josh Triplett 
Signed-off-by: Masahiro Yamada 
---

 Makefile | 26 --
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile
index cc3fe09c4dec..f18d59c81241 100644
--- a/Makefile
+++ b/Makefile
@@ -1545,6 +1545,8 @@ modules_sign_only := y
 endif
 endif
 
+endif # CONFIG_MODULES
+
 modinst_pre :=
 ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
 modinst_pre := __modinst_pre
@@ -1555,18 +1557,18 @@ PHONY += __modinst_pre
 __modinst_pre:
@rm -rf $(MODLIB)/kernel
@rm -f $(MODLIB)/source
-   @mkdir -p $(MODLIB)/kernel
+   @mkdir -p $(MODLIB)
+ifdef CONFIG_MODULES
@ln -s $(abspath $(srctree)) $(MODLIB)/source
@if [ ! $(objtree) -ef  $(MODLIB)/build ]; then \
rm -f $(MODLIB)/build ; \
ln -s $(CURDIR) $(MODLIB)/build ; \
fi
@sed 's:^\(.*\)\.o$$:kernel/\1.ko:' modules.order > 
$(MODLIB)/modules.order
+endif
@cp -f modules.builtin $(MODLIB)/
@cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
 
-endif # CONFIG_MODULES
-
 ###
 # Cleaning is done on three levels.
 # make clean Delete most generated files
@@ -1908,6 +1910,13 @@ help:
@echo  '  clean   - remove generated files in module directory 
only'
@echo  ''
 
+__external_modules_error:
+   @echo >&2 '***'
+   @echo >&2 '*** The present kernel disabled CONFIG_MODULES.'
+   @echo >&2 '*** You cannot build or install external modules.'
+   @echo >&2 '***'
+   @false
+
 endif # KBUILD_EXTMOD
 
 # ---
@@ -1944,13 +1953,10 @@ else # CONFIG_MODULES
 # Modules not configured
 # ---
 
-modules modules_install:
-   @echo >&2 '***'
-   @echo >&2 '*** The present kernel configuration has modules disabled.'
-   @echo >&2 '*** To use the module feature, please run "make menuconfig" 
etc.'
-   @echo >&2 '*** to enable CONFIG_MODULES.'
-   @echo >&2 '***'
-   @exit 1
+PHONY += __external_modules_error
+
+modules modules_install: __external_modules_error
+   @:
 
 KBUILD_MODULES :=
 
-- 
2.39.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH v9 08/11] kbuild: implement CONFIG_TRIM_UNUSED_KSYMS without recursion

2023-06-11 Thread Masahiro Yamada
When CONFIG_TRIM_UNUSED_KSYMS is enabled, Kbuild recursively traverses
the directory tree to determine which EXPORT_SYMBOL to trim. If an
EXPORT_SYMBOL turns out to be unused by anyone, Kbuild begins the
second traverse, where some source files are recompiled with their
EXPORT_SYMBOL() tuned into a no-op.

Linus stated negative opinions about this slowness in commits:

 - 5cf0fd591f2e ("Kbuild: disable TRIM_UNUSED_KSYMS option")
 - a555bdd0c58c ("Kbuild: enable TRIM_UNUSED_KSYMS again, with some guarding")

We can do this better now. The final data structures of EXPORT_SYMBOL
are generated by the modpost stage, so modpost can selectively emit
KSYMTAB entries that are really used by modules.

Commit f73edc8951b2 ("kbuild: unify two modpost invocations") is another
ground-work to do this in a one-pass algorithm. With the list of modules,
modpost sets sym->used if it is used by a module. modpost emits KSYMTAB
only for symbols with sym->used==true.

BTW, Nicolas explained why the trimming was implemented with recursion:

  https://lore.kernel.org/all/2o2rpn97-79nq-p7s2-nq5-8p833914...@syhkavp.arg/

Actually, we never achieved that level of optimization where the chain
reaction of trimming comes into play because:

 - CONFIG_LTO_CLANG cannot remove any unused symbols
 - CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is enabled only for vmlinux,
   but not modules

If deeper trimming is required, we need to revisit this, but I guess
that is unlikely to happen.

Signed-off-by: Masahiro Yamada 
---

Changes in v9:
  - fix short options in getopt()
  - Do not dump trimmed symbols into Module.symvers

Changes in v7:
  - Remove *.usyms

Changes in v5:
  - Clean up more

 .gitignore  |  2 -
 Makefile| 22 ++-
 include/linux/export.h  | 67 +-
 scripts/Makefile.build  | 15 +---
 scripts/Makefile.modpost|  7 
 scripts/adjust_autoksyms.sh | 73 -
 scripts/basic/fixdep.c  |  3 +-
 scripts/gen_autoksyms.sh| 62 ---
 scripts/gen_ksymdeps.sh | 30 ---
 scripts/mod/modpost.c   | 57 ++---
 scripts/remove-stale-files  |  4 ++
 11 files changed, 78 insertions(+), 264 deletions(-)
 delete mode 100755 scripts/adjust_autoksyms.sh
 delete mode 100755 scripts/gen_autoksyms.sh
 delete mode 100755 scripts/gen_ksymdeps.sh

diff --git a/.gitignore b/.gitignore
index 7f86e0837909..c3ce78ca20d2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -51,7 +51,6 @@
 *.symversions
 *.tab.[ch]
 *.tar
-*.usyms
 *.xz
 *.zst
 Module.symvers
@@ -112,7 +111,6 @@ modules.order
 #
 /include/config/
 /include/generated/
-/include/ksym/
 /arch/*/include/generated/
 
 # stgit generated dirs
diff --git a/Makefile b/Makefile
index f836936fb4d8..cc3fe09c4dec 100644
--- a/Makefile
+++ b/Makefile
@@ -1193,28 +1193,12 @@ endif
 export KBUILD_VMLINUX_LIBS
 export KBUILD_LDS  := arch/$(SRCARCH)/kernel/vmlinux.lds
 
-# Recurse until adjust_autoksyms.sh is satisfied
-PHONY += autoksyms_recursive
 ifdef CONFIG_TRIM_UNUSED_KSYMS
 # For the kernel to actually contain only the needed exported symbols,
 # we have to build modules as well to determine what those symbols are.
-# (this can be evaluated only once include/config/auto.conf has been included)
 KBUILD_MODULES := 1
-
-autoksyms_recursive: $(build-dir) modules.order
-   $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
- "$(MAKE) -f $(srctree)/Makefile autoksyms_recursive"
 endif
 
-autoksyms_h := $(if $(CONFIG_TRIM_UNUSED_KSYMS), include/generated/autoksyms.h)
-
-quiet_cmd_autoksyms_h = GEN $@
-  cmd_autoksyms_h = mkdir -p $(dir $@); \
-   $(CONFIG_SHELL) $(srctree)/scripts/gen_autoksyms.sh $@
-
-$(autoksyms_h):
-   $(call cmd,autoksyms_h)
-
 # '$(AR) mPi' needs 'T' to workaround the bug of llvm-ar <= 14
 quiet_cmd_ar_vmlinux.a = AR  $@
   cmd_ar_vmlinux.a = \
@@ -1223,7 +1207,7 @@ quiet_cmd_ar_vmlinux.a = AR  $@
$(AR) mPiT $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f 
$(srctree)/scripts/head-object-list.txt)
 
 targets += vmlinux.a
-vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt 
autoksyms_recursive FORCE
+vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE
$(call if_changed,ar_vmlinux.a)
 
 PHONY += vmlinux_o
@@ -1279,7 +1263,7 @@ scripts: scripts_basic scripts_dtc
 PHONY += prepare archprepare
 
 archprepare: outputmakefile archheaders archscripts scripts 
include/config/kernel.release \
-   asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h \
+   asm-generic $(version_h) include/generated/utsrelease.h \
include/generated/compile.h include/generated/autoconf.h 
remove-stale-files
 
 prepare0: archprepare
@@ -2039,7 +2023,7 @@ clean: $(clean-dirs)
-o -name '*.dtb.S' -o -name

[PATCH v9 11/11] linux/export.h: rename 'sec' argument to 'license'

2023-06-11 Thread Masahiro Yamada
Now, EXPORT_SYMBOL() is populated in two stages. In the first stage,
all of EXPORT_SYMBOL/EXPORT_SYMBOL_GPL go into the same section,
'.export_symbol'.

'sec' does not make sense any more. Rename it to 'license'.

Signed-off-by: Masahiro Yamada 
Reviewed-by: Nick Desaulniers 
---

(no changes since v7)

Changes in v7:
 - New patch

 include/linux/export.h | 8 
 include/linux/pm.h | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/linux/export.h b/include/linux/export.h
index 1de600734071..beed8387e0a4 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -57,11 +57,11 @@ extern struct module __this_module;
  * be reused in other execution contexts such as the UEFI stub or the
  * decompressor.
  */
-#define __EXPORT_SYMBOL(sym, sec, ns)
+#define __EXPORT_SYMBOL(sym, license, ns)
 
 #elif defined(__GENKSYMS__)
 
-#define __EXPORT_SYMBOL(sym, sec, ns)  __GENKSYMS_EXPORT_SYMBOL(sym)
+#define __EXPORT_SYMBOL(sym, license, ns)  __GENKSYMS_EXPORT_SYMBOL(sym)
 
 #elif defined(__ASSEMBLY__)
 
@@ -78,9 +78,9 @@ extern struct module __this_module;
 #endif /* CONFIG_MODULES */
 
 #ifdef DEFAULT_SYMBOL_NAMESPACE
-#define _EXPORT_SYMBOL(sym, sec)   __EXPORT_SYMBOL(sym, sec, 
__stringify(DEFAULT_SYMBOL_NAMESPACE))
+#define _EXPORT_SYMBOL(sym, license)   __EXPORT_SYMBOL(sym, license, 
__stringify(DEFAULT_SYMBOL_NAMESPACE))
 #else
-#define _EXPORT_SYMBOL(sym, sec)   __EXPORT_SYMBOL(sym, sec, "")
+#define _EXPORT_SYMBOL(sym, license)   __EXPORT_SYMBOL(sym, license, "")
 #endif
 
 #define EXPORT_SYMBOL(sym) _EXPORT_SYMBOL(sym, "")
diff --git a/include/linux/pm.h b/include/linux/pm.h
index f615193587d2..badad7d11f4f 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -375,14 +375,14 @@ const struct dev_pm_ops name = { \
 }
 
 #ifdef CONFIG_PM
-#define _EXPORT_DEV_PM_OPS(name, sec, ns)  \
+#define _EXPORT_DEV_PM_OPS(name, license, ns)  \
const struct dev_pm_ops name;   \
-   __EXPORT_SYMBOL(name, sec, ns); \
+   __EXPORT_SYMBOL(name, license, ns); \
const struct dev_pm_ops name
 #define EXPORT_PM_FN_GPL(name) EXPORT_SYMBOL_GPL(name)
 #define EXPORT_PM_FN_NS_GPL(name, ns)  EXPORT_SYMBOL_NS_GPL(name, ns)
 #else
-#define _EXPORT_DEV_PM_OPS(name, sec, ns)  \
+#define _EXPORT_DEV_PM_OPS(name, license, ns)  \
static __maybe_unused const struct dev_pm_ops __static_##name
 #define EXPORT_PM_FN_GPL(name)
 #define EXPORT_PM_FN_NS_GPL(name, ns)
-- 
2.39.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH v9 09/11] modpost: merge two similar section mismatch warnings

2023-06-11 Thread Masahiro Yamada
In case of section mismatch, modpost shows slightly different messages.

For extable section mismatch:

 "%s(%s+0x%lx): Section mismatch in reference to the %s:%s\n"

For the other cases:

 "%s: section mismatch in reference: %s (section: %s) -> %s (section: %s)\n"

They are similar. Merge them.

Signed-off-by: Masahiro Yamada 
Reviewed-by: Nick Desaulniers 
---


 scripts/mod/modpost.c | 18 +++---
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 50d950e904a4..0adda14451fa 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1147,21 +1147,10 @@ static void default_mismatch_handler(const char 
*modname, struct elf_info *elf,
 
sec_mismatch_count++;
 
-   switch (mismatch->mismatch) {
-   case TEXT_TO_ANY_INIT:
-   case DATA_TO_ANY_INIT:
-   case TEXTDATA_TO_ANY_EXIT:
-   case XXXINIT_TO_SOME_INIT:
-   case XXXEXIT_TO_SOME_EXIT:
-   case ANY_INIT_TO_ANY_EXIT:
-   case ANY_EXIT_TO_ANY_INIT:
-   warn("%s: section mismatch in reference: %s (section: %s) -> %s 
(section: %s)\n",
-modname, fromsym, fromsec, tosym, tosec);
-   break;
-   case EXTABLE_TO_NON_TEXT:
-   warn("%s(%s+0x%lx): Section mismatch in reference to the 
%s:%s\n",
-modname, fromsec, (long)faddr, tosec, tosym);
+   warn("%s: section mismatch in reference: %s (section: %s) -> %s 
(section: %s)\n",
+modname, fromsym, fromsec, tosym, tosec);
 
+   if (mismatch->mismatch == EXTABLE_TO_NON_TEXT) {
if (match(tosec, mismatch->bad_tosec))
fatal("The relocation at %s+0x%lx references\n"
  "section \"%s\" which is black-listed.\n"
@@ -1181,7 +1170,6 @@ static void default_mismatch_handler(const char *modname, 
struct elf_info *elf,
else
error("%s+0x%lx references non-executable section 
'%s'\n",
  fromsec, (long)faddr, tosec);
-   break;
}
 }
 
-- 
2.39.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH v9 10/11] modpost: show offset from symbol for section mismatch warnings

2023-06-11 Thread Masahiro Yamada
Currently, modpost only shows the symbol names and section names, so it
repeats the same message if there are multiple relocations in the same
symbol. It is common the relocation spans across multiple instructions.

It is better to show the offset from the symbol.

Signed-off-by: Masahiro Yamada 
Reviewed-by: Nick Desaulniers 
---


 scripts/mod/modpost.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 0adda14451fa..f26d5050e6da 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1147,8 +1147,8 @@ static void default_mismatch_handler(const char *modname, 
struct elf_info *elf,
 
sec_mismatch_count++;
 
-   warn("%s: section mismatch in reference: %s (section: %s) -> %s 
(section: %s)\n",
-modname, fromsym, fromsec, tosym, tosec);
+   warn("%s: section mismatch in reference: %s+0x%x (section: %s) -> %s 
(section: %s)\n",
+modname, fromsym, (unsigned int)(faddr - from->st_value), fromsec, 
tosym, tosec);
 
if (mismatch->mismatch == EXTABLE_TO_NON_TEXT) {
if (match(tosec, mismatch->bad_tosec))
-- 
2.39.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH v9 07/11] modpost: use null string instead of NULL pointer for default namespace

2023-06-11 Thread Masahiro Yamada
The default namespace is the null string, "".

When set, the null string "" is converted to NULL:

  s->namespace = namespace[0] ? NOFAIL(strdup(namespace)) : NULL;

When printed, the NULL pointer is get back to the null string:

  sym->namespace ?: ""

This saves 1 byte memory allocated for "", but loses the readability.

In kernel-space, we strive to save memory, but modpost is a userspace
tool used to build the kernel. On modern systems, such small piece of
memory is not a big deal.

Handle the namespace string as is.

Signed-off-by: Masahiro Yamada 
Reviewed-by: Nick Desaulniers 
---


 scripts/mod/modpost.c | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 79ad0a346a5c..051ff67875ec 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -300,6 +300,13 @@ static bool contains_namespace(struct list_head *head, 
const char *namespace)
 {
struct namespace_list *list;
 
+   /*
+* The default namespace is null string "", which is always implicitly
+* contained.
+*/
+   if (!namespace[0])
+   return true;
+
list_for_each_entry(list, head, list) {
if (!strcmp(list->namespace, namespace))
return true;
@@ -369,7 +376,7 @@ static struct symbol *sym_add_exported(const char *name, 
struct module *mod,
s = alloc_symbol(name);
s->module = mod;
s->is_gpl_only = gpl_only;
-   s->namespace = namespace[0] ? NOFAIL(strdup(namespace)) : NULL;
+   s->namespace = NOFAIL(strdup(namespace));
list_add_tail(>list, >exported_symbols);
hash_add_symbol(s);
 
@@ -1829,8 +1836,7 @@ static void check_exports(struct module *mod)
else
basename = mod->name;
 
-   if (exp->namespace &&
-   !contains_namespace(>imported_namespaces, 
exp->namespace)) {
+   if (!contains_namespace(>imported_namespaces, 
exp->namespace)) {
modpost_log(allow_missing_ns_imports ? LOG_WARN : 
LOG_ERROR,
"module %s uses symbol %s from namespace 
%s, but does not import it.\n",
basename, exp->name, exp->namespace);
@@ -1916,8 +1922,7 @@ static void add_exported_symbols(struct buffer *buf, 
struct module *mod)
list_for_each_entry(sym, >exported_symbols, list)
buf_printf(buf, "KSYMTAB_%s(%s, \"%s\", \"%s\");\n",
   sym->is_func ? "FUNC" : "DATA", sym->name,
-  sym->is_gpl_only ? "_gpl" : "",
-  sym->namespace ?: "");
+  sym->is_gpl_only ? "_gpl" : "", sym->namespace);
 
if (!modversions)
return;
@@ -2185,7 +2190,7 @@ static void write_dump(const char *fname)
buf_printf(, 
"0x%08x\t%s\t%s\tEXPORT_SYMBOL%s\t%s\n",
   sym->crc, sym->name, mod->name,
   sym->is_gpl_only ? "_GPL" : "",
-  sym->namespace ?: "");
+  sym->namespace);
}
}
write_buf(, fname);
-- 
2.39.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH v9 05/11] modpost: check static EXPORT_SYMBOL* by modpost again

2023-06-11 Thread Masahiro Yamada
Commit 31cb50b5590f ("kbuild: check static EXPORT_SYMBOL* by script
instead of modpost") moved the static EXPORT_SYMBOL* check from the
mostpost to a shell script because I thought it must be checked per
compilation unit to avoid false negatives.

I came up with an idea to do this in modpost, against combined ELF
files. The relocation entries in ELF will find the correct exported
symbol even if there exist symbols with the same name in different
compilation units.

Again, the same sample code.

  Makefile:

obj-y += foo1.o foo2.o

  foo1.c:

#include 
static void foo(void) {}
EXPORT_SYMBOL(foo);

  foo2.c:

void foo(void) {}

Then, modpost can catch it correctly.

MODPOST Module.symvers
  ERROR: modpost: vmlinux: local symbol 'foo' was exported

Signed-off-by: Masahiro Yamada 
Reviewed-by: Nick Desaulniers 
---

(no changes since v6)

Changes in v6:
  - Make the symbol name in the warning more precise

 scripts/Makefile.build |  4 ---
 scripts/check-local-export | 70 --
 scripts/mod/modpost.c  |  7 
 3 files changed, 7 insertions(+), 74 deletions(-)
 delete mode 100755 scripts/check-local-export

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 4119e737fe87..210142c3ff00 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -222,8 +222,6 @@ cmd_gen_ksymdeps = \
$(CONFIG_SHELL) $(srctree)/scripts/gen_ksymdeps.sh $@ >> 
$(dot-target).cmd
 endif
 
-cmd_check_local_export = $(srctree)/scripts/check-local-export $@
-
 ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),)
 cmd_warn_shared_object = $(if $(word 2, $(modname-multi)),$(warning 
$(kbuild-file): $*.o is added to multiple modules: $(modname-multi)))
 endif
@@ -231,7 +229,6 @@ endif
 define rule_cc_o_c
$(call cmd_and_fixdep,cc_o_c)
$(call cmd,gen_ksymdeps)
-   $(call cmd,check_local_export)
$(call cmd,checksrc)
$(call cmd,checkdoc)
$(call cmd,gen_objtooldep)
@@ -243,7 +240,6 @@ endef
 define rule_as_o_S
$(call cmd_and_fixdep,as_o_S)
$(call cmd,gen_ksymdeps)
-   $(call cmd,check_local_export)
$(call cmd,gen_objtooldep)
$(call cmd,gen_symversions_S)
$(call cmd,warn_shared_object)
diff --git a/scripts/check-local-export b/scripts/check-local-export
deleted file mode 100755
index 86ad94647164..
--- a/scripts/check-local-export
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/bin/sh
-# SPDX-License-Identifier: GPL-2.0-only
-#
-# Copyright (C) 2022 Masahiro Yamada 
-# Copyright (C) 2022 Owen Rafferty 
-#
-# Exit with error if a local exported symbol is found.
-# EXPORT_SYMBOL should be used for global symbols.
-
-set -e
-pid=$$
-
-# If there is no symbol in the object, ${NM} (both GNU nm and llvm-nm) shows
-# 'no symbols' diagnostic (but exits with 0). It is harmless and hidden by
-# '2>/dev/null'. However, it suppresses real error messages as well. Add a
-# hand-crafted error message here.
-#
-# TODO:
-# Use --quiet instead of 2>/dev/null when we upgrade the minimum version of
-# binutils to 2.37, llvm to 13.0.0.
-# Then, the following line will be simpler:
-#   { ${NM} --quiet ${1} || kill 0; } |
-
-{ ${NM} ${1} 2>/dev/null || { echo "${0}: ${NM} failed" >&2; kill $pid; } } |
-${AWK} -v "file=${1}" '
-BEGIN {
-   i = 0
-}
-
-# Skip the line if the number of fields is less than 3.
-#
-# case 1)
-#   For undefined symbols, the first field (value) is empty.
-#   The outout looks like this:
-# " U _printk"
-#   It is unneeded to record undefined symbols.
-#
-# case 2)
-#   For Clang LTO, llvm-nm outputs a line with type t but empty name:
-# " t"
-!length($3) {
-   next
-}
-
-# save (name, type) in the associative array
-{ symbol_types[$3]=$2 }
-
-# append the exported symbol to the array
-($3 ~ /^__export_symbol_.*/) {
-   export_symbols[i] = $3
-   sub(/^__export_symbol_/, "", export_symbols[i])
-   i++
-}
-
-END {
-   exit_code = 0
-   for (j = 0; j < i; ++j) {
-   name = export_symbols[j]
-   # nm(3) says "If lowercase, the symbol is usually local"
-   if (symbol_types[name] ~ /[a-z]/) {
-   printf "%s: error: local symbol %s was exported\n",
-   file, name | "cat 1>&2"
-   exit_code = 1
-   }
-   }
-
-   exit exit_code
-}'
-
-exit $?
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index bdf4244da993..10da82ad5874 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1210,6 +1210,13 @@ static void check_export_symbol(struct module *mod, 
struct elf_info *elf,
return;
}
 
+   if (ELF_ST_BIND(sym->st_info) != STB_GLOBAL &&
+   ELF_ST_BIND(sym->st_info) != STB_WEAK) {
+  

[PATCH v9 02/11] modpost: pass struct module pointer to check_section_mismatch()

2023-06-11 Thread Masahiro Yamada
The next commit will use it.

Signed-off-by: Masahiro Yamada 
Reviewed-by: Nick Desaulniers 
---


 scripts/mod/modpost.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 8decf04633bc..403ba4d923f5 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1211,7 +1211,7 @@ static void default_mismatch_handler(const char *modname, 
struct elf_info *elf,
}
 }
 
-static void check_section_mismatch(const char *modname, struct elf_info *elf,
+static void check_section_mismatch(struct module *mod, struct elf_info *elf,
   Elf_Sym *sym,
   unsigned int fsecndx, const char *fromsec,
   Elf_Addr faddr, Elf_Addr taddr)
@@ -1222,7 +1222,7 @@ static void check_section_mismatch(const char *modname, 
struct elf_info *elf,
if (!mismatch)
return;
 
-   default_mismatch_handler(modname, elf, mismatch, sym,
+   default_mismatch_handler(mod->name, elf, mismatch, sym,
 fsecndx, fromsec, faddr,
 tosec, taddr);
 }
@@ -1406,7 +1406,7 @@ static int addend_mips_rel(struct elf_info *elf, Elf_Shdr 
*sechdr, Elf_Rela *r)
 #define R_LARCH_SUB32  55
 #endif
 
-static void section_rela(const char *modname, struct elf_info *elf,
+static void section_rela(struct module *mod, struct elf_info *elf,
 Elf_Shdr *sechdr)
 {
Elf_Rela *rela;
@@ -1452,12 +1452,12 @@ static void section_rela(const char *modname, struct 
elf_info *elf,
break;
}
 
-   check_section_mismatch(modname, elf, elf->symtab_start + r_sym,
+   check_section_mismatch(mod, elf, elf->symtab_start + r_sym,
   fsecndx, fromsec, r.r_offset, 
r.r_addend);
}
 }
 
-static void section_rel(const char *modname, struct elf_info *elf,
+static void section_rel(struct module *mod, struct elf_info *elf,
Elf_Shdr *sechdr)
 {
Elf_Rel *rel;
@@ -1507,7 +1507,7 @@ static void section_rel(const char *modname, struct 
elf_info *elf,
fatal("Please add code to calculate addend for this 
architecture\n");
}
 
-   check_section_mismatch(modname, elf, elf->symtab_start + r_sym,
+   check_section_mismatch(mod, elf, elf->symtab_start + r_sym,
   fsecndx, fromsec, r.r_offset, 
r.r_addend);
}
 }
@@ -1524,19 +1524,19 @@ static void section_rel(const char *modname, struct 
elf_info *elf,
  * to find all references to a section that reference a section that will
  * be discarded and warns about it.
  **/
-static void check_sec_ref(const char *modname, struct elf_info *elf)
+static void check_sec_ref(struct module *mod, struct elf_info *elf)
 {
int i;
Elf_Shdr *sechdrs = elf->sechdrs;
 
/* Walk through all sections */
for (i = 0; i < elf->num_sections; i++) {
-   check_section(modname, elf, >sechdrs[i]);
+   check_section(mod->name, elf, >sechdrs[i]);
/* We want to process only relocation sections and not .init */
if (sechdrs[i].sh_type == SHT_RELA)
-   section_rela(modname, elf, >sechdrs[i]);
+   section_rela(mod, elf, >sechdrs[i]);
else if (sechdrs[i].sh_type == SHT_REL)
-   section_rel(modname, elf, >sechdrs[i]);
+   section_rel(mod, elf, >sechdrs[i]);
}
 }
 
@@ -1707,7 +1707,7 @@ static void read_symbols(const char *modname)
 sym_get_data(, sym));
}
 
-   check_sec_ref(modname, );
+   check_sec_ref(mod, );
 
if (!mod->is_vmlinux) {
version = get_modinfo(, "version");
-- 
2.39.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH v9 06/11] modpost: squash sym_update_namespace() into sym_add_exported()

2023-06-11 Thread Masahiro Yamada
Pass a set of the name, license, and namespace to sym_add_exported().

sym_update_namespace() is unneeded.

Signed-off-by: Masahiro Yamada 
Reviewed-by: Nick Desaulniers 
---

 scripts/mod/modpost.c | 27 ---
 1 file changed, 4 insertions(+), 23 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 10da82ad5874..79ad0a346a5c 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -355,26 +355,8 @@ static const char *sec_name(const struct elf_info *info, 
unsigned int secindex)
 
 #define strstarts(str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0)
 
-static void sym_update_namespace(const char *symname, const char *namespace)
-{
-   struct symbol *s = find_symbol(symname);
-
-   /*
-* That symbol should have been created earlier and thus this is
-* actually an assertion.
-*/
-   if (!s) {
-   error("Could not update namespace(%s) for symbol %s\n",
- namespace, symname);
-   return;
-   }
-
-   free(s->namespace);
-   s->namespace = namespace[0] ? NOFAIL(strdup(namespace)) : NULL;
-}
-
 static struct symbol *sym_add_exported(const char *name, struct module *mod,
-  bool gpl_only)
+  bool gpl_only, const char *namespace)
 {
struct symbol *s = find_symbol(name);
 
@@ -387,6 +369,7 @@ static struct symbol *sym_add_exported(const char *name, 
struct module *mod,
s = alloc_symbol(name);
s->module = mod;
s->is_gpl_only = gpl_only;
+   s->namespace = namespace[0] ? NOFAIL(strdup(namespace)) : NULL;
list_add_tail(>list, >exported_symbols);
hash_add_symbol(s);
 
@@ -1236,8 +1219,7 @@ static void check_export_symbol(struct module *mod, 
struct elf_info *elf,
}
 
data += strlen(data) + 1;   /* namespace */
-   s = sym_add_exported(name, mod, is_gpl);
-   sym_update_namespace(name, data);
+   s = sym_add_exported(name, mod, is_gpl, data);
 
/*
 * We need to be aware whether we are exporting a function or
@@ -2180,9 +2162,8 @@ static void read_dump(const char *fname)
mod = new_module(modname, strlen(modname));
mod->from_dump = true;
}
-   s = sym_add_exported(symname, mod, gpl_only);
+   s = sym_add_exported(symname, mod, gpl_only, namespace);
sym_set_crc(s, crc);
-   sym_update_namespace(symname, namespace);
}
free(buf);
return;
-- 
2.39.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH v9 04/11] ia64,export.h: replace EXPORT_DATA_SYMBOL* with EXPORT_SYMBOL*

2023-06-11 Thread Masahiro Yamada
With the previous refactoring, you can always use EXPORT_SYMBOL*.

Replace two instances in ia64, then remove EXPORT_DATA_SYMBOL*.

Signed-off-by: Masahiro Yamada 
Reviewed-by: Nick Desaulniers 
---


 arch/ia64/kernel/head.S  | 2 +-
 arch/ia64/kernel/ivt.S   | 2 +-
 include/asm-generic/export.h | 3 ---
 3 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/ia64/kernel/head.S b/arch/ia64/kernel/head.S
index f22469f1c1fc..c096500590e9 100644
--- a/arch/ia64/kernel/head.S
+++ b/arch/ia64/kernel/head.S
@@ -170,7 +170,7 @@ RestRR: 
\
__PAGE_ALIGNED_DATA
 
.global empty_zero_page
-EXPORT_DATA_SYMBOL_GPL(empty_zero_page)
+EXPORT_SYMBOL_GPL(empty_zero_page)
 empty_zero_page:
.skip PAGE_SIZE
 
diff --git a/arch/ia64/kernel/ivt.S b/arch/ia64/kernel/ivt.S
index d6d4229b28db..7a418e324d30 100644
--- a/arch/ia64/kernel/ivt.S
+++ b/arch/ia64/kernel/ivt.S
@@ -87,7 +87,7 @@
 
.align 32768// align on 32KB boundary
.global ia64_ivt
-   EXPORT_DATA_SYMBOL(ia64_ivt)
+   EXPORT_SYMBOL(ia64_ivt)
 ia64_ivt:
 
/
 // 0x Entry 0 (size 64 bundles) VHPT Translation (8,20,47)
diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h
index 0ae9f38a904c..570cd4da7210 100644
--- a/include/asm-generic/export.h
+++ b/include/asm-generic/export.h
@@ -8,7 +8,4 @@
  */
 #include 
 
-#define EXPORT_DATA_SYMBOL(name)   EXPORT_SYMBOL(name)
-#define EXPORT_DATA_SYMBOL_GPL(name)   EXPORT_SYMBOL_GPL(name)
-
 #endif
-- 
2.39.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH v9 03/11] kbuild: generate KSYMTAB entries by modpost

2023-06-11 Thread Masahiro Yamada
Commit 7b4537199a4a ("kbuild: link symbol CRCs at final link, removing
CONFIG_MODULE_REL_CRCS") made modpost output CRCs in the same way
whether the EXPORT_SYMBOL() is placed in *.c or *.S.

For further cleanups, this commit applies a similar approach to the
entire data structure of EXPORT_SYMBOL().

The EXPORT_SYMBOL() compilation is split into two stages.

When a source file is compiled, EXPORT_SYMBOL() is converted into a
dummy symbol in the .export_symbol section.

For example,

EXPORT_SYMBOL(foo);
EXPORT_SYMBOL_NS_GPL(bar, BAR_NAMESPACE);

will be encoded into the following assembly code:

.section ".export_symbol","a"
__export_symbol_foo:
.asciz ""
.asciz ""
.balign 8
.quad foo
.previous

.section ".export_symbol","a"
__export_symbol_bar:
.asciz "GPL"
.asciz "BAR_NAMESPACE"
.balign 8
.quad bar
.previous

They are mere markers to tell modpost the name, license, and namespace
of the symbols. They will be dropped from the final vmlinux and modules
because the *(.export_symbol) will go into /DISCARD/ in the linker script.

Then, modpost extracts all the information about EXPORT_SYMBOL() from the
.export_symbol section, and generates the final C code:

KSYMTAB_FUNC(foo, "", "");
KSYMTAB_FUNC(bar, "_gpl", "BAR_NAMESPACE");

KSYMTAB_FUNC() (or KSYMTAB_DATA() if it is data) is expanded to struct
kernel_symbol that will be linked to the vmlinux or a module.

With this change, EXPORT_SYMBOL() works in the same way for *.c and *.S
files, providing the following benefits.

[1] Deprecate EXPORT_DATA_SYMBOL()

In the old days, EXPORT_SYMBOL() was only available in C files. To export
a symbol in *.S, EXPORT_SYMBOL() was placed in a separate *.c file.
arch/arm/kernel/armksyms.c is one example written in the classic manner.

Commit 22823ab419d8 ("EXPORT_SYMBOL() for asm") removed this limitation.
Since then, EXPORT_SYMBOL() can be placed close to the symbol definition
in *.S files. It was a nice improvement.

However, as that commit mentioned, you need to use EXPORT_DATA_SYMBOL()
for data objects on some architectures.

In the new approach, modpost checks symbol's type (STT_FUNC or not),
and outputs KSYMTAB_FUNC() or KSYMTAB_DATA() accordingly.

There are only two users of EXPORT_DATA_SYMBOL:

  EXPORT_DATA_SYMBOL_GPL(empty_zero_page)(arch/ia64/kernel/head.S)
  EXPORT_DATA_SYMBOL(ia64_ivt)   (arch/ia64/kernel/ivt.S)

They are transformed as follows and output into .vmlinux.export.c

  KSYMTAB_DATA(empty_zero_page, "_gpl", "");
  KSYMTAB_DATA(ia64_ivt, "", "");

The other EXPORT_SYMBOL users in ia64 assembly are output as
KSYMTAB_FUNC().

EXPORT_DATA_SYMBOL() is now deprecated.

[2] merge  and 

There are two similar header implementations:

  include/linux/export.hfor .c files
  include/asm-generic/export.h  for .S files

Ideally, the functionality should be consistent between them, but they
tend to diverge.

Commit 8651ec01daed ("module: add support for symbol namespaces.") did
not support the namespace for *.S files.

This commit shifts the essential implementation part to C, which supports
EXPORT_SYMBOL_NS() for *.S files.

 and  will remain as a wrapper of
 for a while.

They will be removed after #include  directives are all
replaced with #include .

[3] Implement CONFIG_TRIM_UNUSED_KSYMS in one-pass algorithm (by a later commit)

When CONFIG_TRIM_UNUSED_KSYMS is enabled, Kbuild recursively traverses
the directory tree to determine which EXPORT_SYMBOL to trim. If an
EXPORT_SYMBOL turns out to be unused by anyone, Kbuild begins the
second traverse, where some source files are recompiled with their
EXPORT_SYMBOL() tuned into a no-op.

We can do this better now; modpost can selectively emit KSYMTAB entries
that are really used by modules.

Signed-off-by: Masahiro Yamada 
Reviewed-by: Nick Desaulniers 
---

Changes in v9:
  - Fix build error for ARC when CONFIG_DEBUG_INFO is enabled.
Use ASM_NL because hard-coding instruction separator does not work
  - Change the marker format to encode the license as a string

Changes in v8:
  - Fix the definition of EXPORT_SYMBOL() to v7.
It seems to cause a regression for xtensa. (reported by 0day bot)

Changes in v7:
  - Fix sparse warning reported by 0day bot
https://lore.kernel.org/linux-kbuild/202305280830.rj5ltc9m-...@intel.com/

Changes in v6:
  - Fix build error on UML

Changes in v5:
  - Fix build error on ARM

Changes in v4:
  - Version 3 did not work if a same name symbol exists in a different 
compilation unit
Fix it.

Changes in v3:
  - Move struct kernel_symbol to kernel/module/internal.h

Changes in v2:
  - Use KSYMTAB_FUNC and KSYMTAB_DATA for functions and data, respectively
This distinction is

[PATCH v9 01/11] ARC: define ASM_NL and __ALIGN(_STR) outside #ifdef __ASSEMBLY__ guard

2023-06-11 Thread Masahiro Yamada
ASM_NL is useful not only in *.S files but also in .c files for using
inline assembler in C code.

On ARC, however, ASM_NL is evaluated inconsistently. It is expanded to
a backquote (`) in *.S files, but a semicolon (;) in *.c files because
arch/arc/include/asm/linkage.h defines it inside #ifdef __ASSEMBLY__,
so the definition for C code falls back to the default value defined in
include/linux/linkage.h.

If ASM_NL is used in inline assembler in .c files, it will result in
wrong assembly code because a semicolon is not an instruction separator,
but the start of a comment for ARC.

Move ASM_NL (also __ALIGN and __ALIGN_STR) out of the #ifdef.

Fixes: 9df62f054406 ("arch: use ASM_NL instead of ';' for assembler new line 
character in the macro")
Fixes: 8d92e992a785 ("ARC: define __ALIGN_STR and __ALIGN symbols for ARC")
Signed-off-by: Masahiro Yamada 
---

Changes in v9:
  - New patch

 arch/arc/include/asm/linkage.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arc/include/asm/linkage.h b/arch/arc/include/asm/linkage.h
index c9434ff3aa4c..8a3fb71e9cfa 100644
--- a/arch/arc/include/asm/linkage.h
+++ b/arch/arc/include/asm/linkage.h
@@ -8,6 +8,10 @@
 
 #include 
 
+#define ASM_NL  `  /* use '`' to mark new line in macro */
+#define __ALIGN.align 4
+#define __ALIGN_STR__stringify(__ALIGN)
+
 #ifdef __ASSEMBLY__
 
 .macro ST2 e, o, off
@@ -28,10 +32,6 @@
 #endif
 .endm
 
-#define ASM_NL  `  /* use '`' to mark new line in macro */
-#define __ALIGN.align 4
-#define __ALIGN_STR__stringify(__ALIGN)
-
 /* annotation for data we want in DCCM - if enabled in .config */
 .macro ARCFP_DATA nm
 #ifdef CONFIG_ARC_HAS_DCCM
-- 
2.39.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH v9 00/11] Unify and , remove EXPORT_DATA_SYMBOL(), faster TRIM_UNUSED_KSYMS

2023-06-11 Thread Masahiro Yamada


My goals:

 - Refactors EXPORT_SYMBOL,  and .
   You can still put EXPORT_SYMBOL() in *.S file, very close to the definition,
   but you do not need to care about whether it is a function or a data.
   This removes EXPORT_DATA_SYMBOL().

 - Re-implement TRIM_UNUSED_KSYMS in one-pass.
   This makes the building faster.

 - Move the static EXPORT_SYMBOL check to modpost.
   This also makes the building faster.

This patch set is applicable to linux-next 20230609.

Previous version
v8: 
https://lore.kernel.org/linux-kbuild/cak7lnarbvqdwgspowgju87aknvzvnwjl-bbj3xj-2w+fpid...@mail.gmail.com/T/#t
v7: 
https://lore.kernel.org/linux-kbuild/20230608142428.256985-1-masahi...@kernel.org/T/#mbaddcee18c9a8cf0a9b1f3fc562d09526cb69540
v6: 
https://lore.kernel.org/linux-kbuild/CAK7LNARjzGnj+sYX=_5yQ+8qoOQ2KB5N-_Ye53Ru3=xicez...@mail.gmail.com/T/#t
v5: 
https://lore.kernel.org/linux-kbuild/CAK7LNARBiOywrMLbR=9n35sk19u0qm3xcpy7d1wqv-eyb4w...@mail.gmail.com/T/#t
v4: 
https://lore.kernel.org/linux-kbuild/CAK7LNASDzy9RERN6+q6WgR4ROYZQue=sbqgbcoyuvepbyht...@mail.gmail.com/T/#t
v3: https://lore.kernel.org/all/20220928063947.299333-1-masahi...@kernel.org/



Masahiro Yamada (11):
  ARC: define ASM_NL and __ALIGN(_STR) outside #ifdef __ASSEMBLY__ guard
  modpost: pass struct module pointer to check_section_mismatch()
  kbuild: generate KSYMTAB entries by modpost
  ia64,export.h: replace EXPORT_DATA_SYMBOL* with EXPORT_SYMBOL*
  modpost: check static EXPORT_SYMBOL* by modpost again
  modpost: squash sym_update_namespace() into sym_add_exported()
  modpost: use null string instead of NULL pointer for default namespace
  kbuild: implement CONFIG_TRIM_UNUSED_KSYMS without recursion
  modpost: merge two similar section mismatch warnings
  modpost: show offset from symbol for section mismatch warnings
  linux/export.h: rename 'sec' argument to 'license'

 .gitignore|   2 -
 Makefile  |  22 +--
 arch/arc/include/asm/linkage.h|   8 +-
 arch/ia64/include/asm/Kbuild  |   1 +
 arch/ia64/include/asm/export.h|   3 -
 arch/ia64/kernel/head.S   |   2 +-
 arch/ia64/kernel/ivt.S|   2 +-
 include/asm-generic/export.h  |  83 +-
 include/asm-generic/vmlinux.lds.h |   1 +
 include/linux/export-internal.h   |  49 ++
 include/linux/export.h| 128 
 include/linux/pm.h|  10 +-
 kernel/module/internal.h  |  12 ++
 scripts/Makefile.build|  27 +---
 scripts/Makefile.modpost  |   7 +
 scripts/adjust_autoksyms.sh   |  73 -
 scripts/basic/fixdep.c|   3 +-
 scripts/check-local-export|  70 -
 scripts/gen_autoksyms.sh  |  62 
 scripts/gen_ksymdeps.sh   |  30 
 scripts/mod/modpost.c | 242 +++---
 scripts/mod/modpost.h |   1 +
 scripts/remove-stale-files|   4 +
 23 files changed, 283 insertions(+), 559 deletions(-)
 delete mode 100644 arch/ia64/include/asm/export.h
 delete mode 100755 scripts/adjust_autoksyms.sh
 delete mode 100755 scripts/check-local-export
 delete mode 100755 scripts/gen_autoksyms.sh
 delete mode 100755 scripts/gen_ksymdeps.sh

-- 
2.39.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] kbuild: drop support for CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3

2022-07-10 Thread Masahiro Yamada
On Wed, Jun 29, 2022 at 7:48 PM Miko Larsson  wrote:
>
> On Tuesday, 28 June 2022 23:04:07 CEST Nick Desaulniers wrote:
> > The difference in most compilers between `-O3` and `-O2` is mostly down
> > to whether loops with statically determinable trip counts are fully
> > unrolled vs unrolled to a multiple of SIMD width.
> >
> > This patch is effectively a revert of
> > commit 15f5db60a137 ("kbuild,arc: add
> > CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 for ARC") without re-adding
> > ARCH_CFLAGS
> >
> > Ever since
> > commit cfdbc2e16e65 ("ARC: Build system: Makefiles, Kconfig, Linker
> > script")
> > ARC has been built with -O3, though the reason for doing so was not
> > specified in inline comments or the commit message. This commit does not
> > re-add -O3 to arch/arc/Makefile.
> >
> > Folks looking to experiment with `-O3` (or any compiler flag for that
> > matter) may pass them along to the command line invocation of make:
> >
> > $ make KCFLAGS=-O3
> >
> > Code that looks to re-add an explicit Kconfig option for `-O3` should
> > provide:
> > 1. A rigorous and reproducible performance profile of a reasonable
> >userspace workload that demonstrates a hot loop in the kernel that
> >would benefit from `-O3` over `-O2`.
> > 2. Disassembly of said loop body before and after.
> > 3. Provides stats on terms of increase in file size.
> >
>
> Might be worth cleaning up the rest of the kernel of instances of -O3,
> too. -O3 used to build lz4 and mips vdso, for instance. Might be a bit
> of a digression, though


This patch focuses on the removal of CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3,
so I think it is OK as-is.

The rest of cleanups, if needed,
should be submitted separately.




>
> --
> ~miko
>
>


-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] kbuild: drop support for CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3

2022-07-10 Thread Masahiro Yamada
gs/haps_hs_smp_defconfig 
> b/arch/arc/configs/haps_hs_smp_defconfig
> index bc927221afc0..8d82cdb7f86a 100644
> --- a/arch/arc/configs/haps_hs_smp_defconfig
> +++ b/arch/arc/configs/haps_hs_smp_defconfig
> @@ -11,7 +11,6 @@ CONFIG_NAMESPACES=y
>  # CONFIG_UTS_NS is not set
>  # CONFIG_PID_NS is not set
>  CONFIG_BLK_DEV_INITRD=y
> -CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
>  CONFIG_EMBEDDED=y
>  CONFIG_PERF_EVENTS=y
>  # CONFIG_VM_EVENT_COUNTERS is not set
> diff --git a/arch/arc/configs/hsdk_defconfig b/arch/arc/configs/hsdk_defconfig
> index aa75a575..f856b03e0fb5 100644
> --- a/arch/arc/configs/hsdk_defconfig
> +++ b/arch/arc/configs/hsdk_defconfig
> @@ -9,7 +9,6 @@ CONFIG_NAMESPACES=y
>  # CONFIG_PID_NS is not set
>  CONFIG_BLK_DEV_INITRD=y
>  CONFIG_BLK_DEV_RAM=y
> -CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
>  CONFIG_EMBEDDED=y
>  CONFIG_PERF_EVENTS=y
>  # CONFIG_VM_EVENT_COUNTERS is not set
> diff --git a/arch/arc/configs/nsim_700_defconfig 
> b/arch/arc/configs/nsim_700_defconfig
> index 326f6cde7826..a1ce12bf5b16 100644
> --- a/arch/arc/configs/nsim_700_defconfig
> +++ b/arch/arc/configs/nsim_700_defconfig
> @@ -11,7 +11,6 @@ CONFIG_NAMESPACES=y
>  # CONFIG_UTS_NS is not set
>  # CONFIG_PID_NS is not set
>  CONFIG_BLK_DEV_INITRD=y
> -CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
>  CONFIG_KALLSYMS_ALL=y
>  CONFIG_EMBEDDED=y
>  CONFIG_PERF_EVENTS=y
> diff --git a/arch/arc/configs/nsimosci_defconfig 
> b/arch/arc/configs/nsimosci_defconfig
> index bf39a0091679..ca10f4a2c823 100644
> --- a/arch/arc/configs/nsimosci_defconfig
> +++ b/arch/arc/configs/nsimosci_defconfig
> @@ -10,7 +10,6 @@ CONFIG_NAMESPACES=y
>  # CONFIG_UTS_NS is not set
>  # CONFIG_PID_NS is not set
>  CONFIG_BLK_DEV_INITRD=y
> -CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
>  CONFIG_KALLSYMS_ALL=y
>  CONFIG_EMBEDDED=y
>  CONFIG_PERF_EVENTS=y
> diff --git a/arch/arc/configs/nsimosci_hs_defconfig 
> b/arch/arc/configs/nsimosci_hs_defconfig
> index 7121bd71c543..31b6ec3683c6 100644
> --- a/arch/arc/configs/nsimosci_hs_defconfig
> +++ b/arch/arc/configs/nsimosci_hs_defconfig
> @@ -10,7 +10,6 @@ CONFIG_NAMESPACES=y
>  # CONFIG_UTS_NS is not set
>  # CONFIG_PID_NS is not set
>  CONFIG_BLK_DEV_INITRD=y
> -CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
>  CONFIG_KALLSYMS_ALL=y
>  CONFIG_EMBEDDED=y
>  CONFIG_PERF_EVENTS=y
> diff --git a/arch/arc/configs/nsimosci_hs_smp_defconfig 
> b/arch/arc/configs/nsimosci_hs_smp_defconfig
> index f9863b294a70..41a0037f48a5 100644
> --- a/arch/arc/configs/nsimosci_hs_smp_defconfig
> +++ b/arch/arc/configs/nsimosci_hs_smp_defconfig
> @@ -8,7 +8,6 @@ CONFIG_IKCONFIG_PROC=y
>  # CONFIG_UTS_NS is not set
>  # CONFIG_PID_NS is not set
>  CONFIG_BLK_DEV_INITRD=y
> -CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
>  CONFIG_PERF_EVENTS=y
>  # CONFIG_COMPAT_BRK is not set
>  CONFIG_KPROBES=y
> diff --git a/arch/arc/configs/tb10x_defconfig 
> b/arch/arc/configs/tb10x_defconfig
> index a12656ec0072..d93b65008d4a 100644
> --- a/arch/arc/configs/tb10x_defconfig
> +++ b/arch/arc/configs/tb10x_defconfig
> @@ -14,7 +14,6 @@ CONFIG_INITRAMFS_SOURCE="../tb10x-rootfs.cpio"
>  CONFIG_INITRAMFS_ROOT_UID=2100
>  CONFIG_INITRAMFS_ROOT_GID=501
>  # CONFIG_RD_GZIP is not set
> -CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
>  CONFIG_KALLSYMS_ALL=y
>  # CONFIG_AIO is not set
>  CONFIG_EMBEDDED=y
> diff --git a/arch/arc/configs/vdk_hs38_defconfig 
> b/arch/arc/configs/vdk_hs38_defconfig
> index d7c858df520c..0c3b21416819 100644
> --- a/arch/arc/configs/vdk_hs38_defconfig
> +++ b/arch/arc/configs/vdk_hs38_defconfig
> @@ -4,7 +4,6 @@ CONFIG_HIGH_RES_TIMERS=y
>  CONFIG_IKCONFIG=y
>  CONFIG_IKCONFIG_PROC=y
>  CONFIG_BLK_DEV_INITRD=y
> -CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
>  CONFIG_EMBEDDED=y
>  CONFIG_PERF_EVENTS=y
>  # CONFIG_VM_EVENT_COUNTERS is not set
> diff --git a/arch/arc/configs/vdk_hs38_smp_defconfig 
> b/arch/arc/configs/vdk_hs38_smp_defconfig
> index 015c1d43889e..f9ad9d3ee702 100644
> --- a/arch/arc/configs/vdk_hs38_smp_defconfig
> +++ b/arch/arc/configs/vdk_hs38_smp_defconfig
> @@ -4,7 +4,6 @@ CONFIG_HIGH_RES_TIMERS=y
>  CONFIG_IKCONFIG=y
>  CONFIG_IKCONFIG_PROC=y
>  CONFIG_BLK_DEV_INITRD=y
> -CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
>  CONFIG_EMBEDDED=y
>  CONFIG_PERF_EVENTS=y
>  # CONFIG_VM_EVENT_COUNTERS is not set
> diff --git a/init/Kconfig b/init/Kconfig
> index c7900e8975f1..1b4d8acc3def 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -1401,13 +1401,6 @@ config CC_OPTIMIZE_FOR_PERFORMANCE
>   with the "-O2" compiler flag for best performance and most
>   helpful compile-time warnings.
>
> -config CC_OPTIMIZE_FOR_PERFORMANCE_O3
> -   bool "Optimize more for performance (-O3)"
> -   depends on ARC
> -   help
> - Choosing this option will pass "-O3" to your compiler to optimize
> - the kernel yet more for performance.
> -
>  config CC_OPTIMIZE_FOR_SIZE
> bool "Optimize for size (-Os)"
> help
> --
> 2.37.0.rc0.161.g10f37bed90-goog
>


-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 2/2] kbuild: use more subdir- for visiting subdirectories while cleaning

2021-10-13 Thread Masahiro Yamada
Documentation/kbuild/makefiles.rst suggests to use "archclean" for
cleaning arch/$(SRCARCH)/boot/.

Since commit d92cc4d51643 ("kbuild: require all architectures to have
arch/$(SRCARCH)/Kbuild"), we can use the "subdir- += boot" trick for
all architectures. This can take advantage of the parallel option (-j)
for "make clean".

I also cleaned up the comments. The "archdep" target does not exist.

Signed-off-by: Masahiro Yamada 
---

 Documentation/kbuild/makefiles.rst | 17 ++---
 arch/alpha/Kbuild  |  3 +++
 arch/alpha/Makefile|  3 ---
 arch/arc/Kbuild|  3 +++
 arch/arc/Makefile  |  3 ---
 arch/arm/Kbuild|  3 +++
 arch/arm/Makefile  |  4 
 arch/arm64/Kbuild  |  3 +++
 arch/arm64/Makefile|  7 ---
 arch/arm64/kernel/Makefile |  3 +++
 arch/csky/Kbuild   |  3 +++
 arch/csky/Makefile |  3 ---
 arch/h8300/Kbuild  |  3 +++
 arch/h8300/Makefile|  3 ---
 arch/ia64/Makefile |  2 --
 arch/m68k/Makefile |  4 +---
 arch/microblaze/Kbuild |  3 +++
 arch/microblaze/Makefile   |  3 ---
 arch/mips/Kbuild   |  3 +++
 arch/mips/Makefile |  8 +---
 arch/mips/boot/Makefile|  3 +++
 arch/nds32/Kbuild  |  3 +++
 arch/nds32/Makefile|  3 ---
 arch/nios2/Kbuild  |  3 +++
 arch/nios2/Makefile|  6 +-
 arch/openrisc/Kbuild   |  3 +++
 arch/openrisc/Makefile |  7 +--
 arch/parisc/Kbuild |  3 +++
 arch/parisc/Makefile   |  7 +--
 arch/powerpc/Kbuild|  3 +++
 arch/powerpc/Makefile  |  7 +--
 arch/riscv/Kbuild  |  3 +++
 arch/riscv/Makefile|  7 +--
 arch/s390/Kbuild   |  3 +++
 arch/s390/Makefile |  8 +---
 arch/sh/Kbuild |  3 +++
 arch/sh/Makefile   |  3 ---
 arch/sparc/Kbuild  |  3 +++
 arch/sparc/Makefile|  3 ---
 arch/x86/Kbuild|  3 +++
 arch/x86/Makefile  |  2 --
 arch/xtensa/Makefile   |  4 +---
 42 files changed, 71 insertions(+), 103 deletions(-)

diff --git a/Documentation/kbuild/makefiles.rst 
b/Documentation/kbuild/makefiles.rst
index db3af0b45baf..b008b90b92c9 100644
--- a/Documentation/kbuild/makefiles.rst
+++ b/Documentation/kbuild/makefiles.rst
@@ -1050,22 +1050,9 @@ is not sufficient this sometimes needs to be explicit.
 The above assignment instructs kbuild to descend down in the
 directory compressed/ when "make clean" is executed.
 
-To support the clean infrastructure in the Makefiles that build the
-final bootimage there is an optional target named archclean:
-
-   Example::
-
-   #arch/x86/Makefile
-   archclean:
-   $(Q)$(MAKE) $(clean)=arch/x86/boot
-
-When "make clean" is executed, make will descend down in arch/x86/boot,
-and clean as usual. The Makefile located in arch/x86/boot/ may use
-the subdir- trick to descend further down.
-
 Note 1: arch/$(SRCARCH)/Makefile cannot use "subdir-", because that file is
-included in the top level makefile, and the kbuild infrastructure
-is not operational at that point.
+included in the top level makefile. Instead, arch/$(SRCARCH)/Kbuild can use
+"subdir-".
 
 Note 2: All directories listed in core-y, libs-y, drivers-y and net-y will
 be visited during "make clean".
diff --git a/arch/alpha/Kbuild b/arch/alpha/Kbuild
index c2302017403a..345d79df24bb 100644
--- a/arch/alpha/Kbuild
+++ b/arch/alpha/Kbuild
@@ -1,3 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 obj-y  += kernel/ mm/
 obj-$(CONFIG_MATHEMU)  += math-emu/
+
+# for cleaning
+subdir- += boot
diff --git a/arch/alpha/Makefile b/arch/alpha/Makefile
index 52529ee42dac..881cb913e23a 100644
--- a/arch/alpha/Makefile
+++ b/arch/alpha/Makefile
@@ -55,9 +55,6 @@ $(boot)/vmlinux.gz: vmlinux
 bootimage bootpfile bootpzfile: vmlinux
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
 
-archclean:
-   $(Q)$(MAKE) $(clean)=$(boot)
-
 archheaders:
$(Q)$(MAKE) $(build)=arch/alpha/kernel/syscalls all
 
diff --git a/arch/arc/Kbuild b/arch/arc/Kbuild
index 699d8cae9b1f..b94102fff68b 100644
--- a/arch/arc/Kbuild
+++ b/arch/arc/Kbuild
@@ -1,3 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-y += kernel/
 obj-y += mm/
+
+# for cleaning
+subdir- += boot
diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index 08995f6c6441..efc54f3e35e0 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -112,6 +112,3 @@ uImage: $(uimage-default-y)
@$(kecho) '  Image $(boot)/uImage is ready'
 
 CLEAN_FILES

Re: [PATCH 4/7] arc: replace cc-option-yn uses with cc-option

2021-08-24 Thread Masahiro Yamada
On Wed, Aug 18, 2021 at 10:40 AM Nathan Chancellor  wrote:
>
>
>
> On 8/17/2021 11:07 AM, 'Nick Desaulniers' via Clang Built Linux wrote:
> > On Mon, Aug 16, 2021 at 7:05 PM Nathan Chancellor  wrote:
> >>
> >> On 8/16/2021 5:21 PM, 'Nick Desaulniers' via Clang Built Linux wrote:
> >>> cc-option-yn can be replaced with cc-option. ie.
> >>> Checking for support:
> >>> ifeq ($(call cc-option-yn,$(FLAG)),y)
> >>> becomes:
> >>> ifneq ($(call cc-option,$(FLAG)),)
> >>>
> >>> Checking for lack of support:
> >>> ifeq ($(call cc-option-yn,$(FLAG)),n)
> >>> becomes:
> >>> ifeq ($(call cc-option,$(FLAG)),)
> >>>
> >>> This allows us to pursue removing cc-option-yn.
> >>>
> >>> Cc: Vineet Gupta 
> >>> Cc: linux-snps-arc@lists.infradead.org
> >>> Signed-off-by: Nick Desaulniers 
> >>> ---
> >>>arch/arc/Makefile | 3 +--
> >>>1 file changed, 1 insertion(+), 2 deletions(-)
> >>>
> >>> diff --git a/arch/arc/Makefile b/arch/arc/Makefile
> >>> index c0d87ac2e221..8782a03f24a8 100644
> >>> --- a/arch/arc/Makefile
> >>> +++ b/arch/arc/Makefile
> >>> @@ -18,8 +18,7 @@ ifeq ($(CONFIG_ARC_TUNE_MCPU),"")
> >>>cflags-y+= $(tune-mcpu-def-y)
> >>>else
> >>>tune-mcpu   := $(shell echo 
> >>> $(CONFIG_ARC_TUNE_MCPU))
> >>> -tune-mcpu-ok := $(call cc-option-yn, 
> >>> $(tune-mcpu))
> >>> -ifeq ($(tune-mcpu-ok),y)
> >>> +ifneq ($(call cc-option,$(tune-mcpu)),)
> >>>cflags-y+= $(tune-mcpu)
> >>
> >> Any reason not to just turn this into
> >>
> >> cflags-y += $(call cc-option,$(tune-mcpu))
> >>
> >> ?
> >
> > Yes, you'll need to pull up the source; the diff doesn't provide
> > enough context. tune-mcpu is used in the body of the else branch
> > hinted at by the diff. PTAL
>
> Ah, fair enough. The warning is a little unconventional but oh well :)
>
> Reviewed-by: Nathan Chancellor 
>
> >>
> >> If $(tune-mcpu) is empty or invalid, nothing will be added to cflags-y.
> >>
> >>>else
> >>># The flag provided by 'CONFIG_ARC_TUNE_MCPU' option isn't known by 
> >>> this compiler
> >>>
> >
> >
> >

Applied to linux-kbuild.


-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 2/3] trace: refactor TRACE_IRQFLAGS_SUPPORT in Kconfig

2021-07-30 Thread Masahiro Yamada
Make architectures select TRACE_IRQFLAGS_SUPPORT instead of
having many defines.

Signed-off-by: Masahiro Yamada 
---

 arch/Kconfig  | 3 +++
 arch/arc/Kconfig  | 4 +---
 arch/arm/Kconfig  | 5 +
 arch/arm64/Kconfig| 4 +---
 arch/csky/Kconfig | 4 +---
 arch/hexagon/Kconfig  | 4 +---
 arch/microblaze/Kconfig   | 1 +
 arch/microblaze/Kconfig.debug | 5 -
 arch/mips/Kconfig | 1 +
 arch/mips/Kconfig.debug   | 4 
 arch/nds32/Kconfig| 4 +---
 arch/nios2/Kconfig| 3 ---
 arch/openrisc/Kconfig | 4 +---
 arch/parisc/Kconfig   | 1 +
 arch/parisc/Kconfig.debug | 3 ---
 arch/powerpc/Kconfig  | 5 +
 arch/riscv/Kconfig| 4 +---
 arch/s390/Kconfig | 1 +
 arch/s390/Kconfig.debug   | 3 ---
 arch/sh/Kconfig   | 1 +
 arch/sh/Kconfig.debug | 3 ---
 arch/sparc/Kconfig| 1 +
 arch/sparc/Kconfig.debug  | 4 
 arch/um/Kconfig   | 5 +
 arch/x86/Kconfig  | 1 +
 arch/x86/Kconfig.debug| 3 ---
 arch/xtensa/Kconfig   | 4 +---
 27 files changed, 21 insertions(+), 64 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 129df498a8e1..9471a0feecaf 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -197,6 +197,9 @@ config HAVE_FUNCTION_ERROR_INJECTION
 config HAVE_NMI
bool
 
+config TRACE_IRQFLAGS_SUPPORT
+   bool
+
 #
 # An arch should select this if it provides all these things:
 #
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index d8f51eb8963b..0c81df3a5c7a 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -49,9 +49,7 @@ config ARC
select PERF_USE_VMALLOC if ARC_CACHE_VIPT_ALIASING
select HAVE_ARCH_JUMP_LABEL if ISA_ARCV2 && !CPU_ENDIAN_BE32
select SET_FS
-
-config TRACE_IRQFLAGS_SUPPORT
-   def_bool y
+   select TRACE_IRQFLAGS_SUPPORT
 
 config LOCKDEP_SUPPORT
def_bool y
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 82f908fa5676..3564647283e1 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -128,6 +128,7 @@ config ARM
select RTC_LIB
select SET_FS
select SYS_SUPPORTS_APM_EMULATION
+   select TRACE_IRQFLAGS_SUPPORT if !CPU_V7M
# Above selects are sorted alphabetically; please add new ones
# according to that.  Thanks.
help
@@ -191,10 +192,6 @@ config LOCKDEP_SUPPORT
bool
default y
 
-config TRACE_IRQFLAGS_SUPPORT
-   bool
-   default !CPU_V7M
-
 config ARCH_HAS_ILOG2_U32
bool
 
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index b5b13a932561..67b04ae5d010 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -221,6 +221,7 @@ config ARM64
select SYSCTL_EXCEPTION_TRACE
select THREAD_INFO_IN_TASK
select HAVE_ARCH_USERFAULTFD_MINOR if USERFAULTFD
+   select TRACE_IRQFLAGS_SUPPORT
help
  ARM 64-bit (AArch64) Linux support.
 
@@ -288,9 +289,6 @@ config ILLEGAL_POINTER_VALUE
 config LOCKDEP_SUPPORT
def_bool y
 
-config TRACE_IRQFLAGS_SUPPORT
-   def_bool y
-
 config GENERIC_BUG
def_bool y
depends on BUG
diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
index 2716f6395ba7..9d4d898df76b 100644
--- a/arch/csky/Kconfig
+++ b/arch/csky/Kconfig
@@ -82,6 +82,7 @@ config CSKY
select PCI_SYSCALL if PCI
select PCI_MSI if PCI
select SET_FS
+   select TRACE_IRQFLAGS_SUPPORT
 
 config LOCKDEP_SUPPORT
def_bool y
@@ -139,9 +140,6 @@ config STACKTRACE_SUPPORT
 config TIME_LOW_RES
def_bool y
 
-config TRACE_IRQFLAGS_SUPPORT
-   def_bool y
-
 config CPU_TLB_SIZE
int
default "128"   if (CPU_CK610 || CPU_CK807 || CPU_CK810)
diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig
index e5a852080730..f993c4deaf23 100644
--- a/arch/hexagon/Kconfig
+++ b/arch/hexagon/Kconfig
@@ -31,6 +31,7 @@ config HEXAGON
select GENERIC_CPU_DEVICES
select SET_FS
select ARCH_WANT_LD_ORPHAN_WARN
+   select TRACE_IRQFLAGS_SUPPORT
help
  Qualcomm Hexagon is a processor architecture designed for high
  performance and low power across a wide variety of applications.
@@ -52,9 +53,6 @@ config EARLY_PRINTK
 config MMU
def_bool y
 
-config TRACE_IRQFLAGS_SUPPORT
-   def_bool y
-
 config GENERIC_CSUM
def_bool y
 
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 14a67a42fcae..59798e43cdb0 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -44,6 +44,7 @@ config MICROBLAZE
select SPARSE_IRQ
select SET_FS
select ZONE_DMA
+   select TRACE_IRQFLAGS_SUPPORT
 
 # Endianness selection
 choice
diff --git a/arch/microblaze/Kconfig.debug b/arch/microblaze/Kconfig.debug
index 865527ac332a..a4e40e534e6a 100644
--- a/arch/microblaze/Kconfig.debug
+++ b/arch/microblaze/Kconfi

Re: [PATCH 1/5] kbuild: require all architectures to have arch/$(SRCARCH)/Kbuild

2021-05-26 Thread Masahiro Yamada
On Wed, May 12, 2021 at 5:00 PM Masahiro Yamada  wrote:
>
> arch/$(SRCARCH)/Kbuild is useful for Makefile cleanups because you can
> use the obj-y syntax.
>
> Add an empty file if it is missing in arch/$(SRCARCH)/.
>
> Signed-off-by: Masahiro Yamada 
> ---


Applied to linux-kbuild.

>
>  Makefile   | 2 +-
>  arch/alpha/Kbuild  | 1 +
>  arch/arc/Makefile  | 3 ---
>  arch/arm/Makefile  | 1 -
>  arch/arm64/Makefile| 1 -
>  arch/csky/Kbuild   | 1 +
>  arch/h8300/Kbuild  | 1 +
>  arch/hexagon/Kbuild| 1 +
>  arch/ia64/Kbuild   | 1 +
>  arch/microblaze/Kbuild | 1 +
>  arch/mips/Makefile | 3 ---
>  arch/nds32/Kbuild  | 1 +
>  arch/nios2/Kbuild  | 1 +
>  arch/openrisc/Makefile | 1 -
>  arch/parisc/Kbuild | 1 +
>  arch/powerpc/Makefile  | 3 ---
>  arch/riscv/Makefile| 1 -
>  arch/s390/Makefile | 3 ---
>  arch/sh/Kbuild | 1 +
>  arch/sparc/Makefile| 3 ---
>  arch/um/Kbuild | 1 +
>  arch/x86/Makefile  | 3 ---
>  arch/xtensa/Kbuild | 1 +
>  23 files changed, 13 insertions(+), 23 deletions(-)
>  create mode 100644 arch/alpha/Kbuild
>  create mode 100644 arch/csky/Kbuild
>  create mode 100644 arch/h8300/Kbuild
>  create mode 100644 arch/hexagon/Kbuild
>  create mode 100644 arch/ia64/Kbuild
>  create mode 100644 arch/microblaze/Kbuild
>  create mode 100644 arch/nds32/Kbuild
>  create mode 100644 arch/nios2/Kbuild
>  create mode 100644 arch/parisc/Kbuild
>  create mode 100644 arch/sh/Kbuild
>  create mode 100644 arch/um/Kbuild
>  create mode 100644 arch/xtensa/Kbuild
>
> diff --git a/Makefile b/Makefile
> index 15b6476d0f89..7df040b1b023 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -658,7 +658,7 @@ endif
>
>  ifeq ($(KBUILD_EXTMOD),)
>  # Objects we will link into vmlinux / subdirs we need to visit
> -core-y := init/ usr/
> +core-y := init/ usr/ arch/$(SRCARCH)/
>  drivers-y  := drivers/ sound/
>  drivers-$(CONFIG_SAMPLES) += samples/
>  drivers-$(CONFIG_NET) += net/
> diff --git a/arch/alpha/Kbuild b/arch/alpha/Kbuild
> new file mode 100644
> index ..a4e40e534e6a
> --- /dev/null
> +++ b/arch/alpha/Kbuild
> @@ -0,0 +1 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> diff --git a/arch/arc/Makefile b/arch/arc/Makefile
> index 4392c9c189c4..3e6d4b84797f 100644
> --- a/arch/arc/Makefile
> +++ b/arch/arc/Makefile
> @@ -85,9 +85,6 @@ KBUILD_LDFLAGS+= $(ldflags-y)
>
>  head-y := arch/arc/kernel/head.o
>
> -# See arch/arc/Kbuild for content of core part of the kernel
> -core-y += arch/arc/
> -
>  # w/o this dtb won't embed into kernel binary
>  core-y += arch/arc/boot/dts/
>
> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
> index 415c3514573a..173da685a52e 100644
> --- a/arch/arm/Makefile
> +++ b/arch/arm/Makefile
> @@ -252,7 +252,6 @@ endif
>
>  export TEXT_OFFSET GZFLAGS MMUEXT
>
> -core-y += arch/arm/
>  # If we have a machine-specific directory, then include it in the build.
>  core-y += $(machdirs) $(platdirs)
>
> diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
> index 7ef44478560d..b73c151f3a53 100644
> --- a/arch/arm64/Makefile
> +++ b/arch/arm64/Makefile
> @@ -149,7 +149,6 @@ KBUILD_CFLAGS += 
> -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
>  KBUILD_CPPFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
>  KBUILD_AFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
>
> -core-y += arch/arm64/
>  libs-y := arch/arm64/lib/ $(libs-y)
>  libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
>
> diff --git a/arch/csky/Kbuild b/arch/csky/Kbuild
> new file mode 100644
> index ..a4e40e534e6a
> --- /dev/null
> +++ b/arch/csky/Kbuild
> @@ -0,0 +1 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> diff --git a/arch/h8300/Kbuild b/arch/h8300/Kbuild
> new file mode 100644
> index ..a4e40e534e6a
> --- /dev/null
> +++ b/arch/h8300/Kbuild
> @@ -0,0 +1 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> diff --git a/arch/hexagon/Kbuild b/arch/hexagon/Kbuild
> new file mode 100644
> index ..a4e40e534e6a
> --- /dev/null
> +++ b/arch/hexagon/Kbuild
> @@ -0,0 +1 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> diff --git a/arch/ia64/Kbuild b/arch/ia64/Kbuild
> new file mode 100644
> index ..a4e40e534e6a
> --- /dev/null
> +++ b/arch/ia64/Kbuild
> @@ -0,0 +1 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> diff --git a/arch/microblaze/Kbuild b/arch/microblaze/Kbuild
> new file mode 100644
> index ..a4e40e53

[PATCH 1/5] kbuild: require all architectures to have arch/$(SRCARCH)/Kbuild

2021-05-12 Thread Masahiro Yamada
arch/$(SRCARCH)/Kbuild is useful for Makefile cleanups because you can
use the obj-y syntax.

Add an empty file if it is missing in arch/$(SRCARCH)/.

Signed-off-by: Masahiro Yamada 
---

 Makefile   | 2 +-
 arch/alpha/Kbuild  | 1 +
 arch/arc/Makefile  | 3 ---
 arch/arm/Makefile  | 1 -
 arch/arm64/Makefile| 1 -
 arch/csky/Kbuild   | 1 +
 arch/h8300/Kbuild  | 1 +
 arch/hexagon/Kbuild| 1 +
 arch/ia64/Kbuild   | 1 +
 arch/microblaze/Kbuild | 1 +
 arch/mips/Makefile | 3 ---
 arch/nds32/Kbuild  | 1 +
 arch/nios2/Kbuild  | 1 +
 arch/openrisc/Makefile | 1 -
 arch/parisc/Kbuild | 1 +
 arch/powerpc/Makefile  | 3 ---
 arch/riscv/Makefile| 1 -
 arch/s390/Makefile | 3 ---
 arch/sh/Kbuild | 1 +
 arch/sparc/Makefile| 3 ---
 arch/um/Kbuild | 1 +
 arch/x86/Makefile  | 3 ---
 arch/xtensa/Kbuild | 1 +
 23 files changed, 13 insertions(+), 23 deletions(-)
 create mode 100644 arch/alpha/Kbuild
 create mode 100644 arch/csky/Kbuild
 create mode 100644 arch/h8300/Kbuild
 create mode 100644 arch/hexagon/Kbuild
 create mode 100644 arch/ia64/Kbuild
 create mode 100644 arch/microblaze/Kbuild
 create mode 100644 arch/nds32/Kbuild
 create mode 100644 arch/nios2/Kbuild
 create mode 100644 arch/parisc/Kbuild
 create mode 100644 arch/sh/Kbuild
 create mode 100644 arch/um/Kbuild
 create mode 100644 arch/xtensa/Kbuild

diff --git a/Makefile b/Makefile
index 15b6476d0f89..7df040b1b023 100644
--- a/Makefile
+++ b/Makefile
@@ -658,7 +658,7 @@ endif
 
 ifeq ($(KBUILD_EXTMOD),)
 # Objects we will link into vmlinux / subdirs we need to visit
-core-y := init/ usr/
+core-y := init/ usr/ arch/$(SRCARCH)/
 drivers-y  := drivers/ sound/
 drivers-$(CONFIG_SAMPLES) += samples/
 drivers-$(CONFIG_NET) += net/
diff --git a/arch/alpha/Kbuild b/arch/alpha/Kbuild
new file mode 100644
index ..a4e40e534e6a
--- /dev/null
+++ b/arch/alpha/Kbuild
@@ -0,0 +1 @@
+# SPDX-License-Identifier: GPL-2.0-only
diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index 4392c9c189c4..3e6d4b84797f 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -85,9 +85,6 @@ KBUILD_LDFLAGS+= $(ldflags-y)
 
 head-y := arch/arc/kernel/head.o
 
-# See arch/arc/Kbuild for content of core part of the kernel
-core-y += arch/arc/
-
 # w/o this dtb won't embed into kernel binary
 core-y += arch/arc/boot/dts/
 
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 415c3514573a..173da685a52e 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -252,7 +252,6 @@ endif
 
 export TEXT_OFFSET GZFLAGS MMUEXT
 
-core-y += arch/arm/
 # If we have a machine-specific directory, then include it in the build.
 core-y += $(machdirs) $(platdirs)
 
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 7ef44478560d..b73c151f3a53 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -149,7 +149,6 @@ KBUILD_CFLAGS += 
-DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
 KBUILD_CPPFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
 KBUILD_AFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
 
-core-y += arch/arm64/
 libs-y := arch/arm64/lib/ $(libs-y)
 libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
 
diff --git a/arch/csky/Kbuild b/arch/csky/Kbuild
new file mode 100644
index ..a4e40e534e6a
--- /dev/null
+++ b/arch/csky/Kbuild
@@ -0,0 +1 @@
+# SPDX-License-Identifier: GPL-2.0-only
diff --git a/arch/h8300/Kbuild b/arch/h8300/Kbuild
new file mode 100644
index ..a4e40e534e6a
--- /dev/null
+++ b/arch/h8300/Kbuild
@@ -0,0 +1 @@
+# SPDX-License-Identifier: GPL-2.0-only
diff --git a/arch/hexagon/Kbuild b/arch/hexagon/Kbuild
new file mode 100644
index ..a4e40e534e6a
--- /dev/null
+++ b/arch/hexagon/Kbuild
@@ -0,0 +1 @@
+# SPDX-License-Identifier: GPL-2.0-only
diff --git a/arch/ia64/Kbuild b/arch/ia64/Kbuild
new file mode 100644
index ..a4e40e534e6a
--- /dev/null
+++ b/arch/ia64/Kbuild
@@ -0,0 +1 @@
+# SPDX-License-Identifier: GPL-2.0-only
diff --git a/arch/microblaze/Kbuild b/arch/microblaze/Kbuild
new file mode 100644
index ..a4e40e534e6a
--- /dev/null
+++ b/arch/microblaze/Kbuild
@@ -0,0 +1 @@
+# SPDX-License-Identifier: GPL-2.0-only
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 258234c35a09..4e942b7ef022 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -332,9 +332,6 @@ head-y := arch/mips/kernel/head.o
 libs-y += arch/mips/lib/
 libs-$(CONFIG_MIPS_FP_SUPPORT) += arch/mips/math-emu/
 
-# See arch/mips/Kbuild for content of core part of the kernel
-core-y += arch/mips/
-
 drivers-y  += arch/mips/crypto/
 
 # suspend and hibernation support
diff --git a/arch/nds32/Kbuild b/arch/nds32/Kbuild
new file mode 100644
index ..a4e40e534e6a
--- /dev/null
+++ b/arch/nds32/Kbuild
@@ -0,0 +1 @@
+# SPDX

Re: [PATCH] kbuild: use ?= to assign CROSS_COMPILE by arch-Makefile

2021-04-12 Thread Masahiro Yamada
On Mon, Apr 12, 2021 at 5:15 PM Masahiro Yamada  wrote:
>
> On Mon, Apr 12, 2021 at 4:44 PM Geert Uytterhoeven  
> wrote:
> >
> > Hi Yamada-san,
> >
> > On Sun, Apr 11, 2021 at 3:56 PM Masahiro Yamada  
> > wrote:
> > > Use ?= operator to let arch/*/Makefile to assign CROSS_COMPILE only
> > > when CROSS_COMPILE is undefined.
> > >
> > > This allows arch-Makefiles to drop the ifeq ($(CROSS_COMPILE),)
> > > conditional.
> > >
> > > This slightly changes the behavior; the arch-Makefile previously
> > > overrode CROSS_COMPILE when CROSS_COMPILE has already been made empty
> > > via an environment variable as in 'export CROSS_COMPILE='.
> > >
> > > With this commit, arch-Makefle will respect the user's environment
> > > set-up, which seems to be a more correct behavior.
> > >
> > > Signed-off-by: Masahiro Yamada 
> >
> > Thanks for your patch!
> >
> > > ---
> > >
> > >  arch/arc/Makefile| 4 +---
> > >  arch/h8300/Makefile  | 4 +---
> > >  arch/m68k/Makefile   | 4 +---
> > >  arch/mips/Makefile   | 4 +---
> > >  arch/parisc/Makefile | 6 ++
> > >  arch/sh/Makefile | 4 +---
> >
> > What about arch/xtensa/Makefile?
> >
> > > --- a/arch/m68k/Makefile
> > > +++ b/arch/m68k/Makefile
> > > @@ -17,10 +17,8 @@
> > >  KBUILD_DEFCONFIG := multi_defconfig
> > >
> > >  ifneq ($(SUBARCH),$(ARCH))
> > > -   ifeq ($(CROSS_COMPILE),)
> > > -   CROSS_COMPILE := $(call cc-cross-prefix, \
> > > +   CROSS_COMPILE ?= $(call cc-cross-prefix, \
> > > m68k-linux-gnu- m68k-linux- 
> > > m68k-unknown-linux-gnu-)
> > > -   endif
> > >  endif
> >
> > This does not seem to work as expected: my standard build scripts
> > (using "make ARCH=m68k") no longer pick up the cross-compiler,
> > but fall back to the native compiler, thus breaking the build.
>
>
> Agh, sorry, this patch does not work
> because the top Makefile exports CROSS_COMPILE.
>
> export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS
> CROSS_COMPILE LD CC
>
>
>
> Removing CROSS_COMPILE from that makes ?= work,
> but it would break other parts.
>
>
> Please ignore this patch.
>
>
>
>
> > Gr{oetje,eeting}s,
> >
> > Geert
> >
> > --
> > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> > ge...@linux-m68k.org
> >
> > In personal conversations with technical people, I call myself a hacker. But
> > when I'm talking to journalists I just say "programmer" or something like 
> > that.
> > -- Linus Torvalds
>


The following will make this patch work, but probably it is better to
not do this...




diff --git a/Makefile b/Makefile
index cc77fd45ca64..26bf482f0d88 100644
--- a/Makefile
+++ b/Makefile
@@ -506,7 +506,7 @@ KBUILD_LDFLAGS_MODULE :=
 KBUILD_LDFLAGS :=
 CLANG_FLAGS :=

-export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS
CROSS_COMPILE LD CC
+export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS LD CC
 export CPP AR NM STRIP OBJCOPY OBJDUMP READELF PAHOLE RESOLVE_BTFIDS
LEX YACC AWK INSTALLKERNEL
 export PERL PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
 export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD
@@ -681,6 +681,8 @@ export RETPOLINE_VDSO_CFLAGS

 include arch/$(SRCARCH)/Makefile

+export CROSS_COMPILE
+
 ifdef need-config
 ifdef may-sync-config
 # Read in dependencies to all Kconfig* files, make sure to run syncconfig if






-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] kbuild: use ?= to assign CROSS_COMPILE by arch-Makefile

2021-04-12 Thread Masahiro Yamada
On Mon, Apr 12, 2021 at 4:44 PM Geert Uytterhoeven  wrote:
>
> Hi Yamada-san,
>
> On Sun, Apr 11, 2021 at 3:56 PM Masahiro Yamada  wrote:
> > Use ?= operator to let arch/*/Makefile to assign CROSS_COMPILE only
> > when CROSS_COMPILE is undefined.
> >
> > This allows arch-Makefiles to drop the ifeq ($(CROSS_COMPILE),)
> > conditional.
> >
> > This slightly changes the behavior; the arch-Makefile previously
> > overrode CROSS_COMPILE when CROSS_COMPILE has already been made empty
> > via an environment variable as in 'export CROSS_COMPILE='.
> >
> > With this commit, arch-Makefle will respect the user's environment
> > set-up, which seems to be a more correct behavior.
> >
> > Signed-off-by: Masahiro Yamada 
>
> Thanks for your patch!
>
> > ---
> >
> >  arch/arc/Makefile| 4 +---
> >  arch/h8300/Makefile  | 4 +---
> >  arch/m68k/Makefile   | 4 +---
> >  arch/mips/Makefile   | 4 +---
> >  arch/parisc/Makefile | 6 ++
> >  arch/sh/Makefile | 4 +---
>
> What about arch/xtensa/Makefile?
>
> > --- a/arch/m68k/Makefile
> > +++ b/arch/m68k/Makefile
> > @@ -17,10 +17,8 @@
> >  KBUILD_DEFCONFIG := multi_defconfig
> >
> >  ifneq ($(SUBARCH),$(ARCH))
> > -   ifeq ($(CROSS_COMPILE),)
> > -   CROSS_COMPILE := $(call cc-cross-prefix, \
> > +   CROSS_COMPILE ?= $(call cc-cross-prefix, \
> > m68k-linux-gnu- m68k-linux- m68k-unknown-linux-gnu-)
> > -   endif
> >  endif
>
> This does not seem to work as expected: my standard build scripts
> (using "make ARCH=m68k") no longer pick up the cross-compiler,
> but fall back to the native compiler, thus breaking the build.


Agh, sorry, this patch does not work
because the top Makefile exports CROSS_COMPILE.

export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS
CROSS_COMPILE LD CC



Removing CROSS_COMPILE from that makes ?= work,
but it would break other parts.


Please ignore this patch.




> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds



-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH] kbuild: use ?= to assign CROSS_COMPILE by arch-Makefile

2021-04-11 Thread Masahiro Yamada
Use ?= operator to let arch/*/Makefile to assign CROSS_COMPILE only
when CROSS_COMPILE is undefined.

This allows arch-Makefiles to drop the ifeq ($(CROSS_COMPILE),)
conditional.

This slightly changes the behavior; the arch-Makefile previously
overrode CROSS_COMPILE when CROSS_COMPILE has already been made empty
via an environment variable as in 'export CROSS_COMPILE='.

With this commit, arch-Makefle will respect the user's environment
set-up, which seems to be a more correct behavior.

Signed-off-by: Masahiro Yamada 
---

 arch/arc/Makefile| 4 +---
 arch/h8300/Makefile  | 4 +---
 arch/m68k/Makefile   | 4 +---
 arch/mips/Makefile   | 4 +---
 arch/parisc/Makefile | 6 ++
 arch/sh/Makefile | 4 +---
 6 files changed, 7 insertions(+), 19 deletions(-)

diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index 4392c9c189c4..bd5a9daa3461 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -5,9 +5,7 @@
 
 KBUILD_DEFCONFIG := haps_hs_smp_defconfig
 
-ifeq ($(CROSS_COMPILE),)
-CROSS_COMPILE := $(call cc-cross-prefix, arc-linux- arceb-linux-)
-endif
+CROSS_COMPILE ?= $(call cc-cross-prefix, arc-linux- arceb-linux-)
 
 cflags-y   += -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__
 
diff --git a/arch/h8300/Makefile b/arch/h8300/Makefile
index ba0f26cfad61..d6e466dbfc00 100644
--- a/arch/h8300/Makefile
+++ b/arch/h8300/Makefile
@@ -26,9 +26,7 @@ KBUILD_LDFLAGS += $(ldflags-y)
 
 CHECKFLAGS += -msize-long
 
-ifeq ($(CROSS_COMPILE),)
-CROSS_COMPILE := $(call cc-cross-prefix, h8300-unknown-linux- h8300-linux-)
-endif
+CROSS_COMPILE ?= $(call cc-cross-prefix, h8300-unknown-linux- h8300-linux-)
 
 core-y += arch/$(ARCH)/kernel/ arch/$(ARCH)/mm/
 core-y += arch/$(ARCH)/boot/dts/
diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
index ea14f2046fb4..79208ad7a355 100644
--- a/arch/m68k/Makefile
+++ b/arch/m68k/Makefile
@@ -17,10 +17,8 @@
 KBUILD_DEFCONFIG := multi_defconfig
 
 ifneq ($(SUBARCH),$(ARCH))
-   ifeq ($(CROSS_COMPILE),)
-   CROSS_COMPILE := $(call cc-cross-prefix, \
+   CROSS_COMPILE ?= $(call cc-cross-prefix, \
m68k-linux-gnu- m68k-linux- m68k-unknown-linux-gnu-)
-   endif
 endif
 
 #
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index e71d587af49c..75e4e46532a4 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -51,9 +51,7 @@ UTS_MACHINE   := mips64
 endif
 
 ifneq ($(SUBARCH),$(ARCH))
-  ifeq ($(CROSS_COMPILE),)
-CROSS_COMPILE := $(call cc-cross-prefix, $(tool-archpref)-linux-  
$(tool-archpref)-linux-gnu-  $(tool-archpref)-unknown-linux-gnu-)
-  endif
+  CROSS_COMPILE ?= $(call cc-cross-prefix, $(tool-archpref)-linux-  
$(tool-archpref)-linux-gnu-  $(tool-archpref)-unknown-linux-gnu-)
 endif
 
 ifdef CONFIG_FUNCTION_GRAPH_TRACER
diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
index 7d9f71aa829a..62272cb3513c 100644
--- a/arch/parisc/Makefile
+++ b/arch/parisc/Makefile
@@ -42,12 +42,10 @@ endif
 export LD_BFD
 
 ifneq ($(SUBARCH),$(UTS_MACHINE))
-   ifeq ($(CROSS_COMPILE),)
-   CC_SUFFIXES = linux linux-gnu unknown-linux-gnu
-   CROSS_COMPILE := $(call cc-cross-prefix, \
+   CC_SUFFIXES = linux linux-gnu unknown-linux-gnu
+   CROSS_COMPILE ?= $(call cc-cross-prefix, \
$(foreach a,$(CC_ARCHES), \
$(foreach s,$(CC_SUFFIXES),$(a)-$(s)-)))
-   endif
 endif
 
 ifdef CONFIG_DYNAMIC_FTRACE
diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index 3bcbf52fb30e..0e8277be362e 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -10,9 +10,7 @@
 # for more details.
 #
 ifneq ($(SUBARCH),$(ARCH))
-  ifeq ($(CROSS_COMPILE),)
-CROSS_COMPILE := $(call cc-cross-prefix, sh-linux- sh-linux-gnu- 
sh-unknown-linux-gnu-)
-  endif
+  CROSS_COMPILE ?= $(call cc-cross-prefix, sh-linux- sh-linux-gnu- 
sh-unknown-linux-gnu-)
 endif
 
 KBUILD_DEFCONFIG   := shx3_defconfig
-- 
2.27.0


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 0/6] ARC: build: fix various issues in arc boot Makefile

2020-12-01 Thread Masahiro Yamada
On Wed, Nov 25, 2020 at 1:40 PM Vineet Gupta  wrote:
>
> Hi Masahiro San,
>
> On 11/21/20 11:36 AM, Masahiro Yamada wrote:
> >
> >
> > Masahiro Yamada (6):
> >ARC: build: remove non-existing bootpImage from KBUILD_IMAGE
> >ARC: build: add uImage.lzma to the top-level target
> >ARC: build: add boot_targets to PHONY
> >ARC: build: move symlink creation to arch/arc/Makefile to avoid race
> >ARC: build: remove unneeded extra-y
> >ARC: build: use $(READELF) instead of hard-coded readelf
> >
> >   arch/arc/Makefile  | 20 +---
> >   arch/arc/boot/Makefile | 18 --
> >   2 files changed, 17 insertions(+), 21 deletions(-)
>
> This LGTM. Do you want me to pick up these via ARC tree ?
>
> Thx,
> -Vineet

Yes, please. Thanks.




-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 3/6] ARC: build: add boot_targets to PHONY

2020-11-21 Thread Masahiro Yamada
The top-level boot_targets (uImage and uImage.*) should be phony
targets. They just let Kbuild descend into arch/arc/boot/ and create
files there.

If a file exists in the top directory with the same name, the boot
image will not be created.

You can confirm it by the following steps:

  $ export CROSS_COMPILE=
  $ make -s ARCH=arc defconfig all   # vmlinux will be built
  $ touch uImage.gz
  $ make ARCH=arc uImage.gz
  CALLscripts/atomic/check-atomics.sh
  CALLscripts/checksyscalls.sh
  CHK include/generated/compile.h
  # arch/arc/boot/uImage.gz is not created

Specify the targets as PHONY to fix this.

Signed-off-by: Masahiro Yamada 
---

 arch/arc/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index 61a41123ad4c..cf9da9aea12a 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -104,6 +104,7 @@ boot:= arch/arc/boot
 
 boot_targets := uImage uImage.bin uImage.gz uImage.lzma
 
+PHONY += $(boot_targets)
 $(boot_targets): vmlinux
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
 
-- 
2.25.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 4/6] ARC: build: move symlink creation to arch/arc/Makefile to avoid race

2020-11-21 Thread Masahiro Yamada
If you run 'make uImage uImage.gz' with the parallel option, uImage.gz
will be created by two threads simultaneously.

This is because arch/arc/Makefile does not specify the dependency
between uImage and uImage.gz. Hence, GNU Make assumes they can be
built in parallel. One thread descends into arch/arc/boot/ to create
uImage, and another to create uImage.gz.

Please notice the same log is displayed twice in the following steps:

  $ export CROSS_COMPILE=
  $ make -s ARCH=arc defconfig
  $ make -j$(nproc) ARCH=arc uImage uImage.gz
  [ snip ]
LD  vmlinux
SORTTAB vmlinux
SYSMAP  System.map
OBJCOPY arch/arc/boot/vmlinux.bin
OBJCOPY arch/arc/boot/vmlinux.bin
GZIParch/arc/boot/vmlinux.bin.gz
GZIParch/arc/boot/vmlinux.bin.gz
UIMAGE  arch/arc/boot/uImage.gz
UIMAGE  arch/arc/boot/uImage.gz
  Image Name:   Linux-5.10.0-rc4-3-g62f23044
  Created:  Sun Nov 22 02:52:26 2020
  Image Type:   ARC Linux Kernel Image (gzip compressed)
  Data Size:2109376 Bytes = 2059.94 KiB = 2.01 MiB
  Load Address: 8000
  Entry Point:  80004000
Image arch/arc/boot/uImage is ready
  Image Name:   Linux-5.10.0-rc4-3-g62f23044
  Created:  Sun Nov 22 02:52:26 2020
  Image Type:   ARC Linux Kernel Image (gzip compressed)
  Data Size:2815455 Bytes = 2749.47 KiB = 2.69 MiB
  Load Address: 8000
  Entry Point:  80004000

This is a race between the two threads trying to write to the same file
arch/arc/boot/uImage.gz. This is a potential problem that can generate
a broken file.

I fixed a similar problem for ARM by commit 3939f3345050 ("ARM: 8418/1:
add boot image dependencies to not generate invalid images").

I highly recommend to avoid such build rules that cause a race condition.

Move the uImage rule to arch/arc/Makefile.

Another strangeness is that arch/arc/boot/Makefile compares the
timestamps between $(obj)/uImage and $(obj)/uImage.*:

  $(obj)/uImage: $(obj)/uImage.$(suffix-y)
  @ln -sf $(notdir $<) $@
  @echo '  Image $@ is ready'

This does not work as expected since $(obj)/uImage is a symlink.
The symlink should be created in a phony target rule.

I used $(kecho) instead of echo to suppress the message
'Image arch/arc/boot/uImage is ready' when the -s option is given.

Signed-off-by: Masahiro Yamada 
---

 arch/arc/Makefile  | 13 -
 arch/arc/boot/Makefile | 11 +--
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index cf9da9aea12a..578bdbbb0fa7 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -102,11 +102,22 @@ libs-y+= arch/arc/lib/ $(LIBGCC)
 
 boot   := arch/arc/boot
 
-boot_targets := uImage uImage.bin uImage.gz uImage.lzma
+boot_targets := uImage.bin uImage.gz uImage.lzma
 
 PHONY += $(boot_targets)
 $(boot_targets): vmlinux
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
 
+uimage-default-y   := uImage.bin
+uimage-default-$(CONFIG_KERNEL_GZIP)   := uImage.gz
+uimage-default-$(CONFIG_KERNEL_LZMA)   := uImage.lzma
+
+PHONY += uImage
+uImage: $(uimage-default-y)
+   @ln -sf $< $(boot)/uImage
+   @$(kecho) '  Image $(boot)/uImage is ready'
+
+CLEAN_FILES += $(boot)/uImage
+
 archclean:
$(Q)$(MAKE) $(clean)=$(boot)
diff --git a/arch/arc/boot/Makefile b/arch/arc/boot/Makefile
index 538b92f4dd25..3b1f8a69a89e 100644
--- a/arch/arc/boot/Makefile
+++ b/arch/arc/boot/Makefile
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-targets := vmlinux.bin vmlinux.bin.gz uImage
+targets := vmlinux.bin vmlinux.bin.gz
 
 # uImage build relies on mkimage being availble on your host for ARC target
 # You will need to build u-boot for ARC, rename mkimage to arc-elf32-mkimage
@@ -13,11 +13,6 @@ LINUX_START_TEXT = $$(readelf -h vmlinux | \
 UIMAGE_LOADADDR= $(CONFIG_LINUX_LINK_BASE)
 UIMAGE_ENTRYADDR   = $(LINUX_START_TEXT)
 
-suffix-y := bin
-suffix-$(CONFIG_KERNEL_GZIP)   := gz
-suffix-$(CONFIG_KERNEL_LZMA)   := lzma
-
-targets += uImage
 targets += uImage.bin
 targets += uImage.gz
 targets += uImage.lzma
@@ -42,7 +37,3 @@ $(obj)/uImage.gz: $(obj)/vmlinux.bin.gz FORCE
 
 $(obj)/uImage.lzma: $(obj)/vmlinux.bin.lzma FORCE
$(call if_changed,uimage,lzma)
-
-$(obj)/uImage: $(obj)/uImage.$(suffix-y)
-   @ln -sf $(notdir $<) $@
-   @echo '  Image $@ is ready'
-- 
2.25.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 6/6] ARC: build: use $(READELF) instead of hard-coded readelf

2020-11-21 Thread Masahiro Yamada
The top Makefile defines READELF as the readelf in the cross-toolchains.
Use it rather than the host readelf.

Signed-off-by: Masahiro Yamada 
---

 arch/arc/boot/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arc/boot/Makefile b/arch/arc/boot/Makefile
index b3870cc100bf..5648748c285f 100644
--- a/arch/arc/boot/Makefile
+++ b/arch/arc/boot/Makefile
@@ -6,7 +6,7 @@
 
 OBJCOPYFLAGS= -O binary -R .note -R .note.gnu.build-id -R .comment -S
 
-LINUX_START_TEXT = $$(readelf -h vmlinux | \
+LINUX_START_TEXT = $$($(READELF) -h vmlinux | \
grep "Entry point address" | grep -o 0x.*)
 
 UIMAGE_LOADADDR= $(CONFIG_LINUX_LINK_BASE)
-- 
2.25.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 2/6] ARC: build: add uImage.lzma to the top-level target

2020-11-21 Thread Masahiro Yamada
arch/arc/boot/Makefile supports uImage.lzma, but you cannot do
'make uImage.lzma' because the corresponding target is missing
in arch/arc/Makefile. Add it.

I also changed the assignment operator '+=' to ':=' since this is the
only place where we expect this variable to be set.

Signed-off-by: Masahiro Yamada 
---

 arch/arc/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index acf99420e161..61a41123ad4c 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -102,7 +102,7 @@ libs-y  += arch/arc/lib/ $(LIBGCC)
 
 boot   := arch/arc/boot
 
-boot_targets += uImage uImage.bin uImage.gz
+boot_targets := uImage uImage.bin uImage.gz uImage.lzma
 
 $(boot_targets): vmlinux
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
-- 
2.25.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 5/6] ARC: build: remove unneeded extra-y

2020-11-21 Thread Masahiro Yamada
Adding vmlinux.* to extra-y has no point because we expect they are
built on demand while building uImage.*

Add them to 'targets' is enough to include the corresponding .cmd file.

Signed-off-by: Masahiro Yamada 
---

 arch/arc/boot/Makefile | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/arc/boot/Makefile b/arch/arc/boot/Makefile
index 3b1f8a69a89e..b3870cc100bf 100644
--- a/arch/arc/boot/Makefile
+++ b/arch/arc/boot/Makefile
@@ -1,5 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
-targets := vmlinux.bin vmlinux.bin.gz
 
 # uImage build relies on mkimage being availble on your host for ARC target
 # You will need to build u-boot for ARC, rename mkimage to arc-elf32-mkimage
@@ -13,12 +12,12 @@ LINUX_START_TEXT = $$(readelf -h vmlinux | \
 UIMAGE_LOADADDR= $(CONFIG_LINUX_LINK_BASE)
 UIMAGE_ENTRYADDR   = $(LINUX_START_TEXT)
 
+targets += vmlinux.bin
+targets += vmlinux.bin.gz
+targets += vmlinux.bin.lzma
 targets += uImage.bin
 targets += uImage.gz
 targets += uImage.lzma
-extra-y += vmlinux.bin
-extra-y += vmlinux.bin.gz
-extra-y += vmlinux.bin.lzma
 
 $(obj)/vmlinux.bin: vmlinux FORCE
$(call if_changed,objcopy)
-- 
2.25.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 0/6] ARC: build: fix various issues in arc boot Makefile

2020-11-21 Thread Masahiro Yamada




Masahiro Yamada (6):
  ARC: build: remove non-existing bootpImage from KBUILD_IMAGE
  ARC: build: add uImage.lzma to the top-level target
  ARC: build: add boot_targets to PHONY
  ARC: build: move symlink creation to arch/arc/Makefile to avoid race
  ARC: build: remove unneeded extra-y
  ARC: build: use $(READELF) instead of hard-coded readelf

 arch/arc/Makefile  | 20 +---
 arch/arc/boot/Makefile | 18 --
 2 files changed, 17 insertions(+), 21 deletions(-)

-- 
2.25.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 1/6] ARC: build: remove non-existing bootpImage from KBUILD_IMAGE

2020-11-21 Thread Masahiro Yamada
The deb-pkg builds for ARCH=arc fail.

  $ export CROSS_COMPILE=
  $ make -s ARCH=arc defconfig
  $ make ARCH=arc bindeb-pkg
  SORTTAB vmlinux
  SYSMAP  System.map
  MODPOST Module.symvers
  make KERNELRELEASE=5.10.0-rc4 ARCH=arc KBUILD_BUILD_VERSION=2 -f ./Makefile 
intdeb-pkg
  sh ./scripts/package/builddeb
  cp: cannot stat 'arch/arc/boot/bootpImage': No such file or directory
  make[4]: *** [scripts/Makefile.package:87: intdeb-pkg] Error 1
  make[3]: *** [Makefile:1527: intdeb-pkg] Error 2
  make[2]: *** [debian/rules:13: binary-arch] Error 2
  dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 
2
  make[1]: *** [scripts/Makefile.package:83: bindeb-pkg] Error 2
  make: *** [Makefile:1527: bindeb-pkg] Error 2

The reason is obvious; arch/arc/Makefile sets $(boot)/bootpImage as
the default image, but there is no rule to build it.

Remove the meaningless KBUILD_IMAGE assignment so it will fallback
to the default vmlinux. With this change, you can build the deb package.

I removed the 'bootpImage' target as well. At best, it provides
'make bootpImage' as an alias of 'make vmlinux', but I do not see
much sense in doing so.

Signed-off-by: Masahiro Yamada 
---

 arch/arc/Makefile | 6 --
 1 file changed, 6 deletions(-)

diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index 0c6bf0d1df7a..acf99420e161 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -102,12 +102,6 @@ libs-y += arch/arc/lib/ $(LIBGCC)
 
 boot   := arch/arc/boot
 
-#default target for make without any arguments.
-KBUILD_IMAGE   := $(boot)/bootpImage
-
-all:   bootpImage
-bootpImage: vmlinux
-
 boot_targets += uImage uImage.bin uImage.gz
 
 $(boot_targets): vmlinux
-- 
2.25.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] arc: remove #ifndef CONFIG_AS_CFI_SIGNAL_FRAME

2020-04-13 Thread Masahiro Yamada
On Mon, Apr 13, 2020 at 2:38 PM Vineet Gupta  wrote:
>
> On 4/12/20 7:05 PM, Masahiro Yamada wrote:
> > CONFIG_AS_CFI_SIGNAL_FRAME is never defined for ARC.
> >
> > Suggested-by: Nick Desaulniers 
>
> Where, how ?


I was working on various cleanups of x86 CONFIG_AS_* macros.

https://lore.kernel.org/patchwork/patch/1214512/


I removed CONFIG_AS_CFI_SIGNAL_FRAME from x86.

Nick pointed out the same name macro used in ARC,
which is not defined anywhere.





> > Signed-off-by: Masahiro Yamada 
> > ---
> >
> >  arch/arc/kernel/unwind.c | 2 --
> >  1 file changed, 2 deletions(-)
> >
> > diff --git a/arch/arc/kernel/unwind.c b/arch/arc/kernel/unwind.c
> > index 27ea64b1fa33..f87758a6851b 100644
> > --- a/arch/arc/kernel/unwind.c
> > +++ b/arch/arc/kernel/unwind.c
> > @@ -1178,11 +1178,9 @@ int arc_unwind(struct unwind_frame_info *frame)
> >  #endif
> >
> >   /* update frame */
> > -#ifndef CONFIG_AS_CFI_SIGNAL_FRAME
> >   if (frame->call_frame
> >   && !UNW_DEFAULT_RA(state.regs[retAddrReg], state.dataAlign))
> >   frame->call_frame = 0;
> > -#endif
> >   cfa = FRAME_REG(state.cfa.reg, unsigned long) + state.cfa.offs;
> >   startLoc = min_t(unsigned long, UNW_SP(frame), cfa);
> >   endLoc = max_t(unsigned long, UNW_SP(frame), cfa);
>
> Actually there's more scope for cleanup here. The while signal frame stuff is 
> not
> relevant here at all as this is only kernel stack frames. So all of
> frame->call_frame stuff is bogus at best.
>
> I once had an branch with ~15 patches to clean this all up. Let me go find it.


I am not familiar with ARC code.

So, I leave this up to you for further cleanups.

>
> Curious though about the CC list, is this patch part of a bigger series or 
> some
> such. So many people from all over suddenly interested in ARC ;-)


Presumably, they touched this file in the past,
and scripts/get_maintainers.pl picked them up.


masahiro@oscar:~/ref/linux$ scripts/get_maintainer.pl  -f
arch/arc/kernel/unwind.c
Vineet Gupta  (supporter:SYNOPSYS ARC
ARCHITECTURE,commit_signer:2/5=40%)
Kees Cook  (commit_signer:2/5=40%)
"Gustavo A. R. Silva" 
(commit_signer:2/5=40%,authored:2/5=40%,added_lines:3/11=27%,removed_lines:2/14=14%)
Enrico Weigelt  (commit_signer:1/5=20%)
Greg Kroah-Hartman  (commit_signer:1/5=20%)
Thomas Gleixner 
(authored:1/5=20%,added_lines:1/11=9%,removed_lines:4/14=29%)
Pankaj Bharadiya 
(authored:1/5=20%,added_lines:3/11=27%,removed_lines:3/14=21%)
Arnd Bergmann 
(authored:1/5=20%,added_lines:4/11=36%,removed_lines:5/14=36%)
linux-snps-arc@lists.infradead.org (open list:SYNOPSYS ARC ARCHITECTURE)
linux-ker...@vger.kernel.org (open list)



> -Vineet



-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH] arc: remove #ifndef CONFIG_AS_CFI_SIGNAL_FRAME

2020-04-12 Thread Masahiro Yamada
CONFIG_AS_CFI_SIGNAL_FRAME is never defined for ARC.

Suggested-by: Nick Desaulniers 
Signed-off-by: Masahiro Yamada 
---

 arch/arc/kernel/unwind.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/arc/kernel/unwind.c b/arch/arc/kernel/unwind.c
index 27ea64b1fa33..f87758a6851b 100644
--- a/arch/arc/kernel/unwind.c
+++ b/arch/arc/kernel/unwind.c
@@ -1178,11 +1178,9 @@ int arc_unwind(struct unwind_frame_info *frame)
 #endif
 
/* update frame */
-#ifndef CONFIG_AS_CFI_SIGNAL_FRAME
if (frame->call_frame
&& !UNW_DEFAULT_RA(state.regs[retAddrReg], state.dataAlign))
frame->call_frame = 0;
-#endif
cfa = FRAME_REG(state.cfa.reg, unsigned long) + state.cfa.offs;
startLoc = min_t(unsigned long, UNW_SP(frame), cfa);
endLoc = max_t(unsigned long, UNW_SP(frame), cfa);
-- 
2.25.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH] arc: ptrace: hard-code "arc" instead of UTS_MACHINE

2020-04-12 Thread Masahiro Yamada
ARC uses the UTS_MACHINE defined in the top Makefile as follows:

  UTS_MACHINE := $(ARCH)

We know it is "arc" when we are building the kernel for ARC.
Hard-code user_regset_view::name, like many other architectures do.

Signed-off-by: Masahiro Yamada 
---

 arch/arc/kernel/Makefile | 3 ---
 arch/arc/kernel/ptrace.c | 2 +-
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/arc/kernel/Makefile b/arch/arc/kernel/Makefile
index 75539670431a..8c4fc4b54c14 100644
--- a/arch/arc/kernel/Makefile
+++ b/arch/arc/kernel/Makefile
@@ -3,9 +3,6 @@
 # Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
 #
 
-# Pass UTS_MACHINE for user_regset definition
-CFLAGS_ptrace.o+= -DUTS_MACHINE='"$(UTS_MACHINE)"'
-
 obj-y  := arcksyms.o setup.o irq.o reset.o ptrace.o process.o devtree.o
 obj-y  += signal.o traps.o sys.o troubleshoot.o stacktrace.o disasm.o
 obj-$(CONFIG_ISA_ARCOMPACT)+= entry-compact.o intc-compact.o
diff --git a/arch/arc/kernel/ptrace.c b/arch/arc/kernel/ptrace.c
index d5f3fcf273b5..f49a054a1016 100644
--- a/arch/arc/kernel/ptrace.c
+++ b/arch/arc/kernel/ptrace.c
@@ -253,7 +253,7 @@ static const struct user_regset arc_regsets[] = {
 };
 
 static const struct user_regset_view user_arc_view = {
-   .name   = UTS_MACHINE,
+   .name   = "arc",
.e_machine  = EM_ARC_INUSE,
.regsets= arc_regsets,
.n  = ARRAY_SIZE(arc_regsets)
-- 
2.25.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] ARC: [plat-hsdk]: fix USB regression

2020-04-07 Thread Masahiro Yamada
On Wed, Apr 8, 2020 at 1:22 AM Eugeniy Paltsev
 wrote:
>
> Hi Masahiro,
>
> I'm wondering what is proper way to deal with such type of regressions?
> Is is responsibility of person who change kconfig to check (and possibly 
> adjust) affected defconfigs?


I think the patch submitter should take care of
affected defconfigs when (s)he drops select/imply.
Also, this kind of mistake should be caught
in the review process.



-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] initramfs: restore default compression behaviour

2020-03-16 Thread Masahiro Yamada
On Mon, Mar 16, 2020 at 8:22 PM Eugeniy Paltsev
 wrote:
>
> Hi Masahiro,
>
> >From: Masahiro Yamada 
> >Sent: Wednesday, March 11, 2020 23:12
> >To: Eugeniy Paltsev
> >Cc: Linux Kernel Mailing List; arcml; Vineet Gupta; Alexey Brodkin
> >Subject: Re: [PATCH] initramfs: restore default compression behaviour
> >
> >Hi Eugeniy.
> >
> >On Wed, Mar 11, 2020 at 7:22 PM Eugeniy Paltsev
> > wrote:
> >>
> >> Even though INITRAMFS_SOURCE kconfig option isn't set in most of
> >> defconfigs it is used (set) extensively by various build systems.
> >> Commit f26661e12765 ("initramfs: make initramfs compression choice
> >> non-optional") has changed default compression mode. Previously we
> >> compress initramfs using available compression algorithm. Now
> >> we don't use any compression at all by default.
> >> It significantly increases the image size in case of build system
> >> chooses embedded initramfs. Initially I faced with this issue while
> >> using buildroot.
> >>
> >> As of today it's not possible to set preferred compression mode
> >> in target defconfig as this option depends on INITRAMFS_SOURCE
> >> being set.
> >> Modification of build systems doesn't look like good option in this
> >> case as it requires to check against kernel version when setting
> >> compression mode. The reason for this is that kconfig options
> >> describing compression mode was renamed (in same patch series)
> >
> >Which commit?
> >
> >I do not remember the renaming of kconfig options
> >with this regard.
>
> Ok, I've checked it again - looks like I was confused a bit by
> "CONFIG_INITRAMFS_COMPRESSION" option
> as in v5.5 kernel I have in ".config":
> CONFIG_INITRAMFS_COMPRESSION=".gz"
>
> And for v5.6-rc1 I have in ".config":
> CONFIG_INITRAMFS_COMPRESSION_GZIP=y
>
> But they are different options actually...


Right.

There is no prompt for CONFIG_INITRAMFS_COMPRESSION.
So, users have no control of it.

Because this is just a matter of the file extension,
commit 65e00e04e5aea34 moved the logic to Makefile.




-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v2] initramfs: restore default compression behavior

2020-03-16 Thread Masahiro Yamada
On Mon, Mar 16, 2020 at 8:25 PM Eugeniy Paltsev
 wrote:
>
> Even though INITRAMFS_SOURCE kconfig option isn't set in most of
> defconfigs it is used (set) extensively by various build systems.
> Commit f26661e12765 ("initramfs: make initramfs compression choice
> non-optional") has changed default compression mode. Previously we
> compress initramfs using available compression algorithm. Now
> we don't use any compression at all by default.
> It significantly increases the image size in case of build system
> chooses embedded initramfs. Initially I faced with this issue while
> using buildroot.
>
> As of today it's not possible to set preferred compression mode
> in target defconfig as this option depends on INITRAMFS_SOURCE
> being set. Modification of all build systems either doesn't look
> like good option.
>
> Let's instead rewrite initramfs compression mode choices list
> the way that "INITRAMFS_COMPRESSION_NONE" will be the last option
> in the list. In that case it will be chosen only if all other
> options (which implements any compression) are not available.
>
> Signed-off-by: Eugeniy Paltsev 


Applied to linux-kbuild.
Thanks.



> ---
>  usr/Kconfig | 22 +++---
>  1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/usr/Kconfig b/usr/Kconfig
> index bdf5bbd40727..96afb03b65f9 100644
> --- a/usr/Kconfig
> +++ b/usr/Kconfig
> @@ -124,17 +124,6 @@ choice
>
>   If in doubt, select 'None'
>
> -config INITRAMFS_COMPRESSION_NONE
> -   bool "None"
> -   help
> - Do not compress the built-in initramfs at all. This may sound 
> wasteful
> - in space, but, you should be aware that the built-in initramfs will 
> be
> - compressed at a later stage anyways along with the rest of the 
> kernel,
> - on those architectures that support this. However, not compressing 
> the
> - initramfs may lead to slightly higher memory consumption during a
> - short time at boot, while both the cpio image and the unpacked
> - filesystem image will be present in memory simultaneously
> -
>  config INITRAMFS_COMPRESSION_GZIP
> bool "Gzip"
> depends on RD_GZIP
> @@ -207,4 +196,15 @@ config INITRAMFS_COMPRESSION_LZ4
>   If you choose this, keep in mind that most distros don't provide lz4
>   by default which could cause a build failure.
>
> +config INITRAMFS_COMPRESSION_NONE
> +   bool "None"
> +   help
> + Do not compress the built-in initramfs at all. This may sound 
> wasteful
> + in space, but, you should be aware that the built-in initramfs will 
> be
> + compressed at a later stage anyways along with the rest of the 
> kernel,
> + on those architectures that support this. However, not compressing 
> the
> + initramfs may lead to slightly higher memory consumption during a
> + short time at boot, while both the cpio image and the unpacked
> + filesystem image will be present in memory simultaneously
> +
>  endchoice
> --
> 2.21.1
>


-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] initramfs: restore default compression behaviour

2020-03-11 Thread Masahiro Yamada
Hi Eugeniy.

On Wed, Mar 11, 2020 at 7:22 PM Eugeniy Paltsev
 wrote:
>
> Even though INITRAMFS_SOURCE kconfig option isn't set in most of
> defconfigs it is used (set) extensively by various build systems.
> Commit f26661e12765 ("initramfs: make initramfs compression choice
> non-optional") has changed default compression mode. Previously we
> compress initramfs using available compression algorithm. Now
> we don't use any compression at all by default.
> It significantly increases the image size in case of build system
> chooses embedded initramfs. Initially I faced with this issue while
> using buildroot.
>
> As of today it's not possible to set preferred compression mode
> in target defconfig as this option depends on INITRAMFS_SOURCE
> being set.
> Modification of build systems doesn't look like good option in this
> case as it requires to check against kernel version when setting
> compression mode. The reason for this is that kconfig options
> describing compression mode was renamed (in same patch series)

Which commit?

I do not remember the renaming of kconfig options
with this regard.



> so
> we are not able to simply enable one option for old and new kernels.
>
> Given that I propose to use GZIP as default here instead of NO
> compression. It should be used only when available but given that
> gzip is enabled by default it looks like good enough choice.



Another solution would be to move
INITRAMFS_COMPRESSION_NONE to the end of the choice menu.

The default of the choice menu is the first visible entry.

GZIP if RD_GZIP is defined, BZIP2 if RD_BZIP2 is defined ...



> Signed-off-by: Eugeniy Paltsev 
> ---
>  usr/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/usr/Kconfig b/usr/Kconfig
> index bdf5bbd40727..690ef9020819 100644
> --- a/usr/Kconfig
> +++ b/usr/Kconfig
> @@ -102,6 +102,7 @@ config RD_LZ4
>
>  choice
> prompt "Built-in initramfs compression mode"
> +   default INITRAMFS_COMPRESSION_GZIP if RD_GZIP
> depends on INITRAMFS_SOURCE != ""
> help
>   This option allows you to decide by which algorithm the builtin
> --
> 2.21.1
>


-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 1/2] asm-generic: Make msi.h a mandatory include/asm header

2019-10-24 Thread Masahiro Yamada
On Thu, Oct 24, 2019 at 7:13 PM Michal Simek  wrote:
>
> msi.h is generic for all architectures expect of x86 which has own version.

Maybe a typo?  "except"


Anyway, the code looks good to me.

Reviewed-by: Masahiro Yamada 


> Enabling MSI by including msi.h to architecture Kbuild is just additional
> step which doesn't need to be done.
> The patch was created based on request to enable MSI for Microblaze.
>
> Suggested-by: Christoph Hellwig 
> Signed-off-by: Michal Simek 
> ---
>
> https://lore.kernel.org/linux-riscv/20191008154604.ga7...@infradead.org/
> ---
>  arch/arc/include/asm/Kbuild | 1 -
>  arch/arm/include/asm/Kbuild | 1 -
>  arch/arm64/include/asm/Kbuild   | 1 -
>  arch/mips/include/asm/Kbuild| 1 -
>  arch/powerpc/include/asm/Kbuild | 1 -
>  arch/riscv/include/asm/Kbuild   | 1 -
>  arch/sparc/include/asm/Kbuild   | 1 -
>  include/asm-generic/Kbuild  | 1 +
>  8 files changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild
> index 393d4f5e1450..1b505694691e 100644
> --- a/arch/arc/include/asm/Kbuild
> +++ b/arch/arc/include/asm/Kbuild
> @@ -17,7 +17,6 @@ generic-y += local64.h
>  generic-y += mcs_spinlock.h
>  generic-y += mm-arch-hooks.h
>  generic-y += mmiowb.h
> -generic-y += msi.h
>  generic-y += parport.h
>  generic-y += percpu.h
>  generic-y += preempt.h
> diff --git a/arch/arm/include/asm/Kbuild b/arch/arm/include/asm/Kbuild
> index 68ca86f85eb7..fa579b23b4df 100644
> --- a/arch/arm/include/asm/Kbuild
> +++ b/arch/arm/include/asm/Kbuild
> @@ -12,7 +12,6 @@ generic-y += local.h
>  generic-y += local64.h
>  generic-y += mm-arch-hooks.h
>  generic-y += mmiowb.h
> -generic-y += msi.h
>  generic-y += parport.h
>  generic-y += preempt.h
>  generic-y += seccomp.h
> diff --git a/arch/arm64/include/asm/Kbuild b/arch/arm64/include/asm/Kbuild
> index 98a5405c8558..bd23f87d6c55 100644
> --- a/arch/arm64/include/asm/Kbuild
> +++ b/arch/arm64/include/asm/Kbuild
> @@ -16,7 +16,6 @@ generic-y += local64.h
>  generic-y += mcs_spinlock.h
>  generic-y += mm-arch-hooks.h
>  generic-y += mmiowb.h
> -generic-y += msi.h
>  generic-y += qrwlock.h
>  generic-y += qspinlock.h
>  generic-y += serial.h
> diff --git a/arch/mips/include/asm/Kbuild b/arch/mips/include/asm/Kbuild
> index c8b595c60910..61b0fc2026e6 100644
> --- a/arch/mips/include/asm/Kbuild
> +++ b/arch/mips/include/asm/Kbuild
> @@ -13,7 +13,6 @@ generic-y += irq_work.h
>  generic-y += local64.h
>  generic-y += mcs_spinlock.h
>  generic-y += mm-arch-hooks.h
> -generic-y += msi.h
>  generic-y += parport.h
>  generic-y += percpu.h
>  generic-y += preempt.h
> diff --git a/arch/powerpc/include/asm/Kbuild b/arch/powerpc/include/asm/Kbuild
> index 64870c7be4a3..17726f2e46de 100644
> --- a/arch/powerpc/include/asm/Kbuild
> +++ b/arch/powerpc/include/asm/Kbuild
> @@ -10,4 +10,3 @@ generic-y += local64.h
>  generic-y += mcs_spinlock.h
>  generic-y += preempt.h
>  generic-y += vtime.h
> -generic-y += msi.h
> diff --git a/arch/riscv/include/asm/Kbuild b/arch/riscv/include/asm/Kbuild
> index 16970f246860..1efaeddf1e4b 100644
> --- a/arch/riscv/include/asm/Kbuild
> +++ b/arch/riscv/include/asm/Kbuild
> @@ -22,7 +22,6 @@ generic-y += kvm_para.h
>  generic-y += local.h
>  generic-y += local64.h
>  generic-y += mm-arch-hooks.h
> -generic-y += msi.h
>  generic-y += percpu.h
>  generic-y += preempt.h
>  generic-y += sections.h
> diff --git a/arch/sparc/include/asm/Kbuild b/arch/sparc/include/asm/Kbuild
> index b6212164847b..62de2eb2773d 100644
> --- a/arch/sparc/include/asm/Kbuild
> +++ b/arch/sparc/include/asm/Kbuild
> @@ -18,7 +18,6 @@ generic-y += mcs_spinlock.h
>  generic-y += mm-arch-hooks.h
>  generic-y += mmiowb.h
>  generic-y += module.h
> -generic-y += msi.h
>  generic-y += preempt.h
>  generic-y += serial.h
>  generic-y += trace_clock.h
> diff --git a/include/asm-generic/Kbuild b/include/asm-generic/Kbuild
> index adff14fcb8e4..ddfee1bd9dc1 100644
> --- a/include/asm-generic/Kbuild
> +++ b/include/asm-generic/Kbuild
> @@ -4,4 +4,5 @@
>  # (This file is not included when SRCARCH=um since UML borrows several
>  # asm headers from the host architecutre.)
>
> +mandatory-y += msi.h
>  mandatory-y += simd.h
> --
> 2.17.1
>


-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 2/3] kbuild, arc: add CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 for ARC

2019-09-03 Thread Masahiro Yamada
On Sat, Aug 31, 2019 at 1:43 AM Vineet Gupta  wrote:
>
> On 8/20/19 10:09 AM, Masahiro Yamada wrote:
> > arch/arc/Makefile overrides -O2 with -O3. This is the only user of
> > ARCH_CFLAGS. There is no user of ARCH_CPPFLAGS or ARCH_AFLAGS.
> > My plan is to remove ARCH_{CPP,A,C}FLAGS after refactoring the ARC
> > Makefile.
>
> Why, it seems like a good generic facility for arches to over-ride stuff
> (specially adding any toggles at the end of cmdline).
>
> And even if there are no current users, it would be good to have. I 
> understand we
> don't keep code for future, but strictly this is meta-code ;-)

We can re-add it whenever we need it.



> > Currently, ARC has no way to enable -Wmaybe-uninitialized because both
> > -O3 and -Os disable it. Enabling it will be useful for compile-testing.
> > This commit allows allmodconfig (, which defaults to -O2) to enable it.
>
> But this is a separate issue and was done on purpose because of unbearable 
> build
> spew at the time. As an experiment I enabled it in current kernel and at -O3 
> we
> still get the dreaded spew in net/sunrpc/xdr.c and some more in net/ipv4. The 
> spew
> doesn't happen at -O2 and seems not ARC specific as I can see this with ARM 
> -O3
> build with gcc 7.3 (buildroot 2018.08)
>
> | $ make ARCH=arm CROSS_COMPILE=arm-linux- net
> | ..
> | ..
> | ../net/sunrpc/xdr.c: In function ‘xdr_encode_word’:
> | ../net/sunrpc/xdr.c:1199:2: warning: ‘subbuf.tail[0].iov_base’ may be used
> | uninitialized in this function [-Wmaybe-uninitialized]
> |  memcpy(subbuf->tail[0].iov_base, obj, this_len);
> |  ^~~
> | ../net/sunrpc/xdr.c:1205:17: note: ‘subbuf.tail[0].iov_base’ was declared 
> here
> |  struct xdr_buf subbuf;
>
>
> I understand the value of this toggle, but the spew is too much and at times
> obfuscated likely other real issues.
> > Add CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y to all the defconfig files
> > in arch/arc/configs/ in order to keep the current config settings.
>
> My first reaction to adding this to all defconfigs was that this was 
> inelegant :
> for lack of better word :-)
>
> But indeed it seems better this way as we can now experiment with -O2 vs. -O3 
> from
> config, rather than hardwiring to -O3.
>
> So if you could please split out the Wmaybe-uninitialized change

I could not understand your request.

I added 'imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED'
for CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3.

I cannot split it out. Otherwise, you will see false-positive
maybe-uninitialized warnings.


> Acked-by: Vineet Gupta 

Thanks.


-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 2/3] kbuild, arc: add CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 for ARC

2019-08-28 Thread Masahiro Yamada
Hi Vineet,

On Wed, Aug 21, 2019 at 2:10 AM Masahiro Yamada
 wrote:
>
> arch/arc/Makefile overrides -O2 with -O3. This is the only user of
> ARCH_CFLAGS. There is no user of ARCH_CPPFLAGS or ARCH_AFLAGS.
> My plan is to remove ARCH_{CPP,A,C}FLAGS after refactoring the ARC
> Makefile.
>
> Currently, ARC has no way to enable -Wmaybe-uninitialized because both
> -O3 and -Os disable it. Enabling it will be useful for compile-testing.
> This commit allows allmodconfig (, which defaults to -O2) to enable it.
>
> Add CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y to all the defconfig files
> in arch/arc/configs/ in order to keep the current config settings.
>
> Signed-off-by: Masahiro Yamada 
> ---

If it is OK to apply this to my kbuild tree,
can I get your ACK?

If you see any problem, please let me know.

Thanks.



>
>  Makefile   | 10 ++
>  arch/arc/Makefile  |  8 
>  arch/arc/configs/axs101_defconfig  |  1 +
>  arch/arc/configs/axs103_defconfig  |  1 +
>  arch/arc/configs/axs103_smp_defconfig  |  1 +
>  arch/arc/configs/haps_hs_defconfig |  1 +
>  arch/arc/configs/haps_hs_smp_defconfig |  1 +
>  arch/arc/configs/hsdk_defconfig|  1 +
>  arch/arc/configs/nps_defconfig |  1 +
>  arch/arc/configs/nsim_700_defconfig|  1 +
>  arch/arc/configs/nsim_hs_defconfig |  1 +
>  arch/arc/configs/nsim_hs_smp_defconfig |  1 +
>  arch/arc/configs/nsimosci_defconfig|  1 +
>  arch/arc/configs/nsimosci_hs_defconfig |  1 +
>  arch/arc/configs/nsimosci_hs_smp_defconfig |  1 +
>  arch/arc/configs/tb10x_defconfig   |  1 +
>  arch/arc/configs/vdk_hs38_defconfig|  1 +
>  arch/arc/configs/vdk_hs38_smp_defconfig|  1 +
>  init/Kconfig   | 12 ++--
>  19 files changed, 32 insertions(+), 14 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index bc55f366677d..891e47da503f 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -716,10 +716,12 @@ KBUILD_CFLAGS += $(call cc-disable-warning, 
> format-truncation)
>  KBUILD_CFLAGS  += $(call cc-disable-warning, format-overflow)
>  KBUILD_CFLAGS  += $(call cc-disable-warning, address-of-packed-member)
>
> -ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
> -KBUILD_CFLAGS  += -Os
> -else
> -KBUILD_CFLAGS   += -O2
> +ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
> +KBUILD_CFLAGS += -O2
> +else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3
> +KBUILD_CFLAGS += -O3
> +else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
> +KBUILD_CFLAGS += -Os
>  endif
>
>  ifdef CONFIG_CC_DISABLE_WARN_MAYBE_UNINITIALIZED
> diff --git a/arch/arc/Makefile b/arch/arc/Makefile
> index ee6d1184c2b1..f1c44cccf8d6 100644
> --- a/arch/arc/Makefile
> +++ b/arch/arc/Makefile
> @@ -48,14 +48,6 @@ endif
>  cfi := $(call as-instr,.cfi_startproc\n.cfi_endproc,-DARC_DW2_UNWIND_AS_CFI)
>  cflags-$(CONFIG_ARC_DW2_UNWIND)+= 
> -fasynchronous-unwind-tables $(cfi)
>
> -ifndef CONFIG_CC_OPTIMIZE_FOR_SIZE
> -# Generic build system uses -O2, we want -O3
> -# Note: No need to add to cflags-y as that happens anyways
> -#
> -# Disable the false maybe-uninitialized warings gcc spits out at -O3
> -ARCH_CFLAGS += -O3 $(call cc-disable-warning,maybe-uninitialized,)
> -endif
> -
>  # small data is default for elf32 tool-chain. If not usable, disable it
>  # This also allows repurposing GP as scratch reg to gcc reg allocator
>  disable_small_data := y
> diff --git a/arch/arc/configs/axs101_defconfig 
> b/arch/arc/configs/axs101_defconfig
> index e31a8ebc3ecc..0016149f9583 100644
> --- a/arch/arc/configs/axs101_defconfig
> +++ b/arch/arc/configs/axs101_defconfig
> @@ -9,6 +9,7 @@ CONFIG_NAMESPACES=y
>  # CONFIG_UTS_NS is not set
>  # CONFIG_PID_NS is not set
>  CONFIG_BLK_DEV_INITRD=y
> +CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
>  CONFIG_EMBEDDED=y
>  CONFIG_PERF_EVENTS=y
>  # CONFIG_VM_EVENT_COUNTERS is not set
> diff --git a/arch/arc/configs/axs103_defconfig 
> b/arch/arc/configs/axs103_defconfig
> index e0e8567f0d75..5b031582a1cf 100644
> --- a/arch/arc/configs/axs103_defconfig
> +++ b/arch/arc/configs/axs103_defconfig
> @@ -9,6 +9,7 @@ CONFIG_NAMESPACES=y
>  # CONFIG_UTS_NS is not set
>  # CONFIG_PID_NS is not set
>  CONFIG_BLK_DEV_INITRD=y
> +CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
>  CONFIG_EMBEDDED=y
>  CONFIG_PERF_EVENTS=y
>  # CONFIG_VM_EVENT_COUNTERS is not set
> diff --git a/arch/arc/configs/axs103_smp_defconfig 
> b/arch/arc/configs/axs103_smp_defconfig
> index fcbc952bc75b..d4eec39e0112 100644
> --- a/arch/arc/configs/axs103_smp_defconfig
> +++ b/arch/arc/configs/axs103_smp_defconfig
> @@ -9,6 +9,7 @@ CONFIG_NAMESP

[PATCH 3/3] kbuild: remove ARCH_{CPP,A,C}FLAGS

2019-08-20 Thread Masahiro Yamada
These flags were added by commit 61754c18752f ("kbuild: Allow arch
Makefiles to override {cpp,ld,c}flags") to allow ARC to override -O2.

We did not see any other usage after all. Now that ARC switched to
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3, there is no more user of
these variables.

Signed-off-by: Masahiro Yamada 
---

 Documentation/kbuild/makefiles.rst |  7 ---
 Makefile   | 14 --
 2 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/Documentation/kbuild/makefiles.rst 
b/Documentation/kbuild/makefiles.rst
index 36ba92e199d2..712cdbcdbe91 100644
--- a/Documentation/kbuild/makefiles.rst
+++ b/Documentation/kbuild/makefiles.rst
@@ -988,13 +988,6 @@ When kbuild executes, the following steps are followed 
(roughly):
$(KBUILD_ARFLAGS) set by the top level Makefile to "D" (deterministic
mode) if this option is supported by $(AR).
 
-ARCH_CPPFLAGS, ARCH_AFLAGS, ARCH_CFLAGS   Overrides the kbuild defaults
-
-   These variables are appended to the KBUILD_CPPFLAGS,
-   KBUILD_AFLAGS, and KBUILD_CFLAGS, respectively, after the
-   top-level Makefile has set any other flags. This provides a
-   means for an architecture to override the defaults.
-
 KBUILD_LDS
 
The linker script with full path. Assigned by the top-level Makefile.
diff --git a/Makefile b/Makefile
index 891e47da503f..6551f136afb0 100644
--- a/Makefile
+++ b/Makefile
@@ -661,11 +661,6 @@ RETPOLINE_VDSO_CFLAGS := $(call 
cc-option,$(RETPOLINE_VDSO_CFLAGS_GCC),$(call cc
 export RETPOLINE_CFLAGS
 export RETPOLINE_VDSO_CFLAGS
 
-# The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default
-# values of the respective KBUILD_* variables
-ARCH_CPPFLAGS :=
-ARCH_AFLAGS :=
-ARCH_CFLAGS :=
 include arch/$(SRCARCH)/Makefile
 
 ifdef need-config
@@ -918,11 +913,10 @@ include scripts/Makefile.kasan
 include scripts/Makefile.extrawarn
 include scripts/Makefile.ubsan
 
-# Add any arch overrides and user supplied CPPFLAGS, AFLAGS and CFLAGS as the
-# last assignments
-KBUILD_CPPFLAGS += $(ARCH_CPPFLAGS) $(KCPPFLAGS)
-KBUILD_AFLAGS   += $(ARCH_AFLAGS)   $(KAFLAGS)
-KBUILD_CFLAGS   += $(ARCH_CFLAGS)   $(KCFLAGS)
+# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
+KBUILD_CPPFLAGS += $(KCPPFLAGS)
+KBUILD_AFLAGS   += $(KAFLAGS)
+KBUILD_CFLAGS   += $(KCFLAGS)
 
 KBUILD_LDFLAGS_MODULE += --build-id
 LDFLAGS_vmlinux += --build-id
-- 
2.17.1



[PATCH 2/3] kbuild,arc: add CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 for ARC

2019-08-20 Thread Masahiro Yamada
arch/arc/Makefile overrides -O2 with -O3. This is the only user of
ARCH_CFLAGS. There is no user of ARCH_CPPFLAGS or ARCH_AFLAGS.
My plan is to remove ARCH_{CPP,A,C}FLAGS after refactoring the ARC
Makefile.

Currently, ARC has no way to enable -Wmaybe-uninitialized because both
-O3 and -Os disable it. Enabling it will be useful for compile-testing.
This commit allows allmodconfig (, which defaults to -O2) to enable it.

Add CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y to all the defconfig files
in arch/arc/configs/ in order to keep the current config settings.

Signed-off-by: Masahiro Yamada 
---

 Makefile   | 10 ++
 arch/arc/Makefile  |  8 
 arch/arc/configs/axs101_defconfig  |  1 +
 arch/arc/configs/axs103_defconfig  |  1 +
 arch/arc/configs/axs103_smp_defconfig  |  1 +
 arch/arc/configs/haps_hs_defconfig |  1 +
 arch/arc/configs/haps_hs_smp_defconfig |  1 +
 arch/arc/configs/hsdk_defconfig|  1 +
 arch/arc/configs/nps_defconfig |  1 +
 arch/arc/configs/nsim_700_defconfig|  1 +
 arch/arc/configs/nsim_hs_defconfig |  1 +
 arch/arc/configs/nsim_hs_smp_defconfig |  1 +
 arch/arc/configs/nsimosci_defconfig|  1 +
 arch/arc/configs/nsimosci_hs_defconfig |  1 +
 arch/arc/configs/nsimosci_hs_smp_defconfig |  1 +
 arch/arc/configs/tb10x_defconfig   |  1 +
 arch/arc/configs/vdk_hs38_defconfig|  1 +
 arch/arc/configs/vdk_hs38_smp_defconfig|  1 +
 init/Kconfig   | 12 ++--
 19 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/Makefile b/Makefile
index bc55f366677d..891e47da503f 100644
--- a/Makefile
+++ b/Makefile
@@ -716,10 +716,12 @@ KBUILD_CFLAGS += $(call cc-disable-warning, 
format-truncation)
 KBUILD_CFLAGS  += $(call cc-disable-warning, format-overflow)
 KBUILD_CFLAGS  += $(call cc-disable-warning, address-of-packed-member)
 
-ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
-KBUILD_CFLAGS  += -Os
-else
-KBUILD_CFLAGS   += -O2
+ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
+KBUILD_CFLAGS += -O2
+else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3
+KBUILD_CFLAGS += -O3
+else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
+KBUILD_CFLAGS += -Os
 endif
 
 ifdef CONFIG_CC_DISABLE_WARN_MAYBE_UNINITIALIZED
diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index ee6d1184c2b1..f1c44cccf8d6 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -48,14 +48,6 @@ endif
 cfi := $(call as-instr,.cfi_startproc\n.cfi_endproc,-DARC_DW2_UNWIND_AS_CFI)
 cflags-$(CONFIG_ARC_DW2_UNWIND)+= -fasynchronous-unwind-tables 
$(cfi)
 
-ifndef CONFIG_CC_OPTIMIZE_FOR_SIZE
-# Generic build system uses -O2, we want -O3
-# Note: No need to add to cflags-y as that happens anyways
-#
-# Disable the false maybe-uninitialized warings gcc spits out at -O3
-ARCH_CFLAGS += -O3 $(call cc-disable-warning,maybe-uninitialized,)
-endif
-
 # small data is default for elf32 tool-chain. If not usable, disable it
 # This also allows repurposing GP as scratch reg to gcc reg allocator
 disable_small_data := y
diff --git a/arch/arc/configs/axs101_defconfig 
b/arch/arc/configs/axs101_defconfig
index e31a8ebc3ecc..0016149f9583 100644
--- a/arch/arc/configs/axs101_defconfig
+++ b/arch/arc/configs/axs101_defconfig
@@ -9,6 +9,7 @@ CONFIG_NAMESPACES=y
 # CONFIG_UTS_NS is not set
 # CONFIG_PID_NS is not set
 CONFIG_BLK_DEV_INITRD=y
+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
 CONFIG_EMBEDDED=y
 CONFIG_PERF_EVENTS=y
 # CONFIG_VM_EVENT_COUNTERS is not set
diff --git a/arch/arc/configs/axs103_defconfig 
b/arch/arc/configs/axs103_defconfig
index e0e8567f0d75..5b031582a1cf 100644
--- a/arch/arc/configs/axs103_defconfig
+++ b/arch/arc/configs/axs103_defconfig
@@ -9,6 +9,7 @@ CONFIG_NAMESPACES=y
 # CONFIG_UTS_NS is not set
 # CONFIG_PID_NS is not set
 CONFIG_BLK_DEV_INITRD=y
+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
 CONFIG_EMBEDDED=y
 CONFIG_PERF_EVENTS=y
 # CONFIG_VM_EVENT_COUNTERS is not set
diff --git a/arch/arc/configs/axs103_smp_defconfig 
b/arch/arc/configs/axs103_smp_defconfig
index fcbc952bc75b..d4eec39e0112 100644
--- a/arch/arc/configs/axs103_smp_defconfig
+++ b/arch/arc/configs/axs103_smp_defconfig
@@ -9,6 +9,7 @@ CONFIG_NAMESPACES=y
 # CONFIG_UTS_NS is not set
 # CONFIG_PID_NS is not set
 CONFIG_BLK_DEV_INITRD=y
+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
 CONFIG_EMBEDDED=y
 CONFIG_PERF_EVENTS=y
 # CONFIG_VM_EVENT_COUNTERS is not set
diff --git a/arch/arc/configs/haps_hs_defconfig 
b/arch/arc/configs/haps_hs_defconfig
index 436f2135bdc1..47ff8a97e42d 100644
--- a/arch/arc/configs/haps_hs_defconfig
+++ b/arch/arc/configs/haps_hs_defconfig
@@ -10,6 +10,7 @@ CONFIG_NAMESPACES=y
 # CONFIG_UTS_NS is not set
 # CONFIG_PID_NS is not set
 CONFIG_BLK_DEV_INITRD=y
+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
 CONFIG_EXPERT=y
 CONFIG_PERF_EVENTS=y
 # CONFIG_COMPAT_BRK is not set
diff --git a/arch/arc/configs/haps_hs_smp_defconfig 
b/arch/arc/configs/haps_hs_smp_defconfig
index

[PATCH 1/3] init/Kconfig: rework help of CONFIG_CC_OPTIMIZE_FOR_SIZE

2019-08-20 Thread Masahiro Yamada
CONFIG_CC_OPTIMIZE_FOR_SIZE was originally an independent boolean
option, but commit 877417e6ffb9 ("Kbuild: change CC_OPTIMIZE_FOR_SIZE
definition") turned it into a choice between _PERFORMANCE and _SIZE.

The phrase "If unsure, say N." sounds like an independent option.
Reword the help text to make it appropriate for the choice menu.

Signed-off-by: Masahiro Yamada 
---

 init/Kconfig | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/init/Kconfig b/init/Kconfig
index bf971b5c707d..149efd82447f 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1219,10 +1219,8 @@ config CC_OPTIMIZE_FOR_SIZE
bool "Optimize for size"
imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED  # avoid false positives
help
- Enabling this option will pass "-Os" instead of "-O2" to
- your compiler resulting in a smaller kernel.
-
- If unsure, say N.
+ Choosing this option will pass "-Os" to your compiler resulting
+ in a smaller kernel.
 
 endchoice
 
-- 
2.17.1



Re: [TRIVIAL PATCH] of: per-file dtc preprocessor flags

2019-07-21 Thread Masahiro Yamada
On Sun, Jul 21, 2019 at 12:38 AM Eugeniy Paltsev
 wrote:
>
> Hi Masahiro,
>
> On Sat, 2019-07-20 at 11:40 +0900, Masahiro Yamada wrote:
> > On Sat, Jul 20, 2019 at 4:28 AM Eugeniy Paltsev
> >  wrote:
> > > As of today we are able to pass custom flags to dtc compiler but not
> > > to dtc preprocessor.
> > > This ability is required for including some board-specific header files.
> > > It allows us to pass defined constants to dts without their duplication
> > > in several places.
> >
> > How to use this option in a useful way?
> >
> > I see a bunch of defined constants under include/dt-bindings/.
> >
> > If you are talking about code duplication across architectures,
> > you can include arm dtsi from arm64 dts, or vice versa.
> > This was made possible by the symbolic links
> > in scripts/dtc/include-prefixes/.
> >
> > Could you please elaborate your issues if you cannot solve them
> > by the current strategy?
> >
>
> Here is the example:
>
> We have several FPGA-based boards (haps_hs, haps_hs_idu,...) which are 
> involved
> in SW and HW automated verification. For some tests we randomize physical 
> memory
> location so we patch 'CONFIG_LINUX_RAM_BASE' kconfig variable and 'memory' 
> node in
> device tree. We want to keep number of patches as less as possible (to avoid
> conflicts on their applying) so we want to avoid duplication and pass
> 'CONFIG_LINUX_RAM_BASE' directly to dts by including it from
> 'include/generated/autoconf.h':
>
> ->8
> memory {
> device_type = "memory";
> -   /* CONFIG_LINUX_RAM_BASE needs to match low mem start */
> -   reg = <0x8000 0x2000>;  /* 512 */
> +   reg = ;  /* 512 */



So, we need the kernel configuration to build DT?

I am scared with this idea.

I believe DT files should be able to be compiled
irrespective of the .config because they are
re-used for other projects.

devicetree-rebasing is a subset of the kernel tree
that collects DT.

If you upstream that patch, this will be broken, at least.

git://git.kernel.org/pub/scm/linux/kernel/git/devicetree/devicetree-rebasing.git



-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [TRIVIAL PATCH] of: per-file dtc preprocessor flags

2019-07-19 Thread Masahiro Yamada
On Sat, Jul 20, 2019 at 4:28 AM Eugeniy Paltsev
 wrote:
>
> As of today we are able to pass custom flags to dtc compiler but not
> to dtc preprocessor.
> This ability is required for including some board-specific header files.
> It allows us to pass defined constants to dts without their duplication
> in several places.

How to use this option in a useful way?

I see a bunch of defined constants under include/dt-bindings/.

If you are talking about code duplication across architectures,
you can include arm dtsi from arm64 dts, or vice versa.
This was made possible by the symbolic links
in scripts/dtc/include-prefixes/.

Could you please elaborate your issues if you cannot solve them
by the current strategy?



> Signed-off-by: Eugeniy Paltsev 
> ---
>  scripts/Makefile.lib | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index f1f38c8cdc74..f2595a608dce 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -166,6 +166,8 @@ dtc_cpp_flags  = -Wp,-MD,$(depfile).pre.tmp -nostdinc 
>\
>  $(addprefix -I,$(DTC_INCLUDE))  \
>  -undef -D__DTS__
>
> +dtc_cpp_flags  += $(DTC_CPP_FLAGS_$(basetarget))
> +
>  # Useful for describing the dependency of composite objects
>  # Usage:
>  #   $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add)
> --
> 2.21.0
>


-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH] fixup! kbuild: remove obj and src from the top Makefile

2019-07-09 Thread Masahiro Yamada
Merging today's kbuild tree would break arc, um, parisc.
I just noticed it now. I will fix it soon for tomorrow's linux-next.

If needed, this might be useful for today's linux-next.

Signed-off-by: Masahiro Yamada 
---

 arch/arc/Makefile|  2 +-
 arch/parisc/Makefile | 12 ++--
 arch/um/Makefile |  2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index 03a0b19c92cd..ee6d1184c2b1 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -19,7 +19,7 @@ ifdef CONFIG_ARC_CURR_IN_REG
 # any kernel headers, and missing the r25 global register
 # Can't do unconditionally because of recursive include issues
 # due to 
-LINUXINCLUDE   +=  -include ${src}/arch/arc/include/asm/current.h
+LINUXINCLUDE   +=  -include $(srctree)/arch/arc/include/asm/current.h
 endif
 
 cflags-y   += -fsection-anchors
diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
index 58d46665cad9..8acb8fa1f8d6 100644
--- a/arch/parisc/Makefile
+++ b/arch/parisc/Makefile
@@ -120,8 +120,8 @@ PALO := $(shell if (which palo 2>&1); then : ; \
elif [ -x /sbin/palo ]; then echo /sbin/palo; \
fi)
 
-PALOCONF := $(shell if [ -f $(src)/palo.conf ]; then echo $(src)/palo.conf; \
-   else echo $(obj)/palo.conf; \
+PALOCONF := $(shell if [ -f $(srctree)/palo.conf ]; then echo 
$(srctree)/palo.conf; \
+   else echo $(objtree)/palo.conf; \
fi)
 
 palo lifimage: vmlinuz
@@ -131,8 +131,8 @@ palo lifimage: vmlinuz
false; \
fi
@if test ! -f "$(PALOCONF)"; then \
-   cp $(src)/arch/parisc/defpalo.conf $(obj)/palo.conf; \
-   echo 'A generic palo config file ($(obj)/palo.conf) has been 
created for you.'; \
+   cp $(srctree)/arch/parisc/defpalo.conf $(objtree)/palo.conf; \
+   echo 'A generic palo config file ($(objree)/palo.conf) has been 
created for you.'; \
echo 'You should check it and re-run "make palo".'; \
echo 'WARNING: the "lifimage" file is now placed in this 
directory by default!'; \
false; \
@@ -162,10 +162,10 @@ vmlinuz: vmlinux
 endif
 
 install:
-   $(CONFIG_SHELL) $(src)/arch/parisc/install.sh \
+   $(CONFIG_SHELL) $(srctree)/arch/parisc/install.sh \
$(KERNELRELEASE) vmlinux System.map "$(INSTALL_PATH)"
 zinstall:
-   $(CONFIG_SHELL) $(src)/arch/parisc/install.sh \
+   $(CONFIG_SHELL) $(srctree)/arch/parisc/install.sh \
$(KERNELRELEASE) vmlinuz System.map "$(INSTALL_PATH)"
 
 CLEAN_FILES+= lifimage
diff --git a/arch/um/Makefile b/arch/um/Makefile
index 273130cf91d1..d2daa206872d 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -73,7 +73,7 @@ KBUILD_AFLAGS += $(ARCH_INCLUDE)
 USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFLAGS))) 
\
$(ARCH_INCLUDE) $(MODE_INCLUDE) $(filter -I%,$(CFLAGS)) \
-D_FILE_OFFSET_BITS=64 -idirafter $(srctree)/include \
-   -idirafter $(obj)/include -D__KERNEL__ -D__UM_HOST__
+   -idirafter $(objtree)/include -D__KERNEL__ -D__UM_HOST__
 
 #This will adjust *FLAGS accordingly to the platform.
 include $(ARCH_DIR)/Makefile-os-$(OS)
-- 
2.17.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 00/15] kbuild: refactor headers_install and support compile-test of UAPI headers

2019-06-18 Thread Masahiro Yamada
On Tue, Jun 4, 2019 at 7:15 PM Masahiro Yamada
 wrote:
>
>
> Multiple people have suggested to compile-test UAPI headers.
>
> Currently, Kbuild provides simple sanity checks by headers_check
> but they are not enough to catch bugs.
>
> The most recent patch I know is David Howells' work:
> https://patchwork.kernel.org/patch/10590203/
>
> I agree that we need better tests for UAPI headers,
> but I want to integrate it in a clean way.
>
> The idea that has been in my mind is to compile each header
> to make sure the selfcontainedness.
>
> Recently, Jani Nikula proposed a new syntax 'header-test-y'.
> https://patchwork.kernel.org/patch/10947005/
>
> So, I implemented UAPI compile-testing on top of that.
>
> When adding a new feature, cleaning the code first is a
> good practice.
>
> [1] Remove headers_install_all
>
> This target installs UAPI headers of all architectures
> in a single tree.
> It does not make sense to compile test of headers from
> multiple arches at the same time. Hence, removed.
>
> [2] Split header installation into 'make headers' and 'make headers_install'
>
> To compile-test UAPI headers, we need a work-directory somewhere
> to save objects and .*.cmd files.
>
> usr/include/ will be the work-directory.
>
> Since we cannot pollute the final destination of headers_install,
>
> I split the header installation into two stages.
>
> 'make headers' will build up
> the ready-to-install headers in usr/include,
> which will be also used as a work-directory for the compile-test.
>
> 'make headers_install' will copy headers
> from usr/include to $(INSTALL_HDR_PATH)/include.
>
> [3] Support compile-test of UAPI headers
>
> This is implemented in usr/include/Makefile
>
>
> Jani Nikula (1):
>   kbuild: add support for ensuring headers are self-contained
>
> Masahiro Yamada (14):
>   kbuild: remove headers_{install,check}_all
>   kbuild: remove stale dependency between Documentation/ and
> headers_install
>   kbuild: make gdb_script depend on prepare0 instead of prepare
>   kbuild: fix Kconfig prompt of CONFIG_HEADERS_CHECK
>   kbuild: add CONFIG_HEADERS_INSTALL and loosen the dependency of
> samples
>   kbuild: remove build_unifdef target in scripts/Makefile
>   kbuild: build all prerequisite of headers_install simultaneously
>   kbuild: add 'headers' target to build up ready-to-install uapi headers
>   kbuild: re-implement Makefile.headersinst without directory descending
>   kbuild: move hdr-inst shorthand to top Makefile
>   kbuild: simplify scripts/headers_install.sh
>   kbuild: deb-pkg: do not run headers_check
>   fixup: kbuild: add support for ensuring headers are self-contained
>   kbuild: compile test UAPI headers to ensure they are self-contained

Series, applied to linux-kbuild.


>  Documentation/kbuild/headers_install.txt |   7 --
>  Documentation/kbuild/makefiles.txt   |  13 ++-
>  Makefile |  56 +-
>  arch/arc/configs/tb10x_defconfig |   1 +
>  arch/nds32/configs/defconfig |   1 +
>  arch/parisc/configs/a500_defconfig   |   1 +
>  arch/parisc/configs/b180_defconfig   |   1 +
>  arch/parisc/configs/c3000_defconfig  |   1 +
>  arch/parisc/configs/default_defconfig|   1 +
>  arch/powerpc/configs/ppc6xx_defconfig|   1 +
>  arch/s390/configs/debug_defconfig|   1 +
>  include/uapi/{linux => }/Kbuild  |   6 +-
>  init/Kconfig |  20 
>  lib/Kconfig.debug|  25 +++--
>  samples/Kconfig  |  14 ++-
>  samples/Makefile |   4 +-
>  scripts/Kbuild.include   |   6 --
>  scripts/Makefile |   5 -
>  scripts/Makefile.build   |   9 ++
>  scripts/Makefile.headersinst | 132 ++-
>  scripts/Makefile.lib |   3 +
>  scripts/cc-system-headers.sh |   8 ++
>  scripts/headers.sh   |  29 -
>  scripts/headers_install.sh   |  48 -
>  scripts/package/builddeb |   2 +-
>  usr/.gitignore   |   1 -
>  usr/Makefile |   2 +
>  usr/include/.gitignore   |   3 +
>  usr/include/Makefile | 132 +++
>  29 files changed, 329 insertions(+), 204 deletions(-)
>  rename include/uapi/{linux => }/Kbuild (77%)
>  create mode 100755 scripts/cc-system-headers.sh
>  delete mode 100755 scripts/headers.sh
>  create mode 100644 usr/include/.gitignore
>  create mode 100644 usr/include/Makefile
>
> --
> 2.17.1
>

Re: [PATCH] ARC: build: Try to guess CROSS_COMPILE with cc-cross-prefix

2019-06-12 Thread Masahiro Yamada
Hi.

On Tue, Jun 4, 2019 at 2:49 AM Alexey Brodkin
 wrote:
>
> Hi Vineet,
>
> > -Original Message-
> > From: Vineet Gupta 
> > Sent: Monday, June 3, 2019 7:25 PM
> > To: Alexey Brodkin ; 
> > linux-snps-arc@lists.infradead.org
> > Cc: linux-ker...@vger.kernel.org; Masahiro Yamada 
> > 
> > Subject: Re: [PATCH] ARC: build: Try to guess CROSS_COMPILE with 
> > cc-cross-prefix
> >
> > On 6/2/19 11:31 PM, Alexey Brodkin wrote:
> > > For a long time we used to hard-code CROSS_COMPILE prefix
> > > for ARC until it started to cause problems, so we decided to
> > > solely rely on CROSS_COMPILE externally set by a user:
> > > commit 40660f1fcee8 ("ARC: build: Don't set CROSS_COMPILE in arch's 
> > > Makefile").
> > >
> > > While it works perfectly fine for build-systems where the prefix
> > > gets defined anyways for us human beings it's quite an annoying
> > > requirement especially given most of time the same one prefix
> > > "arc-linux-" is all what we need.
> > >
> > > It looks like finally we're getting the best of both worlds:
> > >  1. W/o cross-toolchain we still may install headers, build .dtb etc
> > >  2. W/ cross-toolchain get the kerne built with only ARCH=arc
> > >
> > > Inspired by [1] & [2].
> > >
> > > [1] 
> > > http://lists.infradead.org/pipermail/linux-snps-arc/2019-May/005788.html
> > > [2] 
> > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fc2b47b55f17
> > >
> > > A side note: even though "cc-cross-prefix" does its job it pollutes
> > > console with output of "which" for all the prefixes it didn't manage to 
> > > find
> > > a matching cross-compiler for like that:
> > > | # ARCH=arc make defconfig
> > > | which: no arceb-linux-gcc in (~/.local/bin:~/bin:/usr/bin:/usr/sbin)
> > > | *** Default configuration is based on 'nsim_hs_defconfig'


I just noticed this patch is queued on top of v5.2-rc4.
(2bc42bfba9b247abd)

This 'side note' is no longer needed or reproducible
because -rc4 contains my fix-up (913ab9780fc0212).

I do not know if the ARC maitainer is happy to rebase.

Just for your information.


-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 2/2] arch: replace _BITUL() in kernel-space headers with BIT()

2019-06-09 Thread Masahiro Yamada
Now that BIT() can be used from assembly code, we can safely replace
_BITUL() with equivalent BIT().

UAPI headers are still required to use _BITUL(), but there is no more
reason to use it in kernel headers. BIT() is shorter.

Signed-off-by: Masahiro Yamada 
---

 arch/arc/include/asm/pgtable.h  |  8 +--
 arch/arc/plat-eznps/include/plat/ctop.h | 15 ++---
 arch/arm64/include/asm/sysreg.h | 82 -
 arch/s390/include/asm/ctl_reg.h | 42 ++---
 arch/s390/include/asm/nmi.h | 20 +++---
 arch/s390/include/asm/processor.h   | 20 +++---
 arch/s390/include/asm/ptrace.h  | 10 +--
 arch/s390/include/asm/setup.h   | 40 ++--
 arch/s390/include/asm/thread_info.h | 34 +-
 9 files changed, 136 insertions(+), 135 deletions(-)

diff --git a/arch/arc/include/asm/pgtable.h b/arch/arc/include/asm/pgtable.h
index cf4be70d5892..8e729649d1b1 100644
--- a/arch/arc/include/asm/pgtable.h
+++ b/arch/arc/include/asm/pgtable.h
@@ -35,7 +35,7 @@
 #ifndef _ASM_ARC_PGTABLE_H
 #define _ASM_ARC_PGTABLE_H
 
-#include 
+#include 
 #define __ARCH_USE_5LEVEL_HACK
 #include 
 #include 
@@ -218,11 +218,11 @@
 #define BITS_FOR_PTE   (PGDIR_SHIFT - PAGE_SHIFT)
 #define BITS_FOR_PGD   (32 - PGDIR_SHIFT)
 
-#define PGDIR_SIZE _BITUL(PGDIR_SHIFT) /* vaddr span, not PDG sz */
+#define PGDIR_SIZE BIT(PGDIR_SHIFT)/* vaddr span, not PDG sz */
 #define PGDIR_MASK (~(PGDIR_SIZE-1))
 
-#definePTRS_PER_PTE_BITUL(BITS_FOR_PTE)
-#definePTRS_PER_PGD_BITUL(BITS_FOR_PGD)
+#definePTRS_PER_PTEBIT(BITS_FOR_PTE)
+#definePTRS_PER_PGDBIT(BITS_FOR_PGD)
 
 /*
  * Number of entries a user land program use.
diff --git a/arch/arc/plat-eznps/include/plat/ctop.h 
b/arch/arc/plat-eznps/include/plat/ctop.h
index 309a994f64f0..a4a61531c7fb 100644
--- a/arch/arc/plat-eznps/include/plat/ctop.h
+++ b/arch/arc/plat-eznps/include/plat/ctop.h
@@ -10,6 +10,7 @@
 #error "Incorrect ctop.h include"
 #endif
 
+#include 
 #include 
 #include 
 
@@ -51,19 +52,19 @@
 #define CTOP_INST_AXOR_DI_R2_R2_R3 0x4A664C06
 
 /* Do not use D$ for address in 2G-3G */
-#define HW_COMPLY_KRN_NOT_D_CACHED _BITUL(28)
+#define HW_COMPLY_KRN_NOT_D_CACHED BIT(28)
 
 #define NPS_MSU_EN_CFG 0x80
 #define NPS_CRG_BLKID  0x480
-#define NPS_CRG_SYNC_BIT   _BITUL(0)
+#define NPS_CRG_SYNC_BIT   BIT(0)
 #define NPS_GIM_BLKID  0x5C0
 
 /* GIM registers and fields*/
-#define NPS_GIM_UART_LINE  _BITUL(7)
-#define NPS_GIM_DBG_LAN_EAST_TX_DONE_LINE  _BITUL(10)
-#define NPS_GIM_DBG_LAN_EAST_RX_RDY_LINE   _BITUL(11)
-#define NPS_GIM_DBG_LAN_WEST_TX_DONE_LINE  _BITUL(25)
-#define NPS_GIM_DBG_LAN_WEST_RX_RDY_LINE   _BITUL(26)
+#define NPS_GIM_UART_LINE  BIT(7)
+#define NPS_GIM_DBG_LAN_EAST_TX_DONE_LINE  BIT(10)
+#define NPS_GIM_DBG_LAN_EAST_RX_RDY_LINE   BIT(11)
+#define NPS_GIM_DBG_LAN_WEST_TX_DONE_LINE  BIT(25)
+#define NPS_GIM_DBG_LAN_WEST_RX_RDY_LINE   BIT(26)
 
 #ifndef __ASSEMBLY__
 /* Functional registers definition */
diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h
index 902d75b60914..3bcd8294acc0 100644
--- a/arch/arm64/include/asm/sysreg.h
+++ b/arch/arm64/include/asm/sysreg.h
@@ -20,7 +20,7 @@
 #ifndef __ASM_SYSREG_H
 #define __ASM_SYSREG_H
 
-#include 
+#include 
 #include 
 
 /*
@@ -458,31 +458,31 @@
 #define SYS_ZCR_EL12   sys_reg(3, 5, 1, 2, 0)
 
 /* Common SCTLR_ELx flags. */
-#define SCTLR_ELx_DSSBS(_BITUL(44))
-#define SCTLR_ELx_ENIA (_BITUL(31))
-#define SCTLR_ELx_ENIB (_BITUL(30))
-#define SCTLR_ELx_ENDA (_BITUL(27))
-#define SCTLR_ELx_EE(_BITUL(25))
-#define SCTLR_ELx_IESB (_BITUL(21))
-#define SCTLR_ELx_WXN  (_BITUL(19))
-#define SCTLR_ELx_ENDB (_BITUL(13))
-#define SCTLR_ELx_I(_BITUL(12))
-#define SCTLR_ELx_SA   (_BITUL(3))
-#define SCTLR_ELx_C(_BITUL(2))
-#define SCTLR_ELx_A(_BITUL(1))
-#define SCTLR_ELx_M(_BITUL(0))
+#define SCTLR_ELx_DSSBS(BIT(44))
+#define SCTLR_ELx_ENIA (BIT(31))
+#define SCTLR_ELx_ENIB (BIT(30))
+#define SCTLR_ELx_ENDA (BIT(27))
+#define SCTLR_ELx_EE(BIT(25))
+#define SCTLR_ELx_IESB (BIT(21))
+#define SCTLR_ELx_WXN  (BIT(19))
+#define SCTLR_ELx_ENDB (BIT(13))
+#define SCTLR_ELx_I(BIT(12))
+#define SCTLR_ELx_SA   (BIT(3))
+#define SCTLR_ELx_C(BIT(2))
+#define SCTLR_ELx_A(BIT(1))
+#define SCTLR_ELx_M(BIT(0))
 
 #define SCTLR_ELx_FLAGS(SCTLR_ELx_M  | SCTLR_ELx_A | SCTLR_ELx_C | \
 SCTLR_ELx_SA | SCTLR_ELx_I | SCTLR_ELx_IESB)
 
 /* SCTLR_EL2 specific flags. */
-#define SCTLR_EL2_RES1 ((_BITUL(4))  | (_BITUL(5))  | (_BITUL(11)) | 
(_BITUL(16)) | \
-(_BITUL(18)) | (_BITUL(22)) | (_BITUL(23)) | 
(_BITUL(28)) | \
- 

[PATCH v2] kbuild: use more portable 'command -v' for cc-cross-prefix

2019-06-05 Thread Masahiro Yamada
To print the pathname that will be used by shell in the current
environment, 'command -v' is a standardized way. [1]

'which' is also often used in scripts, but it is less portable.

When I worked on commit bd55f96fa9fc ("kbuild: refactor cc-cross-prefix
implementation"), I was eager to use 'command -v' but it did not work.
(The reason is explained below.)

I kept 'which' as before but got rid of '> /dev/null 2>&1' as I
thought it was no longer needed. Sorry, I was wrong.

It works well on my Ubuntu machine, but Alexey Brodkin reports noisy
warnings on CentOS7 when 'which' fails to find the given command in
the PATH environment.

  $ which foo
  which: no foo in 
(/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)

Given that behavior of 'which' depends on system (and it may not be
installed by default), I want to try 'command -v' once again.

The specification [1] clearly describes the behavior of 'command -v'
when the given command is not found:

  Otherwise, no output shall be written and the exit status shall reflect
  that the name was not found.

However, we need a little magic to use 'command -v' from Make.

$(shell ...) passes the argument to a subshell for execution, and
returns the standard output of the command.

Here is a trick. GNU Make may optimize this by executing the command
directly instead of forking a subshell, if no shell special characters
are found in the command and omitting the subshell will not change the
behavior.

In this case, no shell special character is used. So, Make will try
to run it directly. However, 'command' is a shell-builtin command,
then Make would fail to find it in the PATH environment:

  $ make ARCH=m68k defconfig
  make: command: Command not found
  make: command: Command not found
  make: command: Command not found

In fact, Make has a table of shell-builtin commands because it must
ask the shell to execute them.

Until recently, 'command' was missing in the table.

This issue was fixed by the following commit:

| commit 1af314465e5dfe3e8baa839a32a72e83c04f26ef
| Author: Paul Smith 
| Date:   Sun Nov 12 18:10:28 2017 -0500
|
| * job.c: Add "command" as a known shell built-in.
|
| This is not a POSIX shell built-in but it's common in UNIX shells.
| Reported by Nick Bowler .

Because the latest release is GNU Make 4.2.1 in 2016, this commit is
not included in any released versions. (But some distributions may
have back-ported it.)

We need to trick Make to spawn a subshell. There are various ways to
do so:

 1) Use a shell special character '~' as dummy

$(shell : ~; command -v $(c)gcc)

 2) Use a variable reference, which always expands to the empty string
(suggested by David Laight)

$(shell command$${x:+} -v $(c)gcc)

 3) Use redirect

$(shell command -v $(c)gcc 2>/dev/null)

I chose 3) to not confuse people. The stderr would not be polluted
anyway, but it will provide extra safety, and is easy to understand.

Tested on Make 3.81, 3.82, 4.0, 4.1, 4.2, 4.2.1

[1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html

Fixes: bd55f96fa9fc ("kbuild: refactor cc-cross-prefix implementation")
Cc: linux-stable  # 5.1
Reported-by: Alexey Brodkin 
Signed-off-by: Masahiro Yamada 
Tested-by: Alexey Brodkin 
---

Changes in v2:
  - Use dummy redirect

 scripts/Kbuild.include | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 85d758233483..fd8aa314c156 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -74,8 +74,11 @@ endef
 # Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-)
 # Return first  where a gcc is found in PATH.
 # If no gcc found in PATH with listed prefixes return nothing
+#
+# Note: 2>/dev/null is here to force Make to invoke a shell. This workaround
+# is needed because this issue was only fixed after GNU Make 4.2.1 release.
 cc-cross-prefix = $(firstword $(foreach c, $(filter-out -%, $(1)), \
-   $(if $(shell which $(c)gcc), $(c
+   $(if $(shell command -v $(c)gcc 2>/dev/null), $(c
 
 # output directory for tests below
 TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
-- 
2.17.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 00/15] kbuild: refactor headers_install and support compile-test of UAPI headers

2019-06-04 Thread Masahiro Yamada
On Tue, Jun 4, 2019 at 7:15 PM Masahiro Yamada
 wrote:
>
>
> Multiple people have suggested to compile-test UAPI headers.
>
> Currently, Kbuild provides simple sanity checks by headers_check
> but they are not enough to catch bugs.
>
> The most recent patch I know is David Howells' work:
> https://patchwork.kernel.org/patch/10590203/
>
> I agree that we need better tests for UAPI headers,
> but I want to integrate it in a clean way.
>
> The idea that has been in my mind is to compile each header
> to make sure the selfcontainedness.


For convenience, I pushed this series at

git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git
uapi-header-test-v1

(13/15 was replaced with v2)


If you want to test it quickly, please check-out it, then

  $ make -j8 allmodconfig usr/

(As I noted in the commit log, you need to use
a compiler that provides , , etc.)


-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] kbuild: use more portable 'command -v' for cc-cross-prefix

2019-06-04 Thread Masahiro Yamada
On Tue, Jun 4, 2019 at 6:01 PM David Laight  wrote:
>
> From: Masahiro Yamada
> > Sent: 04 June 2019 04:31
> ...
> > > > > You could use:
> > > > > $(shell sh -c "command -v $(c)gcc")
> > > > > or maybe:
> > > > > $(shell command$${x:+} -v $(c)gcc)
> > > >
> > > >
> > > > How about this?
> > > >
> > > >   $(shell : ~; command -v $(c)gcc)
> > >
> > > Overcomplicated 
> > >
> > > I've not looked at the list of 'special characters' in make,
> > > but I suspect any variable expansion is enough.
> > > Since ${x:+} always expands to the empty string (whether or
> > > not 'x' is defined) it can't have any unfortunate side effects.
> >
> >
> > Probably, my eyes are used to Makefile.
> > ":" is a no-op command, and it is used everywhere in kernel Makefiles
> > in the form of "@:'
> >
> > It depends on people which solution seems simpler.
> > So, this argument tends to end up with bikesheding.
>
> I am fully aware of ':', it is a shell builtin that always return success.
> Usually used when you want the side-effects of substitutions without
> executing anything (eg : ${foo:=bar} ), to change the result of a
> sequence of shell commands or as a dummy (eg while :; do :; done; )
> Very annoyingly bash parses !: as something other than 'not true'.
>
> $(shell command$${x:+} -v $(c)gcc) will be marginally faster
> because it is less parsing.
>

I will use this:

$(shell command -v $(c)gcc 2>/dev/null)

Make does not handle redirection by itself.

'2>/dev/null' is easy to understand,
and might be useful as extra safety.




-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 05/15] kbuild: add CONFIG_HEADERS_INSTALL and loosen the dependency of samples

2019-06-04 Thread Masahiro Yamada
Commit 5318321d367c ("samples: disable CONFIG_SAMPLES for UML") used
a big hammer to fix the build errors under the samples/ directory,
while only some samples actually include uapi headers from usr/include.

Introduce CONFIG_HEADERS_INSTALL since 'depends on HEADERS_INSTALL' is
clearer than 'depends on !UML'. If this option is enabled, uapi headers
are installed before starting directory descending.

I added 'depends on HEADERS_INSTALL' to per-sample CONFIG options.
This allows UML to compile some samples.

$ make ARCH=um allmodconfig samples/
  [ snip ]
  CC [M]  samples/configfs/configfs_sample.o
  CC [M]  samples/kfifo/bytestream-example.o
  CC [M]  samples/kfifo/dma-example.o
  CC [M]  samples/kfifo/inttype-example.o
  CC [M]  samples/kfifo/record-example.o
  CC [M]  samples/kobject/kobject-example.o
  CC [M]  samples/kobject/kset-example.o
  CC [M]  samples/trace_events/trace-events-sample.o
  CC [M]  samples/trace_printk/trace-printk.o
  AR  samples/vfio-mdev/built-in.a
  AR  samples/built-in.a

Signed-off-by: Masahiro Yamada 
---

 Makefile  |  8 
 arch/arc/configs/tb10x_defconfig  |  1 +
 arch/nds32/configs/defconfig  |  1 +
 arch/parisc/configs/a500_defconfig|  1 +
 arch/parisc/configs/b180_defconfig|  1 +
 arch/parisc/configs/c3000_defconfig   |  1 +
 arch/parisc/configs/default_defconfig |  1 +
 arch/powerpc/configs/ppc6xx_defconfig |  1 +
 arch/s390/configs/debug_defconfig |  1 +
 lib/Kconfig.debug | 19 ++-
 samples/Kconfig   | 14 +++---
 samples/Makefile  |  4 ++--
 12 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/Makefile b/Makefile
index 8348939765d3..ce5a9551860d 100644
--- a/Makefile
+++ b/Makefile
@@ -1053,9 +1053,6 @@ vmlinux: scripts/link-vmlinux.sh autoksyms_recursive 
$(vmlinux-deps) FORCE
 
 targets := vmlinux
 
-# Some samples need headers_install.
-samples: headers_install
-
 # The actual objects are generated when descending,
 # make sure no implicit rule kicks in
 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
@@ -1199,6 +1196,10 @@ headers_check: headers_install
$(Q)$(MAKE) $(hdr-inst)=include/uapi dst=include HDRCHECK=1
$(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi dst=include 
HDRCHECK=1
 
+ifdef CONFIG_HEADERS_INSTALL
+prepare: headers_install
+endif
+
 ifdef CONFIG_HEADERS_CHECK
 all: headers_check
 endif
@@ -1745,7 +1746,6 @@ build-dir = $(patsubst %/,%,$(dir $(build-target)))
 PHONY += /
 /: ./
 
-samples/: headers_install
 %/: prepare FORCE
$(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir)
 
diff --git a/arch/arc/configs/tb10x_defconfig b/arch/arc/configs/tb10x_defconfig
index 5b5119d2b5d5..dc739bd093e3 100644
--- a/arch/arc/configs/tb10x_defconfig
+++ b/arch/arc/configs/tb10x_defconfig
@@ -94,6 +94,7 @@ CONFIG_CONFIGFS_FS=y
 CONFIG_DEBUG_INFO=y
 CONFIG_STRIP_ASM_SYMS=y
 CONFIG_DEBUG_FS=y
+CONFIG_HEADERS_INSTALL=y
 CONFIG_HEADERS_CHECK=y
 CONFIG_DEBUG_SECTION_MISMATCH=y
 CONFIG_MAGIC_SYSRQ=y
diff --git a/arch/nds32/configs/defconfig b/arch/nds32/configs/defconfig
index 65ce9259081b..40313a635075 100644
--- a/arch/nds32/configs/defconfig
+++ b/arch/nds32/configs/defconfig
@@ -92,6 +92,7 @@ CONFIG_DEBUG_INFO=y
 CONFIG_DEBUG_INFO_DWARF4=y
 CONFIG_GDB_SCRIPTS=y
 CONFIG_READABLE_ASM=y
+CONFIG_HEADERS_INSTALL=y
 CONFIG_HEADERS_CHECK=y
 CONFIG_DEBUG_SECTION_MISMATCH=y
 CONFIG_MAGIC_SYSRQ=y
diff --git a/arch/parisc/configs/a500_defconfig 
b/arch/parisc/configs/a500_defconfig
index 5acb93dcaabf..390c0bc09179 100644
--- a/arch/parisc/configs/a500_defconfig
+++ b/arch/parisc/configs/a500_defconfig
@@ -167,6 +167,7 @@ CONFIG_NLS_ISO8859_1=m
 CONFIG_NLS_ISO8859_15=m
 CONFIG_NLS_UTF8=m
 CONFIG_DEBUG_FS=y
+CONFIG_HEADERS_INSTALL=y
 CONFIG_HEADERS_CHECK=y
 CONFIG_MAGIC_SYSRQ=y
 # CONFIG_DEBUG_BUGVERBOSE is not set
diff --git a/arch/parisc/configs/b180_defconfig 
b/arch/parisc/configs/b180_defconfig
index 83ffd161aec5..bdf1fe2b217f 100644
--- a/arch/parisc/configs/b180_defconfig
+++ b/arch/parisc/configs/b180_defconfig
@@ -91,6 +91,7 @@ CONFIG_NLS_ASCII=m
 CONFIG_NLS_ISO8859_1=m
 CONFIG_NLS_ISO8859_15=m
 CONFIG_NLS_UTF8=m
+CONFIG_HEADERS_INSTALL=y
 CONFIG_HEADERS_CHECK=y
 CONFIG_MAGIC_SYSRQ=y
 CONFIG_DEBUG_KERNEL=y
diff --git a/arch/parisc/configs/c3000_defconfig 
b/arch/parisc/configs/c3000_defconfig
index 8d41a73bd71b..ed4d49575b38 100644
--- a/arch/parisc/configs/c3000_defconfig
+++ b/arch/parisc/configs/c3000_defconfig
@@ -140,6 +140,7 @@ CONFIG_NLS_ISO8859_1=m
 CONFIG_NLS_ISO8859_15=m
 CONFIG_NLS_UTF8=m
 CONFIG_DEBUG_FS=y
+CONFIG_HEADERS_INSTALL=y
 CONFIG_HEADERS_CHECK=y
 CONFIG_MAGIC_SYSRQ=y
 CONFIG_DEBUG_MUTEXES=y
diff --git a/arch/parisc/configs/default_defconfig 
b/arch/parisc/configs/default_defconfig
index 52c9050a7c5c..fcfd9eaadf9b 100644
--- a/arch/parisc/configs/default_defconfig
+++ b/arch/parisc/configs/default_defconfig
@@ -184,6 +184,7 @@ CONFIG_NL

[PATCH 00/15] kbuild: refactor headers_install and support compile-test of UAPI headers

2019-06-04 Thread Masahiro Yamada


Multiple people have suggested to compile-test UAPI headers.

Currently, Kbuild provides simple sanity checks by headers_check
but they are not enough to catch bugs.

The most recent patch I know is David Howells' work:
https://patchwork.kernel.org/patch/10590203/

I agree that we need better tests for UAPI headers,
but I want to integrate it in a clean way.

The idea that has been in my mind is to compile each header
to make sure the selfcontainedness.

Recently, Jani Nikula proposed a new syntax 'header-test-y'.
https://patchwork.kernel.org/patch/10947005/

So, I implemented UAPI compile-testing on top of that.

When adding a new feature, cleaning the code first is a
good practice.

[1] Remove headers_install_all

This target installs UAPI headers of all architectures
in a single tree.
It does not make sense to compile test of headers from
multiple arches at the same time. Hence, removed.

[2] Split header installation into 'make headers' and 'make headers_install'

To compile-test UAPI headers, we need a work-directory somewhere
to save objects and .*.cmd files.

usr/include/ will be the work-directory.

Since we cannot pollute the final destination of headers_install,

I split the header installation into two stages.

'make headers' will build up
the ready-to-install headers in usr/include,
which will be also used as a work-directory for the compile-test.

'make headers_install' will copy headers
from usr/include to $(INSTALL_HDR_PATH)/include.

[3] Support compile-test of UAPI headers

This is implemented in usr/include/Makefile


Jani Nikula (1):
  kbuild: add support for ensuring headers are self-contained

Masahiro Yamada (14):
  kbuild: remove headers_{install,check}_all
  kbuild: remove stale dependency between Documentation/ and
headers_install
  kbuild: make gdb_script depend on prepare0 instead of prepare
  kbuild: fix Kconfig prompt of CONFIG_HEADERS_CHECK
  kbuild: add CONFIG_HEADERS_INSTALL and loosen the dependency of
samples
  kbuild: remove build_unifdef target in scripts/Makefile
  kbuild: build all prerequisite of headers_install simultaneously
  kbuild: add 'headers' target to build up ready-to-install uapi headers
  kbuild: re-implement Makefile.headersinst without directory descending
  kbuild: move hdr-inst shorthand to top Makefile
  kbuild: simplify scripts/headers_install.sh
  kbuild: deb-pkg: do not run headers_check
  fixup: kbuild: add support for ensuring headers are self-contained
  kbuild: compile test UAPI headers to ensure they are self-contained

 Documentation/kbuild/headers_install.txt |   7 --
 Documentation/kbuild/makefiles.txt   |  13 ++-
 Makefile |  56 +-
 arch/arc/configs/tb10x_defconfig |   1 +
 arch/nds32/configs/defconfig |   1 +
 arch/parisc/configs/a500_defconfig   |   1 +
 arch/parisc/configs/b180_defconfig   |   1 +
 arch/parisc/configs/c3000_defconfig  |   1 +
 arch/parisc/configs/default_defconfig|   1 +
 arch/powerpc/configs/ppc6xx_defconfig|   1 +
 arch/s390/configs/debug_defconfig|   1 +
 include/uapi/{linux => }/Kbuild  |   6 +-
 init/Kconfig |  20 
 lib/Kconfig.debug|  25 +++--
 samples/Kconfig  |  14 ++-
 samples/Makefile |   4 +-
 scripts/Kbuild.include   |   6 --
 scripts/Makefile |   5 -
 scripts/Makefile.build   |   9 ++
 scripts/Makefile.headersinst | 132 ++-
 scripts/Makefile.lib |   3 +
 scripts/cc-system-headers.sh |   8 ++
 scripts/headers.sh   |  29 -
 scripts/headers_install.sh   |  48 -
 scripts/package/builddeb |   2 +-
 usr/.gitignore   |   1 -
 usr/Makefile |   2 +
 usr/include/.gitignore   |   3 +
 usr/include/Makefile | 132 +++
 29 files changed, 329 insertions(+), 204 deletions(-)
 rename include/uapi/{linux => }/Kbuild (77%)
 create mode 100755 scripts/cc-system-headers.sh
 delete mode 100755 scripts/headers.sh
 create mode 100644 usr/include/.gitignore
 create mode 100644 usr/include/Makefile

-- 
2.17.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] kbuild: use more portable 'command -v' for cc-cross-prefix

2019-06-03 Thread Masahiro Yamada
On Mon, Jun 3, 2019 at 9:43 PM David Laight  wrote:
>
> From: Masahiro Yamada
> > Sent: 03 June 2019 12:45
> > On Mon, Jun 3, 2019 at 8:16 PM David Laight  wrote:
> > >
> > > From: Masahiro Yamada
> > > > Sent: 03 June 2019 11:49
> > > >
> > > > To print the pathname that will be used by shell in the current
> > > > environment, 'command -v' is a standardized way. [1]
> > > >
> > > > 'which' is also often used in scripting, but it is not portable.
> > >
> > > All uses of 'which' should be expunged.
> > > It is a bourne shell script that is trying to emulate a csh builtin.
> > > It is doomed to fail in corner cases.
> > > ISTR it has serious problems with shell functions and aliases.
> >
> > OK, I do not have time to check it treewide.
> > I expect somebody will contribute to it.
> >
> >
> >
> > BTW, I see yet another way to get the command path.
> >
> > 'type -path' is bash-specific.
>
> 'type' itself should be supported by all shells, but the output
> format (esp for errors) probably varies.
>
> > Maybe, we should do this too:
> >
> > diff --git a/scripts/mkuboot.sh b/scripts/mkuboot.sh
> > index 4b1fe09e9042..77829ee4268e 100755
> > --- a/scripts/mkuboot.sh
> > +++ b/scripts/mkuboot.sh
> > @@ -1,14 +1,14 @@
> > -#!/bin/bash
> > +#!/bin/sh
>
> /bin/sh might be 'dash' - which is just plain broken in so many ways.
> Try (IIRC) ${foo%${foo#bar}}
> It might even be the original SYSV /bin/sh which doesn't support $((expr))
> or ${foo#bar} - but that may break too much, but $SHELL might fix it.


We cannot use any tool
if you start to argue like
"Hey, I know ancient implementation that did not work as expected".

Nobody can cover all corner-cases.
That's why we have standard.

I think the reliable source is the
Open Group Specification.

The behavior of /bin/sh is defined here:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_01

${parameter%[word]} and ${parameter#[word]} are defined,
so we can use them in /bin/sh scripts.


> dash probably has the rather obscure bug in stripping '\n' from $(...)
> output that I found and fixed in NetBSD's ash may years ago.
> Try: foo="$(jot -b "" 130)"
> All 130 '\n' should be deleted.
> Mostly it fails to delete all the '\n', but it can remove extra ones!
>
> David
>
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 
> 1PT, UK
> Registration No: 1397386 (Wales)



-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] kbuild: use more portable 'command -v' for cc-cross-prefix

2019-06-03 Thread Masahiro Yamada
On Mon, Jun 3, 2019 at 10:09 PM David Laight  wrote:
>
> From: Masahiro Yamada
> > Sent: 03 June 2019 12:38
> > Hi David,
> >
> > On Mon, Jun 3, 2019 at 8:14 PM David Laight  wrote:
> > >
> > > From: Masahiro Yamada
> > > > Sent: 03 June 2019 11:49
> > > >
> > > > To print the pathname that will be used by shell in the current
> > > > environment, 'command -v' is a standardized way. [1]
> > > >
> > > > 'which' is also often used in scripting, but it is not portable.
> > > >
> > > > When I worked on commit bd55f96fa9fc ("kbuild: refactor cc-cross-prefix
> > > > implementation"), I was eager to use 'command -v' but it did not work.
> > > > (The reason is explained below.)
> > > >
> > > > I kept 'which' as before but got rid of '> /dev/null 2>&1' as I
> > > > thought it was no longer needed. Sorry, I was wrong.
> > > >
> > > > It works well on my Ubuntu machine, but Alexey Brodkin reports annoying
> > > > warnings from the 'which' on CentOS 7 when the given command is not
> > > > found in the PATH environment.
> > > >
> > > >   $ which foo
> > > >   which: no foo in 
> > > > (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)
> > > >
> > > > Given that behavior of 'which' is different on environment, I want
> > > > to try 'command -v' again.
> > > >
> > > > The specification [1] clearly describes the behavior of 'command -v'
> > > > when the given command is not found:
> > > >
> > > >   Otherwise, no output shall be written and the exit status shall 
> > > > reflect
> > > >   that the name was not found.
> > > >
> > > > However, we need a little magic to use 'command -v' from Make.
> > > >
> > > > $(shell ...) passes the argument to a subshell for execution, and
> > > > returns the standard output of the command.
> > > >
> > > > Here is a trick. GNU Make may optimize this by executing the command
> > > > directly instead of forking a subshell, if no shell special characters
> > > > are found in the command line and omitting the subshell will not
> > > > change the behavior.
> > > >
> > > > In this case, no shell special character is used. So, Make will try
> > > > to run the command directly. However, 'command' is a shell-builtin
> > > > command. In fact, Make has a table of shell-builtin commands because
> > > > it must spawn a subshell to execute them.
> > > >
> > > > Until recently, 'command' was missing in the table.
> > > >
> > > > This issue was fixed by the following commit:
> > > >
> > > > | commit 1af314465e5dfe3e8baa839a32a72e83c04f26ef
> > > > | Author: Paul Smith 
> > > > | Date:   Sun Nov 12 18:10:28 2017 -0500
> > > > |
> > > > | * job.c: Add "command" as a known shell built-in.
> > > > |
> > > > | This is not a POSIX shell built-in but it's common in UNIX shells.
> > > > | Reported by Nick Bowler .
> > > >
> > > > This is not included in any released versions of Make yet.
> > > > (But, some distributions may have back-ported the fix-up.)
> > > >
> > > > To trick Make and let it fork the subshell, I added a shell special
> > > > character '~'. We may be able to get rid of this workaround someday,
> > > > but it is very far into the future.
> > > >
> > > > [1] 
> > > > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html
> > > >
> > > > Fixes: bd55f96fa9fc ("kbuild: refactor cc-cross-prefix implementation")
> > > > Cc: linux-stable  # 5.1
> > > > Reported-by: Alexey Brodkin 
> > > > Signed-off-by: Masahiro Yamada 
> > > > ---
> > > >
> > > >  scripts/Kbuild.include | 5 -
> > > >  1 file changed, 4 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
> > > > index 85d758233483..5a32ca80c3f6 100644
> > > > --- a/scripts/Kbuild.include
> > > > +++ b/scripts/Kbuild.include
> > > > @@ -74,8 +74,11 @@ endef
> > > >  # Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- 
> > > > m68k-linux-)
&

Re: [PATCH] ARC: build: Try to guess CROSS_COMPILE with cc-cross-prefix

2019-06-03 Thread Masahiro Yamada
On Tue, Jun 4, 2019 at 1:27 AM Vineet Gupta  wrote:
>
> On 6/2/19 11:31 PM, Alexey Brodkin wrote:
> > For a long time we used to hard-code CROSS_COMPILE prefix
> > for ARC until it started to cause problems, so we decided to
> > solely rely on CROSS_COMPILE externally set by a user:
> > commit 40660f1fcee8 ("ARC: build: Don't set CROSS_COMPILE in arch's 
> > Makefile").
> >
> > While it works perfectly fine for build-systems where the prefix
> > gets defined anyways for us human beings it's quite an annoying
> > requirement especially given most of time the same one prefix
> > "arc-linux-" is all what we need.
> >
> > It looks like finally we're getting the best of both worlds:
> >  1. W/o cross-toolchain we still may install headers, build .dtb etc
> >  2. W/ cross-toolchain get the kerne built with only ARCH=arc
> >
> > Inspired by [1] & [2].
> >
> > [1] http://lists.infradead.org/pipermail/linux-snps-arc/2019-May/005788.html
> > [2] 
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fc2b47b55f17
> >
> > A side note: even though "cc-cross-prefix" does its job it pollutes
> > console with output of "which" for all the prefixes it didn't manage to find
> > a matching cross-compiler for like that:
> > | # ARCH=arc make defconfig
> > | which: no arceb-linux-gcc in (~/.local/bin:~/bin:/usr/bin:/usr/sbin)
> > | *** Default configuration is based on 'nsim_hs_defconfig'
> >
> > Signed-off-by: Alexey Brodkin 
> > Cc: Masahiro Yamada 
> > Cc: Vineet Gupta 
>
> Not a big deal but I'd propose we add "Suggested-by: vgupta" since that is 
> where
> it came from.
>
> @Masahiro san I suppose you are OK with this, so perhaps an Ack etc would be 
> nice
> to have.

FWIW,
Reviewed-by: Masahiro Yamada 



-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] kbuild: use more portable 'command -v' for cc-cross-prefix

2019-06-03 Thread Masahiro Yamada
On Mon, Jun 3, 2019 at 8:16 PM David Laight  wrote:
>
> From: Masahiro Yamada
> > Sent: 03 June 2019 11:49
> >
> > To print the pathname that will be used by shell in the current
> > environment, 'command -v' is a standardized way. [1]
> >
> > 'which' is also often used in scripting, but it is not portable.
>
> All uses of 'which' should be expunged.
> It is a bourne shell script that is trying to emulate a csh builtin.
> It is doomed to fail in corner cases.
> ISTR it has serious problems with shell functions and aliases.

OK, I do not have time to check it treewide.
I expect somebody will contribute to it.



BTW, I see yet another way to get the command path.

'type -path' is bash-specific.

Maybe, we should do this too:

diff --git a/scripts/mkuboot.sh b/scripts/mkuboot.sh
index 4b1fe09e9042..77829ee4268e 100755
--- a/scripts/mkuboot.sh
+++ b/scripts/mkuboot.sh
@@ -1,14 +1,14 @@
-#!/bin/bash
+#!/bin/sh
 # SPDX-License-Identifier: GPL-2.0

 #
 # Build U-Boot image when `mkimage' tool is available.
 #

-MKIMAGE=$(type -path "${CROSS_COMPILE}mkimage")
+MKIMAGE=$(command -v "${CROSS_COMPILE}mkimage")

 if [ -z "${MKIMAGE}" ]; then
-   MKIMAGE=$(type -path mkimage)
+   MKIMAGE=$(command -v mkimage)
if [ -z "${MKIMAGE}" ]; then
# Doesn't exist
    echo '"mkimage" command not found - U-Boot images will
not be built' >&2


-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] kbuild: use more portable 'command -v' for cc-cross-prefix

2019-06-03 Thread Masahiro Yamada
Hi David,

On Mon, Jun 3, 2019 at 8:14 PM David Laight  wrote:
>
> From: Masahiro Yamada
> > Sent: 03 June 2019 11:49
> >
> > To print the pathname that will be used by shell in the current
> > environment, 'command -v' is a standardized way. [1]
> >
> > 'which' is also often used in scripting, but it is not portable.
> >
> > When I worked on commit bd55f96fa9fc ("kbuild: refactor cc-cross-prefix
> > implementation"), I was eager to use 'command -v' but it did not work.
> > (The reason is explained below.)
> >
> > I kept 'which' as before but got rid of '> /dev/null 2>&1' as I
> > thought it was no longer needed. Sorry, I was wrong.
> >
> > It works well on my Ubuntu machine, but Alexey Brodkin reports annoying
> > warnings from the 'which' on CentOS 7 when the given command is not
> > found in the PATH environment.
> >
> >   $ which foo
> >   which: no foo in 
> > (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)
> >
> > Given that behavior of 'which' is different on environment, I want
> > to try 'command -v' again.
> >
> > The specification [1] clearly describes the behavior of 'command -v'
> > when the given command is not found:
> >
> >   Otherwise, no output shall be written and the exit status shall reflect
> >   that the name was not found.
> >
> > However, we need a little magic to use 'command -v' from Make.
> >
> > $(shell ...) passes the argument to a subshell for execution, and
> > returns the standard output of the command.
> >
> > Here is a trick. GNU Make may optimize this by executing the command
> > directly instead of forking a subshell, if no shell special characters
> > are found in the command line and omitting the subshell will not
> > change the behavior.
> >
> > In this case, no shell special character is used. So, Make will try
> > to run the command directly. However, 'command' is a shell-builtin
> > command. In fact, Make has a table of shell-builtin commands because
> > it must spawn a subshell to execute them.
> >
> > Until recently, 'command' was missing in the table.
> >
> > This issue was fixed by the following commit:
> >
> > | commit 1af314465e5dfe3e8baa839a32a72e83c04f26ef
> > | Author: Paul Smith 
> > | Date:   Sun Nov 12 18:10:28 2017 -0500
> > |
> > | * job.c: Add "command" as a known shell built-in.
> > |
> > | This is not a POSIX shell built-in but it's common in UNIX shells.
> > | Reported by Nick Bowler .
> >
> > This is not included in any released versions of Make yet.
> > (But, some distributions may have back-ported the fix-up.)
> >
> > To trick Make and let it fork the subshell, I added a shell special
> > character '~'. We may be able to get rid of this workaround someday,
> > but it is very far into the future.
> >
> > [1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html
> >
> > Fixes: bd55f96fa9fc ("kbuild: refactor cc-cross-prefix implementation")
> > Cc: linux-stable  # 5.1
> > Reported-by: Alexey Brodkin 
> > Signed-off-by: Masahiro Yamada 
> > ---
> >
> >  scripts/Kbuild.include | 5 -
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
> > index 85d758233483..5a32ca80c3f6 100644
> > --- a/scripts/Kbuild.include
> > +++ b/scripts/Kbuild.include
> > @@ -74,8 +74,11 @@ endef
> >  # Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- 
> > m68k-linux-)
> >  # Return first  where a gcc is found in PATH.
> >  # If no gcc found in PATH with listed prefixes return nothing
> > +#
> > +# Note: the special character '~' forces Make to invoke a shell. This 
> > workaround
> > +# is needed because this issue was only fixed after GNU Make 4.2.1 release.
> >  cc-cross-prefix = $(firstword $(foreach c, $(filter-out -%, $(1)), \
> > - $(if $(shell which $(c)gcc), $(c
> > + $(if $(shell command -v $(c)gcc ~), $(c
>
> I see a problem here:
> command -v foo bar
> could be deemed to be an error (extra argument).

OK, the specification does not allow to pass arguments
with -v.


> You could use:
> $(shell sh -c "command -v $(c)gcc")
> or maybe:
> $(shell command$${x:+} -v $(c)gcc)


How about this?

  $(shell : ~; command -v $(c)gcc)



-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH] kbuild: use more portable 'command -v' for cc-cross-prefix

2019-06-03 Thread Masahiro Yamada
To print the pathname that will be used by shell in the current
environment, 'command -v' is a standardized way. [1]

'which' is also often used in scripting, but it is not portable.

When I worked on commit bd55f96fa9fc ("kbuild: refactor cc-cross-prefix
implementation"), I was eager to use 'command -v' but it did not work.
(The reason is explained below.)

I kept 'which' as before but got rid of '> /dev/null 2>&1' as I
thought it was no longer needed. Sorry, I was wrong.

It works well on my Ubuntu machine, but Alexey Brodkin reports annoying
warnings from the 'which' on CentOS 7 when the given command is not
found in the PATH environment.

  $ which foo
  which: no foo in 
(/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)

Given that behavior of 'which' is different on environment, I want
to try 'command -v' again.

The specification [1] clearly describes the behavior of 'command -v'
when the given command is not found:

  Otherwise, no output shall be written and the exit status shall reflect
  that the name was not found.

However, we need a little magic to use 'command -v' from Make.

$(shell ...) passes the argument to a subshell for execution, and
returns the standard output of the command.

Here is a trick. GNU Make may optimize this by executing the command
directly instead of forking a subshell, if no shell special characters
are found in the command line and omitting the subshell will not
change the behavior.

In this case, no shell special character is used. So, Make will try
to run the command directly. However, 'command' is a shell-builtin
command. In fact, Make has a table of shell-builtin commands because
it must spawn a subshell to execute them.

Until recently, 'command' was missing in the table.

This issue was fixed by the following commit:

| commit 1af314465e5dfe3e8baa839a32a72e83c04f26ef
| Author: Paul Smith 
| Date:   Sun Nov 12 18:10:28 2017 -0500
|
| * job.c: Add "command" as a known shell built-in.
|
| This is not a POSIX shell built-in but it's common in UNIX shells.
| Reported by Nick Bowler .

This is not included in any released versions of Make yet.
(But, some distributions may have back-ported the fix-up.)

To trick Make and let it fork the subshell, I added a shell special
character '~'. We may be able to get rid of this workaround someday,
but it is very far into the future.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html

Fixes: bd55f96fa9fc ("kbuild: refactor cc-cross-prefix implementation")
Cc: linux-stable  # 5.1
Reported-by: Alexey Brodkin 
Signed-off-by: Masahiro Yamada 
---

 scripts/Kbuild.include | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 85d758233483..5a32ca80c3f6 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -74,8 +74,11 @@ endef
 # Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-)
 # Return first  where a gcc is found in PATH.
 # If no gcc found in PATH with listed prefixes return nothing
+#
+# Note: the special character '~' forces Make to invoke a shell. This 
workaround
+# is needed because this issue was only fixed after GNU Make 4.2.1 release.
 cc-cross-prefix = $(firstword $(foreach c, $(filter-out -%, $(1)), \
-   $(if $(shell which $(c)gcc), $(c
+   $(if $(shell command -v $(c)gcc ~), $(c
 
 # output directory for tests below
 TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
-- 
2.17.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] ARC: build: Try to guess CROSS_COMPILE with cc-cross-prefix

2019-06-03 Thread Masahiro Yamada
Hi Alexey,

On Mon, Jun 3, 2019 at 5:34 PM Alexey Brodkin
 wrote:
>
> Hi Masahiro-san,
>
> > -Original Message-
> > From: Masahiro Yamada 
> > Sent: Monday, June 3, 2019 11:18 AM
> > To: Alexey Brodkin 
> > Cc: arcml ; Linux Kernel Mailing List 
> >  > ker...@vger.kernel.org>; Vineet Gupta 
> > Subject: Re: [PATCH] ARC: build: Try to guess CROSS_COMPILE with 
> > cc-cross-prefix
> >
> > Hi Alexey,
> >
> > On Mon, Jun 3, 2019 at 3:42 PM Alexey Brodkin
> >  wrote:
>
> [snip]
>
> > > A side note: even though "cc-cross-prefix" does its job it pollutes
> > > console with output of "which" for all the prefixes it didn't manage to 
> > > find
> > > a matching cross-compiler for like that:
> > > | # ARCH=arc make defconfig
> > > | which: no arceb-linux-gcc in (~/.local/bin:~/bin:/usr/bin:/usr/sbin)
> > > | *** Default configuration is based on 'nsim_hs_defconfig'
> >
> >
> > Oh really?
> >
> > masahiro@pug:~$ which arc-linux-gcc
> > /home/masahiro/tools/arc/bin/arc-linux-gcc
> > masahiro@pug:~$ which dummy-linux-gcc
> > masahiro@pug:~$ echo $?
> > 1
> >
> >
> > When 'which' cannot find the given command,
> > it does not print anything to stderr.
> >
> > Does it work differently on your machine?
>
> Well on Ubuntu 18.04 indeed which doesn't show anything
> but on my build-server with CentOS 7 I'm getting mentioned verbose output:
> | # cat /etc/redhat-release
> | CentOS Linux release 7.3.1611 (Core)
>
> | # /usr/bin/which -v
> | GNU which v2.20, Copyright (C) 1999 - 2008 Carlo Wood.
> | GNU which comes with ABSOLUTELY NO WARRANTY;
> | This program is free software; your freedom to use, change
> | and distribute this program is protected by the GPL.


OK, confirmed.

Probably using 'which' is a bad idea
since this is not portable.

I will send a fix-up patch soon.



-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] ARC: build: Try to guess CROSS_COMPILE with cc-cross-prefix

2019-06-03 Thread Masahiro Yamada
Hi Alexey,

On Mon, Jun 3, 2019 at 3:42 PM Alexey Brodkin
 wrote:
>
> For a long time we used to hard-code CROSS_COMPILE prefix
> for ARC until it started to cause problems, so we decided to
> solely rely on CROSS_COMPILE externally set by a user:
> commit 40660f1fcee8 ("ARC: build: Don't set CROSS_COMPILE in arch's 
> Makefile").
>
> While it works perfectly fine for build-systems where the prefix
> gets defined anyways for us human beings it's quite an annoying
> requirement especially given most of time the same one prefix
> "arc-linux-" is all what we need.
>
> It looks like finally we're getting the best of both worlds:
>  1. W/o cross-toolchain we still may install headers, build .dtb etc
>  2. W/ cross-toolchain get the kerne built with only ARCH=arc
>
> Inspired by [1] & [2].
>
> [1] http://lists.infradead.org/pipermail/linux-snps-arc/2019-May/005788.html
> [2] 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fc2b47b55f17
>
> A side note: even though "cc-cross-prefix" does its job it pollutes
> console with output of "which" for all the prefixes it didn't manage to find
> a matching cross-compiler for like that:
> | # ARCH=arc make defconfig
> | which: no arceb-linux-gcc in (~/.local/bin:~/bin:/usr/bin:/usr/sbin)
> | *** Default configuration is based on 'nsim_hs_defconfig'


Oh really?

masahiro@pug:~$ which arc-linux-gcc
/home/masahiro/tools/arc/bin/arc-linux-gcc
masahiro@pug:~$ which dummy-linux-gcc
masahiro@pug:~$ echo $?
1


When 'which' cannot find the given command,
it does not print anything to stderr.

Does it work differently on your machine?




-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH] clocksource: arc_timer: use BIT() instead of _BITUL()

2019-05-23 Thread Masahiro Yamada
This is in-kernel C code, so there is no reason to use _BITUL().
Replace it with equivalent BIT().

I added #include  explicitly although it has been included
by other headers eventually.

Signed-off-by: Masahiro Yamada 
---

 drivers/clocksource/arc_timer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/clocksource/arc_timer.c b/drivers/clocksource/arc_timer.c
index b28970ca4a7a..b1f21bf3b83c 100644
--- a/drivers/clocksource/arc_timer.c
+++ b/drivers/clocksource/arc_timer.c
@@ -16,6 +16,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -142,7 +143,7 @@ static u64 arc_read_rtc(struct clocksource *cs)
l = read_aux_reg(AUX_RTC_LOW);
h = read_aux_reg(AUX_RTC_HIGH);
status = read_aux_reg(AUX_RTC_CTRL);
-   } while (!(status & _BITUL(31)));
+   } while (!(status & BIT(31)));
 
return (((u64)h) << 32) | l;
 }
-- 
2.17.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] arc: remove redundant kernel-space generic-y

2019-01-16 Thread Masahiro Yamada
Hi Vineet,


On Thu, Dec 20, 2018 at 4:52 AM Vineet Gupta  wrote:
>
> On 12/19/18 7:16 AM, Masahiro Yamada wrote:
> > Could you pick this up to your arc tree?
>
> Done, will push it in a day or so !
>
> Thx,
> -Vineet

This was not sent in the previous MW.
(Nor did I see ARC pull request.)

Is it aiming for v5.1-rc1 ?




-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] arc: remove redundant kernel-space generic-y

2018-12-19 Thread Masahiro Yamada
Hi Vineet,

On Mon, Dec 17, 2018 at 2:07 PM Vineet Gupta  wrote:
>
> On 12/16/18 6:17 AM, Masahiro Yamada wrote:
> > This commit removes redundant generic-y defines in
> > arch/arc/include/asm/Kbuild.
> >
> > It is redundant to define generic-y when arch-specific implementation
> > exists in arch/$(ARCH)/include/asm/*.h
> >
> > Remove the following generic-y:
> >
> > dma-mapping.h
> >     fb.h
> > kmap_types.h
> > pci.h
> >
> > Signed-off-by: Masahiro Yamada 
>
> Acked-by: Vineet Gupta 


Could you pick this up to your arc tree?


-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH] arc: remove redundant kernel-space generic-y

2018-12-16 Thread Masahiro Yamada
This commit removes redundant generic-y defines in
arch/arc/include/asm/Kbuild.

It is redundant to define generic-y when arch-specific implementation
exists in arch/$(ARCH)/include/asm/*.h

Remove the following generic-y:

dma-mapping.h
fb.h
kmap_types.h
pci.h

Signed-off-by: Masahiro Yamada 
---

 arch/arc/include/asm/Kbuild | 4 
 1 file changed, 4 deletions(-)

diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild
index feed50c..caa2702 100644
--- a/arch/arc/include/asm/Kbuild
+++ b/arch/arc/include/asm/Kbuild
@@ -3,23 +3,19 @@ generic-y += bugs.h
 generic-y += compat.h
 generic-y += device.h
 generic-y += div64.h
-generic-y += dma-mapping.h
 generic-y += emergency-restart.h
 generic-y += extable.h
-generic-y += fb.h
 generic-y += ftrace.h
 generic-y += hardirq.h
 generic-y += hw_irq.h
 generic-y += irq_regs.h
 generic-y += irq_work.h
-generic-y += kmap_types.h
 generic-y += local.h
 generic-y += local64.h
 generic-y += mcs_spinlock.h
 generic-y += mm-arch-hooks.h
 generic-y += msi.h
 generic-y += parport.h
-generic-y += pci.h
 generic-y += percpu.h
 generic-y += preempt.h
 generic-y += topology.h
-- 
2.7.4


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 3/3] arch: remove redundant generic-y defines

2018-12-05 Thread Masahiro Yamada
Now that Kbuild automatically creates asm-generic wrappers for missing
mandatory headers, it is redundant to list the same headers in
generic-y and mandatory-y.

Suggested-by: Sam Ravnborg 
Signed-off-by: Masahiro Yamada 
---

 arch/alpha/include/uapi/asm/Kbuild  |  5 -
 arch/arc/include/uapi/asm/Kbuild| 23 ---
 arch/arm/include/uapi/asm/Kbuild| 15 ---
 arch/arm64/include/uapi/asm/Kbuild  | 17 -
 arch/c6x/include/uapi/asm/Kbuild| 25 -
 arch/h8300/include/uapi/asm/Kbuild  | 25 -
 arch/hexagon/include/uapi/asm/Kbuild| 22 --
 arch/ia64/include/uapi/asm/Kbuild   |  5 -
 arch/m68k/include/uapi/asm/Kbuild   | 18 --
 arch/microblaze/include/uapi/asm/Kbuild | 24 
 arch/mips/include/uapi/asm/Kbuild   |  1 -
 arch/nds32/include/uapi/asm/Kbuild  | 24 
 arch/nios2/include/uapi/asm/Kbuild  | 24 
 arch/openrisc/include/uapi/asm/Kbuild   | 26 --
 arch/parisc/include/uapi/asm/Kbuild |  5 -
 arch/powerpc/include/uapi/asm/Kbuild|  6 --
 arch/riscv/include/uapi/asm/Kbuild  | 25 -
 arch/s390/include/uapi/asm/Kbuild   | 14 --
 arch/sh/include/uapi/asm/Kbuild | 17 -
 arch/sparc/include/uapi/asm/Kbuild  |  1 -
 arch/unicore32/include/uapi/asm/Kbuild  | 27 ---
 arch/x86/include/uapi/asm/Kbuild|  1 -
 arch/xtensa/include/uapi/asm/Kbuild |  8 
 23 files changed, 358 deletions(-)

diff --git a/arch/alpha/include/uapi/asm/Kbuild 
b/arch/alpha/include/uapi/asm/Kbuild
index 1a5b753..14a2e9a 100644
--- a/arch/alpha/include/uapi/asm/Kbuild
+++ b/arch/alpha/include/uapi/asm/Kbuild
@@ -2,8 +2,3 @@
 include include/uapi/asm-generic/Kbuild.asm
 
 generic-y += bpf_perf_event.h
-generic-y += ipcbuf.h
-generic-y += msgbuf.h
-generic-y += poll.h
-generic-y += sembuf.h
-generic-y += shmbuf.h
diff --git a/arch/arc/include/uapi/asm/Kbuild b/arch/arc/include/uapi/asm/Kbuild
index 170b5db..f53f8e4 100644
--- a/arch/arc/include/uapi/asm/Kbuild
+++ b/arch/arc/include/uapi/asm/Kbuild
@@ -1,29 +1,6 @@
 # UAPI Header export list
 include include/uapi/asm-generic/Kbuild.asm
 
-generic-y += auxvec.h
-generic-y += bitsperlong.h
 generic-y += bpf_perf_event.h
-generic-y += errno.h
-generic-y += fcntl.h
-generic-y += ioctl.h
-generic-y += ioctls.h
-generic-y += ipcbuf.h
 generic-y += kvm_para.h
-generic-y += mman.h
-generic-y += msgbuf.h
-generic-y += param.h
-generic-y += poll.h
-generic-y += posix_types.h
-generic-y += resource.h
-generic-y += sembuf.h
-generic-y += shmbuf.h
-generic-y += siginfo.h
-generic-y += socket.h
-generic-y += sockios.h
-generic-y += stat.h
-generic-y += statfs.h
-generic-y += termbits.h
-generic-y += termios.h
-generic-y += types.h
 generic-y += ucontext.h
diff --git a/arch/arm/include/uapi/asm/Kbuild b/arch/arm/include/uapi/asm/Kbuild
index 4d1cc18..279edb1 100644
--- a/arch/arm/include/uapi/asm/Kbuild
+++ b/arch/arm/include/uapi/asm/Kbuild
@@ -6,19 +6,4 @@ generated-y += unistd-common.h
 generated-y += unistd-oabi.h
 generated-y += unistd-eabi.h
 
-generic-y += bitsperlong.h
 generic-y += bpf_perf_event.h
-generic-y += errno.h
-generic-y += ioctl.h
-generic-y += ipcbuf.h
-generic-y += msgbuf.h
-generic-y += param.h
-generic-y += poll.h
-generic-y += resource.h
-generic-y += sembuf.h
-generic-y += shmbuf.h
-generic-y += siginfo.h
-generic-y += socket.h
-generic-y += sockios.h
-generic-y += termbits.h
-generic-y += termios.h
diff --git a/arch/arm64/include/uapi/asm/Kbuild 
b/arch/arm64/include/uapi/asm/Kbuild
index 6c5adf4..bca548a 100644
--- a/arch/arm64/include/uapi/asm/Kbuild
+++ b/arch/arm64/include/uapi/asm/Kbuild
@@ -2,21 +2,4 @@
 # UAPI Header export list
 include include/uapi/asm-generic/Kbuild.asm
 
-generic-y += errno.h
-generic-y += ioctl.h
-generic-y += ioctls.h
-generic-y += ipcbuf.h
 generic-y += kvm_para.h
-generic-y += mman.h
-generic-y += msgbuf.h
-generic-y += poll.h
-generic-y += resource.h
-generic-y += sembuf.h
-generic-y += shmbuf.h
-generic-y += socket.h
-generic-y += sockios.h
-generic-y += swab.h
-generic-y += termbits.h
-generic-y += termios.h
-generic-y += types.h
-generic-y += siginfo.h
diff --git a/arch/c6x/include/uapi/asm/Kbuild b/arch/c6x/include/uapi/asm/Kbuild
index 26644e1..f53f8e4 100644
--- a/arch/c6x/include/uapi/asm/Kbuild
+++ b/arch/c6x/include/uapi/asm/Kbuild
@@ -1,31 +1,6 @@
 # UAPI Header export list
 include include/uapi/asm-generic/Kbuild.asm
 
-generic-y += auxvec.h
-generic-y += bitsperlong.h
 generic-y += bpf_perf_event.h
-generic-y += errno.h
-generic-y += fcntl.h
-generic-y += ioctl.h
-generic-y += ioctls.h
-generic-y += ipcbuf.h
 generic-y += kvm_para.h
-generic-y += mman.h
-generic-y += msgbuf.h
-generic-y += param.h
-generic-y += poll.h
-generic-y

Re: [PATCH v3 6/9] kbuild: consolidate Devicetree dtb build rules

2018-10-01 Thread Masahiro Yamada
Hi Rob,


2018年10月1日(月) 22:26 Rob Herring :
>
> On Mon, Oct 1, 2018 at 12:49 AM Masahiro Yamada
>  wrote:
> >
> > Hi Rob,
> >
> >
> > 2018年9月29日(土) 0:43 Rob Herring :
> >
> > > +#
> > > ---
> > > +# Devicetree files
> > > +
> > > +ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/boot/dts/),)
> > > +dtstree := arch/$(SRCARCH)/boot/dts
> > > +endif
> > > +
> > > +ifneq ($(dtstree),)
> > > +
> > > +%.dtb : scripts_dtc
> >
> > %.dtb: prepare3 prepare
>
> I assume you didn't mean to drop scripts_dtc as that doesn't work.
>
> Why "prepare" here and not on dtbs?


Sorry, my mistake.


%.dtb: prepare3 scripts_dtc

is the correct one.



> > because we need to make sure KERNELRELEASE
> > is correctly defined before dtbs_install happens.
>
> Yes, indeed. With prepare3 added I get:
>
> cp: cannot create regular file
> '/boot/dtbs/4.19.0-rc3-9-g0afba9b7b2ea-dirty': No such file or
> directory
>
> vs. with it:
>
> cp: cannot create regular file '/boot/dtbs/': Not a directory
>
> >
> >
> > > +   $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
> > > +
> > > +PHONY += dtbs dtbs_install
> > > +dtbs: scripts_dtc
> >
> >
> > dtbs: prepare3 scripts_dtc
> >
> >
> >
> > > +   $(Q)$(MAKE) $(build)=$(dtstree)
> > > +
> > > +dtbs_install: dtbs
> >
> >
> > Please do not have dtbs_install to depend on dtbs.
> >
> > No install targets should ever trigger building anything
> > in the source tree.
> >
> >
> > For the background, see the commit log of
> > 19514fc665ffbce624785f76ee7ad0ea6378a527
>
> Okay, thanks.
>
> Rob



-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

Re: [PATCH v3 6/9] kbuild: consolidate Devicetree dtb build rules

2018-09-30 Thread Masahiro Yamada
Hi Rob,


2018年9月29日(土) 0:43 Rob Herring :

> +#
> ---
> +# Devicetree files
> +
> +ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/boot/dts/),)
> +dtstree := arch/$(SRCARCH)/boot/dts
> +endif
> +
> +ifneq ($(dtstree),)
> +
> +%.dtb : scripts_dtc

%.dtb: prepare3 prepare


because we need to make sure KERNELRELEASE
is correctly defined before dtbs_install happens.


> +   $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
> +
> +PHONY += dtbs dtbs_install
> +dtbs: scripts_dtc


dtbs: prepare3 scripts_dtc



> +   $(Q)$(MAKE) $(build)=$(dtstree)
> +
> +dtbs_install: dtbs


Please do not have dtbs_install to depend on dtbs.

No install targets should ever trigger building anything
in the source tree.


For the background, see the commit log of
19514fc665ffbce624785f76ee7ad0ea6378a527




> +   $(Q)$(MAKE) $(dtbinst)=$(dtstree)
> +
> +ifdef CONFIG_OF_EARLY_FLATTREE
> +all: dtbs
> +endif
> +
> +endif
> +
> +PHONY += scripts_dtc
> +scripts_dtc: scripts_basic
> +   $(Q)$(MAKE) $(build)=scripts/dtc
> +
>  #
> -------
>  # Modules
>


-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

Re: [PATCH v3 6/9] kbuild: consolidate Devicetree dtb build rules

2018-09-23 Thread Masahiro Yamada
2018-09-13 11:51 GMT-04:00 Geert Uytterhoeven :
> Hi Yamada-san,
>
> On Wed, Sep 12, 2018 at 3:02 AM Masahiro Yamada
>  wrote:
>> 2018-09-12 0:40 GMT+09:00 Rob Herring :
>> > On Mon, Sep 10, 2018 at 10:04 AM Rob Herring  wrote:
>> >> There is nothing arch specific about building dtb files other than their
>> >> location under /arch/*/boot/dts/. Keeping each arch aligned is a pain.
>> >> The dependencies and supported targets are all slightly different.
>> >> Also, a cross-compiler for each arch is needed, but really the host
>> >> compiler preprocessor is perfectly fine for building dtbs. Move the
>> >> build rules to a common location and remove the arch specific ones. This
>> >> is done in a single step to avoid warnings about overriding rules.
>> >>
>> >> The build dependencies had been a mixture of 'scripts' and/or 'prepare'.
>> >> These pull in several dependencies some of which need a target compiler
>> >> (specifically devicetable-offsets.h) and aren't needed to build dtbs.
>> >> All that is really needed is dtc, so adjust the dependencies to only be
>> >> dtc.
>> >>
>> >> This change enables support 'dtbs_install' on some arches which were
>> >> missing the target.
>> >
>> > [...]
>> >
>> >> @@ -1215,6 +1215,33 @@ kselftest-merge:
>> >> $(srctree)/tools/testing/selftests/*/config
>> >> +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
>> >>
>> >> +# 
>> >> ---
>> >> +# Devicetree files
>> >> +
>> >> +ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/boot/dts/),)
>> >> +dtstree := arch/$(SRCARCH)/boot/dts
>> >> +endif
>> >> +
>> >> +ifdef CONFIG_OF_EARLY_FLATTREE
>> >
>> > This can be true when dtstree is unset. So this line should be this
>> > instead to fix the 0-day reported error:
>> >
>> > ifneq ($(dtstree),)
>> >
>> >> +
>> >> +%.dtb : scripts_dtc
>> >> +   $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
>> >> +
>> >> +PHONY += dtbs dtbs_install
>> >> +dtbs: scripts_dtc
>> >> +   $(Q)$(MAKE) $(build)=$(dtstree)
>> >> +
>> >> +dtbs_install: dtbs
>> >> +   $(Q)$(MAKE) $(dtbinst)=$(dtstree)
>> >> +
>> >> +all: dtbs
>> >> +
>> >> +endif
>>
>>
>> Ah, right.
>> Even x86 can enable OF and OF_UNITTEST.
>>
>>
>>
>> Another solution might be,
>> guard it by 'depends on ARCH_SUPPORTS_OF'.
>>
>>
>>
>> This is actually what ACPI does.
>>
>> menuconfig ACPI
>> bool "ACPI (Advanced Configuration and Power Interface) Support"
>> depends on ARCH_SUPPORTS_ACPI
>>  ...
>
> ACPI is a real platform feature, as it depends on firmware.
>
> CONFIG_OF can be enabled, and DT overlays can be loaded, on any platform,
> even if it has ACPI ;-)
>

OK, understood.

Thanks!



-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: defconfig fails if CROSS_COMPILE is set while cross-gcc is not avaialble

2018-09-12 Thread Masahiro Yamada
Hi Alexey,

2018-09-12 22:43 GMT+09:00 Alexey Brodkin :
> Hi Masahiro,
>
> On Wed, 2018-09-12 at 21:53 +0900, Masahiro Yamada wrote:
>> Hi Alexey.
>>
>> 2018-09-12 21:08 GMT+09:00 Alexey Brodkin :
>> > Hello Masahiro-san,
>> >
>> > Starting from kernel v4.17 it is no longer possible to install kernel 
>> > headers
>> > for ARC architecture if there's no cross-toolchain in PATH.
>>
>>
>> Really?
>>
>> I can do 'make ARCH=arc headers_install'
>> with the latest Linus' tree.
>
> Indeed "headers_install" works that way but is it OK to install headers
> without previous configuration. In my experiment I don't see any differences
> though for example OpenEmbedded on configuration step of "linux-libc-headers"
> do "ARCH=xxx make allnoconfig", see
> https://github.com/openembedded/openembedded-core/blob/master/meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc#L57
>
> That might be some legacy but I'm not really sure,
> worth asking OE people.
>
> For the record in Buildroot no configuration happens for Linux headers,
> see 
> https://git.buildroot.org/buildroot/tree/package/linux-headers/linux-headers.mk#n106


Buildroot is right.

The exported headers should be independent of the kernel configuration.

The interface between user-space and kernel must be stable.
It is strange if it is changed depending on how you configure the kernel.





>> I see the following warnings, but possible to install kernel headers.
>>
>> ./scripts/gcc-version.sh: line 26: arc-linux-gcc: command not found
>> ./scripts/gcc-version.sh: line 27: arc-linux-gcc: command not found
>
> Right... that happens because we're doing 2 hackish things:
> 1. Checking if current toolchain is configured for ARCompact (ARCv1) ISA
>or ARCv2. That's because we use toolchain's libgcc and so we want to warn
>a user if wrong toolchain is used early instead of leaving him to deal with
>final linkage failure.
>See: 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arc/Makefile#n23
>
> 2. Asking CC for a path to libgcc
>See: 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arc/Makefile#n82
>
> [snip]
>
>> I am trying to fix even those warnings
>> by eliminating unneeded compiler invocation.  It is WIP.
>
> And if (1) is not super important (in fact we used to live without it for 
> years)
> (2) requires implementation of libgcc in kernel sources (which BTW will make 
> (1)
> obsolete immediately). We do have it on our todo list though...
> [snip]
>
>> > That doesn't happen for ARM and other arches simply because for ARC
>> > we define CROSS_COMPILE if it is not set by user, see:
>> >
> https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_torvalds_linux.git_tree_arch_arc_Makefile-23n9=DwIBaQ=DPL6_X_6JkXFx7AXWqB0tg=lqdeeSSEes0GFDDl656eViXO7breS55ytWkhpk5R81I=zJsa5MrAtDiYEWr5PZNS1aGk21ETa-qXzLPIddwvoQI=BU0ltPPoRLn3np_ba4HRHfH9i141uZjoS8jsJrg8SNc=
>>
>> I do not think it is a good practice
>> to forcibly set CROSS_COMPILE that users may not have.
>
> Maybe so. Still some arches or random platforms do that.
>
>> arch/m68k/Makefile uses cc-cross-prefix helper
>> to set the first found compiler.
>
> Well I'm not really sure we need to mess with CROSS_COMPILE in kernel.
> I.e. there might be tons of variations depending on who toolchain was built
> etc. So I'd better get rid of CROSS_COMPILE setup in our Makefile.


Agree.  Getting rid of CROSS_COMPILE is better.



>> > Still if CROSS_COMPILE is set before execution of "make defconfig"
>> > then the same problem happens for others.
>> >
>> > I was able to find a series of commits which cause this problem,
>> > here they are:
>> > ->8--
>> > 59f53855babf - gcc-plugins: test plugin support in Kconfig and clean up 
>> > Makefile
>> > 469cb7376c06 - kconfig: add CC_IS_CLANG and CLANG_VERSION
>> > a4353898980c - kconfig: add CC_IS_GCC and GCC_VERSION
>> > ->8--
>> >
>> > What happen is "$(CC)" is passed as an argument and in its turn CC is
>> > "$(CROSS_COMPILE)gcc", see:
>> >
> https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_torvalds_linux.git_tree_Makefile-23n385=DwIBaQ=DPL6_X_6JkXFx7AXWqB0tg=lqdeeSSEes0GFDDl656eViXO7breS55ytWkhpk5R81I=zJsa5MrAtDiYEWr5PZNS1aGk21ETa-qXzLPIddwvoQI=S7zeHBpIp1P94XbyoMsaSnJWRq

Re: defconfig fails if CROSS_COMPILE is set while cross-gcc is not avaialble

2018-09-12 Thread Masahiro Yamada
Hi Alexey.

2018-09-12 21:08 GMT+09:00 Alexey Brodkin :
> Hello Masahiro-san,
>
> Starting from kernel v4.17 it is no longer possible to install kernel headers
> for ARC architecture if there's no cross-toolchain in PATH.


Really?

I can do 'make ARCH=arc headers_install'
with the latest Linus' tree.

I see the following warnings, but possible to install kernel headers.

./scripts/gcc-version.sh: line 26: arc-linux-gcc: command not found
./scripts/gcc-version.sh: line 27: arc-linux-gcc: command not found


If ARC compiler is not found in PATH,
those warnings are displayed with v4.16 or older as well.

I do not see much difference in the behavior.


I am trying to fix even those warnings
by eliminating unneeded compiler invocation.  It is WIP.



> Note installation of headers is just one of use-cases when we might not
> have cross-tools available but still want to run "make xxx_defconfig".
> I.e. the problem is "make xxx_defconfig" with no cross-toolchain.
>
> That's what I see:
> ->8--
> ./scripts/gcc-version.sh: line 26: arc-linux-gcc: command not found
> ./scripts/gcc-version.sh: line 27: arc-linux-gcc: command not found
> ./scripts/gcc-version.sh: line 26: arc-linux-gcc: command not found
> ./scripts/gcc-version.sh: line 27: arc-linux-gcc: command not found
> make: arc-linux-gcc: Command not found
> /bin/sh: arc-linux-gcc: command not found
> /bin/sh: arc-linux-gcc: command not found
> *** Default configuration is based on 'nsim_700_defconfig'
> ./scripts/gcc-version.sh: line 26: arc-linux-gcc: command not found
> ./scripts/gcc-version.sh: line 27: arc-linux-gcc: command not found
> ./scripts/gcc-version.sh: line 29: arc-linux-gcc: command not found
> ./scripts/gcc-version.sh: line 26: arc-linux-gcc: command not found
> ./scripts/gcc-version.sh: line 27: arc-linux-gcc: command not found
> ./scripts/gcc-version.sh: line 29: arc-linux-gcc: command not found
> init/Kconfig:17: syntax error
> init/Kconfig:16: invalid option
> ./scripts/clang-version.sh: line 15: arc-linux-gcc: command not found
> ./scripts/gcc-plugin.sh: line 11: arc-linux-gcc: command not found
> make[1]: *** [scripts/kconfig/Makefile:91: defconfig] Error 1
> make: *** [Makefile:531: defconfig] Error 2
> ->8--
>
> That doesn't happen for ARM and other arches simply because for ARC
> we define CROSS_COMPILE if it is not set by user, see:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arc/Makefile#n9

I do not think it is a good practice
to forcibly set CROSS_COMPILE that users may not have.

arch/m68k/Makefile uses cc-cross-prefix helper
to set the first found compiler.


> Still if CROSS_COMPILE is set before execution of "make defconfig"
> then the same problem happens for others.
>
> I was able to find a series of commits which cause this problem,
> here they are:
> ->8--
> 59f53855babf - gcc-plugins: test plugin support in Kconfig and clean up 
> Makefile
> 469cb7376c06 - kconfig: add CC_IS_CLANG and CLANG_VERSION
> a4353898980c - kconfig: add CC_IS_GCC and GCC_VERSION
> ->8--
>
> What happen is "$(CC)" is passed as an argument and in its turn CC is
> "$(CROSS_COMPILE)gcc", see:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Makefile#n385
>
>
> So if I substitute "CC" with "HOSTCC" in a couple of places (see below)
> the problem goes away. But I'm not really sure if what I do is correct.
> I.e. when we're interested in CC for target and when only host CC is of
> our interest.

I think the log of commit 316d55d55f49eca44
is a good source to know the background of this change.

Now Kconfig requires the target compiler.
So, it does not make sense to
do defconfig with non-existing compiler.



> Would be interesting to know your opinion here.

I'd recommend to not hard-code CROSS_COMPILE.



Thanks.

-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v3 6/9] kbuild: consolidate Devicetree dtb build rules

2018-09-11 Thread Masahiro Yamada
2018-09-12 0:40 GMT+09:00 Rob Herring :
> On Mon, Sep 10, 2018 at 10:04 AM Rob Herring  wrote:
>>
>> There is nothing arch specific about building dtb files other than their
>> location under /arch/*/boot/dts/. Keeping each arch aligned is a pain.
>> The dependencies and supported targets are all slightly different.
>> Also, a cross-compiler for each arch is needed, but really the host
>> compiler preprocessor is perfectly fine for building dtbs. Move the
>> build rules to a common location and remove the arch specific ones. This
>> is done in a single step to avoid warnings about overriding rules.
>>
>> The build dependencies had been a mixture of 'scripts' and/or 'prepare'.
>> These pull in several dependencies some of which need a target compiler
>> (specifically devicetable-offsets.h) and aren't needed to build dtbs.
>> All that is really needed is dtc, so adjust the dependencies to only be
>> dtc.
>>
>> This change enables support 'dtbs_install' on some arches which were
>> missing the target.
>
> [...]
>
>> @@ -1215,6 +1215,33 @@ kselftest-merge:
>> $(srctree)/tools/testing/selftests/*/config
>> +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
>>
>> +# 
>> ---
>> +# Devicetree files
>> +
>> +ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/boot/dts/),)
>> +dtstree := arch/$(SRCARCH)/boot/dts
>> +endif
>> +
>> +ifdef CONFIG_OF_EARLY_FLATTREE
>
> This can be true when dtstree is unset. So this line should be this
> instead to fix the 0-day reported error:
>
> ifneq ($(dtstree),)
>
>> +
>> +%.dtb : scripts_dtc
>> +   $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
>> +
>> +PHONY += dtbs dtbs_install
>> +dtbs: scripts_dtc
>> +   $(Q)$(MAKE) $(build)=$(dtstree)
>> +
>> +dtbs_install: dtbs
>> +   $(Q)$(MAKE) $(dtbinst)=$(dtstree)
>> +
>> +all: dtbs
>> +
>> +endif


Ah, right.
Even x86 can enable OF and OF_UNITTEST.



Another solution might be,
guard it by 'depends on ARCH_SUPPORTS_OF'.



This is actually what ACPI does.

menuconfig ACPI
bool "ACPI (Advanced Configuration and Power Interface) Support"
depends on ARCH_SUPPORTS_ACPI
 ...





-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 6/8] kbuild: consolidate Devicetree dtb build rules

2018-09-07 Thread Masahiro Yamada
2018-08-27 8:56 GMT+09:00 Rob Herring :
> On Sat, Aug 25, 2018 at 9:06 PM Masahiro Yamada
>  wrote:
>>
>> Hi Rob,
>>
>>
>> 2018-08-22 6:55 GMT+09:00 Rob Herring :
>> > There is nothing arch specific about building dtb files other than their
>> > location under /arch/*/boot/dts/. Keeping each arch aligned is a pain.
>> > The dependencies and supported targets are all slightly different.
>> > Also, a cross-compiler for each arch is needed, but really the host
>> > compiler preprocessor is perfectly fine for building dtbs. Move the
>> > build rules to a common location and remove the arch specific ones. This
>> > is done in a single step to avoid warnings about overriding rules.
>> >
>> > The build dependencies had been a mixture of 'scripts' and/or 'prepare'.
>> > These pull in several dependencies some of which need a target compiler
>> > (specifically devicetable-offsets.h) and aren't needed to build dtbs.
>> > All that is really needed is dtc, so adjust the dependencies to only be
>> > dtc.
>> >
>> > This change enables support 'dtbs_install' on some arches which were
>> > missing the target.
>> >
>> > Cc: Masahiro Yamada 
>> > Cc: Michal Marek 
>> > Cc: Vineet Gupta 
>> > Cc: Russell King 
>> > Cc: Catalin Marinas 
>> > Cc: Will Deacon 
>> > Cc: Yoshinori Sato 
>> > Cc: Michal Simek 
>> > Cc: Ralf Baechle 
>> > Cc: Paul Burton 
>> > Cc: James Hogan 
>> > Cc: Ley Foon Tan 
>> > Cc: Benjamin Herrenschmidt 
>> > Cc: Paul Mackerras 
>> > Cc: Michael Ellerman 
>> > Cc: Chris Zankel 
>> > Cc: Max Filippov 
>> > Cc: linux-kbu...@vger.kernel.org
>> > Cc: linux-snps-arc@lists.infradead.org
>> > Cc: linux-arm-ker...@lists.infradead.org
>> > Cc: uclinux-h8-de...@lists.sourceforge.jp
>> > Cc: linux-m...@linux-mips.org
>> > Cc: nios2-...@lists.rocketboards.org
>> > Cc: linuxppc-...@lists.ozlabs.org
>> > Cc: linux-xte...@linux-xtensa.org
>> > Signed-off-by: Rob Herring 
>> > ---
>> >  Makefile | 30 ++
>> >  arch/arc/Makefile|  6 --
>> >  arch/arm/Makefile| 20 +---
>> >  arch/arm64/Makefile  | 17 +
>> >  arch/c6x/Makefile|  2 --
>> >  arch/h8300/Makefile  | 11 +--
>> >  arch/microblaze/Makefile |  4 +---
>> >  arch/mips/Makefile   | 15 +--
>> >  arch/nds32/Makefile  |  2 +-
>> >  arch/nios2/Makefile  |  7 ---
>> >  arch/nios2/boot/Makefile |  4 
>> >  arch/powerpc/Makefile|  3 ---
>> >  arch/xtensa/Makefile | 12 +---
>> >  scripts/Makefile |  1 -
>> >  scripts/Makefile.lib |  2 +-
>> >  15 files changed, 38 insertions(+), 98 deletions(-)
>> >
>> > diff --git a/Makefile b/Makefile
>> > index c13f8b85ba60..6d89e673f192 100644
>> > --- a/Makefile
>> > +++ b/Makefile
>> > @@ -1212,6 +1212,30 @@ kselftest-merge:
>> > $(srctree)/tools/testing/selftests/*/config
>> > +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
>> >
>> > +# 
>> > ---
>> > +# Devicetree files
>> > +
>> > +dtstree := $(wildcard arch/$(SRCARCH)/boot/dts)
>
> BTW, there's an error here too. It doesn't work right with
> KBUILD_OUTPUT set and should be:
>
> ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/boot/dts/),)
> dtstree := arch/$(SRCARCH)/boot/dts
> endif
>
>> > +
>> > +ifdef CONFIG_OF_EARLY_FLATTREE
>> > +
>> > +%.dtb %.dtb.S %.dtb.o: | dtc
>>
>> I think the pipe operator is unnecessary
>> because Kbuild will descend to $(dtstree) anyway.
>
> The pipe means 'order-only', right?

Yes.

> So it is just a weaker dependency
> for things which are not input files as dtc is not. The 'dtc' here is
> just the dtc rule below, not the actual executable. Or am I missing
> something?


The pipe is used when

  - we want to make sure the weaker prerequisite exists

  - but, we do not want to execute the recipe
even if the weaker prerequisite is updated


In this case, we want to execute the recipe _all_the_time_.

We compare the timestamp between %.dtb and %.dts in the sub-directory.

We never know the real depenency until the following recipe is run
 $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@



PHONY += dtbs
dtbs: | dtc
  $(Q)$(MAKE) $(build)=$(dtstree)

Here 'dtbs' is a PHONY target.
We always want to run the recipe.
The pipe operator is not sensible.


-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v2 6/9] kbuild: consolidate Devicetree dtb build rules

2018-09-07 Thread Masahiro Yamada
Hi Rob,

2018-09-07 21:17 GMT+09:00 Rob Herring :
> On Fri, Sep 7, 2018 at 5:33 AM Masahiro Yamada
>  wrote:
>>
>> 2018-09-06 8:53 GMT+09:00 Rob Herring :
>> > There is nothing arch specific about building dtb files other than their
>> > location under /arch/*/boot/dts/. Keeping each arch aligned is a pain.
>> > The dependencies and supported targets are all slightly different.
>> > Also, a cross-compiler for each arch is needed, but really the host
>> > compiler preprocessor is perfectly fine for building dtbs. Move the
>> > build rules to a common location and remove the arch specific ones. This
>> > is done in a single step to avoid warnings about overriding rules.
>> >
>> > The build dependencies had been a mixture of 'scripts' and/or 'prepare'.
>> > These pull in several dependencies some of which need a target compiler
>> > (specifically devicetable-offsets.h) and aren't needed to build dtbs.
>> > All that is really needed is dtc, so adjust the dependencies to only be
>> > dtc.
>> >
>> > This change enables support 'dtbs_install' on some arches which were
>> > missing the target.
>> >
>> > Cc: Masahiro Yamada 
>> > Cc: Michal Marek 
>> > Cc: Vineet Gupta 
>> > Cc: Russell King 
>> > Cc: Catalin Marinas 
>> > Cc: Will Deacon 
>> > Cc: Yoshinori Sato 
>> > Cc: Michal Simek 
>> > Cc: Ralf Baechle 
>> > Cc: Paul Burton 
>> > Cc: James Hogan 
>> > Cc: Ley Foon Tan 
>> > Cc: Benjamin Herrenschmidt 
>> > Cc: Paul Mackerras 
>> > Cc: Michael Ellerman 
>> > Cc: Chris Zankel 
>> > Cc: Max Filippov 
>> > Cc: linux-kbu...@vger.kernel.org
>> > Cc: linux-snps-arc@lists.infradead.org
>> > Cc: linux-arm-ker...@lists.infradead.org
>> > Cc: uclinux-h8-de...@lists.sourceforge.jp
>> > Cc: linux-m...@linux-mips.org
>> > Cc: nios2-...@lists.rocketboards.org
>> > Cc: linuxppc-...@lists.ozlabs.org
>> > Cc: linux-xte...@linux-xtensa.org
>> > Signed-off-by: Rob Herring 
>> > ---
>> > Please ack so I can take the whole series via the DT tree.
>> >
>> > v2:
>> >  - Fix $arch/boot/dts path check for out of tree builds
>> >  - Fix dtc dependency for building built-in dtbs
>> >  - Fix microblaze built-in dtb building
>>
>>
>> This breaks parallel building
>> because two threads could descend into scripts/dtc
>> at the same time.
>>
>> 'all' depends on both 'scripts' and 'dtc'.
>>
>> * 'scripts' target -- descends into scripts/, then scripts/dtc
>> * 'dtc' target -- descents into scripts/dtc directly
>
> Any suggestions for how to fix given the problem with depending on
> scripts? I suppose I could make scripts depend on dtc instead, but I'd
> be back to needing to fix cleaning.

How about making 'prepare' depend on 'dtc'?

Then, remove
subdir-$(CONFIG_DTC) += dtc
from scripts/Makefile

but, add dtc to subdir-


> Or I could just skip removing the
> cross compiler dependency for now.

I want to build scripts/
without target compiler.

modpost is a special host-program
that depends on $(CC).

I will take a look at it
when I find some time.


-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v2 6/9] kbuild: consolidate Devicetree dtb build rules

2018-09-07 Thread Masahiro Yamada
2018-09-06 8:53 GMT+09:00 Rob Herring :
> There is nothing arch specific about building dtb files other than their
> location under /arch/*/boot/dts/. Keeping each arch aligned is a pain.
> The dependencies and supported targets are all slightly different.
> Also, a cross-compiler for each arch is needed, but really the host
> compiler preprocessor is perfectly fine for building dtbs. Move the
> build rules to a common location and remove the arch specific ones. This
> is done in a single step to avoid warnings about overriding rules.
>
> The build dependencies had been a mixture of 'scripts' and/or 'prepare'.
> These pull in several dependencies some of which need a target compiler
> (specifically devicetable-offsets.h) and aren't needed to build dtbs.
> All that is really needed is dtc, so adjust the dependencies to only be
> dtc.
>
> This change enables support 'dtbs_install' on some arches which were
> missing the target.
>
> Cc: Masahiro Yamada 
> Cc: Michal Marek 
> Cc: Vineet Gupta 
> Cc: Russell King 
> Cc: Catalin Marinas 
> Cc: Will Deacon 
> Cc: Yoshinori Sato 
> Cc: Michal Simek 
> Cc: Ralf Baechle 
> Cc: Paul Burton 
> Cc: James Hogan 
> Cc: Ley Foon Tan 
> Cc: Benjamin Herrenschmidt 
> Cc: Paul Mackerras 
> Cc: Michael Ellerman 
> Cc: Chris Zankel 
> Cc: Max Filippov 
> Cc: linux-kbu...@vger.kernel.org
> Cc: linux-snps-arc@lists.infradead.org
> Cc: linux-arm-ker...@lists.infradead.org
> Cc: uclinux-h8-de...@lists.sourceforge.jp
> Cc: linux-m...@linux-mips.org
> Cc: nios2-...@lists.rocketboards.org
> Cc: linuxppc-...@lists.ozlabs.org
> Cc: linux-xte...@linux-xtensa.org
> Signed-off-by: Rob Herring 
> ---
> Please ack so I can take the whole series via the DT tree.
>
> v2:
>  - Fix $arch/boot/dts path check for out of tree builds
>  - Fix dtc dependency for building built-in dtbs
>  - Fix microblaze built-in dtb building


This breaks parallel building
because two threads could descend into scripts/dtc
at the same time.

'all' depends on both 'scripts' and 'dtc'.

* 'scripts' target -- descends into scripts/, then scripts/dtc
* 'dtc' target -- descents into scripts/dtc directly





-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH] arc: remove redundant GCC version checks

2018-08-26 Thread Masahiro Yamada
Commit cafa0010cd51 ("Raise the minimum required gcc version to 4.6")
bumped the minimum GCC version to 4.6 for all architectures.

With GCC >= 4.6 assumed, 'upto_gcc44' is empty, 'atleast_gcc44' is y.

Signed-off-by: Masahiro Yamada 
---

 arch/arc/Makefile | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index fb02619..99cce77 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -43,10 +43,7 @@ ifdef CONFIG_ARC_CURR_IN_REG
 LINUXINCLUDE   +=  -include ${src}/arch/arc/include/asm/current.h
 endif
 
-upto_gcc44:=  $(call cc-ifversion, -le, 0404, y)
-atleast_gcc44 :=  $(call cc-ifversion, -ge, 0404, y)
-
-cflags-$(atleast_gcc44)+= -fsection-anchors
+cflags-y   += -fsection-anchors
 
 cflags-$(CONFIG_ARC_HAS_LLSC)  += -mlock
 cflags-$(CONFIG_ARC_HAS_SWAPE) += -mswape
@@ -82,11 +79,6 @@ cflags-$(disable_small_data) += -mno-sdata 
-fcall-used-gp
 cflags-$(CONFIG_CPU_BIG_ENDIAN)+= -mbig-endian
 ldflags-$(CONFIG_CPU_BIG_ENDIAN)   += -EB
 
-# STAR 9000518362: (fixed with binutils shipping with gcc 4.8)
-# arc-linux-uclibc-ld (buildroot) or arceb-elf32-ld (EZChip) don't accept
-# --build-id w/o "-marclinux". Default arc-elf32-ld is OK
-ldflags-$(upto_gcc44)  += -marclinux
-
 LIBGCC := $(shell $(CC) $(cflags-y) --print-libgcc-file-name)
 
 # Modules with short calls might break for calls into builtin-kernel
-- 
2.7.4


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 6/8] kbuild: consolidate Devicetree dtb build rules

2018-08-25 Thread Masahiro Yamada
Hi Rob,


2018-08-22 6:55 GMT+09:00 Rob Herring :
> There is nothing arch specific about building dtb files other than their
> location under /arch/*/boot/dts/. Keeping each arch aligned is a pain.
> The dependencies and supported targets are all slightly different.
> Also, a cross-compiler for each arch is needed, but really the host
> compiler preprocessor is perfectly fine for building dtbs. Move the
> build rules to a common location and remove the arch specific ones. This
> is done in a single step to avoid warnings about overriding rules.
>
> The build dependencies had been a mixture of 'scripts' and/or 'prepare'.
> These pull in several dependencies some of which need a target compiler
> (specifically devicetable-offsets.h) and aren't needed to build dtbs.
> All that is really needed is dtc, so adjust the dependencies to only be
> dtc.
>
> This change enables support 'dtbs_install' on some arches which were
> missing the target.
>
> Cc: Masahiro Yamada 
> Cc: Michal Marek 
> Cc: Vineet Gupta 
> Cc: Russell King 
> Cc: Catalin Marinas 
> Cc: Will Deacon 
> Cc: Yoshinori Sato 
> Cc: Michal Simek 
> Cc: Ralf Baechle 
> Cc: Paul Burton 
> Cc: James Hogan 
> Cc: Ley Foon Tan 
> Cc: Benjamin Herrenschmidt 
> Cc: Paul Mackerras 
> Cc: Michael Ellerman 
> Cc: Chris Zankel 
> Cc: Max Filippov 
> Cc: linux-kbu...@vger.kernel.org
> Cc: linux-snps-arc@lists.infradead.org
> Cc: linux-arm-ker...@lists.infradead.org
> Cc: uclinux-h8-de...@lists.sourceforge.jp
> Cc: linux-m...@linux-mips.org
> Cc: nios2-...@lists.rocketboards.org
> Cc: linuxppc-...@lists.ozlabs.org
> Cc: linux-xte...@linux-xtensa.org
> Signed-off-by: Rob Herring 
> ---
>  Makefile | 30 ++
>  arch/arc/Makefile|  6 --
>  arch/arm/Makefile| 20 +---
>  arch/arm64/Makefile  | 17 +
>  arch/c6x/Makefile|  2 --
>  arch/h8300/Makefile  | 11 +--
>  arch/microblaze/Makefile |  4 +---
>  arch/mips/Makefile   | 15 +--
>  arch/nds32/Makefile  |  2 +-
>  arch/nios2/Makefile  |  7 ---
>  arch/nios2/boot/Makefile |  4 
>  arch/powerpc/Makefile|  3 ---
>  arch/xtensa/Makefile | 12 +---
>  scripts/Makefile |  1 -
>  scripts/Makefile.lib |  2 +-
>  15 files changed, 38 insertions(+), 98 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index c13f8b85ba60..6d89e673f192 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1212,6 +1212,30 @@ kselftest-merge:
> $(srctree)/tools/testing/selftests/*/config
> +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
>
> +# ---
> +# Devicetree files
> +
> +dtstree := $(wildcard arch/$(SRCARCH)/boot/dts)
> +
> +ifdef CONFIG_OF_EARLY_FLATTREE
> +
> +%.dtb %.dtb.S %.dtb.o: | dtc

I think the pipe operator is unnecessary
because Kbuild will descend to $(dtstree) anyway.


> +   $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
> +
> +PHONY += dtbs
> +dtbs: | dtc

Ditto.


> +   $(Q)$(MAKE) $(build)=$(dtstree)
> +
> +dtbs_install: dtbs
> +   $(Q)$(MAKE) $(dtbinst)=$(dtstree)
> +
> +all: dtbs
> +
> +dtc:
> +   $(Q)$(MAKE) $(build)=scripts/dtc
> +
> +endif
> +


arch/*/boot/dts/ are not only directories that
require dtc.


$ find  drivers/  -name '*.dts'
drivers/staging/mt7621-dts/gbpc1.dts
drivers/staging/pi433/Documentation/devicetree/pi433-overlay.dts
drivers/of/unittest-data/overlay_12.dts
drivers/of/unittest-data/overlay.dts
drivers/of/unittest-data/overlay_5.dts
drivers/of/unittest-data/overlay_bad_symbol.dts
drivers/of/unittest-data/overlay_1.dts
drivers/of/unittest-data/overlay_bad_phandle.dts
drivers/of/unittest-data/overlay_2.dts
drivers/of/unittest-data/overlay_15.dts
drivers/of/unittest-data/overlay_10.dts
drivers/of/unittest-data/testcases.dts
drivers/of/unittest-data/overlay_6.dts
drivers/of/unittest-data/overlay_13.dts
drivers/of/unittest-data/overlay_4.dts
drivers/of/unittest-data/overlay_9.dts
drivers/of/unittest-data/overlay_3.dts
drivers/of/unittest-data/overlay_8.dts
drivers/of/unittest-data/overlay_7.dts
drivers/of/unittest-data/overlay_11.dts
drivers/of/unittest-data/overlay_0.dts
drivers/of/unittest-data/overlay_base.dts
drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7796.dts
drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7795.dts
drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7793.dts
drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dts
drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7791.dts





dtc must be built before descending into any directory.





$ git clean -f -x
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-  defconfig
drivers/gpu/drm/rcar-du/
  HOSTCC  scri

[PATCH] arc: remove redundant UTS_MACHINE define in arch/arc/Makefile

2017-09-20 Thread Masahiro Yamada
The top-level Makefile sets the default of UTS_MACHINE to $(ARCH).

If ARCH and UTS_MACHINE match, arch/$(ARCH)/Makefile need not specify
UTS_MACHINE explicitly.

Signed-off-by: Masahiro Yamada <yamada.masah...@socionext.com>
---

 arch/arc/Makefile | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index 3a4b52b..d37f49d 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -6,8 +6,6 @@
 # published by the Free Software Foundation.
 #
 
-UTS_MACHINE := arc
-
 ifeq ($(CROSS_COMPILE),)
 ifndef CONFIG_CPU_BIG_ENDIAN
 CROSS_COMPILE := arc-linux-
-- 
2.7.4


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] Unexport LANG env variable

2017-06-15 Thread Masahiro Yamada
Hi Alexey,


2017-06-14 22:11 GMT+09:00 Alexey Brodkin <alexey.brod...@synopsys.com>:
> Hi Michal,
>
> On Wed, 2017-06-14 at 15:02 +0200, Michal Marek wrote:
>> Dne 14.6.2017 v 14:40 Alexey Brodkin napsal(a):
>> >
>> > In those cases when we parse output of standard utilities like readelf
>> > etc we rely on a particular sentences. For example for ARC we extract
>> > an entry-point from vmlinux like that:
>> > -->8
>> > readelf -h vmlinux | grep "Entry point address" | grep -o 0x.*
>> > -->8
>> >
>> > And in case LANG is set to anything other than en_XX we're getting
>> > nothing and subsequent execution of mkimage utility fails.
>> >
>> > Probably there're more cases like that but given people rarely
>> > use non-English locales on their dev machines problems like the one
>> > above are not very visible.
>>
>> I'm all for this change but the *.po files in the gcc tree must have
>> been created for a reason:
>>
>>   
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_gcc-2Dmirror_gcc_tree_master_gcc_po=DwICBA=DPL6_X_6JkXFx7AXWqB0tg=lqdeeSSEes
>> 0GFDDl656eViXO7breS55ytWkhpk5R81I=v2ilYYv6Z0WzVaIys3sCQdK3QBI9gqH7hUmoTGPpJ44=S3B79SHovtt1-wLRtngTUM0dKWMiokGE75HIrfgkbbc=
>
> That's for sure.
>
> But then how may we have a predictable environment for our machinery?
>
> I do realize that with that change in place people will start seeing
> non-translated messages from other tools like compiler etc.
>
> But probably that's not the worst idea as well because it helps googling :)


I do not want to lose users' freedom to choose their favorite language.


For example, arch/powerpc/boot/wrapper  does this

LANG=C elfformat="`${CROSS}objdump -p "$kernel" | grep 'file format' |
awk '{print $4}'`"


I think you can solve your problem like that.


-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 06/27] arc: move generic-y of exported headers to uapi/asm/Kbuild

2017-06-11 Thread Masahiro Yamada
Since commit fcc8487d477a ("uapi: export all headers under uapi
directories"), all (and only) headers under uapi directories are
exported, but asm-generic wrappers are still exceptions.

scripts/Makefile.headersinst still need to deal with old-kbuild-file
for headers listed in arch/*/include/asm/Kbuild, but actually exported.

As the last work to finish de-coupling the uapi from kernel headers,
move generic-y of exported headers to uapi/asm/Kbuild.

Signed-off-by: Masahiro Yamada <yamada.masah...@socionext.com>
---

 arch/arc/include/asm/Kbuild  | 25 -
 arch/arc/include/uapi/asm/Kbuild | 26 ++
 2 files changed, 26 insertions(+), 25 deletions(-)

diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild
index 7bee4e4799fd..353dae386b2f 100644
--- a/arch/arc/include/asm/Kbuild
+++ b/arch/arc/include/asm/Kbuild
@@ -1,52 +1,27 @@
-generic-y += auxvec.h
-generic-y += bitsperlong.h
 generic-y += bugs.h
 generic-y += clkdev.h
 generic-y += device.h
 generic-y += div64.h
 generic-y += emergency-restart.h
-generic-y += errno.h
 generic-y += extable.h
 generic-y += fb.h
-generic-y += fcntl.h
 generic-y += ftrace.h
 generic-y += hardirq.h
 generic-y += hw_irq.h
-generic-y += ioctl.h
-generic-y += ioctls.h
-generic-y += ipcbuf.h
 generic-y += irq_regs.h
 generic-y += irq_work.h
 generic-y += kmap_types.h
-generic-y += kvm_para.h
 generic-y += local.h
 generic-y += local64.h
 generic-y += mcs_spinlock.h
 generic-y += mm-arch-hooks.h
-generic-y += mman.h
-generic-y += msgbuf.h
 generic-y += msi.h
-generic-y += param.h
 generic-y += parport.h
 generic-y += pci.h
 generic-y += percpu.h
-generic-y += poll.h
-generic-y += posix_types.h
 generic-y += preempt.h
-generic-y += resource.h
-generic-y += sembuf.h
-generic-y += shmbuf.h
-generic-y += siginfo.h
-generic-y += socket.h
-generic-y += sockios.h
-generic-y += stat.h
-generic-y += statfs.h
-generic-y += termbits.h
-generic-y += termios.h
 generic-y += topology.h
 generic-y += trace_clock.h
-generic-y += types.h
-generic-y += ucontext.h
 generic-y += user.h
 generic-y += vga.h
 generic-y += word-at-a-time.h
diff --git a/arch/arc/include/uapi/asm/Kbuild b/arch/arc/include/uapi/asm/Kbuild
index b15bf6bc0e94..fa6d0ff4ff89 100644
--- a/arch/arc/include/uapi/asm/Kbuild
+++ b/arch/arc/include/uapi/asm/Kbuild
@@ -1,2 +1,28 @@
 # UAPI Header export list
 include include/uapi/asm-generic/Kbuild.asm
+
+generic-y += auxvec.h
+generic-y += bitsperlong.h
+generic-y += errno.h
+generic-y += fcntl.h
+generic-y += ioctl.h
+generic-y += ioctls.h
+generic-y += ipcbuf.h
+generic-y += kvm_para.h
+generic-y += mman.h
+generic-y += msgbuf.h
+generic-y += param.h
+generic-y += poll.h
+generic-y += posix_types.h
+generic-y += resource.h
+generic-y += sembuf.h
+generic-y += shmbuf.h
+generic-y += siginfo.h
+generic-y += socket.h
+generic-y += sockios.h
+generic-y += stat.h
+generic-y += statfs.h
+generic-y += termbits.h
+generic-y += termios.h
+generic-y += types.h
+generic-y += ucontext.h
-- 
2.7.4


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 3/6] arc: Use full path in KBUILD_IMAGE definition

2017-03-20 Thread Masahiro Yamada
2016-11-23 6:34 GMT+09:00 Michal Marek <mma...@suse.com>:
> The KBUILD_IMAGE variable is used by the rpm and deb-pkg targets, which
> expect it to point to the image file in the build directory. The
> builddeb script has a workaround for architectures which only provide
> the basename, but let's provide a clean interface for packaging tools.
>
> Cc: Vineet Gupta <vgu...@synopsys.com>
> Cc: linux-snps-arc@lists.infradead.org
> Signed-off-by: Michal Marek <mma...@suse.com>



Applied to linux-kbuild/misc.  Thanks!



-- 
Best Regards
Masahiro Yamada

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc