All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/5] kbuild: build modules from code in multiple directories.
@ 2018-06-18  4:55 NeilBrown
  2018-06-18  4:55 ` [PATCH 4/5] kbuild: disable KBUILD_MODNAME when building for mod.a NeilBrown
                   ` (5 more replies)
  0 siblings, 6 replies; 20+ messages in thread
From: NeilBrown @ 2018-06-18  4:55 UTC (permalink / raw)
  To: Masahiro Yamada, Michal Marek; +Cc: linux-kernel, linux-kbuild

This set of patches makes it possible to build a module from
code in multiple directories without needing to list files from one
directory in the Makefile of another directory.

The code was developed for lustre (which is now out-of-tree :-( ) but
can be useful elsewhere, such as for xfs and btrfs and others.

In fs/xfs/Makefile the section:

xfs-y				+= $(addprefix libxfs/, \
				   xfs_ag.o \
				   xfs_alloc.o \
				.....

could become

xfs-y += libxfs/

and then in fs/xfs/libxfs/Makefile we would have

modobj-$(CONFIG_XFS_FS) += xfs_ag.o \
			   xfs_alloc.o \
			   .....

A similar process could move filenames for scrub/* from the
fs/xfs/Makefile to fs/xfs/scrub/Makefile

Apart from improving modularity, this means that partial makes such
as:

  make fs/xfs/libxfs/

or

  make fs/xfs/scrub/attr.s

can work.

Comments and review most welcome.

Thanks,
NeilBrown

---

NeilBrown (5):
      kbuild: detect directories in components of a module.
      kbuild: treat a directory listed in a composite object as foo/mod.a
      kbuild: support building of per-directory mod.a
      kbuild: disable KBUILD_MODNAME when building for mod.a
      kbuild: Add documentation for modobj-m


 Documentation/kbuild/makefiles.txt |   65 ++++++++++++++++++++++++++++++++++--
 scripts/Makefile.build             |   57 ++++++++++++++++++++++----------
 scripts/Makefile.lib               |   63 ++++++++++++++++++++++-------------
 3 files changed, 141 insertions(+), 44 deletions(-)

--
Signature


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/5] kbuild: detect directories in components of a module.
  2018-06-18  4:55 [RFC PATCH 0/5] kbuild: build modules from code in multiple directories NeilBrown
  2018-06-18  4:55 ` [PATCH 4/5] kbuild: disable KBUILD_MODNAME when building for mod.a NeilBrown
  2018-06-18  4:55 ` [PATCH 3/5] kbuild: support building of per-directory mod.a NeilBrown
@ 2018-06-18  4:55 ` NeilBrown
  2018-06-18  4:55 ` [PATCH 2/5] kbuild: treat a directory listed in a composite object as foo/mod.a NeilBrown
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 20+ messages in thread
From: NeilBrown @ 2018-06-18  4:55 UTC (permalink / raw)
  To: Masahiro Yamada, Michal Marek; +Cc: linux-kernel, linux-kbuild

This is a first step in a larger change and so can
only be fully understood in the larger context.

This patch changes the code for extracting directories
from a list of objects to extract them from real-obj-X
instead of obj-X.
This should not cause any change in behaviour yet
as listing directories as components of an object is
not currently supported and will cause an error.
A future patch will give a useful meaning to directories
listed in componsite objects.

A consequence of this change is that any subsequent use of obj-y or
obj-m will still have directories listed in it.
There are no subsequent uses of obj-y and only 2 of obj-m.

1/ obj-m is included as a dependency of __build.  subdir-ym, which
  contains all the directories mentioned in obj-m, is also a
  dependency, so this won't change the set of final dependencies.

2/ Any rule that builds a directory listed in obj-m will find that
   quite_modtag has the value '[M]'.  As quiet_modtag is not used
   when descending into directories, this is of no consequence.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 scripts/Makefile.lib |   38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 1bb594fcfe12..ddfdd5cf47cd 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -25,36 +25,36 @@ lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m)))
 # and -m subdirs.  Just put -y's first.
 modorder	:= $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko))
 
+# if $(foo-objs), $(foo-y), or $(foo-m) exists, foo.o is a composite object
+multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
+multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))), $(m))))
+multi-used   := $(multi-used-y) $(multi-used-m)
+single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m)))
+
+# Replace multi-part objects by their individual parts,
+# including built-in.a from subdirectories
+real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
+real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m)))
+
 # Handle objects in subdirs
 # ---------------------------------------------------------------------------
-# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.a
+# o if we encounter foo/ in $(real-obj-y), replace it by foo/built-in.a
 #   and add the directory to the list of dirs to descend into: $(subdir-y)
-# o if we encounter foo/ in $(obj-m), remove it from $(obj-m)
+# o if we encounter foo/ in $(real-obj-m), remove it from $(real-obj-m)
 #   and add the directory to the list of dirs to descend into: $(subdir-m)
-__subdir-y	:= $(patsubst %/,%,$(filter %/, $(obj-y)))
+__subdir-y	:= $(patsubst %/,%,$(filter %/, $(real-obj-y)))
 subdir-y	+= $(__subdir-y)
-__subdir-m	:= $(patsubst %/,%,$(filter %/, $(obj-m)))
+__subdir-m	:= $(patsubst %/,%,$(filter %/, $(real-obj-m)))
 subdir-m	+= $(__subdir-m)
-obj-y		:= $(patsubst %/, %/built-in.a, $(obj-y))
-obj-m		:= $(filter-out %/, $(obj-m))
+real-obj-y	:= $(patsubst %/, %/built-in.a, $(real-obj-y))
+real-obj-m	:= $(filter-out %/, $(real-obj-m))
 
 # Subdirectories we need to descend into
 subdir-ym	:= $(sort $(subdir-y) $(subdir-m))
 
-# if $(foo-objs), $(foo-y), or $(foo-m) exists, foo.o is a composite object
-multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
-multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))), $(m))))
-multi-used   := $(multi-used-y) $(multi-used-m)
-single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m)))
-
-# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to
+# $(subdir-obj-y) is the list of objects in $(real-obj-y) which uses dir/ to
 # tell kbuild to descend
-subdir-obj-y := $(filter %/built-in.a, $(obj-y))
-
-# Replace multi-part objects by their individual parts,
-# including built-in.a from subdirectories
-real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
-real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m)))
+subdir-obj-y := $(filter %/built-in.a, $(real-obj-y))
 
 # DTB
 # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/5] kbuild: treat a directory listed in a composite object as foo/mod.a
  2018-06-18  4:55 [RFC PATCH 0/5] kbuild: build modules from code in multiple directories NeilBrown
                   ` (2 preceding siblings ...)
  2018-06-18  4:55 ` [PATCH 1/5] kbuild: detect directories in components of a module NeilBrown
@ 2018-06-18  4:55 ` NeilBrown
  2018-06-18  9:14   ` kbuild test robot
  2018-06-18  4:55 ` [PATCH 5/5] kbuild: Add documentation for modobj-m NeilBrown
  2018-06-18  8:20 ` [RFC PATCH 0/5] kbuild: build modules from code in multiple directories Christoph Hellwig
  5 siblings, 1 reply; 20+ messages in thread
From: NeilBrown @ 2018-06-18  4:55 UTC (permalink / raw)
  To: Masahiro Yamada, Michal Marek; +Cc: linux-kernel, linux-kbuild

Currently a directory is not permitted in a composite
object.
This patch changes kbuild so that a directory it assumed
to mean the file "mod.a" in that directory.
The file cannot, yet, be created, so this does not yet
affect behaviour.

There are several parts to this.

1/ strip out all the directories from obj-m so that
  the directories that appear in real-obj-m must be
  parts of composite objects
2/ translate those directories from foo/ to foo/mod.a
  at the same time that obj-y directories becomes foo/built-in.a
3/ hold list of directories needed for modules in subdir-obj-m
  so that we can descend into them as required.
4/ We need a little "dance" in "Rule to link composite objects"
  where we strip the mod.a back off - so we can filter against
  the foo-{objs,y,m} macros, then add it back on for
  declaring dependencies.
  As part of this, multi_depend gains an extra argument
  being the name to append to any directory.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 scripts/Makefile.build |   15 ++++++++-------
 scripts/Makefile.lib   |   19 +++++++++++++++----
 2 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 34d9e9ce97c2..928cd073a657 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -416,8 +416,9 @@ endif
 $(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE
 	$(call if_changed_rule,as_o_S)
 
-targets += $(filter-out $(subdir-obj-y), $(real-obj-y)) $(real-obj-m) $(lib-y)
-targets += $(extra-y) $(MAKECMDGOALS) $(always)
+targets += $(filter-out $(subdir-obj-y), $(real-obj-y))
+targets += $(filter-out $(subdir-obj-m), $(real-obj-m))
+targets += $(lib-y) $(extra-y) $(MAKECMDGOALS) $(always)
 
 # Linker scripts preprocessor (.lds.S -> .lds)
 # ---------------------------------------------------------------------------
@@ -441,7 +442,7 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
 # ---------------------------------------------------------------------------
 
 # To build objects in subdirs, we need to descend into the directories
-$(sort $(subdir-obj-y)): $(subdir-ym) ;
+$(sort $(subdir-obj-y) $(subdir-obj-m)): $(subdir-ym) ;
 
 #
 # Rule to compile a set of .o files into one .o file
@@ -521,16 +522,16 @@ link_multi_deps =                     \
 $(filter $(addprefix $(obj)/,         \
 $($(subst $(obj)/,,$(@:.o=-objs)))    \
 $($(subst $(obj)/,,$(@:.o=-y)))       \
-$($(subst $(obj)/,,$(@:.o=-m)))), $^)
+$($(subst $(obj)/,,$(@:.o=-m)))), $(patsubst %/mod.a,%/,$^))
 
 quiet_cmd_link_multi-m = LD [M]  $@
-cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis)
+cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(patsubst %/, --whole-archive %/mod.a --no-whole-archive ,$(link_multi_deps)) $(cmd_secanalysis)
 
 $(multi-used-m): FORCE
 	$(call if_changed,link_multi-m)
-	@{ echo $(@:.o=.ko); echo $(link_multi_deps); \
+	@{ echo $(@:.o=.ko); echo $(patsubst %/,%/mod.a,$(link_multi_deps)); \
 	   $(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod)
-$(call multi_depend, $(multi-used-m), .o, -objs -y -m)
+$(call multi_depend, $(multi-used-m), .o, -objs -y -m,mod.a)
 
 targets += $(multi-used-m)
 targets := $(filter-out $(PHONY), $(targets))
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index ddfdd5cf47cd..6e7aa08324f0 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -12,6 +12,13 @@ KBUILD_CFLAGS += $(subdir-ccflags-y)
 # Figure out what we need to build from the various variables
 # ===========================================================================
 
+# Directories in obj-m only cause that directory to be descended, which
+# is exactly what happens for directories in obj-y. So move all
+# directories from obj-m to obj-y.  Then we will know that any directory
+# in real-obj-m is a component of some other object.
+obj-y := $(obj-y) $(filter %/, $(obj-m))
+obj-m := $(filter-out %/, $(obj-m))
+
 # When an object is listed to be built compiled-in and modular,
 # only build the compiled-in version
 obj-m := $(filter-out $(obj-y),$(obj-m))
@@ -40,14 +47,14 @@ real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))
 # ---------------------------------------------------------------------------
 # o if we encounter foo/ in $(real-obj-y), replace it by foo/built-in.a
 #   and add the directory to the list of dirs to descend into: $(subdir-y)
-# o if we encounter foo/ in $(real-obj-m), remove it from $(real-obj-m)
+# o if we encounter foo/ in $(real-obj-m), replace it by foo/mod.a
 #   and add the directory to the list of dirs to descend into: $(subdir-m)
 __subdir-y	:= $(patsubst %/,%,$(filter %/, $(real-obj-y)))
 subdir-y	+= $(__subdir-y)
 __subdir-m	:= $(patsubst %/,%,$(filter %/, $(real-obj-m)))
 subdir-m	+= $(__subdir-m)
 real-obj-y	:= $(patsubst %/, %/built-in.a, $(real-obj-y))
-real-obj-m	:= $(filter-out %/, $(real-obj-m))
+real-obj-m	:= $(patsubst %/, %/mod.a, $(real-obj-m))
 
 # Subdirectories we need to descend into
 subdir-ym	:= $(sort $(subdir-y) $(subdir-m))
@@ -55,6 +62,9 @@ subdir-ym	:= $(sort $(subdir-y) $(subdir-m))
 # $(subdir-obj-y) is the list of objects in $(real-obj-y) which uses dir/ to
 # tell kbuild to descend
 subdir-obj-y := $(filter %/built-in.a, $(real-obj-y))
+# $(subdir-obj-m) is the list of objects in $(real-obj-m) which uses dir/ to
+# tell kbuild to descend
+subdir-obj-m := $(filter %/mod.a, $(real-obj-m))
 
 # DTB
 # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built
@@ -70,6 +80,7 @@ modorder	:= $(addprefix $(obj)/,$(modorder))
 obj-m		:= $(addprefix $(obj)/,$(obj-m))
 lib-y		:= $(addprefix $(obj)/,$(lib-y))
 subdir-obj-y	:= $(addprefix $(obj)/,$(subdir-obj-y))
+subdir-obj-m	:= $(addprefix $(obj)/,$(subdir-obj-m))
 real-obj-y	:= $(addprefix $(obj)/,$(real-obj-y))
 real-obj-m	:= $(addprefix $(obj)/,$(real-obj-m))
 single-used-m	:= $(addprefix $(obj)/,$(single-used-m))
@@ -172,11 +183,11 @@ dtc_cpp_flags  = -Wp,-MD,$(depfile).pre.tmp -nostdinc                    \
 
 # Useful for describing the dependency of composite objects
 # Usage:
-#   $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add)
+#   $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add, object_in_directories)
 define multi_depend
 $(foreach m, $(notdir $1), \
 	$(eval $(obj)/$m: \
-	$(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s)))))))
+	$(addprefix $(obj)/, $(patsubst %/,%/$4,$(foreach s, $3, $($(m:%$(strip $2)=%$(s))))))))
 endef
 
 # LEX



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 3/5] kbuild: support building of per-directory mod.a
  2018-06-18  4:55 [RFC PATCH 0/5] kbuild: build modules from code in multiple directories NeilBrown
  2018-06-18  4:55 ` [PATCH 4/5] kbuild: disable KBUILD_MODNAME when building for mod.a NeilBrown
@ 2018-06-18  4:55 ` NeilBrown
  2018-06-19  3:57   ` [PATCH 3/5 - v2] " NeilBrown
  2018-06-18  4:55 ` [PATCH 1/5] kbuild: detect directories in components of a module NeilBrown
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 20+ messages in thread
From: NeilBrown @ 2018-06-18  4:55 UTC (permalink / raw)
  To: Masahiro Yamada, Michal Marek; +Cc: linux-kernel, linux-kbuild

This patch allows a "mod.a" to be built in any
directory.  A previous patch allows that mod.a
to be included in any module or another mod.a.

This is achieved via a new pair of macros: modobj-y and modobj-m.

Anything in modobj-y is added to obj-y and is otherwise
ignored.
Anything listed in modobj-m is built, almost as though "modobj.o" was
a requested target.  The objects are then combined
into mod.a.
These objects are always built with part-of-module=y.

This is sufficient to build a module from source in
multiple directories.  Each "other" directory lists
something like
 modobj-$(CONFIG_FOO) += bar.o bar.o bat.o

and the main directory lists

 obj-$(CONFIG-FOO) = foo.o
 foo-y = other1/ ../friend/other2/ module.o

Signed-off-by: NeilBrown <neilb@suse.com>
---
 scripts/Makefile.build |   44 +++++++++++++++++++++++++++++++++-----------
 scripts/Makefile.lib   |   14 ++++++++++----
 2 files changed, 43 insertions(+), 15 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 928cd073a657..e3a622f6e3a9 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -15,6 +15,8 @@ obj-y :=
 obj-m :=
 lib-y :=
 lib-m :=
+modobj-y :=
+modobj-m :=
 always :=
 targets :=
 subdir-y :=
@@ -80,12 +82,16 @@ ifneq ($(strip $(real-obj-y) $(need-builtin)),)
 builtin-target := $(obj)/built-in.a
 endif
 
+ifneq ($(strip $(modobj-m)),)
+modobj-target := $(obj)/mod.a
+endif
+
 modorder-target := $(obj)/modules.order
 
 # We keep a list of all modules in $(MODVERDIR)
 
 __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \
-	 $(if $(KBUILD_MODULES),$(obj-m) $(modorder-target)) \
+	 $(if $(KBUILD_MODULES),$(obj-m) $(modorder-target) $(modobj-target))  \
 	 $(subdir-ym) $(always)
 	@:
 
@@ -119,17 +125,19 @@ modkern_cflags =                                          \
 		$(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL))
 quiet_modtag := $(empty)   $(empty)
 
-$(real-obj-m)        : part-of-module := y
-$(real-obj-m:.o=.i)  : part-of-module := y
-$(real-obj-m:.o=.s)  : part-of-module := y
-$(real-obj-m:.o=.lst): part-of-module := y
+_mod_obj = $(real-obj-m) $(real-modobj-m)
+
+$(_mod_obj)        : part-of-module := y
+$(_mod_obj:.o=.i)  : part-of-module := y
+$(_mod_obj:.o=.s)  : part-of-module := y
+$(_mod_obj:.o=.lst): part-of-module := y
 
-$(real-obj-m)        : quiet_modtag := [M]
-$(real-obj-m:.o=.i)  : quiet_modtag := [M]
-$(real-obj-m:.o=.s)  : quiet_modtag := [M]
-$(real-obj-m:.o=.lst): quiet_modtag := [M]
+$(_mod_obj)        : quiet_modtag := [M]
+$(_mod_obj:.o=.i)  : quiet_modtag := [M]
+$(_mod_obj:.o=.s)  : quiet_modtag := [M]
+$(_mod_obj:.o=.lst): quiet_modtag := [M]
 
-$(obj-m)             : quiet_modtag := [M]
+$(obj-m)           : quiet_modtag := [M]
 
 quiet_cmd_cc_s_c = CC $(quiet_modtag)  $@
 cmd_cc_s_c       = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $<
@@ -417,7 +425,7 @@ $(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE
 	$(call if_changed_rule,as_o_S)
 
 targets += $(filter-out $(subdir-obj-y), $(real-obj-y))
-targets += $(filter-out $(subdir-obj-m), $(real-obj-m))
+targets += $(filter-out $(subdir-obj-m) $(real-modobj-m), $(real-obj-m))
 targets += $(lib-y) $(extra-y) $(MAKECMDGOALS) $(always)
 
 # Linker scripts preprocessor (.lds.S -> .lds)
@@ -508,6 +516,20 @@ targets += $(obj)/lib-ksyms.o
 
 endif
 
+ifdef modobj-target
+
+quiet_cmd_ar_modobj = AR      $@
+      cmd_ar_modobj = rm -f $@; \
+                    $(AR) rcTP$(KBUILD_ARFLAGS) $@ $(filter $(real-modobj-m), $^)
+
+$(modobj-target): $(real-modobj-m) FORCE
+	$(call if_changed,ar_modobj)
+
+targets += $(modobj-target)
+
+endif # modobj-target
+
+
 #
 # Rule to link composite objects
 #
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 6e7aa08324f0..c84167169a59 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -16,12 +16,13 @@ KBUILD_CFLAGS += $(subdir-ccflags-y)
 # is exactly what happens for directories in obj-y. So move all
 # directories from obj-m to obj-y.  Then we will know that any directory
 # in real-obj-m is a component of some other object.
-obj-y := $(obj-y) $(filter %/, $(obj-m))
+obj-y := $(obj-y) $(filter %/, $(obj-m)) $(filter-out $(obj-y), $(modobj-y))
 obj-m := $(filter-out %/, $(obj-m))
 
 # When an object is listed to be built compiled-in and modular,
 # only build the compiled-in version
 obj-m := $(filter-out $(obj-y),$(obj-m))
+modobj-m := $(filter-out $(obj-y), $(modobj-m))
 
 # Libraries are always collected in one lib file.
 # Filter out objects already built-in
@@ -42,6 +43,7 @@ single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m)))
 # including built-in.a from subdirectories
 real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
 real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m)))
+real-modobj-m := $(foreach m, $(modobj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m)))
 
 # Handle objects in subdirs
 # ---------------------------------------------------------------------------
@@ -53,8 +55,11 @@ __subdir-y	:= $(patsubst %/,%,$(filter %/, $(real-obj-y)))
 subdir-y	+= $(__subdir-y)
 __subdir-m	:= $(patsubst %/,%,$(filter %/, $(real-obj-m)))
 subdir-m	+= $(__subdir-m)
+__subdir-mo	:= $(patsubst %/,%,$(filter %/, $(real-modobj-m)))
+subdir-m	+= $(__subdir-mo)
 real-obj-y	:= $(patsubst %/, %/built-in.a, $(real-obj-y))
 real-obj-m	:= $(patsubst %/, %/mod.a, $(real-obj-m))
+real-modobj-m	:= $(patsubst %/, %/mod.a, $(real-modobj-m))
 
 # Subdirectories we need to descend into
 subdir-ym	:= $(sort $(subdir-y) $(subdir-m))
@@ -62,9 +67,9 @@ subdir-ym	:= $(sort $(subdir-y) $(subdir-m))
 # $(subdir-obj-y) is the list of objects in $(real-obj-y) which uses dir/ to
 # tell kbuild to descend
 subdir-obj-y := $(filter %/built-in.a, $(real-obj-y))
-# $(subdir-obj-m) is the list of objects in $(real-obj-m) which uses dir/ to
-# tell kbuild to descend
-subdir-obj-m := $(filter %/mod.a, $(real-obj-m))
+# $(subdir-obj-m) is the list of objects in $(real-obj-m) and
+# $(real-modobj-m) which use dir/ to tell kbuild to descend
+subdir-obj-m := $(filter %/mod.a, $(real-obj-m) $(real-modobj-m))
 
 # DTB
 # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built
@@ -83,6 +88,7 @@ subdir-obj-y	:= $(addprefix $(obj)/,$(subdir-obj-y))
 subdir-obj-m	:= $(addprefix $(obj)/,$(subdir-obj-m))
 real-obj-y	:= $(addprefix $(obj)/,$(real-obj-y))
 real-obj-m	:= $(addprefix $(obj)/,$(real-obj-m))
+real-modobj-m	:= $(addprefix $(obj)/,$(real-modobj-m))
 single-used-m	:= $(addprefix $(obj)/,$(single-used-m))
 multi-used-m	:= $(addprefix $(obj)/,$(multi-used-m))
 subdir-ym	:= $(addprefix $(obj)/,$(subdir-ym))



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 4/5] kbuild: disable KBUILD_MODNAME when building for mod.a
  2018-06-18  4:55 [RFC PATCH 0/5] kbuild: build modules from code in multiple directories NeilBrown
@ 2018-06-18  4:55 ` NeilBrown
  2018-06-27  5:52   ` Masahiro Yamada
  2018-06-18  4:55 ` [PATCH 3/5] kbuild: support building of per-directory mod.a NeilBrown
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 20+ messages in thread
From: NeilBrown @ 2018-06-18  4:55 UTC (permalink / raw)
  To: Masahiro Yamada, Michal Marek; +Cc: linux-kernel, linux-kbuild

When building an object to be included in mod.a we
cannot know the name of the module.  So don't define
KBUILD_MODNAME.  This will ensure attempt to use
that macro when the module name isn't know will
trigger an error.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 scripts/Makefile.lib |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index c84167169a59..d09246474f2e 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -96,7 +96,7 @@ subdir-ym	:= $(addprefix $(obj)/,$(subdir-ym))
 # Finds the multi-part object the current object will be linked into.
 # If the object belongs to two or more multi-part objects, all of them are
 # concatenated with a colon separator.
-modname-multi = $(subst $(space),:,$(sort $(foreach m,$(multi-used),\
+modname-multi = $(subst $(space),:,$(sort $(foreach m,$(multi-used) modobj.o,\
 		$(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=)))))
 
 modname = $(if $(modname-multi),$(modname-multi),$(basetarget))
@@ -106,7 +106,7 @@ modname = $(if $(modname-multi),$(modname-multi),$(basetarget))
 # end up in (or would, if it gets compiled in)
 name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote)
 basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget))
-modname_flags  = -DKBUILD_MODNAME=$(call name-fix,$(modname))
+modname_flags  = $(if $(filter-out modobj,$(modname)),-DKBUILD_MODNAME=$(call name-fix,$(modname)))
 
 orig_c_flags   = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \
                  $(ccflags-y) $(CFLAGS_$(basetarget).o)



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 5/5] kbuild: Add documentation for modobj-m
  2018-06-18  4:55 [RFC PATCH 0/5] kbuild: build modules from code in multiple directories NeilBrown
                   ` (3 preceding siblings ...)
  2018-06-18  4:55 ` [PATCH 2/5] kbuild: treat a directory listed in a composite object as foo/mod.a NeilBrown
@ 2018-06-18  4:55 ` NeilBrown
  2018-06-18  8:20 ` [RFC PATCH 0/5] kbuild: build modules from code in multiple directories Christoph Hellwig
  5 siblings, 0 replies; 20+ messages in thread
From: NeilBrown @ 2018-06-18  4:55 UTC (permalink / raw)
  To: Masahiro Yamada, Michal Marek; +Cc: linux-kernel, linux-kbuild

Add documentation for building modules
from multiple directories using modobj-m.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 Documentation/kbuild/makefiles.txt |   65 ++++++++++++++++++++++++++++++++++--
 1 file changed, 61 insertions(+), 4 deletions(-)

diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 048fc39a6b91..985a60cf0663 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -225,17 +225,74 @@ more details, with real examples.
 	part of the composite object ext2.o if $(CONFIG_EXT2_FS_XATTR)
 	evaluates to 'y'.
 
+	If you wish to include code in some other directory into a
+	module, that directory should be configured to create a
+	mod.a target from the relevant code, as described below.
+	The list of components for the module (e.g. foo-y) should
+	then contain the name of the directory (with trailing /).
+	The mod.a from that directory will be built and included
+	into this module.
+
 	Note: Of course, when you are building objects into the kernel,
 	the syntax above will also work. So, if you have CONFIG_EXT2_FS=y,
 	kbuild will build an ext2.o file for you out of the individual
 	parts and then link this into built-in.a, as you would expect.
 
---- 3.4 Objects which export symbols
+--- 3.4 Loadable modules from multiple directories - modobj-m
+
+	One way to build modules with source from multiple directories
+	is to list relative path names of all source files in a
+	single Makefile.
+
+	Example:
+		btrfs-$(CONFIG_BTRFS_FS_RUN_SANITY_TESTS) += tests/free-space-tests.o \
+		        tests/extent-buffer-tests.o tests/btrfs-tests.o \
+		....
+
+	This works, but defeats the ability to build individual
+	directories, or individual target files such as assembly
+	language targets.
+
+	Example:
+		make btrfs/tests/free-space-tests.s
+
+	A more general way is to create a mod.a file using modobj-m
+
+	Example:
+		modobj-$(CONFIG_LUSTRE_FS) += fid_request.o fid_lib.o lproc_fid.o
+
+	modobj-y is treated identically to obj-y so if CONFIG_LUSTRE_FS=y
+	then these objects are built in to the kernel.  If
+	CONFIG_LUSTRE_FS=m then these objects are gathered into an archive
+	called mod.a.  Archives from other directories can be included
+	by listing the directories in modobj-m, so
+
+	Example:
+		modobj-$(CONFIG_LUSTRE_FS) += fid/ fld/
+
+	This will create a mod.a in the same directory as the
+	Makefile, combining the contents of mod.a from the listed
+	directories.  The mod.a can instead be included into a module
+	by listing the directory with any other local object files.
+
+	Example:
+		obj-$(CONFIG_LUSTRE_FS) += lustre.o
+		lustre-y := module.o
+		lustre-y += obdclass/ ldlm/ ptlrpc/ fld/ osc/ mgc/
+
+	When CONFIG_LUSTRE_FS=m, kbuild will build lustre.ko from module.o and
+	the mod.a archives created in the listed directories.
+
+	When components of a module are built in a different directory
+	kbuild cannot determine the name of the module so the
+	KBUILD_MODNAME macro is left undefined.
+
+--- 3.5 Objects which export symbols
 
 	No special notation is required in the makefiles for
 	modules exporting symbols.
 
---- 3.5 Library file goals - lib-y
+--- 3.6 Library file goals - lib-y
 
 	Objects listed with obj-* are used for modules, or
 	combined in a built-in.a for that specific directory.
@@ -263,7 +320,7 @@ more details, with real examples.
 
 	Use of lib-y is normally restricted to lib/ and arch/*/lib.
 
---- 3.6 Descending down in directories
+--- 3.7 Descending down in directories
 
 	A Makefile is only responsible for building objects in its own
 	directory. Files in subdirectories should be taken care of by
@@ -290,7 +347,7 @@ more details, with real examples.
 	names. This allows kbuild to totally skip the directory if the
 	corresponding CONFIG_ option is neither 'y' nor 'm'.
 
---- 3.7 Compilation flags
+--- 3.8 Compilation flags
 
     ccflags-y, asflags-y and ldflags-y
 	These three flags apply only to the kbuild makefile in which they



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [RFC PATCH 0/5] kbuild: build modules from code in multiple directories.
  2018-06-18  4:55 [RFC PATCH 0/5] kbuild: build modules from code in multiple directories NeilBrown
                   ` (4 preceding siblings ...)
  2018-06-18  4:55 ` [PATCH 5/5] kbuild: Add documentation for modobj-m NeilBrown
@ 2018-06-18  8:20 ` Christoph Hellwig
  2018-06-19  4:05   ` NeilBrown
  5 siblings, 1 reply; 20+ messages in thread
From: Christoph Hellwig @ 2018-06-18  8:20 UTC (permalink / raw)
  To: NeilBrown; +Cc: Masahiro Yamada, Michal Marek, linux-kernel, linux-kbuild

On Mon, Jun 18, 2018 at 02:55:20PM +1000, NeilBrown wrote:
> This set of patches makes it possible to build a module from
> code in multiple directories without needing to list files from one
> directory in the Makefile of another directory.
> 
> The code was developed for lustre (which is now out-of-tree :-( ) but
> can be useful elsewhere, such as for xfs and btrfs and others.
> 
> In fs/xfs/Makefile the section:
> 
> xfs-y				+= $(addprefix libxfs/, \
> 				   xfs_ag.o \
> 				   xfs_alloc.o \
> 				.....
> 
> could become
> 
> xfs-y += libxfs/
> 
> and then in fs/xfs/libxfs/Makefile we would have
> 
> modobj-$(CONFIG_XFS_FS) += xfs_ag.o \
> 			   xfs_alloc.o \
> 			   .....
> 
> A similar process could move filenames for scrub/* from the
> fs/xfs/Makefile to fs/xfs/scrub/Makefile

How about you actually convert it as an example?

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/5] kbuild: treat a directory listed in a composite object as foo/mod.a
  2018-06-18  4:55 ` [PATCH 2/5] kbuild: treat a directory listed in a composite object as foo/mod.a NeilBrown
@ 2018-06-18  9:14   ` kbuild test robot
  2018-06-18 22:30       ` NeilBrown
  0 siblings, 1 reply; 20+ messages in thread
From: kbuild test robot @ 2018-06-18  9:14 UTC (permalink / raw)
  To: NeilBrown
  Cc: kbuild-all, Masahiro Yamada, Michal Marek, linux-kernel, linux-kbuild

[-- Attachment #1: Type: text/plain, Size: 15212 bytes --]

Hi NeilBrown,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on kbuild/for-next]
[also build test ERROR on v4.18-rc1 next-20180618]
[cannot apply to mmarek/for-next mmarek/rc-fixes]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/NeilBrown/kbuild-build-modules-from-code-in-multiple-directories/20180618-130250
base:   https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
config: x86_64-randconfig-in0-06170623 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers/isdn/hardware/mISDN/hfcsusb.o: In function `release_hw':
>> drivers/isdn/hardware/mISDN/hfcsusb.c:1757: undefined reference to `l1_event'
>> drivers/isdn/hardware/mISDN/hfcsusb.c:1759: undefined reference to `mISDN_unregister_device'
>> drivers/isdn/hardware/mISDN/hfcsusb.c:1760: undefined reference to `mISDN_freebchannel'
   drivers/isdn/hardware/mISDN/hfcsusb.c:1761: undefined reference to `mISDN_freebchannel'
>> drivers/isdn/hardware/mISDN/hfcsusb.c:1762: undefined reference to `mISDN_freedchannel'
   drivers/isdn/hardware/mISDN/hfcsusb.o: In function `deactivate_bchannel':
>> drivers/isdn/hardware/mISDN/hfcsusb.c:1788: undefined reference to `mISDN_clear_bchannel'
   drivers/isdn/hardware/mISDN/hfcsusb.o: In function `ph_state_te':
   drivers/isdn/hardware/mISDN/hfcsusb.c:611: undefined reference to `l1_event'
   drivers/isdn/hardware/mISDN/hfcsusb.o: In function `channel_bctrl':
>> drivers/isdn/hardware/mISDN/hfcsusb.c:808: undefined reference to `mISDN_ctrl_bchannel'
   drivers/isdn/hardware/mISDN/hfcsusb.o: In function `tx_iso_complete':
>> drivers/isdn/hardware/mISDN/hfcsusb.c:1345: undefined reference to `get_next_dframe'
>> drivers/isdn/hardware/mISDN/hfcsusb.c:1348: undefined reference to `get_next_bframe'
   drivers/isdn/hardware/mISDN/hfcsusb.o: In function `hfcsusb_rx_frame':
>> drivers/isdn/hardware/mISDN/hfcsusb.c:850: undefined reference to `bchannel_get_rxbuf'
>> drivers/isdn/hardware/mISDN/hfcsusb.c:919: undefined reference to `recv_Dchannel'
>> drivers/isdn/hardware/mISDN/hfcsusb.c:921: undefined reference to `recv_Bchannel'
>> drivers/isdn/hardware/mISDN/hfcsusb.c:924: undefined reference to `recv_Echannel'
   drivers/isdn/hardware/mISDN/hfcsusb.c:943: undefined reference to `recv_Bchannel'
   drivers/isdn/hardware/mISDN/hfcsusb.o: In function `hfcusb_l2l1D':
>> drivers/isdn/hardware/mISDN/hfcsusb.c:301: undefined reference to `dchannel_senddata'
>> drivers/isdn/hardware/mISDN/hfcsusb.c:305: undefined reference to `queue_ch_frame'
   drivers/isdn/hardware/mISDN/hfcsusb.c:360: undefined reference to `l1_event'
   drivers/isdn/hardware/mISDN/hfcsusb.o: In function `setup_instance':
>> drivers/isdn/hardware/mISDN/hfcsusb.c:1843: undefined reference to `mISDN_initdchannel'
   drivers/isdn/hardware/mISDN/hfcsusb.c:1852: undefined reference to `mISDN_initdchannel'
>> drivers/isdn/hardware/mISDN/hfcsusb.c:1861: undefined reference to `mISDN_initbchannel'
>> drivers/isdn/hardware/mISDN/hfcsusb.c:1887: undefined reference to `mISDN_register_device'
   drivers/isdn/hardware/mISDN/hfcsusb.c:1898: undefined reference to `mISDN_freebchannel'
   drivers/isdn/hardware/mISDN/hfcsusb.c:1899: undefined reference to `mISDN_freebchannel'
   drivers/isdn/hardware/mISDN/hfcsusb.c:1900: undefined reference to `mISDN_freedchannel'
   drivers/isdn/hardware/mISDN/hfcsusb.o: In function `hfcusb_l2l1B':
>> drivers/isdn/hardware/mISDN/hfcsusb.c:224: undefined reference to `bchannel_senddata'
   drivers/isdn/hardware/mISDN/hfcsusb.o: In function `open_dchannel':
>> drivers/isdn/hardware/mISDN/hfcsusb.c:454: undefined reference to `create_l1'

vim +1757 drivers/isdn/hardware/mISDN/hfcsusb.c

69f52adb Karsten Keil  2009-01-09  1739  
69f52adb Karsten Keil  2009-01-09  1740  static void
69f52adb Karsten Keil  2009-01-09  1741  release_hw(struct hfcsusb *hw)
69f52adb Karsten Keil  2009-01-09  1742  {
69f52adb Karsten Keil  2009-01-09  1743  	if (debug & DBG_HFC_CALL_TRACE)
69f52adb Karsten Keil  2009-01-09  1744  		printk(KERN_DEBUG "%s: %s\n", hw->name, __func__);
69f52adb Karsten Keil  2009-01-09  1745  
69f52adb Karsten Keil  2009-01-09  1746  	/*
69f52adb Karsten Keil  2009-01-09  1747  	 * stop all endpoints gracefully
69f52adb Karsten Keil  2009-01-09  1748  	 * TODO: mISDN_core should generate CLOSE_CHANNEL
69f52adb Karsten Keil  2009-01-09  1749  	 *       signals after calling mISDN_unregister_device()
69f52adb Karsten Keil  2009-01-09  1750  	 */
69f52adb Karsten Keil  2009-01-09  1751  	hfcsusb_stop_endpoint(hw, HFC_CHAN_D);
69f52adb Karsten Keil  2009-01-09  1752  	hfcsusb_stop_endpoint(hw, HFC_CHAN_B1);
69f52adb Karsten Keil  2009-01-09  1753  	hfcsusb_stop_endpoint(hw, HFC_CHAN_B2);
69f52adb Karsten Keil  2009-01-09  1754  	if (hw->fifos[HFCUSB_PCM_RX].pipe)
69f52adb Karsten Keil  2009-01-09  1755  		hfcsusb_stop_endpoint(hw, HFC_CHAN_E);
69f52adb Karsten Keil  2009-01-09  1756  	if (hw->protocol == ISDN_P_TE_S0)
69f52adb Karsten Keil  2009-01-09 @1757  		l1_event(hw->dch.l1, CLOSE_CHANNEL);
69f52adb Karsten Keil  2009-01-09  1758  
69f52adb Karsten Keil  2009-01-09 @1759  	mISDN_unregister_device(&hw->dch.dev);
69f52adb Karsten Keil  2009-01-09 @1760  	mISDN_freebchannel(&hw->bch[1]);
69f52adb Karsten Keil  2009-01-09 @1761  	mISDN_freebchannel(&hw->bch[0]);
69f52adb Karsten Keil  2009-01-09 @1762  	mISDN_freedchannel(&hw->dch);
69f52adb Karsten Keil  2009-01-09  1763  
69f52adb Karsten Keil  2009-01-09  1764  	if (hw->ctrl_urb) {
69f52adb Karsten Keil  2009-01-09  1765  		usb_kill_urb(hw->ctrl_urb);
69f52adb Karsten Keil  2009-01-09  1766  		usb_free_urb(hw->ctrl_urb);
69f52adb Karsten Keil  2009-01-09  1767  		hw->ctrl_urb = NULL;
69f52adb Karsten Keil  2009-01-09  1768  	}
69f52adb Karsten Keil  2009-01-09  1769  
69f52adb Karsten Keil  2009-01-09  1770  	if (hw->intf)
69f52adb Karsten Keil  2009-01-09  1771  		usb_set_intfdata(hw->intf, NULL);
69f52adb Karsten Keil  2009-01-09  1772  	list_del(&hw->list);
69f52adb Karsten Keil  2009-01-09  1773  	kfree(hw);
69f52adb Karsten Keil  2009-01-09  1774  	hw = NULL;
69f52adb Karsten Keil  2009-01-09  1775  }
69f52adb Karsten Keil  2009-01-09  1776  
69f52adb Karsten Keil  2009-01-09  1777  static void
69f52adb Karsten Keil  2009-01-09  1778  deactivate_bchannel(struct bchannel *bch)
69f52adb Karsten Keil  2009-01-09  1779  {
69f52adb Karsten Keil  2009-01-09  1780  	struct hfcsusb *hw = bch->hw;
69f52adb Karsten Keil  2009-01-09  1781  	u_long flags;
69f52adb Karsten Keil  2009-01-09  1782  
69f52adb Karsten Keil  2009-01-09  1783  	if (bch->debug & DEBUG_HW)
69f52adb Karsten Keil  2009-01-09  1784  		printk(KERN_DEBUG "%s: %s: bch->nr(%i)\n",
69f52adb Karsten Keil  2009-01-09  1785  		       hw->name, __func__, bch->nr);
69f52adb Karsten Keil  2009-01-09  1786  
69f52adb Karsten Keil  2009-01-09  1787  	spin_lock_irqsave(&hw->lock, flags);
fb286f04 Karsten Keil  2009-07-09 @1788  	mISDN_clear_bchannel(bch);
69f52adb Karsten Keil  2009-01-09  1789  	spin_unlock_irqrestore(&hw->lock, flags);
69f52adb Karsten Keil  2009-01-09  1790  	hfcsusb_setup_bch(bch, ISDN_P_NONE);
37952cfa Martin Bachem 2012-05-15  1791  	hfcsusb_stop_endpoint(hw, bch->nr - 1);
69f52adb Karsten Keil  2009-01-09  1792  }
69f52adb Karsten Keil  2009-01-09  1793  
69f52adb Karsten Keil  2009-01-09  1794  /*
69f52adb Karsten Keil  2009-01-09  1795   * Layer 1 B-channel hardware access
69f52adb Karsten Keil  2009-01-09  1796   */
69f52adb Karsten Keil  2009-01-09  1797  static int
69f52adb Karsten Keil  2009-01-09  1798  hfc_bctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
69f52adb Karsten Keil  2009-01-09  1799  {
69f52adb Karsten Keil  2009-01-09  1800  	struct bchannel	*bch = container_of(ch, struct bchannel, ch);
69f52adb Karsten Keil  2009-01-09  1801  	int		ret = -EINVAL;
69f52adb Karsten Keil  2009-01-09  1802  
69f52adb Karsten Keil  2009-01-09  1803  	if (bch->debug & DEBUG_HW)
69f52adb Karsten Keil  2009-01-09  1804  		printk(KERN_DEBUG "%s: cmd:%x %p\n", __func__, cmd, arg);
69f52adb Karsten Keil  2009-01-09  1805  
69f52adb Karsten Keil  2009-01-09  1806  	switch (cmd) {
69f52adb Karsten Keil  2009-01-09  1807  	case HW_TESTRX_RAW:
69f52adb Karsten Keil  2009-01-09  1808  	case HW_TESTRX_HDLC:
69f52adb Karsten Keil  2009-01-09  1809  	case HW_TESTRX_OFF:
69f52adb Karsten Keil  2009-01-09  1810  		ret = -EINVAL;
69f52adb Karsten Keil  2009-01-09  1811  		break;
69f52adb Karsten Keil  2009-01-09  1812  
69f52adb Karsten Keil  2009-01-09  1813  	case CLOSE_CHANNEL:
69f52adb Karsten Keil  2009-01-09  1814  		test_and_clear_bit(FLG_OPEN, &bch->Flags);
69f52adb Karsten Keil  2009-01-09  1815  		deactivate_bchannel(bch);
69f52adb Karsten Keil  2009-01-09  1816  		ch->protocol = ISDN_P_NONE;
69f52adb Karsten Keil  2009-01-09  1817  		ch->peer = NULL;
69f52adb Karsten Keil  2009-01-09  1818  		module_put(THIS_MODULE);
69f52adb Karsten Keil  2009-01-09  1819  		ret = 0;
69f52adb Karsten Keil  2009-01-09  1820  		break;
69f52adb Karsten Keil  2009-01-09  1821  	case CONTROL_CHANNEL:
69f52adb Karsten Keil  2009-01-09  1822  		ret = channel_bctrl(bch, arg);
69f52adb Karsten Keil  2009-01-09  1823  		break;
69f52adb Karsten Keil  2009-01-09  1824  	default:
69f52adb Karsten Keil  2009-01-09  1825  		printk(KERN_WARNING "%s: unknown prim(%x)\n",
69f52adb Karsten Keil  2009-01-09  1826  		       __func__, cmd);
69f52adb Karsten Keil  2009-01-09  1827  	}
69f52adb Karsten Keil  2009-01-09  1828  	return ret;
69f52adb Karsten Keil  2009-01-09  1829  }
69f52adb Karsten Keil  2009-01-09  1830  
69f52adb Karsten Keil  2009-01-09  1831  static int
69f52adb Karsten Keil  2009-01-09  1832  setup_instance(struct hfcsusb *hw, struct device *parent)
69f52adb Karsten Keil  2009-01-09  1833  {
69f52adb Karsten Keil  2009-01-09  1834  	u_long	flags;
69f52adb Karsten Keil  2009-01-09  1835  	int	err, i;
69f52adb Karsten Keil  2009-01-09  1836  
69f52adb Karsten Keil  2009-01-09  1837  	if (debug & DBG_HFC_CALL_TRACE)
69f52adb Karsten Keil  2009-01-09  1838  		printk(KERN_DEBUG "%s: %s\n", hw->name, __func__);
69f52adb Karsten Keil  2009-01-09  1839  
69f52adb Karsten Keil  2009-01-09  1840  	spin_lock_init(&hw->ctrl_lock);
69f52adb Karsten Keil  2009-01-09  1841  	spin_lock_init(&hw->lock);
69f52adb Karsten Keil  2009-01-09  1842  
69f52adb Karsten Keil  2009-01-09 @1843  	mISDN_initdchannel(&hw->dch, MAX_DFRAME_LEN_L1, ph_state);
69f52adb Karsten Keil  2009-01-09  1844  	hw->dch.debug = debug & 0xFFFF;
69f52adb Karsten Keil  2009-01-09  1845  	hw->dch.hw = hw;
69f52adb Karsten Keil  2009-01-09  1846  	hw->dch.dev.Dprotocols = (1 << ISDN_P_TE_S0) | (1 << ISDN_P_NT_S0);
69f52adb Karsten Keil  2009-01-09  1847  	hw->dch.dev.D.send = hfcusb_l2l1D;
69f52adb Karsten Keil  2009-01-09  1848  	hw->dch.dev.D.ctrl = hfc_dctrl;
69f52adb Karsten Keil  2009-01-09  1849  
69f52adb Karsten Keil  2009-01-09  1850  	/* enable E-Channel logging */
69f52adb Karsten Keil  2009-01-09  1851  	if (hw->fifos[HFCUSB_PCM_RX].pipe)
69f52adb Karsten Keil  2009-01-09 @1852  		mISDN_initdchannel(&hw->ech, MAX_DFRAME_LEN_L1, NULL);
69f52adb Karsten Keil  2009-01-09  1853  
69f52adb Karsten Keil  2009-01-09  1854  	hw->dch.dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) |
69f52adb Karsten Keil  2009-01-09  1855  		(1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK));
69f52adb Karsten Keil  2009-01-09  1856  	hw->dch.dev.nrbchan = 2;
69f52adb Karsten Keil  2009-01-09  1857  	for (i = 0; i < 2; i++) {
69f52adb Karsten Keil  2009-01-09  1858  		hw->bch[i].nr = i + 1;
69f52adb Karsten Keil  2009-01-09  1859  		set_channelmap(i + 1, hw->dch.dev.channelmap);
69f52adb Karsten Keil  2009-01-09  1860  		hw->bch[i].debug = debug;
034005a0 Karsten Keil  2012-05-15 @1861  		mISDN_initbchannel(&hw->bch[i], MAX_DATA_MEM, poll >> 1);
69f52adb Karsten Keil  2009-01-09  1862  		hw->bch[i].hw = hw;
69f52adb Karsten Keil  2009-01-09  1863  		hw->bch[i].ch.send = hfcusb_l2l1B;
69f52adb Karsten Keil  2009-01-09  1864  		hw->bch[i].ch.ctrl = hfc_bctrl;
69f52adb Karsten Keil  2009-01-09  1865  		hw->bch[i].ch.nr = i + 1;
69f52adb Karsten Keil  2009-01-09  1866  		list_add(&hw->bch[i].ch.list, &hw->dch.dev.bchannels);
69f52adb Karsten Keil  2009-01-09  1867  	}
69f52adb Karsten Keil  2009-01-09  1868  
69f52adb Karsten Keil  2009-01-09  1869  	hw->fifos[HFCUSB_B1_TX].bch = &hw->bch[0];
69f52adb Karsten Keil  2009-01-09  1870  	hw->fifos[HFCUSB_B1_RX].bch = &hw->bch[0];
69f52adb Karsten Keil  2009-01-09  1871  	hw->fifos[HFCUSB_B2_TX].bch = &hw->bch[1];
69f52adb Karsten Keil  2009-01-09  1872  	hw->fifos[HFCUSB_B2_RX].bch = &hw->bch[1];
69f52adb Karsten Keil  2009-01-09  1873  	hw->fifos[HFCUSB_D_TX].dch = &hw->dch;
69f52adb Karsten Keil  2009-01-09  1874  	hw->fifos[HFCUSB_D_RX].dch = &hw->dch;
69f52adb Karsten Keil  2009-01-09  1875  	hw->fifos[HFCUSB_PCM_RX].ech = &hw->ech;
69f52adb Karsten Keil  2009-01-09  1876  	hw->fifos[HFCUSB_PCM_TX].ech = &hw->ech;
69f52adb Karsten Keil  2009-01-09  1877  
69f52adb Karsten Keil  2009-01-09  1878  	err = setup_hfcsusb(hw);
69f52adb Karsten Keil  2009-01-09  1879  	if (err)
69f52adb Karsten Keil  2009-01-09  1880  		goto out;
69f52adb Karsten Keil  2009-01-09  1881  
69f52adb Karsten Keil  2009-01-09  1882  	snprintf(hw->name, MISDN_MAX_IDLEN - 1, "%s.%d", DRIVER_NAME,
69f52adb Karsten Keil  2009-01-09  1883  		 hfcsusb_cnt + 1);
69f52adb Karsten Keil  2009-01-09  1884  	printk(KERN_INFO "%s: registered as '%s'\n",
69f52adb Karsten Keil  2009-01-09  1885  	       DRIVER_NAME, hw->name);
69f52adb Karsten Keil  2009-01-09  1886  
69f52adb Karsten Keil  2009-01-09 @1887  	err = mISDN_register_device(&hw->dch.dev, parent, hw->name);
69f52adb Karsten Keil  2009-01-09  1888  	if (err)
69f52adb Karsten Keil  2009-01-09  1889  		goto out;
69f52adb Karsten Keil  2009-01-09  1890  
69f52adb Karsten Keil  2009-01-09  1891  	hfcsusb_cnt++;
69f52adb Karsten Keil  2009-01-09  1892  	write_lock_irqsave(&HFClock, flags);
69f52adb Karsten Keil  2009-01-09  1893  	list_add_tail(&hw->list, &HFClist);
69f52adb Karsten Keil  2009-01-09  1894  	write_unlock_irqrestore(&HFClock, flags);
69f52adb Karsten Keil  2009-01-09  1895  	return 0;
69f52adb Karsten Keil  2009-01-09  1896  
69f52adb Karsten Keil  2009-01-09  1897  out:
69f52adb Karsten Keil  2009-01-09  1898  	mISDN_freebchannel(&hw->bch[1]);
69f52adb Karsten Keil  2009-01-09  1899  	mISDN_freebchannel(&hw->bch[0]);
69f52adb Karsten Keil  2009-01-09  1900  	mISDN_freedchannel(&hw->dch);
69f52adb Karsten Keil  2009-01-09  1901  	kfree(hw);
69f52adb Karsten Keil  2009-01-09  1902  	return err;
69f52adb Karsten Keil  2009-01-09  1903  }
69f52adb Karsten Keil  2009-01-09  1904  

:::::: The code at line 1757 was first introduced by commit
:::::: 69f52adb2d534afc41fcc658f155e01f0b322f9e mISDN: Add HFC USB driver

:::::: TO: Karsten Keil <kkeil@suse.de>
:::::: CC: Karsten Keil <kkeil@suse.de>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 31916 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/5] kbuild: treat a directory listed in a composite object as foo/mod.a
  2018-06-18  9:14   ` kbuild test robot
@ 2018-06-18 22:30       ` NeilBrown
  0 siblings, 0 replies; 20+ messages in thread
From: NeilBrown @ 2018-06-18 22:30 UTC (permalink / raw)
  To: kbuild test robot, Karsten Keil
  Cc: kbuild-all, Masahiro Yamada, Michal Marek, linux-kernel, linux-kbuild

[-- Attachment #1: Type: text/plain, Size: 16846 bytes --]

On Mon, Jun 18 2018, kbuild test robot wrote:

> Hi NeilBrown,
>
> Thank you for the patch! Yet something to improve:


Thank you for your testing and problem report! Yet something to improve:-)

This bug is caused by the combination CONFIG_MISDN_HFCUSB=y and CONFIG_MISDN=m
and appears to have nothing to do with my patch.
I suspect drivers/isdn/hardware/mISDN/Kconfig needs

@@ -35,6 +35,7 @@ config MISDN_HFCMULTI_8xx
 config MISDN_HFCUSB
 	tristate "Support for HFC-S USB based TAs"
 	depends on USB
+	depends on MISDN
 	help
 	  Enable support for USB ISDN TAs with Cologne Chip AG's
 	  HFC-S USB ISDN Controller

or similar.

Thanks,
NeilBrown

(config file excerpt for Karsten:
CONFIG_MISDN=m
CONFIG_MISDN_DSP=m
CONFIG_MISDN_L1OIP=m
CONFIG_MISDN_HFCPCI=m
# CONFIG_MISDN_HFCMULTI is not set
CONFIG_MISDN_HFCUSB=y
CONFIG_MISDN_AVMFRITZ=m
CONFIG_MISDN_SPEEDFAX=m
CONFIG_MISDN_INFINEON=m
CONFIG_MISDN_W6692=m
# CONFIG_MISDN_NETJET is not set
CONFIG_MISDN_IPAC=m
CONFIG_MISDN_ISAR=m
)

>
> [auto build test ERROR on kbuild/for-next]
> [also build test ERROR on v4.18-rc1 next-20180618]
> [cannot apply to mmarek/for-next mmarek/rc-fixes]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url:    https://github.com/0day-ci/linux/commits/NeilBrown/kbuild-build-modules-from-code-in-multiple-directories/20180618-130250
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
> config: x86_64-randconfig-in0-06170623 (attached as .config)
> compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
> reproduce:
>         # save the attached .config to linux build tree
>         make ARCH=x86_64 
>
> All errors (new ones prefixed by >>):
>
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `release_hw':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1757: undefined reference to `l1_event'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1759: undefined reference to `mISDN_unregister_device'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1760: undefined reference to `mISDN_freebchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.c:1761: undefined reference to `mISDN_freebchannel'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1762: undefined reference to `mISDN_freedchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `deactivate_bchannel':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1788: undefined reference to `mISDN_clear_bchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `ph_state_te':
>    drivers/isdn/hardware/mISDN/hfcsusb.c:611: undefined reference to `l1_event'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `channel_bctrl':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:808: undefined reference to `mISDN_ctrl_bchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `tx_iso_complete':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1345: undefined reference to `get_next_dframe'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1348: undefined reference to `get_next_bframe'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `hfcsusb_rx_frame':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:850: undefined reference to `bchannel_get_rxbuf'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:919: undefined reference to `recv_Dchannel'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:921: undefined reference to `recv_Bchannel'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:924: undefined reference to `recv_Echannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.c:943: undefined reference to `recv_Bchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `hfcusb_l2l1D':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:301: undefined reference to `dchannel_senddata'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:305: undefined reference to `queue_ch_frame'
>    drivers/isdn/hardware/mISDN/hfcsusb.c:360: undefined reference to `l1_event'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `setup_instance':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1843: undefined reference to `mISDN_initdchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.c:1852: undefined reference to `mISDN_initdchannel'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1861: undefined reference to `mISDN_initbchannel'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1887: undefined reference to `mISDN_register_device'
>    drivers/isdn/hardware/mISDN/hfcsusb.c:1898: undefined reference to `mISDN_freebchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.c:1899: undefined reference to `mISDN_freebchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.c:1900: undefined reference to `mISDN_freedchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `hfcusb_l2l1B':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:224: undefined reference to `bchannel_senddata'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `open_dchannel':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:454: undefined reference to `create_l1'
>
> vim +1757 drivers/isdn/hardware/mISDN/hfcsusb.c
>
> 69f52adb Karsten Keil  2009-01-09  1739  
> 69f52adb Karsten Keil  2009-01-09  1740  static void
> 69f52adb Karsten Keil  2009-01-09  1741  release_hw(struct hfcsusb *hw)
> 69f52adb Karsten Keil  2009-01-09  1742  {
> 69f52adb Karsten Keil  2009-01-09  1743  	if (debug & DBG_HFC_CALL_TRACE)
> 69f52adb Karsten Keil  2009-01-09  1744  		printk(KERN_DEBUG "%s: %s\n", hw->name, __func__);
> 69f52adb Karsten Keil  2009-01-09  1745  
> 69f52adb Karsten Keil  2009-01-09  1746  	/*
> 69f52adb Karsten Keil  2009-01-09  1747  	 * stop all endpoints gracefully
> 69f52adb Karsten Keil  2009-01-09  1748  	 * TODO: mISDN_core should generate CLOSE_CHANNEL
> 69f52adb Karsten Keil  2009-01-09  1749  	 *       signals after calling mISDN_unregister_device()
> 69f52adb Karsten Keil  2009-01-09  1750  	 */
> 69f52adb Karsten Keil  2009-01-09  1751  	hfcsusb_stop_endpoint(hw, HFC_CHAN_D);
> 69f52adb Karsten Keil  2009-01-09  1752  	hfcsusb_stop_endpoint(hw, HFC_CHAN_B1);
> 69f52adb Karsten Keil  2009-01-09  1753  	hfcsusb_stop_endpoint(hw, HFC_CHAN_B2);
> 69f52adb Karsten Keil  2009-01-09  1754  	if (hw->fifos[HFCUSB_PCM_RX].pipe)
> 69f52adb Karsten Keil  2009-01-09  1755  		hfcsusb_stop_endpoint(hw, HFC_CHAN_E);
> 69f52adb Karsten Keil  2009-01-09  1756  	if (hw->protocol == ISDN_P_TE_S0)
> 69f52adb Karsten Keil  2009-01-09 @1757  		l1_event(hw->dch.l1, CLOSE_CHANNEL);
> 69f52adb Karsten Keil  2009-01-09  1758  
> 69f52adb Karsten Keil  2009-01-09 @1759  	mISDN_unregister_device(&hw->dch.dev);
> 69f52adb Karsten Keil  2009-01-09 @1760  	mISDN_freebchannel(&hw->bch[1]);
> 69f52adb Karsten Keil  2009-01-09 @1761  	mISDN_freebchannel(&hw->bch[0]);
> 69f52adb Karsten Keil  2009-01-09 @1762  	mISDN_freedchannel(&hw->dch);
> 69f52adb Karsten Keil  2009-01-09  1763  
> 69f52adb Karsten Keil  2009-01-09  1764  	if (hw->ctrl_urb) {
> 69f52adb Karsten Keil  2009-01-09  1765  		usb_kill_urb(hw->ctrl_urb);
> 69f52adb Karsten Keil  2009-01-09  1766  		usb_free_urb(hw->ctrl_urb);
> 69f52adb Karsten Keil  2009-01-09  1767  		hw->ctrl_urb = NULL;
> 69f52adb Karsten Keil  2009-01-09  1768  	}
> 69f52adb Karsten Keil  2009-01-09  1769  
> 69f52adb Karsten Keil  2009-01-09  1770  	if (hw->intf)
> 69f52adb Karsten Keil  2009-01-09  1771  		usb_set_intfdata(hw->intf, NULL);
> 69f52adb Karsten Keil  2009-01-09  1772  	list_del(&hw->list);
> 69f52adb Karsten Keil  2009-01-09  1773  	kfree(hw);
> 69f52adb Karsten Keil  2009-01-09  1774  	hw = NULL;
> 69f52adb Karsten Keil  2009-01-09  1775  }
> 69f52adb Karsten Keil  2009-01-09  1776  
> 69f52adb Karsten Keil  2009-01-09  1777  static void
> 69f52adb Karsten Keil  2009-01-09  1778  deactivate_bchannel(struct bchannel *bch)
> 69f52adb Karsten Keil  2009-01-09  1779  {
> 69f52adb Karsten Keil  2009-01-09  1780  	struct hfcsusb *hw = bch->hw;
> 69f52adb Karsten Keil  2009-01-09  1781  	u_long flags;
> 69f52adb Karsten Keil  2009-01-09  1782  
> 69f52adb Karsten Keil  2009-01-09  1783  	if (bch->debug & DEBUG_HW)
> 69f52adb Karsten Keil  2009-01-09  1784  		printk(KERN_DEBUG "%s: %s: bch->nr(%i)\n",
> 69f52adb Karsten Keil  2009-01-09  1785  		       hw->name, __func__, bch->nr);
> 69f52adb Karsten Keil  2009-01-09  1786  
> 69f52adb Karsten Keil  2009-01-09  1787  	spin_lock_irqsave(&hw->lock, flags);
> fb286f04 Karsten Keil  2009-07-09 @1788  	mISDN_clear_bchannel(bch);
> 69f52adb Karsten Keil  2009-01-09  1789  	spin_unlock_irqrestore(&hw->lock, flags);
> 69f52adb Karsten Keil  2009-01-09  1790  	hfcsusb_setup_bch(bch, ISDN_P_NONE);
> 37952cfa Martin Bachem 2012-05-15  1791  	hfcsusb_stop_endpoint(hw, bch->nr - 1);
> 69f52adb Karsten Keil  2009-01-09  1792  }
> 69f52adb Karsten Keil  2009-01-09  1793  
> 69f52adb Karsten Keil  2009-01-09  1794  /*
> 69f52adb Karsten Keil  2009-01-09  1795   * Layer 1 B-channel hardware access
> 69f52adb Karsten Keil  2009-01-09  1796   */
> 69f52adb Karsten Keil  2009-01-09  1797  static int
> 69f52adb Karsten Keil  2009-01-09  1798  hfc_bctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
> 69f52adb Karsten Keil  2009-01-09  1799  {
> 69f52adb Karsten Keil  2009-01-09  1800  	struct bchannel	*bch = container_of(ch, struct bchannel, ch);
> 69f52adb Karsten Keil  2009-01-09  1801  	int		ret = -EINVAL;
> 69f52adb Karsten Keil  2009-01-09  1802  
> 69f52adb Karsten Keil  2009-01-09  1803  	if (bch->debug & DEBUG_HW)
> 69f52adb Karsten Keil  2009-01-09  1804  		printk(KERN_DEBUG "%s: cmd:%x %p\n", __func__, cmd, arg);
> 69f52adb Karsten Keil  2009-01-09  1805  
> 69f52adb Karsten Keil  2009-01-09  1806  	switch (cmd) {
> 69f52adb Karsten Keil  2009-01-09  1807  	case HW_TESTRX_RAW:
> 69f52adb Karsten Keil  2009-01-09  1808  	case HW_TESTRX_HDLC:
> 69f52adb Karsten Keil  2009-01-09  1809  	case HW_TESTRX_OFF:
> 69f52adb Karsten Keil  2009-01-09  1810  		ret = -EINVAL;
> 69f52adb Karsten Keil  2009-01-09  1811  		break;
> 69f52adb Karsten Keil  2009-01-09  1812  
> 69f52adb Karsten Keil  2009-01-09  1813  	case CLOSE_CHANNEL:
> 69f52adb Karsten Keil  2009-01-09  1814  		test_and_clear_bit(FLG_OPEN, &bch->Flags);
> 69f52adb Karsten Keil  2009-01-09  1815  		deactivate_bchannel(bch);
> 69f52adb Karsten Keil  2009-01-09  1816  		ch->protocol = ISDN_P_NONE;
> 69f52adb Karsten Keil  2009-01-09  1817  		ch->peer = NULL;
> 69f52adb Karsten Keil  2009-01-09  1818  		module_put(THIS_MODULE);
> 69f52adb Karsten Keil  2009-01-09  1819  		ret = 0;
> 69f52adb Karsten Keil  2009-01-09  1820  		break;
> 69f52adb Karsten Keil  2009-01-09  1821  	case CONTROL_CHANNEL:
> 69f52adb Karsten Keil  2009-01-09  1822  		ret = channel_bctrl(bch, arg);
> 69f52adb Karsten Keil  2009-01-09  1823  		break;
> 69f52adb Karsten Keil  2009-01-09  1824  	default:
> 69f52adb Karsten Keil  2009-01-09  1825  		printk(KERN_WARNING "%s: unknown prim(%x)\n",
> 69f52adb Karsten Keil  2009-01-09  1826  		       __func__, cmd);
> 69f52adb Karsten Keil  2009-01-09  1827  	}
> 69f52adb Karsten Keil  2009-01-09  1828  	return ret;
> 69f52adb Karsten Keil  2009-01-09  1829  }
> 69f52adb Karsten Keil  2009-01-09  1830  
> 69f52adb Karsten Keil  2009-01-09  1831  static int
> 69f52adb Karsten Keil  2009-01-09  1832  setup_instance(struct hfcsusb *hw, struct device *parent)
> 69f52adb Karsten Keil  2009-01-09  1833  {
> 69f52adb Karsten Keil  2009-01-09  1834  	u_long	flags;
> 69f52adb Karsten Keil  2009-01-09  1835  	int	err, i;
> 69f52adb Karsten Keil  2009-01-09  1836  
> 69f52adb Karsten Keil  2009-01-09  1837  	if (debug & DBG_HFC_CALL_TRACE)
> 69f52adb Karsten Keil  2009-01-09  1838  		printk(KERN_DEBUG "%s: %s\n", hw->name, __func__);
> 69f52adb Karsten Keil  2009-01-09  1839  
> 69f52adb Karsten Keil  2009-01-09  1840  	spin_lock_init(&hw->ctrl_lock);
> 69f52adb Karsten Keil  2009-01-09  1841  	spin_lock_init(&hw->lock);
> 69f52adb Karsten Keil  2009-01-09  1842  
> 69f52adb Karsten Keil  2009-01-09 @1843  	mISDN_initdchannel(&hw->dch, MAX_DFRAME_LEN_L1, ph_state);
> 69f52adb Karsten Keil  2009-01-09  1844  	hw->dch.debug = debug & 0xFFFF;
> 69f52adb Karsten Keil  2009-01-09  1845  	hw->dch.hw = hw;
> 69f52adb Karsten Keil  2009-01-09  1846  	hw->dch.dev.Dprotocols = (1 << ISDN_P_TE_S0) | (1 << ISDN_P_NT_S0);
> 69f52adb Karsten Keil  2009-01-09  1847  	hw->dch.dev.D.send = hfcusb_l2l1D;
> 69f52adb Karsten Keil  2009-01-09  1848  	hw->dch.dev.D.ctrl = hfc_dctrl;
> 69f52adb Karsten Keil  2009-01-09  1849  
> 69f52adb Karsten Keil  2009-01-09  1850  	/* enable E-Channel logging */
> 69f52adb Karsten Keil  2009-01-09  1851  	if (hw->fifos[HFCUSB_PCM_RX].pipe)
> 69f52adb Karsten Keil  2009-01-09 @1852  		mISDN_initdchannel(&hw->ech, MAX_DFRAME_LEN_L1, NULL);
> 69f52adb Karsten Keil  2009-01-09  1853  
> 69f52adb Karsten Keil  2009-01-09  1854  	hw->dch.dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) |
> 69f52adb Karsten Keil  2009-01-09  1855  		(1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK));
> 69f52adb Karsten Keil  2009-01-09  1856  	hw->dch.dev.nrbchan = 2;
> 69f52adb Karsten Keil  2009-01-09  1857  	for (i = 0; i < 2; i++) {
> 69f52adb Karsten Keil  2009-01-09  1858  		hw->bch[i].nr = i + 1;
> 69f52adb Karsten Keil  2009-01-09  1859  		set_channelmap(i + 1, hw->dch.dev.channelmap);
> 69f52adb Karsten Keil  2009-01-09  1860  		hw->bch[i].debug = debug;
> 034005a0 Karsten Keil  2012-05-15 @1861  		mISDN_initbchannel(&hw->bch[i], MAX_DATA_MEM, poll >> 1);
> 69f52adb Karsten Keil  2009-01-09  1862  		hw->bch[i].hw = hw;
> 69f52adb Karsten Keil  2009-01-09  1863  		hw->bch[i].ch.send = hfcusb_l2l1B;
> 69f52adb Karsten Keil  2009-01-09  1864  		hw->bch[i].ch.ctrl = hfc_bctrl;
> 69f52adb Karsten Keil  2009-01-09  1865  		hw->bch[i].ch.nr = i + 1;
> 69f52adb Karsten Keil  2009-01-09  1866  		list_add(&hw->bch[i].ch.list, &hw->dch.dev.bchannels);
> 69f52adb Karsten Keil  2009-01-09  1867  	}
> 69f52adb Karsten Keil  2009-01-09  1868  
> 69f52adb Karsten Keil  2009-01-09  1869  	hw->fifos[HFCUSB_B1_TX].bch = &hw->bch[0];
> 69f52adb Karsten Keil  2009-01-09  1870  	hw->fifos[HFCUSB_B1_RX].bch = &hw->bch[0];
> 69f52adb Karsten Keil  2009-01-09  1871  	hw->fifos[HFCUSB_B2_TX].bch = &hw->bch[1];
> 69f52adb Karsten Keil  2009-01-09  1872  	hw->fifos[HFCUSB_B2_RX].bch = &hw->bch[1];
> 69f52adb Karsten Keil  2009-01-09  1873  	hw->fifos[HFCUSB_D_TX].dch = &hw->dch;
> 69f52adb Karsten Keil  2009-01-09  1874  	hw->fifos[HFCUSB_D_RX].dch = &hw->dch;
> 69f52adb Karsten Keil  2009-01-09  1875  	hw->fifos[HFCUSB_PCM_RX].ech = &hw->ech;
> 69f52adb Karsten Keil  2009-01-09  1876  	hw->fifos[HFCUSB_PCM_TX].ech = &hw->ech;
> 69f52adb Karsten Keil  2009-01-09  1877  
> 69f52adb Karsten Keil  2009-01-09  1878  	err = setup_hfcsusb(hw);
> 69f52adb Karsten Keil  2009-01-09  1879  	if (err)
> 69f52adb Karsten Keil  2009-01-09  1880  		goto out;
> 69f52adb Karsten Keil  2009-01-09  1881  
> 69f52adb Karsten Keil  2009-01-09  1882  	snprintf(hw->name, MISDN_MAX_IDLEN - 1, "%s.%d", DRIVER_NAME,
> 69f52adb Karsten Keil  2009-01-09  1883  		 hfcsusb_cnt + 1);
> 69f52adb Karsten Keil  2009-01-09  1884  	printk(KERN_INFO "%s: registered as '%s'\n",
> 69f52adb Karsten Keil  2009-01-09  1885  	       DRIVER_NAME, hw->name);
> 69f52adb Karsten Keil  2009-01-09  1886  
> 69f52adb Karsten Keil  2009-01-09 @1887  	err = mISDN_register_device(&hw->dch.dev, parent, hw->name);
> 69f52adb Karsten Keil  2009-01-09  1888  	if (err)
> 69f52adb Karsten Keil  2009-01-09  1889  		goto out;
> 69f52adb Karsten Keil  2009-01-09  1890  
> 69f52adb Karsten Keil  2009-01-09  1891  	hfcsusb_cnt++;
> 69f52adb Karsten Keil  2009-01-09  1892  	write_lock_irqsave(&HFClock, flags);
> 69f52adb Karsten Keil  2009-01-09  1893  	list_add_tail(&hw->list, &HFClist);
> 69f52adb Karsten Keil  2009-01-09  1894  	write_unlock_irqrestore(&HFClock, flags);
> 69f52adb Karsten Keil  2009-01-09  1895  	return 0;
> 69f52adb Karsten Keil  2009-01-09  1896  
> 69f52adb Karsten Keil  2009-01-09  1897  out:
> 69f52adb Karsten Keil  2009-01-09  1898  	mISDN_freebchannel(&hw->bch[1]);
> 69f52adb Karsten Keil  2009-01-09  1899  	mISDN_freebchannel(&hw->bch[0]);
> 69f52adb Karsten Keil  2009-01-09  1900  	mISDN_freedchannel(&hw->dch);
> 69f52adb Karsten Keil  2009-01-09  1901  	kfree(hw);
> 69f52adb Karsten Keil  2009-01-09  1902  	return err;
> 69f52adb Karsten Keil  2009-01-09  1903  }
> 69f52adb Karsten Keil  2009-01-09  1904  
>
> :::::: The code at line 1757 was first introduced by commit
> :::::: 69f52adb2d534afc41fcc658f155e01f0b322f9e mISDN: Add HFC USB driver
>
> :::::: TO: Karsten Keil <kkeil@suse.de>
> :::::: CC: Karsten Keil <kkeil@suse.de>
>
> ---
> 0-DAY kernel test infrastructure                Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/5] kbuild: treat a directory listed in a composite object as foo/mod.a
@ 2018-06-18 22:30       ` NeilBrown
  0 siblings, 0 replies; 20+ messages in thread
From: NeilBrown @ 2018-06-18 22:30 UTC (permalink / raw)
  To: kbuild test robot, Karsten Keil
  Cc: kbuild-all, Masahiro Yamada, Michal Marek, linux-kernel, linux-kbuild

[-- Attachment #1: Type: text/plain, Size: 16846 bytes --]

On Mon, Jun 18 2018, kbuild test robot wrote:

> Hi NeilBrown,
>
> Thank you for the patch! Yet something to improve:


Thank you for your testing and problem report! Yet something to improve:-)

This bug is caused by the combination CONFIG_MISDN_HFCUSB=y and CONFIG_MISDN=m
and appears to have nothing to do with my patch.
I suspect drivers/isdn/hardware/mISDN/Kconfig needs

@@ -35,6 +35,7 @@ config MISDN_HFCMULTI_8xx
 config MISDN_HFCUSB
 	tristate "Support for HFC-S USB based TAs"
 	depends on USB
+	depends on MISDN
 	help
 	  Enable support for USB ISDN TAs with Cologne Chip AG's
 	  HFC-S USB ISDN Controller

or similar.

Thanks,
NeilBrown

(config file excerpt for Karsten:
CONFIG_MISDN=m
CONFIG_MISDN_DSP=m
CONFIG_MISDN_L1OIP=m
CONFIG_MISDN_HFCPCI=m
# CONFIG_MISDN_HFCMULTI is not set
CONFIG_MISDN_HFCUSB=y
CONFIG_MISDN_AVMFRITZ=m
CONFIG_MISDN_SPEEDFAX=m
CONFIG_MISDN_INFINEON=m
CONFIG_MISDN_W6692=m
# CONFIG_MISDN_NETJET is not set
CONFIG_MISDN_IPAC=m
CONFIG_MISDN_ISAR=m
)

>
> [auto build test ERROR on kbuild/for-next]
> [also build test ERROR on v4.18-rc1 next-20180618]
> [cannot apply to mmarek/for-next mmarek/rc-fixes]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url:    https://github.com/0day-ci/linux/commits/NeilBrown/kbuild-build-modules-from-code-in-multiple-directories/20180618-130250
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
> config: x86_64-randconfig-in0-06170623 (attached as .config)
> compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
> reproduce:
>         # save the attached .config to linux build tree
>         make ARCH=x86_64 
>
> All errors (new ones prefixed by >>):
>
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `release_hw':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1757: undefined reference to `l1_event'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1759: undefined reference to `mISDN_unregister_device'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1760: undefined reference to `mISDN_freebchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.c:1761: undefined reference to `mISDN_freebchannel'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1762: undefined reference to `mISDN_freedchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `deactivate_bchannel':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1788: undefined reference to `mISDN_clear_bchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `ph_state_te':
>    drivers/isdn/hardware/mISDN/hfcsusb.c:611: undefined reference to `l1_event'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `channel_bctrl':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:808: undefined reference to `mISDN_ctrl_bchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `tx_iso_complete':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1345: undefined reference to `get_next_dframe'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1348: undefined reference to `get_next_bframe'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `hfcsusb_rx_frame':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:850: undefined reference to `bchannel_get_rxbuf'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:919: undefined reference to `recv_Dchannel'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:921: undefined reference to `recv_Bchannel'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:924: undefined reference to `recv_Echannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.c:943: undefined reference to `recv_Bchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `hfcusb_l2l1D':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:301: undefined reference to `dchannel_senddata'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:305: undefined reference to `queue_ch_frame'
>    drivers/isdn/hardware/mISDN/hfcsusb.c:360: undefined reference to `l1_event'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `setup_instance':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1843: undefined reference to `mISDN_initdchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.c:1852: undefined reference to `mISDN_initdchannel'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1861: undefined reference to `mISDN_initbchannel'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1887: undefined reference to `mISDN_register_device'
>    drivers/isdn/hardware/mISDN/hfcsusb.c:1898: undefined reference to `mISDN_freebchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.c:1899: undefined reference to `mISDN_freebchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.c:1900: undefined reference to `mISDN_freedchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `hfcusb_l2l1B':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:224: undefined reference to `bchannel_senddata'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `open_dchannel':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:454: undefined reference to `create_l1'
>
> vim +1757 drivers/isdn/hardware/mISDN/hfcsusb.c
>
> 69f52adb Karsten Keil  2009-01-09  1739  
> 69f52adb Karsten Keil  2009-01-09  1740  static void
> 69f52adb Karsten Keil  2009-01-09  1741  release_hw(struct hfcsusb *hw)
> 69f52adb Karsten Keil  2009-01-09  1742  {
> 69f52adb Karsten Keil  2009-01-09  1743  	if (debug & DBG_HFC_CALL_TRACE)
> 69f52adb Karsten Keil  2009-01-09  1744  		printk(KERN_DEBUG "%s: %s\n", hw->name, __func__);
> 69f52adb Karsten Keil  2009-01-09  1745  
> 69f52adb Karsten Keil  2009-01-09  1746  	/*
> 69f52adb Karsten Keil  2009-01-09  1747  	 * stop all endpoints gracefully
> 69f52adb Karsten Keil  2009-01-09  1748  	 * TODO: mISDN_core should generate CLOSE_CHANNEL
> 69f52adb Karsten Keil  2009-01-09  1749  	 *       signals after calling mISDN_unregister_device()
> 69f52adb Karsten Keil  2009-01-09  1750  	 */
> 69f52adb Karsten Keil  2009-01-09  1751  	hfcsusb_stop_endpoint(hw, HFC_CHAN_D);
> 69f52adb Karsten Keil  2009-01-09  1752  	hfcsusb_stop_endpoint(hw, HFC_CHAN_B1);
> 69f52adb Karsten Keil  2009-01-09  1753  	hfcsusb_stop_endpoint(hw, HFC_CHAN_B2);
> 69f52adb Karsten Keil  2009-01-09  1754  	if (hw->fifos[HFCUSB_PCM_RX].pipe)
> 69f52adb Karsten Keil  2009-01-09  1755  		hfcsusb_stop_endpoint(hw, HFC_CHAN_E);
> 69f52adb Karsten Keil  2009-01-09  1756  	if (hw->protocol == ISDN_P_TE_S0)
> 69f52adb Karsten Keil  2009-01-09 @1757  		l1_event(hw->dch.l1, CLOSE_CHANNEL);
> 69f52adb Karsten Keil  2009-01-09  1758  
> 69f52adb Karsten Keil  2009-01-09 @1759  	mISDN_unregister_device(&hw->dch.dev);
> 69f52adb Karsten Keil  2009-01-09 @1760  	mISDN_freebchannel(&hw->bch[1]);
> 69f52adb Karsten Keil  2009-01-09 @1761  	mISDN_freebchannel(&hw->bch[0]);
> 69f52adb Karsten Keil  2009-01-09 @1762  	mISDN_freedchannel(&hw->dch);
> 69f52adb Karsten Keil  2009-01-09  1763  
> 69f52adb Karsten Keil  2009-01-09  1764  	if (hw->ctrl_urb) {
> 69f52adb Karsten Keil  2009-01-09  1765  		usb_kill_urb(hw->ctrl_urb);
> 69f52adb Karsten Keil  2009-01-09  1766  		usb_free_urb(hw->ctrl_urb);
> 69f52adb Karsten Keil  2009-01-09  1767  		hw->ctrl_urb = NULL;
> 69f52adb Karsten Keil  2009-01-09  1768  	}
> 69f52adb Karsten Keil  2009-01-09  1769  
> 69f52adb Karsten Keil  2009-01-09  1770  	if (hw->intf)
> 69f52adb Karsten Keil  2009-01-09  1771  		usb_set_intfdata(hw->intf, NULL);
> 69f52adb Karsten Keil  2009-01-09  1772  	list_del(&hw->list);
> 69f52adb Karsten Keil  2009-01-09  1773  	kfree(hw);
> 69f52adb Karsten Keil  2009-01-09  1774  	hw = NULL;
> 69f52adb Karsten Keil  2009-01-09  1775  }
> 69f52adb Karsten Keil  2009-01-09  1776  
> 69f52adb Karsten Keil  2009-01-09  1777  static void
> 69f52adb Karsten Keil  2009-01-09  1778  deactivate_bchannel(struct bchannel *bch)
> 69f52adb Karsten Keil  2009-01-09  1779  {
> 69f52adb Karsten Keil  2009-01-09  1780  	struct hfcsusb *hw = bch->hw;
> 69f52adb Karsten Keil  2009-01-09  1781  	u_long flags;
> 69f52adb Karsten Keil  2009-01-09  1782  
> 69f52adb Karsten Keil  2009-01-09  1783  	if (bch->debug & DEBUG_HW)
> 69f52adb Karsten Keil  2009-01-09  1784  		printk(KERN_DEBUG "%s: %s: bch->nr(%i)\n",
> 69f52adb Karsten Keil  2009-01-09  1785  		       hw->name, __func__, bch->nr);
> 69f52adb Karsten Keil  2009-01-09  1786  
> 69f52adb Karsten Keil  2009-01-09  1787  	spin_lock_irqsave(&hw->lock, flags);
> fb286f04 Karsten Keil  2009-07-09 @1788  	mISDN_clear_bchannel(bch);
> 69f52adb Karsten Keil  2009-01-09  1789  	spin_unlock_irqrestore(&hw->lock, flags);
> 69f52adb Karsten Keil  2009-01-09  1790  	hfcsusb_setup_bch(bch, ISDN_P_NONE);
> 37952cfa Martin Bachem 2012-05-15  1791  	hfcsusb_stop_endpoint(hw, bch->nr - 1);
> 69f52adb Karsten Keil  2009-01-09  1792  }
> 69f52adb Karsten Keil  2009-01-09  1793  
> 69f52adb Karsten Keil  2009-01-09  1794  /*
> 69f52adb Karsten Keil  2009-01-09  1795   * Layer 1 B-channel hardware access
> 69f52adb Karsten Keil  2009-01-09  1796   */
> 69f52adb Karsten Keil  2009-01-09  1797  static int
> 69f52adb Karsten Keil  2009-01-09  1798  hfc_bctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
> 69f52adb Karsten Keil  2009-01-09  1799  {
> 69f52adb Karsten Keil  2009-01-09  1800  	struct bchannel	*bch = container_of(ch, struct bchannel, ch);
> 69f52adb Karsten Keil  2009-01-09  1801  	int		ret = -EINVAL;
> 69f52adb Karsten Keil  2009-01-09  1802  
> 69f52adb Karsten Keil  2009-01-09  1803  	if (bch->debug & DEBUG_HW)
> 69f52adb Karsten Keil  2009-01-09  1804  		printk(KERN_DEBUG "%s: cmd:%x %p\n", __func__, cmd, arg);
> 69f52adb Karsten Keil  2009-01-09  1805  
> 69f52adb Karsten Keil  2009-01-09  1806  	switch (cmd) {
> 69f52adb Karsten Keil  2009-01-09  1807  	case HW_TESTRX_RAW:
> 69f52adb Karsten Keil  2009-01-09  1808  	case HW_TESTRX_HDLC:
> 69f52adb Karsten Keil  2009-01-09  1809  	case HW_TESTRX_OFF:
> 69f52adb Karsten Keil  2009-01-09  1810  		ret = -EINVAL;
> 69f52adb Karsten Keil  2009-01-09  1811  		break;
> 69f52adb Karsten Keil  2009-01-09  1812  
> 69f52adb Karsten Keil  2009-01-09  1813  	case CLOSE_CHANNEL:
> 69f52adb Karsten Keil  2009-01-09  1814  		test_and_clear_bit(FLG_OPEN, &bch->Flags);
> 69f52adb Karsten Keil  2009-01-09  1815  		deactivate_bchannel(bch);
> 69f52adb Karsten Keil  2009-01-09  1816  		ch->protocol = ISDN_P_NONE;
> 69f52adb Karsten Keil  2009-01-09  1817  		ch->peer = NULL;
> 69f52adb Karsten Keil  2009-01-09  1818  		module_put(THIS_MODULE);
> 69f52adb Karsten Keil  2009-01-09  1819  		ret = 0;
> 69f52adb Karsten Keil  2009-01-09  1820  		break;
> 69f52adb Karsten Keil  2009-01-09  1821  	case CONTROL_CHANNEL:
> 69f52adb Karsten Keil  2009-01-09  1822  		ret = channel_bctrl(bch, arg);
> 69f52adb Karsten Keil  2009-01-09  1823  		break;
> 69f52adb Karsten Keil  2009-01-09  1824  	default:
> 69f52adb Karsten Keil  2009-01-09  1825  		printk(KERN_WARNING "%s: unknown prim(%x)\n",
> 69f52adb Karsten Keil  2009-01-09  1826  		       __func__, cmd);
> 69f52adb Karsten Keil  2009-01-09  1827  	}
> 69f52adb Karsten Keil  2009-01-09  1828  	return ret;
> 69f52adb Karsten Keil  2009-01-09  1829  }
> 69f52adb Karsten Keil  2009-01-09  1830  
> 69f52adb Karsten Keil  2009-01-09  1831  static int
> 69f52adb Karsten Keil  2009-01-09  1832  setup_instance(struct hfcsusb *hw, struct device *parent)
> 69f52adb Karsten Keil  2009-01-09  1833  {
> 69f52adb Karsten Keil  2009-01-09  1834  	u_long	flags;
> 69f52adb Karsten Keil  2009-01-09  1835  	int	err, i;
> 69f52adb Karsten Keil  2009-01-09  1836  
> 69f52adb Karsten Keil  2009-01-09  1837  	if (debug & DBG_HFC_CALL_TRACE)
> 69f52adb Karsten Keil  2009-01-09  1838  		printk(KERN_DEBUG "%s: %s\n", hw->name, __func__);
> 69f52adb Karsten Keil  2009-01-09  1839  
> 69f52adb Karsten Keil  2009-01-09  1840  	spin_lock_init(&hw->ctrl_lock);
> 69f52adb Karsten Keil  2009-01-09  1841  	spin_lock_init(&hw->lock);
> 69f52adb Karsten Keil  2009-01-09  1842  
> 69f52adb Karsten Keil  2009-01-09 @1843  	mISDN_initdchannel(&hw->dch, MAX_DFRAME_LEN_L1, ph_state);
> 69f52adb Karsten Keil  2009-01-09  1844  	hw->dch.debug = debug & 0xFFFF;
> 69f52adb Karsten Keil  2009-01-09  1845  	hw->dch.hw = hw;
> 69f52adb Karsten Keil  2009-01-09  1846  	hw->dch.dev.Dprotocols = (1 << ISDN_P_TE_S0) | (1 << ISDN_P_NT_S0);
> 69f52adb Karsten Keil  2009-01-09  1847  	hw->dch.dev.D.send = hfcusb_l2l1D;
> 69f52adb Karsten Keil  2009-01-09  1848  	hw->dch.dev.D.ctrl = hfc_dctrl;
> 69f52adb Karsten Keil  2009-01-09  1849  
> 69f52adb Karsten Keil  2009-01-09  1850  	/* enable E-Channel logging */
> 69f52adb Karsten Keil  2009-01-09  1851  	if (hw->fifos[HFCUSB_PCM_RX].pipe)
> 69f52adb Karsten Keil  2009-01-09 @1852  		mISDN_initdchannel(&hw->ech, MAX_DFRAME_LEN_L1, NULL);
> 69f52adb Karsten Keil  2009-01-09  1853  
> 69f52adb Karsten Keil  2009-01-09  1854  	hw->dch.dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) |
> 69f52adb Karsten Keil  2009-01-09  1855  		(1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK));
> 69f52adb Karsten Keil  2009-01-09  1856  	hw->dch.dev.nrbchan = 2;
> 69f52adb Karsten Keil  2009-01-09  1857  	for (i = 0; i < 2; i++) {
> 69f52adb Karsten Keil  2009-01-09  1858  		hw->bch[i].nr = i + 1;
> 69f52adb Karsten Keil  2009-01-09  1859  		set_channelmap(i + 1, hw->dch.dev.channelmap);
> 69f52adb Karsten Keil  2009-01-09  1860  		hw->bch[i].debug = debug;
> 034005a0 Karsten Keil  2012-05-15 @1861  		mISDN_initbchannel(&hw->bch[i], MAX_DATA_MEM, poll >> 1);
> 69f52adb Karsten Keil  2009-01-09  1862  		hw->bch[i].hw = hw;
> 69f52adb Karsten Keil  2009-01-09  1863  		hw->bch[i].ch.send = hfcusb_l2l1B;
> 69f52adb Karsten Keil  2009-01-09  1864  		hw->bch[i].ch.ctrl = hfc_bctrl;
> 69f52adb Karsten Keil  2009-01-09  1865  		hw->bch[i].ch.nr = i + 1;
> 69f52adb Karsten Keil  2009-01-09  1866  		list_add(&hw->bch[i].ch.list, &hw->dch.dev.bchannels);
> 69f52adb Karsten Keil  2009-01-09  1867  	}
> 69f52adb Karsten Keil  2009-01-09  1868  
> 69f52adb Karsten Keil  2009-01-09  1869  	hw->fifos[HFCUSB_B1_TX].bch = &hw->bch[0];
> 69f52adb Karsten Keil  2009-01-09  1870  	hw->fifos[HFCUSB_B1_RX].bch = &hw->bch[0];
> 69f52adb Karsten Keil  2009-01-09  1871  	hw->fifos[HFCUSB_B2_TX].bch = &hw->bch[1];
> 69f52adb Karsten Keil  2009-01-09  1872  	hw->fifos[HFCUSB_B2_RX].bch = &hw->bch[1];
> 69f52adb Karsten Keil  2009-01-09  1873  	hw->fifos[HFCUSB_D_TX].dch = &hw->dch;
> 69f52adb Karsten Keil  2009-01-09  1874  	hw->fifos[HFCUSB_D_RX].dch = &hw->dch;
> 69f52adb Karsten Keil  2009-01-09  1875  	hw->fifos[HFCUSB_PCM_RX].ech = &hw->ech;
> 69f52adb Karsten Keil  2009-01-09  1876  	hw->fifos[HFCUSB_PCM_TX].ech = &hw->ech;
> 69f52adb Karsten Keil  2009-01-09  1877  
> 69f52adb Karsten Keil  2009-01-09  1878  	err = setup_hfcsusb(hw);
> 69f52adb Karsten Keil  2009-01-09  1879  	if (err)
> 69f52adb Karsten Keil  2009-01-09  1880  		goto out;
> 69f52adb Karsten Keil  2009-01-09  1881  
> 69f52adb Karsten Keil  2009-01-09  1882  	snprintf(hw->name, MISDN_MAX_IDLEN - 1, "%s.%d", DRIVER_NAME,
> 69f52adb Karsten Keil  2009-01-09  1883  		 hfcsusb_cnt + 1);
> 69f52adb Karsten Keil  2009-01-09  1884  	printk(KERN_INFO "%s: registered as '%s'\n",
> 69f52adb Karsten Keil  2009-01-09  1885  	       DRIVER_NAME, hw->name);
> 69f52adb Karsten Keil  2009-01-09  1886  
> 69f52adb Karsten Keil  2009-01-09 @1887  	err = mISDN_register_device(&hw->dch.dev, parent, hw->name);
> 69f52adb Karsten Keil  2009-01-09  1888  	if (err)
> 69f52adb Karsten Keil  2009-01-09  1889  		goto out;
> 69f52adb Karsten Keil  2009-01-09  1890  
> 69f52adb Karsten Keil  2009-01-09  1891  	hfcsusb_cnt++;
> 69f52adb Karsten Keil  2009-01-09  1892  	write_lock_irqsave(&HFClock, flags);
> 69f52adb Karsten Keil  2009-01-09  1893  	list_add_tail(&hw->list, &HFClist);
> 69f52adb Karsten Keil  2009-01-09  1894  	write_unlock_irqrestore(&HFClock, flags);
> 69f52adb Karsten Keil  2009-01-09  1895  	return 0;
> 69f52adb Karsten Keil  2009-01-09  1896  
> 69f52adb Karsten Keil  2009-01-09  1897  out:
> 69f52adb Karsten Keil  2009-01-09  1898  	mISDN_freebchannel(&hw->bch[1]);
> 69f52adb Karsten Keil  2009-01-09  1899  	mISDN_freebchannel(&hw->bch[0]);
> 69f52adb Karsten Keil  2009-01-09  1900  	mISDN_freedchannel(&hw->dch);
> 69f52adb Karsten Keil  2009-01-09  1901  	kfree(hw);
> 69f52adb Karsten Keil  2009-01-09  1902  	return err;
> 69f52adb Karsten Keil  2009-01-09  1903  }
> 69f52adb Karsten Keil  2009-01-09  1904  
>
> :::::: The code at line 1757 was first introduced by commit
> :::::: 69f52adb2d534afc41fcc658f155e01f0b322f9e mISDN: Add HFC USB driver
>
> :::::: TO: Karsten Keil <kkeil@suse.de>
> :::::: CC: Karsten Keil <kkeil@suse.de>
>
> ---
> 0-DAY kernel test infrastructure                Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 3/5 - v2] kbuild: support building of per-directory mod.a
  2018-06-18  4:55 ` [PATCH 3/5] kbuild: support building of per-directory mod.a NeilBrown
@ 2018-06-19  3:57   ` NeilBrown
  0 siblings, 0 replies; 20+ messages in thread
From: NeilBrown @ 2018-06-19  3:57 UTC (permalink / raw)
  To: Masahiro Yamada, Michal Marek; +Cc: linux-kernel, linux-kbuild

[-- Attachment #1: Type: text/plain, Size: 7269 bytes --]


This patch allows a "mod.a" to be built in any
directory.  A previous patch allows that mod.a
to be included in any module or another mod.a.

This is achieved via a new pair of macros: modobj-y and modobj-m.

Anything in modobj-y is added to obj-y and is otherwise
ignored.
Anything listed in modobj-m is built, almost as though "modobj.o" was
a requested target.  The objects are then combined
into mod.a.
These objects are always built with part-of-module=y.

This is sufficient to build a module from source in
multiple directories.  Each "other" directory lists
something like
 modobj-$(CONFIG_FOO) += bar.o bar.o bat.o

and the main directory lists

 obj-$(CONFIG-FOO) = foo.o
 foo-y = other1/ ../friend/other2/ module.o

Signed-off-by: NeilBrown <neilb@suse.com>
---

There was bug in the first version of this.
This line:
+targets += $(filter-out $(subdir-obj-m) $(real-modobj-m), $(real-obj-m))
is now
+targets += $(filter-out $(subdir-obj-m), $(real-modobj-m) $(real-obj-m))

Comma in the wrong place.

Thanks,
NeilBrown

 scripts/Makefile.build | 44 +++++++++++++++++++++++++++++++++-----------
 scripts/Makefile.lib   | 14 ++++++++++----
 2 files changed, 43 insertions(+), 15 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 928cd073a657..8ac10348c131 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -15,6 +15,8 @@ obj-y :=
 obj-m :=
 lib-y :=
 lib-m :=
+modobj-y :=
+modobj-m :=
 always :=
 targets :=
 subdir-y :=
@@ -80,12 +82,16 @@ ifneq ($(strip $(real-obj-y) $(need-builtin)),)
 builtin-target := $(obj)/built-in.a
 endif
 
+ifneq ($(strip $(modobj-m)),)
+modobj-target := $(obj)/mod.a
+endif
+
 modorder-target := $(obj)/modules.order
 
 # We keep a list of all modules in $(MODVERDIR)
 
 __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \
-	 $(if $(KBUILD_MODULES),$(obj-m) $(modorder-target)) \
+	 $(if $(KBUILD_MODULES),$(obj-m) $(modorder-target) $(modobj-target))  \
 	 $(subdir-ym) $(always)
 	@:
 
@@ -119,17 +125,19 @@ modkern_cflags =                                          \
 		$(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL))
 quiet_modtag := $(empty)   $(empty)
 
-$(real-obj-m)        : part-of-module := y
-$(real-obj-m:.o=.i)  : part-of-module := y
-$(real-obj-m:.o=.s)  : part-of-module := y
-$(real-obj-m:.o=.lst): part-of-module := y
+_mod_obj = $(real-obj-m) $(real-modobj-m)
+
+$(_mod_obj)        : part-of-module := y
+$(_mod_obj:.o=.i)  : part-of-module := y
+$(_mod_obj:.o=.s)  : part-of-module := y
+$(_mod_obj:.o=.lst): part-of-module := y
 
-$(real-obj-m)        : quiet_modtag := [M]
-$(real-obj-m:.o=.i)  : quiet_modtag := [M]
-$(real-obj-m:.o=.s)  : quiet_modtag := [M]
-$(real-obj-m:.o=.lst): quiet_modtag := [M]
+$(_mod_obj)        : quiet_modtag := [M]
+$(_mod_obj:.o=.i)  : quiet_modtag := [M]
+$(_mod_obj:.o=.s)  : quiet_modtag := [M]
+$(_mod_obj:.o=.lst): quiet_modtag := [M]
 
-$(obj-m)             : quiet_modtag := [M]
+$(obj-m)           : quiet_modtag := [M]
 
 quiet_cmd_cc_s_c = CC $(quiet_modtag)  $@
 cmd_cc_s_c       = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $<
@@ -417,7 +425,7 @@ $(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE
 	$(call if_changed_rule,as_o_S)
 
 targets += $(filter-out $(subdir-obj-y), $(real-obj-y))
-targets += $(filter-out $(subdir-obj-m), $(real-obj-m))
+targets += $(filter-out $(subdir-obj-m), $(real-modobj-m) $(real-obj-m))
 targets += $(lib-y) $(extra-y) $(MAKECMDGOALS) $(always)
 
 # Linker scripts preprocessor (.lds.S -> .lds)
@@ -508,6 +516,20 @@ targets += $(obj)/lib-ksyms.o
 
 endif
 
+ifdef modobj-target
+
+quiet_cmd_ar_modobj = AR      $@
+      cmd_ar_modobj = rm -f $@; \
+                    $(AR) rcTP$(KBUILD_ARFLAGS) $@ $(filter $(real-modobj-m), $^)
+
+$(modobj-target): $(real-modobj-m) FORCE
+	$(call if_changed,ar_modobj)
+
+targets += $(modobj-target)
+
+endif # modobj-target
+
+
 #
 # Rule to link composite objects
 #
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 6e7aa08324f0..c84167169a59 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -16,12 +16,13 @@ KBUILD_CFLAGS += $(subdir-ccflags-y)
 # is exactly what happens for directories in obj-y. So move all
 # directories from obj-m to obj-y.  Then we will know that any directory
 # in real-obj-m is a component of some other object.
-obj-y := $(obj-y) $(filter %/, $(obj-m))
+obj-y := $(obj-y) $(filter %/, $(obj-m)) $(filter-out $(obj-y), $(modobj-y))
 obj-m := $(filter-out %/, $(obj-m))
 
 # When an object is listed to be built compiled-in and modular,
 # only build the compiled-in version
 obj-m := $(filter-out $(obj-y),$(obj-m))
+modobj-m := $(filter-out $(obj-y), $(modobj-m))
 
 # Libraries are always collected in one lib file.
 # Filter out objects already built-in
@@ -42,6 +43,7 @@ single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m)))
 # including built-in.a from subdirectories
 real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
 real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m)))
+real-modobj-m := $(foreach m, $(modobj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m)))
 
 # Handle objects in subdirs
 # ---------------------------------------------------------------------------
@@ -53,8 +55,11 @@ __subdir-y	:= $(patsubst %/,%,$(filter %/, $(real-obj-y)))
 subdir-y	+= $(__subdir-y)
 __subdir-m	:= $(patsubst %/,%,$(filter %/, $(real-obj-m)))
 subdir-m	+= $(__subdir-m)
+__subdir-mo	:= $(patsubst %/,%,$(filter %/, $(real-modobj-m)))
+subdir-m	+= $(__subdir-mo)
 real-obj-y	:= $(patsubst %/, %/built-in.a, $(real-obj-y))
 real-obj-m	:= $(patsubst %/, %/mod.a, $(real-obj-m))
+real-modobj-m	:= $(patsubst %/, %/mod.a, $(real-modobj-m))
 
 # Subdirectories we need to descend into
 subdir-ym	:= $(sort $(subdir-y) $(subdir-m))
@@ -62,9 +67,9 @@ subdir-ym	:= $(sort $(subdir-y) $(subdir-m))
 # $(subdir-obj-y) is the list of objects in $(real-obj-y) which uses dir/ to
 # tell kbuild to descend
 subdir-obj-y := $(filter %/built-in.a, $(real-obj-y))
-# $(subdir-obj-m) is the list of objects in $(real-obj-m) which uses dir/ to
-# tell kbuild to descend
-subdir-obj-m := $(filter %/mod.a, $(real-obj-m))
+# $(subdir-obj-m) is the list of objects in $(real-obj-m) and
+# $(real-modobj-m) which use dir/ to tell kbuild to descend
+subdir-obj-m := $(filter %/mod.a, $(real-obj-m) $(real-modobj-m))
 
 # DTB
 # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built
@@ -83,6 +88,7 @@ subdir-obj-y	:= $(addprefix $(obj)/,$(subdir-obj-y))
 subdir-obj-m	:= $(addprefix $(obj)/,$(subdir-obj-m))
 real-obj-y	:= $(addprefix $(obj)/,$(real-obj-y))
 real-obj-m	:= $(addprefix $(obj)/,$(real-obj-m))
+real-modobj-m	:= $(addprefix $(obj)/,$(real-modobj-m))
 single-used-m	:= $(addprefix $(obj)/,$(single-used-m))
 multi-used-m	:= $(addprefix $(obj)/,$(multi-used-m))
 subdir-ym	:= $(addprefix $(obj)/,$(subdir-ym))
-- 
2.14.0.rc0.dirty


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [RFC PATCH 0/5] kbuild: build modules from code in multiple directories.
  2018-06-18  8:20 ` [RFC PATCH 0/5] kbuild: build modules from code in multiple directories Christoph Hellwig
@ 2018-06-19  4:05   ` NeilBrown
  2018-06-19  4:47     ` Christoph Hellwig
  0 siblings, 1 reply; 20+ messages in thread
From: NeilBrown @ 2018-06-19  4:05 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Masahiro Yamada, Michal Marek, linux-kernel, linux-kbuild

[-- Attachment #1: Type: text/plain, Size: 6271 bytes --]

On Mon, Jun 18 2018, Christoph Hellwig wrote:

> On Mon, Jun 18, 2018 at 02:55:20PM +1000, NeilBrown wrote:
>> This set of patches makes it possible to build a module from
>> code in multiple directories without needing to list files from one
>> directory in the Makefile of another directory.
>> 
>> The code was developed for lustre (which is now out-of-tree :-( ) but
>> can be useful elsewhere, such as for xfs and btrfs and others.
>> 
>> In fs/xfs/Makefile the section:
>> 
>> xfs-y				+= $(addprefix libxfs/, \
>> 				   xfs_ag.o \
>> 				   xfs_alloc.o \
>> 				.....
>> 
>> could become
>> 
>> xfs-y += libxfs/
>> 
>> and then in fs/xfs/libxfs/Makefile we would have
>> 
>> modobj-$(CONFIG_XFS_FS) += xfs_ag.o \
>> 			   xfs_alloc.o \
>> 			   .....
>> 
>> A similar process could move filenames for scrub/* from the
>> fs/xfs/Makefile to fs/xfs/scrub/Makefile
>
> How about you actually convert it as an example?

Sure ... found a bug while testing it.  Thanks :-)

From ac7953b4ba6d9a2a69dab84dd772aafca38d8377 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.com>
Date: Tue, 19 Jun 2018 13:59:16 +1000
Subject: [PATCH] kbuild/xfs: example modobj-m conversion

This is a demonstration patch to show how
xfs can be changed to make use of the proposed modobj-m=
functionality, should the xfs developers want that.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 fs/xfs/Makefile        | 78 ++------------------------------------------------
 fs/xfs/libxfs/Makefile | 43 ++++++++++++++++++++++++++++
 fs/xfs/scrub/Makefile  | 29 +++++++++++++++++++
 3 files changed, 74 insertions(+), 76 deletions(-)
 create mode 100644 fs/xfs/libxfs/Makefile
 create mode 100644 fs/xfs/scrub/Makefile

diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
index 2f3f75a7f180..0ba854045fe9 100644
--- a/fs/xfs/Makefile
+++ b/fs/xfs/Makefile
@@ -15,47 +15,7 @@ obj-$(CONFIG_XFS_FS)		+= xfs.o
 xfs-y				+= xfs_trace.o
 
 # build the libxfs code first
-xfs-y				+= $(addprefix libxfs/, \
-				   xfs_ag.o \
-				   xfs_alloc.o \
-				   xfs_alloc_btree.o \
-				   xfs_attr.o \
-				   xfs_attr_leaf.o \
-				   xfs_attr_remote.o \
-				   xfs_bit.o \
-				   xfs_bmap.o \
-				   xfs_bmap_btree.o \
-				   xfs_btree.o \
-				   xfs_da_btree.o \
-				   xfs_da_format.o \
-				   xfs_defer.o \
-				   xfs_dir2.o \
-				   xfs_dir2_block.o \
-				   xfs_dir2_data.o \
-				   xfs_dir2_leaf.o \
-				   xfs_dir2_node.o \
-				   xfs_dir2_sf.o \
-				   xfs_dquot_buf.o \
-				   xfs_ialloc.o \
-				   xfs_ialloc_btree.o \
-				   xfs_iext_tree.o \
-				   xfs_inode_fork.o \
-				   xfs_inode_buf.o \
-				   xfs_log_rlimit.o \
-				   xfs_ag_resv.o \
-				   xfs_rmap.o \
-				   xfs_rmap_btree.o \
-				   xfs_refcount.o \
-				   xfs_refcount_btree.o \
-				   xfs_sb.o \
-				   xfs_symlink_remote.o \
-				   xfs_trans_resv.o \
-				   xfs_types.o \
-				   )
-# xfs_rtbitmap is shared with libxfs
-xfs-$(CONFIG_XFS_RT)		+= $(addprefix libxfs/, \
-				   xfs_rtbitmap.o \
-				   )
+xfs-y				+= libxfs/
 
 # highlevel code
 xfs-y				+= xfs_aops.o \
@@ -127,38 +87,4 @@ xfs-$(CONFIG_SYSCTL)		+= xfs_sysctl.o
 xfs-$(CONFIG_COMPAT)		+= xfs_ioctl32.o
 xfs-$(CONFIG_EXPORTFS_BLOCK_OPS)	+= xfs_pnfs.o
 
-# online scrub/repair
-ifeq ($(CONFIG_XFS_ONLINE_SCRUB),y)
-
-# Tracepoints like to blow up, so build that before everything else
-
-xfs-y				+= $(addprefix scrub/, \
-				   trace.o \
-				   agheader.o \
-				   alloc.o \
-				   attr.o \
-				   bmap.o \
-				   btree.o \
-				   common.o \
-				   dabtree.o \
-				   dir.o \
-				   ialloc.o \
-				   inode.o \
-				   parent.o \
-				   refcount.o \
-				   rmap.o \
-				   scrub.o \
-				   symlink.o \
-				   )
-
-xfs-$(CONFIG_XFS_RT)		+= scrub/rtbitmap.o
-xfs-$(CONFIG_XFS_QUOTA)		+= scrub/quota.o
-
-# online repair
-ifeq ($(CONFIG_XFS_ONLINE_REPAIR),y)
-xfs-y				+= $(addprefix scrub/, \
-				   agheader_repair.o \
-				   repair.o \
-				   )
-endif
-endif
+xfs-$(CONFIG_XFS_ONLINE_SCRUB)	+= scrub/
diff --git a/fs/xfs/libxfs/Makefile b/fs/xfs/libxfs/Makefile
new file mode 100644
index 000000000000..9b90c289bdda
--- /dev/null
+++ b/fs/xfs/libxfs/Makefile
@@ -0,0 +1,43 @@
+# SPDX-License-Identifier: GPL-2.0
+
+ccflags-y += -I$(src)/..
+
+# xfs_rtbitmap is shared with libxfs
+xobj-$(CONFIG_XFS_RT)		+= xfs_rtbitmap.o
+
+modobj-$(CONFIG_XFS_FS) +=	   xfs_ag.o \
+				   xfs_alloc.o \
+				   xfs_alloc_btree.o \
+				   xfs_attr.o \
+				   xfs_attr_leaf.o \
+				   xfs_attr_remote.o \
+				   xfs_bit.o \
+				   xfs_bmap.o \
+				   xfs_bmap_btree.o \
+				   xfs_btree.o \
+				   xfs_da_btree.o \
+				   xfs_da_format.o \
+				   xfs_defer.o \
+				   xfs_dir2.o \
+				   xfs_dir2_block.o \
+				   xfs_dir2_data.o \
+				   xfs_dir2_leaf.o \
+				   xfs_dir2_node.o \
+				   xfs_dir2_sf.o \
+				   xfs_dquot_buf.o \
+				   xfs_ialloc.o \
+				   xfs_ialloc_btree.o \
+				   xfs_iext_tree.o \
+				   xfs_inode_fork.o \
+				   xfs_inode_buf.o \
+				   xfs_log_rlimit.o \
+				   xfs_ag_resv.o \
+				   xfs_rmap.o \
+				   xfs_rmap_btree.o \
+				   xfs_refcount.o \
+				   xfs_refcount_btree.o \
+				   xfs_sb.o \
+				   xfs_symlink_remote.o \
+				   xfs_trans_resv.o \
+				   xfs_types.o \
+				   $(xobj-y)
diff --git a/fs/xfs/scrub/Makefile b/fs/xfs/scrub/Makefile
new file mode 100644
index 000000000000..f91818a0e6ee
--- /dev/null
+++ b/fs/xfs/scrub/Makefile
@@ -0,0 +1,29 @@
+# SPDX-License-Identifier: GPL-2.0
+
+# Tracepoints like to blow up, so build that before everything else
+
+ccflags-y += -I$(src)/..
+ccflags-y += -I$(src)/../libxfs
+
+xobj-$(CONFIG_XFS_RT)		+= rtbitmap.o
+xobj-$(CONFIG_XFS_QUOTA)	+= quota.o
+xobj-$(CONFIG_XFS_ONLINE_REPAIR)+= agheader_repair.o \
+				   repair.o
+
+modobj-$(CONFIG_XFS_FS) +=	   trace.o \
+				   agheader.o \
+				   alloc.o \
+				   attr.o \
+				   bmap.o \
+				   btree.o \
+				   common.o \
+				   dabtree.o \
+				   dir.o \
+				   ialloc.o \
+				   inode.o \
+				   parent.o \
+				   refcount.o \
+				   rmap.o \
+				   scrub.o \
+				   symlink.o \
+				   $(xobj-y)
-- 
2.14.0.rc0.dirty


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [RFC PATCH 0/5] kbuild: build modules from code in multiple directories.
  2018-06-19  4:05   ` NeilBrown
@ 2018-06-19  4:47     ` Christoph Hellwig
  2018-06-19  5:03       ` Darrick J. Wong
  0 siblings, 1 reply; 20+ messages in thread
From: Christoph Hellwig @ 2018-06-19  4:47 UTC (permalink / raw)
  To: NeilBrown
  Cc: Christoph Hellwig, Masahiro Yamada, Michal Marek, linux-kernel,
	linux-kbuild, linux-xfs

On Tue, Jun 19, 2018 at 02:05:23PM +1000, NeilBrown wrote:
> From: NeilBrown <neilb@suse.com>
> Date: Tue, 19 Jun 2018 13:59:16 +1000
> Subject: [PATCH] kbuild/xfs: example modobj-m conversion
> 
> This is a demonstration patch to show how
> xfs can be changed to make use of the proposed modobj-m=
> functionality, should the xfs developers want that.

Well, IFF we go with this new functionality I think everyone should
be using it instead of the current hacks.

So text like the above should be in the series cover letter, and this
patch should have an actual description..

I see no argument against these changes, but I've also added the XFS
list.

> 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  fs/xfs/Makefile        | 78 ++------------------------------------------------
>  fs/xfs/libxfs/Makefile | 43 ++++++++++++++++++++++++++++
>  fs/xfs/scrub/Makefile  | 29 +++++++++++++++++++
>  3 files changed, 74 insertions(+), 76 deletions(-)
>  create mode 100644 fs/xfs/libxfs/Makefile
>  create mode 100644 fs/xfs/scrub/Makefile
> 
> diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
> index 2f3f75a7f180..0ba854045fe9 100644
> --- a/fs/xfs/Makefile
> +++ b/fs/xfs/Makefile
> @@ -15,47 +15,7 @@ obj-$(CONFIG_XFS_FS)		+= xfs.o
>  xfs-y				+= xfs_trace.o
>  
>  # build the libxfs code first
> -xfs-y				+= $(addprefix libxfs/, \
> -				   xfs_ag.o \
> -				   xfs_alloc.o \
> -				   xfs_alloc_btree.o \
> -				   xfs_attr.o \
> -				   xfs_attr_leaf.o \
> -				   xfs_attr_remote.o \
> -				   xfs_bit.o \
> -				   xfs_bmap.o \
> -				   xfs_bmap_btree.o \
> -				   xfs_btree.o \
> -				   xfs_da_btree.o \
> -				   xfs_da_format.o \
> -				   xfs_defer.o \
> -				   xfs_dir2.o \
> -				   xfs_dir2_block.o \
> -				   xfs_dir2_data.o \
> -				   xfs_dir2_leaf.o \
> -				   xfs_dir2_node.o \
> -				   xfs_dir2_sf.o \
> -				   xfs_dquot_buf.o \
> -				   xfs_ialloc.o \
> -				   xfs_ialloc_btree.o \
> -				   xfs_iext_tree.o \
> -				   xfs_inode_fork.o \
> -				   xfs_inode_buf.o \
> -				   xfs_log_rlimit.o \
> -				   xfs_ag_resv.o \
> -				   xfs_rmap.o \
> -				   xfs_rmap_btree.o \
> -				   xfs_refcount.o \
> -				   xfs_refcount_btree.o \
> -				   xfs_sb.o \
> -				   xfs_symlink_remote.o \
> -				   xfs_trans_resv.o \
> -				   xfs_types.o \
> -				   )
> -# xfs_rtbitmap is shared with libxfs
> -xfs-$(CONFIG_XFS_RT)		+= $(addprefix libxfs/, \
> -				   xfs_rtbitmap.o \
> -				   )
> +xfs-y				+= libxfs/
>  
>  # highlevel code
>  xfs-y				+= xfs_aops.o \
> @@ -127,38 +87,4 @@ xfs-$(CONFIG_SYSCTL)		+= xfs_sysctl.o
>  xfs-$(CONFIG_COMPAT)		+= xfs_ioctl32.o
>  xfs-$(CONFIG_EXPORTFS_BLOCK_OPS)	+= xfs_pnfs.o
>  
> -# online scrub/repair
> -ifeq ($(CONFIG_XFS_ONLINE_SCRUB),y)
> -
> -# Tracepoints like to blow up, so build that before everything else
> -
> -xfs-y				+= $(addprefix scrub/, \
> -				   trace.o \
> -				   agheader.o \
> -				   alloc.o \
> -				   attr.o \
> -				   bmap.o \
> -				   btree.o \
> -				   common.o \
> -				   dabtree.o \
> -				   dir.o \
> -				   ialloc.o \
> -				   inode.o \
> -				   parent.o \
> -				   refcount.o \
> -				   rmap.o \
> -				   scrub.o \
> -				   symlink.o \
> -				   )
> -
> -xfs-$(CONFIG_XFS_RT)		+= scrub/rtbitmap.o
> -xfs-$(CONFIG_XFS_QUOTA)		+= scrub/quota.o
> -
> -# online repair
> -ifeq ($(CONFIG_XFS_ONLINE_REPAIR),y)
> -xfs-y				+= $(addprefix scrub/, \
> -				   agheader_repair.o \
> -				   repair.o \
> -				   )
> -endif
> -endif
> +xfs-$(CONFIG_XFS_ONLINE_SCRUB)	+= scrub/
> diff --git a/fs/xfs/libxfs/Makefile b/fs/xfs/libxfs/Makefile
> new file mode 100644
> index 000000000000..9b90c289bdda
> --- /dev/null
> +++ b/fs/xfs/libxfs/Makefile
> @@ -0,0 +1,43 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +ccflags-y += -I$(src)/..
> +
> +# xfs_rtbitmap is shared with libxfs
> +xobj-$(CONFIG_XFS_RT)		+= xfs_rtbitmap.o
> +
> +modobj-$(CONFIG_XFS_FS) +=	   xfs_ag.o \
> +				   xfs_alloc.o \
> +				   xfs_alloc_btree.o \
> +				   xfs_attr.o \
> +				   xfs_attr_leaf.o \
> +				   xfs_attr_remote.o \
> +				   xfs_bit.o \
> +				   xfs_bmap.o \
> +				   xfs_bmap_btree.o \
> +				   xfs_btree.o \
> +				   xfs_da_btree.o \
> +				   xfs_da_format.o \
> +				   xfs_defer.o \
> +				   xfs_dir2.o \
> +				   xfs_dir2_block.o \
> +				   xfs_dir2_data.o \
> +				   xfs_dir2_leaf.o \
> +				   xfs_dir2_node.o \
> +				   xfs_dir2_sf.o \
> +				   xfs_dquot_buf.o \
> +				   xfs_ialloc.o \
> +				   xfs_ialloc_btree.o \
> +				   xfs_iext_tree.o \
> +				   xfs_inode_fork.o \
> +				   xfs_inode_buf.o \
> +				   xfs_log_rlimit.o \
> +				   xfs_ag_resv.o \
> +				   xfs_rmap.o \
> +				   xfs_rmap_btree.o \
> +				   xfs_refcount.o \
> +				   xfs_refcount_btree.o \
> +				   xfs_sb.o \
> +				   xfs_symlink_remote.o \
> +				   xfs_trans_resv.o \
> +				   xfs_types.o \
> +				   $(xobj-y)
> diff --git a/fs/xfs/scrub/Makefile b/fs/xfs/scrub/Makefile
> new file mode 100644
> index 000000000000..f91818a0e6ee
> --- /dev/null
> +++ b/fs/xfs/scrub/Makefile
> @@ -0,0 +1,29 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +# Tracepoints like to blow up, so build that before everything else
> +
> +ccflags-y += -I$(src)/..
> +ccflags-y += -I$(src)/../libxfs
> +
> +xobj-$(CONFIG_XFS_RT)		+= rtbitmap.o
> +xobj-$(CONFIG_XFS_QUOTA)	+= quota.o
> +xobj-$(CONFIG_XFS_ONLINE_REPAIR)+= agheader_repair.o \
> +				   repair.o
> +
> +modobj-$(CONFIG_XFS_FS) +=	   trace.o \
> +				   agheader.o \
> +				   alloc.o \
> +				   attr.o \
> +				   bmap.o \
> +				   btree.o \
> +				   common.o \
> +				   dabtree.o \
> +				   dir.o \
> +				   ialloc.o \
> +				   inode.o \
> +				   parent.o \
> +				   refcount.o \
> +				   rmap.o \
> +				   scrub.o \
> +				   symlink.o \
> +				   $(xobj-y)
> -- 
> 2.14.0.rc0.dirty
> 


---end quoted text---

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC PATCH 0/5] kbuild: build modules from code in multiple directories.
  2018-06-19  4:47     ` Christoph Hellwig
@ 2018-06-19  5:03       ` Darrick J. Wong
  0 siblings, 0 replies; 20+ messages in thread
From: Darrick J. Wong @ 2018-06-19  5:03 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: NeilBrown, Masahiro Yamada, Michal Marek, linux-kernel,
	linux-kbuild, linux-xfs

On Mon, Jun 18, 2018 at 09:47:48PM -0700, Christoph Hellwig wrote:
> On Tue, Jun 19, 2018 at 02:05:23PM +1000, NeilBrown wrote:
> > From: NeilBrown <neilb@suse.com>
> > Date: Tue, 19 Jun 2018 13:59:16 +1000
> > Subject: [PATCH] kbuild/xfs: example modobj-m conversion
> > 
> > This is a demonstration patch to show how
> > xfs can be changed to make use of the proposed modobj-m=
> > functionality, should the xfs developers want that.
> 
> Well, IFF we go with this new functionality I think everyone should
> be using it instead of the current hacks.
> 
> So text like the above should be in the series cover letter, and this
> patch should have an actual description..
> 
> I see no argument against these changes, but I've also added the XFS
> list.

Yes, please send the entire series to the xfs list in the future.

It looks like a reasonable reorganization of makefile goop. :)

(Will dig for the rest of the series on lkml tomorrow I guess.)

> > 
> > Signed-off-by: NeilBrown <neilb@suse.com>
> > ---
> >  fs/xfs/Makefile        | 78 ++------------------------------------------------
> >  fs/xfs/libxfs/Makefile | 43 ++++++++++++++++++++++++++++
> >  fs/xfs/scrub/Makefile  | 29 +++++++++++++++++++
> >  3 files changed, 74 insertions(+), 76 deletions(-)
> >  create mode 100644 fs/xfs/libxfs/Makefile
> >  create mode 100644 fs/xfs/scrub/Makefile
> > 
> > diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
> > index 2f3f75a7f180..0ba854045fe9 100644
> > --- a/fs/xfs/Makefile
> > +++ b/fs/xfs/Makefile
> > @@ -15,47 +15,7 @@ obj-$(CONFIG_XFS_FS)		+= xfs.o
> >  xfs-y				+= xfs_trace.o
> >  
> >  # build the libxfs code first
> > -xfs-y				+= $(addprefix libxfs/, \
> > -				   xfs_ag.o \
> > -				   xfs_alloc.o \
> > -				   xfs_alloc_btree.o \
> > -				   xfs_attr.o \
> > -				   xfs_attr_leaf.o \
> > -				   xfs_attr_remote.o \
> > -				   xfs_bit.o \
> > -				   xfs_bmap.o \
> > -				   xfs_bmap_btree.o \
> > -				   xfs_btree.o \
> > -				   xfs_da_btree.o \
> > -				   xfs_da_format.o \
> > -				   xfs_defer.o \
> > -				   xfs_dir2.o \
> > -				   xfs_dir2_block.o \
> > -				   xfs_dir2_data.o \
> > -				   xfs_dir2_leaf.o \
> > -				   xfs_dir2_node.o \
> > -				   xfs_dir2_sf.o \
> > -				   xfs_dquot_buf.o \
> > -				   xfs_ialloc.o \
> > -				   xfs_ialloc_btree.o \
> > -				   xfs_iext_tree.o \
> > -				   xfs_inode_fork.o \
> > -				   xfs_inode_buf.o \
> > -				   xfs_log_rlimit.o \
> > -				   xfs_ag_resv.o \
> > -				   xfs_rmap.o \
> > -				   xfs_rmap_btree.o \
> > -				   xfs_refcount.o \
> > -				   xfs_refcount_btree.o \
> > -				   xfs_sb.o \
> > -				   xfs_symlink_remote.o \
> > -				   xfs_trans_resv.o \
> > -				   xfs_types.o \
> > -				   )
> > -# xfs_rtbitmap is shared with libxfs
> > -xfs-$(CONFIG_XFS_RT)		+= $(addprefix libxfs/, \
> > -				   xfs_rtbitmap.o \
> > -				   )
> > +xfs-y				+= libxfs/
> >  
> >  # highlevel code
> >  xfs-y				+= xfs_aops.o \
> > @@ -127,38 +87,4 @@ xfs-$(CONFIG_SYSCTL)		+= xfs_sysctl.o
> >  xfs-$(CONFIG_COMPAT)		+= xfs_ioctl32.o
> >  xfs-$(CONFIG_EXPORTFS_BLOCK_OPS)	+= xfs_pnfs.o
> >  
> > -# online scrub/repair
> > -ifeq ($(CONFIG_XFS_ONLINE_SCRUB),y)
> > -
> > -# Tracepoints like to blow up, so build that before everything else
> > -
> > -xfs-y				+= $(addprefix scrub/, \
> > -				   trace.o \
> > -				   agheader.o \
> > -				   alloc.o \
> > -				   attr.o \
> > -				   bmap.o \
> > -				   btree.o \
> > -				   common.o \
> > -				   dabtree.o \
> > -				   dir.o \
> > -				   ialloc.o \
> > -				   inode.o \
> > -				   parent.o \
> > -				   refcount.o \
> > -				   rmap.o \
> > -				   scrub.o \
> > -				   symlink.o \
> > -				   )
> > -
> > -xfs-$(CONFIG_XFS_RT)		+= scrub/rtbitmap.o
> > -xfs-$(CONFIG_XFS_QUOTA)		+= scrub/quota.o
> > -
> > -# online repair
> > -ifeq ($(CONFIG_XFS_ONLINE_REPAIR),y)
> > -xfs-y				+= $(addprefix scrub/, \
> > -				   agheader_repair.o \
> > -				   repair.o \
> > -				   )
> > -endif
> > -endif
> > +xfs-$(CONFIG_XFS_ONLINE_SCRUB)	+= scrub/
> > diff --git a/fs/xfs/libxfs/Makefile b/fs/xfs/libxfs/Makefile
> > new file mode 100644
> > index 000000000000..9b90c289bdda
> > --- /dev/null
> > +++ b/fs/xfs/libxfs/Makefile
> > @@ -0,0 +1,43 @@
> > +# SPDX-License-Identifier: GPL-2.0
> > +
> > +ccflags-y += -I$(src)/..
> > +
> > +# xfs_rtbitmap is shared with libxfs
> > +xobj-$(CONFIG_XFS_RT)		+= xfs_rtbitmap.o
> > +
> > +modobj-$(CONFIG_XFS_FS) +=	   xfs_ag.o \
> > +				   xfs_alloc.o \
> > +				   xfs_alloc_btree.o \
> > +				   xfs_attr.o \
> > +				   xfs_attr_leaf.o \
> > +				   xfs_attr_remote.o \
> > +				   xfs_bit.o \
> > +				   xfs_bmap.o \
> > +				   xfs_bmap_btree.o \
> > +				   xfs_btree.o \
> > +				   xfs_da_btree.o \
> > +				   xfs_da_format.o \
> > +				   xfs_defer.o \
> > +				   xfs_dir2.o \
> > +				   xfs_dir2_block.o \
> > +				   xfs_dir2_data.o \
> > +				   xfs_dir2_leaf.o \
> > +				   xfs_dir2_node.o \
> > +				   xfs_dir2_sf.o \
> > +				   xfs_dquot_buf.o \
> > +				   xfs_ialloc.o \
> > +				   xfs_ialloc_btree.o \
> > +				   xfs_iext_tree.o \
> > +				   xfs_inode_fork.o \
> > +				   xfs_inode_buf.o \
> > +				   xfs_log_rlimit.o \
> > +				   xfs_ag_resv.o \
> > +				   xfs_rmap.o \
> > +				   xfs_rmap_btree.o \
> > +				   xfs_refcount.o \
> > +				   xfs_refcount_btree.o \
> > +				   xfs_sb.o \
> > +				   xfs_symlink_remote.o \
> > +				   xfs_trans_resv.o \
> > +				   xfs_types.o \
> > +				   $(xobj-y)
> > diff --git a/fs/xfs/scrub/Makefile b/fs/xfs/scrub/Makefile
> > new file mode 100644
> > index 000000000000..f91818a0e6ee
> > --- /dev/null
> > +++ b/fs/xfs/scrub/Makefile
> > @@ -0,0 +1,29 @@
> > +# SPDX-License-Identifier: GPL-2.0
> > +
> > +# Tracepoints like to blow up, so build that before everything else

This comment ought to stay with trace.o below because that's what it
applies to.

--D

> > +
> > +ccflags-y += -I$(src)/..
> > +ccflags-y += -I$(src)/../libxfs
> > +
> > +xobj-$(CONFIG_XFS_RT)		+= rtbitmap.o
> > +xobj-$(CONFIG_XFS_QUOTA)	+= quota.o
> > +xobj-$(CONFIG_XFS_ONLINE_REPAIR)+= agheader_repair.o \
> > +				   repair.o
> > +
> > +modobj-$(CONFIG_XFS_FS) +=	   trace.o \
> > +				   agheader.o \
> > +				   alloc.o \
> > +				   attr.o \
> > +				   bmap.o \
> > +				   btree.o \
> > +				   common.o \
> > +				   dabtree.o \
> > +				   dir.o \
> > +				   ialloc.o \
> > +				   inode.o \
> > +				   parent.o \
> > +				   refcount.o \
> > +				   rmap.o \
> > +				   scrub.o \
> > +				   symlink.o \
> > +				   $(xobj-y)
> > -- 
> > 2.14.0.rc0.dirty
> > 
> 
> 
> ---end quoted text---
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 4/5] kbuild: disable KBUILD_MODNAME when building for mod.a
  2018-06-18  4:55 ` [PATCH 4/5] kbuild: disable KBUILD_MODNAME when building for mod.a NeilBrown
@ 2018-06-27  5:52   ` Masahiro Yamada
  2018-07-03 22:14     ` NeilBrown
  0 siblings, 1 reply; 20+ messages in thread
From: Masahiro Yamada @ 2018-06-27  5:52 UTC (permalink / raw)
  To: NeilBrown
  Cc: Michal Marek, Linux Kernel Mailing List, Linux Kbuild mailing list

2018-06-18 13:55 GMT+09:00 NeilBrown <neilb@suse.com>:
> When building an object to be included in mod.a we
> cannot know the name of the module.  So don't define
> KBUILD_MODNAME.  This will ensure attempt to use
> that macro when the module name isn't know will
> trigger an error.

Honestly, I hate KBUILD_MODNAME.

If KBUILD_MODNAME is undefined,
you cannot call pr_debug() in the sub-directory for example.

CONFIG_DYNAMIC_DEBUG requires KBUILD_MODNAME,
but people often miss to notice that, then cause build errors.





> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  scripts/Makefile.lib |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index c84167169a59..d09246474f2e 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -96,7 +96,7 @@ subdir-ym     := $(addprefix $(obj)/,$(subdir-ym))
>  # Finds the multi-part object the current object will be linked into.
>  # If the object belongs to two or more multi-part objects, all of them are
>  # concatenated with a colon separator.
> -modname-multi = $(subst $(space),:,$(sort $(foreach m,$(multi-used),\
> +modname-multi = $(subst $(space),:,$(sort $(foreach m,$(multi-used) modobj.o,\
>                 $(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=)))))
>
>  modname = $(if $(modname-multi),$(modname-multi),$(basetarget))
> @@ -106,7 +106,7 @@ modname = $(if $(modname-multi),$(modname-multi),$(basetarget))
>  # end up in (or would, if it gets compiled in)
>  name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote)
>  basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget))
> -modname_flags  = -DKBUILD_MODNAME=$(call name-fix,$(modname))
> +modname_flags  = $(if $(filter-out modobj,$(modname)),-DKBUILD_MODNAME=$(call name-fix,$(modname)))
>
>  orig_c_flags   = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \
>                   $(ccflags-y) $(CFLAGS_$(basetarget).o)
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 4/5] kbuild: disable KBUILD_MODNAME when building for mod.a
  2018-06-27  5:52   ` Masahiro Yamada
@ 2018-07-03 22:14     ` NeilBrown
  2018-07-04 12:08       ` Masahiro Yamada
  0 siblings, 1 reply; 20+ messages in thread
From: NeilBrown @ 2018-07-03 22:14 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Michal Marek, Linux Kernel Mailing List, Linux Kbuild mailing list

[-- Attachment #1: Type: text/plain, Size: 1428 bytes --]

On Wed, Jun 27 2018, Masahiro Yamada wrote:

> 2018-06-18 13:55 GMT+09:00 NeilBrown <neilb@suse.com>:
>> When building an object to be included in mod.a we
>> cannot know the name of the module.  So don't define
>> KBUILD_MODNAME.  This will ensure attempt to use
>> that macro when the module name isn't know will
>> trigger an error.
>
> Honestly, I hate KBUILD_MODNAME.
>
> If KBUILD_MODNAME is undefined,
> you cannot call pr_debug() in the sub-directory for example.

I think this is only true if you have something like

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

in your .c files.  Developers who use modobj-m could be advised not to
do this.

>
> CONFIG_DYNAMIC_DEBUG requires KBUILD_MODNAME,
> but people often miss to notice that, then cause build errors.

Yes, I can see that.
We could change it to use a default ("no-name") if KBUILD_MODNAME isn't
defined.  Or we could require that KBUILD_MODNAME always be defined.

Where I've been using these patches I've sometimes been adding

  ccflags-y += -DKBUILD_MODNAME='"FOO"'

to Makefiles so that modules_params get handled correctly on non-module
builds.  I've thought about instead allowing "modobj-name" to be defined
and requiring that it be set if either modobj-[yn] is set.  Then it gets
used for the KBUILD_MODNAME when building modobj modules.

Would you prefer to always require KBUILD_MODNAME, or to use a default
name for dynamic-debug?

Thanks,
NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 4/5] kbuild: disable KBUILD_MODNAME when building for mod.a
  2018-07-03 22:14     ` NeilBrown
@ 2018-07-04 12:08       ` Masahiro Yamada
  2018-07-04 21:54         ` NeilBrown
  0 siblings, 1 reply; 20+ messages in thread
From: Masahiro Yamada @ 2018-07-04 12:08 UTC (permalink / raw)
  To: NeilBrown
  Cc: Michal Marek, Linux Kernel Mailing List, Linux Kbuild mailing list

2018-07-04 7:14 GMT+09:00 NeilBrown <neilb@suse.com>:
> On Wed, Jun 27 2018, Masahiro Yamada wrote:
>
>> 2018-06-18 13:55 GMT+09:00 NeilBrown <neilb@suse.com>:
>>> When building an object to be included in mod.a we
>>> cannot know the name of the module.  So don't define
>>> KBUILD_MODNAME.  This will ensure attempt to use
>>> that macro when the module name isn't know will
>>> trigger an error.
>>
>> Honestly, I hate KBUILD_MODNAME.
>>
>> If KBUILD_MODNAME is undefined,
>> you cannot call pr_debug() in the sub-directory for example.
>
> I think this is only true if you have something like
>
> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>
> in your .c files.  Developers who use modobj-m could be advised not to
> do this.
>
>>
>> CONFIG_DYNAMIC_DEBUG requires KBUILD_MODNAME,
>> but people often miss to notice that, then cause build errors.
>
> Yes, I can see that.
> We could change it to use a default ("no-name") if KBUILD_MODNAME isn't
> defined.  Or we could require that KBUILD_MODNAME always be defined.
>
> Where I've been using these patches I've sometimes been adding
>
>   ccflags-y += -DKBUILD_MODNAME='"FOO"'
>
> to Makefiles so that modules_params get handled correctly on non-module
> builds.  I've thought about instead allowing "modobj-name" to be defined
> and requiring that it be set if either modobj-[yn] is set.  Then it gets
> used for the KBUILD_MODNAME when building modobj modules.
>
> Would you prefer to always require KBUILD_MODNAME, or to use a default
> name for dynamic-debug?
>
> Thanks,
> NeilBrown


I prefer flat directory structure for modules.
Most of modules fit in a single directory.


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 4/5] kbuild: disable KBUILD_MODNAME when building for mod.a
  2018-07-04 12:08       ` Masahiro Yamada
@ 2018-07-04 21:54         ` NeilBrown
  2018-07-05  9:06           ` Masahiro Yamada
  0 siblings, 1 reply; 20+ messages in thread
From: NeilBrown @ 2018-07-04 21:54 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Michal Marek, Linux Kernel Mailing List, Linux Kbuild mailing list

[-- Attachment #1: Type: text/plain, Size: 1136 bytes --]

On Wed, Jul 04 2018, Masahiro Yamada wrote:

> 2018-07-04 7:14 GMT+09:00 NeilBrown <neilb@suse.com>:
>>
>> Where I've been using these patches I've sometimes been adding
>>
>>   ccflags-y += -DKBUILD_MODNAME='"FOO"'
>>
>> to Makefiles so that modules_params get handled correctly on non-module
>> builds.  I've thought about instead allowing "modobj-name" to be defined
>> and requiring that it be set if either modobj-[yn] is set.  Then it gets
>> used for the KBUILD_MODNAME when building modobj modules.
>>
>> Would you prefer to always require KBUILD_MODNAME, or to use a default
>> name for dynamic-debug?
>>
>> Thanks,
>> NeilBrown
>
>
> I prefer flat directory structure for modules.
> Most of modules fit in a single directory.

I'd prefer that too in general.
But some modules are bigger than others and some times it helps to
sub-divide a module.
xfs, btrfs, ceph, net/dccp, and lustre all already use multiple
directories despite the poor support, so clearly some developers
like a more structured approach to organizing their code.
Wouldn't it be good to allow them to make full use of the kbuild system?

Thanks,
NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 4/5] kbuild: disable KBUILD_MODNAME when building for mod.a
  2018-07-04 21:54         ` NeilBrown
@ 2018-07-05  9:06           ` Masahiro Yamada
  2018-07-05 23:03             ` NeilBrown
  0 siblings, 1 reply; 20+ messages in thread
From: Masahiro Yamada @ 2018-07-05  9:06 UTC (permalink / raw)
  To: NeilBrown
  Cc: Michal Marek, Linux Kernel Mailing List, Linux Kbuild mailing list

2018-07-05 6:54 GMT+09:00 NeilBrown <neilb@suse.com>:
> On Wed, Jul 04 2018, Masahiro Yamada wrote:
>
>> 2018-07-04 7:14 GMT+09:00 NeilBrown <neilb@suse.com>:
>>>
>>> Where I've been using these patches I've sometimes been adding
>>>
>>>   ccflags-y += -DKBUILD_MODNAME='"FOO"'
>>>
>>> to Makefiles so that modules_params get handled correctly on non-module
>>> builds.  I've thought about instead allowing "modobj-name" to be defined
>>> and requiring that it be set if either modobj-[yn] is set.  Then it gets
>>> used for the KBUILD_MODNAME when building modobj modules.
>>>
>>> Would you prefer to always require KBUILD_MODNAME, or to use a default
>>> name for dynamic-debug?
>>>
>>> Thanks,
>>> NeilBrown
>>
>>
>> I prefer flat directory structure for modules.
>> Most of modules fit in a single directory.
>
> I'd prefer that too in general.
> But some modules are bigger than others and some times it helps to
> sub-divide a module.
> xfs, btrfs, ceph, net/dccp, and lustre all already use multiple
> directories despite the poor support, so clearly some developers
> like a more structured approach to organizing their code.
> Wouldn't it be good to allow them to make full use of the kbuild system?


xfs is quite big, but the others are not too bad.
You can collect files into a single directory if you want.
If you mind the namespace, one tip might be to group files with prefix.
For example,

  drivers/btrfs/tests/foo.o  ->  drivers/btrfs/test-foo.o

I do not want to introduce a mess to core build scripts.


> Thanks,
> NeilBrown



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 4/5] kbuild: disable KBUILD_MODNAME when building for mod.a
  2018-07-05  9:06           ` Masahiro Yamada
@ 2018-07-05 23:03             ` NeilBrown
  0 siblings, 0 replies; 20+ messages in thread
From: NeilBrown @ 2018-07-05 23:03 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Michal Marek, Linux Kernel Mailing List, Linux Kbuild mailing list

[-- Attachment #1: Type: text/plain, Size: 2473 bytes --]

On Thu, Jul 05 2018, Masahiro Yamada wrote:

> 2018-07-05 6:54 GMT+09:00 NeilBrown <neilb@suse.com>:
>> On Wed, Jul 04 2018, Masahiro Yamada wrote:
>>
>>> 2018-07-04 7:14 GMT+09:00 NeilBrown <neilb@suse.com>:
>>>>
>>>> Where I've been using these patches I've sometimes been adding
>>>>
>>>>   ccflags-y += -DKBUILD_MODNAME='"FOO"'
>>>>
>>>> to Makefiles so that modules_params get handled correctly on non-module
>>>> builds.  I've thought about instead allowing "modobj-name" to be defined
>>>> and requiring that it be set if either modobj-[yn] is set.  Then it gets
>>>> used for the KBUILD_MODNAME when building modobj modules.
>>>>
>>>> Would you prefer to always require KBUILD_MODNAME, or to use a default
>>>> name for dynamic-debug?
>>>>
>>>> Thanks,
>>>> NeilBrown
>>>
>>>
>>> I prefer flat directory structure for modules.
>>> Most of modules fit in a single directory.
>>
>> I'd prefer that too in general.
>> But some modules are bigger than others and some times it helps to
>> sub-divide a module.
>> xfs, btrfs, ceph, net/dccp, and lustre all already use multiple
>> directories despite the poor support, so clearly some developers
>> like a more structured approach to organizing their code.
>> Wouldn't it be good to allow them to make full use of the kbuild system?
>
>
> xfs is quite big, but the others are not too bad.
> You can collect files into a single directory if you want.
> If you mind the namespace, one tip might be to group files with prefix.
> For example,
>
>   drivers/btrfs/tests/foo.o  ->  drivers/btrfs/test-foo.o

Certainly that is possible.  We could even place all of linux in a
single directory, but that would be a bad idea.  Subdividing large
bodies of code into files and then directories is a widely used
practice.  Why do you want make it hard for people to structure their
code in the way that seems most suitable to them?
My particular interest is lustre which has quite a few more
subdirectories than btrfs or xfs.  It currently builds as nearly a dozen
modules, one per directory (and that is just the client side).  This
requires a lot more exports than should be necessary, and exposes
internal detail unnecessarily. I would much rather it were fewer
modules.

>
> I do not want to introduce a mess to core build scripts.

What mess are you referring to?  The code I provided follows the style
of the current code and has the same general level of complexity as the
current code.  How is it a mess?

Thanks,
NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2018-07-05 23:03 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-18  4:55 [RFC PATCH 0/5] kbuild: build modules from code in multiple directories NeilBrown
2018-06-18  4:55 ` [PATCH 4/5] kbuild: disable KBUILD_MODNAME when building for mod.a NeilBrown
2018-06-27  5:52   ` Masahiro Yamada
2018-07-03 22:14     ` NeilBrown
2018-07-04 12:08       ` Masahiro Yamada
2018-07-04 21:54         ` NeilBrown
2018-07-05  9:06           ` Masahiro Yamada
2018-07-05 23:03             ` NeilBrown
2018-06-18  4:55 ` [PATCH 3/5] kbuild: support building of per-directory mod.a NeilBrown
2018-06-19  3:57   ` [PATCH 3/5 - v2] " NeilBrown
2018-06-18  4:55 ` [PATCH 1/5] kbuild: detect directories in components of a module NeilBrown
2018-06-18  4:55 ` [PATCH 2/5] kbuild: treat a directory listed in a composite object as foo/mod.a NeilBrown
2018-06-18  9:14   ` kbuild test robot
2018-06-18 22:30     ` NeilBrown
2018-06-18 22:30       ` NeilBrown
2018-06-18  4:55 ` [PATCH 5/5] kbuild: Add documentation for modobj-m NeilBrown
2018-06-18  8:20 ` [RFC PATCH 0/5] kbuild: build modules from code in multiple directories Christoph Hellwig
2018-06-19  4:05   ` NeilBrown
2018-06-19  4:47     ` Christoph Hellwig
2018-06-19  5:03       ` Darrick J. Wong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.