diff mbox series

cifs: Fix tracing build error with O=

Message ID 20190620064023.cwvcj5g4rgnmkmmn@gondor.apana.org.au (mailing list archive)
State New, archived
Headers show
Series cifs: Fix tracing build error with O= | expand

Commit Message

Herbert Xu June 20, 2019, 6:40 a.m. UTC
Currently if you build the kernel with O= then fs/cifs fails with:

$ make O=build
...
  CC [M]  fs/cifs/trace.o
In file included from ../fs/cifs/trace.h:846:0,
                 from ../fs/cifs/trace.c:8:
../include/trace/define_trace.h:95:43: fatal error: ./trace.h: No such file or directory
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
                                           ^
compilation terminated.

The reason is that -I$(src) expands to -Ifs/cifs which does not
work with O=.  This patch fixes it by adding srctree to the front.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Comments

Masahiro Yamada June 20, 2019, 6:54 a.m. UTC | #1
Hi Herbert,

> -----Original Message-----
> From: Herbert Xu [mailto:herbert@gondor.apana.org.au]
> Sent: Thursday, June 20, 2019 3:40 PM
> To: Steve French <stfrench@microsoft.com>; linux-cifs@vger.kernel.org
> Cc: Yamada, Masahiro/山田 真弘 <yamada.masahiro@socionext.com>
> Subject: cifs: Fix tracing build error with O=
> 
> Currently if you build the kernel with O= then fs/cifs fails with:
> 
> $ make O=build
> ...
>   CC [M]  fs/cifs/trace.o
> In file included from ../fs/cifs/trace.h:846:0,
>                  from ../fs/cifs/trace.c:8:
> ../include/trace/define_trace.h:95:43: fatal error: ./trace.h: No such
> file or directory
>  #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
>                                            ^
> compilation terminated.



Which kernel version are you testing?

I cannot reproduce the build error on the latest Linus tree.


$ make O=build allmodconfig fs/cifs/

perfectly works for me.



In fact, Kbuild automatically adds  "-I $(srctree)/$(src)"
for O=... building

See this code:

https://github.com/torvalds/linux/blob/v5.2-rc5/scripts/Makefile.lib#L144


So, I wonder why you need to duplicate "-I $(srctree)/$(src)"


Thanks.


> 
> The reason is that -I$(src) expands to -Ifs/cifs which does not
> work with O=.  This patch fixes it by adding srctree to the front.
> 
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
> 
> diff --git a/fs/cifs/Makefile b/fs/cifs/Makefile
> index 51af69a1a328..616163deee18 100644
> --- a/fs/cifs/Makefile
> +++ b/fs/cifs/Makefile
> @@ -2,7 +2,7 @@
>  #
>  # Makefile for Linux CIFS/SMB2/SMB3 VFS client
>  #
> -ccflags-y += -I$(src)		# needed for trace events
> +ccflags-y += -I$(srctree)/$(src)		# needed for trace
> events
>  obj-$(CONFIG_CIFS) += cifs.o
> 
>  cifs-y := trace.o cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o
> \
> --
> Email: Herbert Xu <herbert@gondor.apana.org.au>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Herbert Xu June 20, 2019, 7:58 a.m. UTC | #2
On Thu, Jun 20, 2019 at 06:54:42AM +0000, yamada.masahiro@socionext.com wrote:
>
> I cannot reproduce the build error on the latest Linus tree.
> 
> 
> $ make O=build allmodconfig fs/cifs/
> 
> perfectly works for me.

I was trying to build just the fs/cifs directory with

	make O=build M=fs/cifs

But I see now that this can't possibly work as M= only supports
absolute paths.  As M= is supposed to replace SUBDIRS=, what are
we supposed to do to build just a directory?

Thanks,
Masahiro Yamada June 20, 2019, 11:56 a.m. UTC | #3
On Thu, Jun 20, 2019 at 4:58 PM Herbert Xu <herbert@gondor.apana.org.au> wrote:
>
> On Thu, Jun 20, 2019 at 06:54:42AM +0000, yamada.masahiro@socionext.com wrote:
> >
> > I cannot reproduce the build error on the latest Linus tree.
> >
> >
> > $ make O=build allmodconfig fs/cifs/
> >
> > perfectly works for me.
>
> I was trying to build just the fs/cifs directory with
>
>         make O=build M=fs/cifs
>
> But I see now that this can't possibly work as M= only supports
> absolute paths.  As M= is supposed to replace SUBDIRS=, what are
> we supposed to do to build just a directory?


Documentation/kbuild/kbuild.txt says
M= and KBUILD_EXTMOD (and older form SUBDIRS= too)
are for building external modules.

Yet, many people still wrongly use them to build
in-kernel directories just because they seem to work
(but do not really).

The similar question, and the answer is here:
https://lkml.org/lkml/2019/1/17/584
Herbert Xu June 20, 2019, 12:47 p.m. UTC | #4
On Thu, Jun 20, 2019 at 08:56:10PM +0900, Masahiro Yamada wrote:
>
> The similar question, and the answer is here:
> https://lkml.org/lkml/2019/1/17/584

But it doesn't work with O=:

$ rm -rf build-compile/fs/cifs
$ make O=build-compile fs/cifs
make[1]: Entering directory '/home/herbert/src/build/kernel/test/build-compile'
make[1]: Nothing to be done for '../fs/cifs'.
make[1]: Leaving directory '/home/herbert/src/build/kernel/test/build-compile'
$

Cheers,
Masahiro Yamada June 20, 2019, 12:56 p.m. UTC | #5
On Thu, Jun 20, 2019 at 9:47 PM Herbert Xu <herbert@gondor.apana.org.au> wrote:
>
> On Thu, Jun 20, 2019 at 08:56:10PM +0900, Masahiro Yamada wrote:
> >
> > The similar question, and the answer is here:
> > https://lkml.org/lkml/2019/1/17/584
>
> But it doesn't work with O=:
>
> $ rm -rf build-compile/fs/cifs
> $ make O=build-compile fs/cifs
> make[1]: Entering directory '/home/herbert/src/build/kernel/test/build-compile'
> make[1]: Nothing to be done for '../fs/cifs'.
> make[1]: Leaving directory '/home/herbert/src/build/kernel/test/build-compile'
> $

You missed the trailing slash.

I suggested 'fs/cifs/' instead of 'fs/cifs'
Herbert Xu June 20, 2019, 1:36 p.m. UTC | #6
On Thu, Jun 20, 2019 at 09:56:53PM +0900, Masahiro Yamada wrote:
>
> > But it doesn't work with O=:
> >
> > $ rm -rf build-compile/fs/cifs
> > $ make O=build-compile fs/cifs
> > make[1]: Entering directory '/home/herbert/src/build/kernel/test/build-compile'
> > make[1]: Nothing to be done for '../fs/cifs'.
> > make[1]: Leaving directory '/home/herbert/src/build/kernel/test/build-compile'
> > $
> 
> You missed the trailing slash.
> 
> I suggested 'fs/cifs/' instead of 'fs/cifs'

Aha, that indeed works.  Thanks!
diff mbox series

Patch

diff --git a/fs/cifs/Makefile b/fs/cifs/Makefile
index 51af69a1a328..616163deee18 100644
--- a/fs/cifs/Makefile
+++ b/fs/cifs/Makefile
@@ -2,7 +2,7 @@ 
 #
 # Makefile for Linux CIFS/SMB2/SMB3 VFS client
 #
-ccflags-y += -I$(src)		# needed for trace events
+ccflags-y += -I$(srctree)/$(src)		# needed for trace events
 obj-$(CONFIG_CIFS) += cifs.o
 
 cifs-y := trace.o cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o \