kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: greg@kroah.com (Greg KH)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Out-of-tree module build in a dedicated build directory.
Date: Thu, 15 Mar 2018 15:01:31 +0100	[thread overview]
Message-ID: <20180315140131.GA15029@kroah.com> (raw)
In-Reply-To: <CAA181pyevyLHkFiO7UUJh8BrzzrBY8PFb=9jMyqJtEywR819ig@mail.gmail.com>

On Thu, Mar 15, 2018 at 02:33:31PM +0100, Aleksei Fedotov wrote:
> >> It looks like passing O= or KBUILD_OUTPUT= doesn't work for out of tree modules.
> 
> > It doesn't?  It should, what is the result when you try to do that?
> 
> It is trying to use path specified in O= as path to the pre-build
> kernel and fails to find kernel scripts:
> 
> $ make V=1 -C $(KDIR) M=`pwd` O=`pwd`/build_x86
> make: Entering directory '/home/lexa/linux'
> make -C /home/lexa/module/build_x86 KBUILD_SRC=/home/lexa/linux \
> -f /home/lexa/linux/Makefile
> make[1]: Entering directory '/home/lexa/module/build_x86'
> mkdir -p /home/lexa/module/.tmp_versions ; rm -f
> /home/lexa/module/.tmp_versions/*
> 
>   WARNING: Symbol version dump ./Module.symvers
>            is missing; modules will have no dependencies and modversions.
> 
> make -f /home/lexa/linux/scripts/Makefile.build obj=/home/lexa/module
> make -f /home/lexa/linux/scripts/Makefile.build
> obj=/home/lexa/module/module1 need-builtin=1
>    rm -f /home/lexa/module/module1/built-in.o; ar rcSTPD
> /home/lexa/module/module1/built-in.o
>   gcc -Wp,-MD,/home/lexa/module/module1/.task1.o.d  -nostdinc -isystem
> /usr/lib/gcc/x86_64-linux-gnu/5/include
> -I/home/lexa/linux/arch/x86/include -I./arch/x86/include/generated
> -I/home/lexa/linux/include -I./include
> -I/home/lexa/linux/arch/x86/include/uapi
> -I./arch/x86/include/generated/uapi -I/home/lexa/linux/include/uapi
> -I./include/generated/uapi -include
> /home/lexa/linux/include/linux/kconfig.h  -I/home/lexa/module/module1
> -I/home/lexa/module/module1 -D__KERNEL__ -Wall -Wundef
> -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common
> -fshort-wchar -Werror-implicit-function-declaration
> -Wno-format-security -std=gnu89 -fno-PIE -mno-sse -mno-mmx -mno-sse2
> -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387
> -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup
> -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time
> -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1
> -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_SSSE3=1
> -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1
> -DCONFIG_AS_AVX512=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1
> -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables
> -mindirect-branch=thunk-extern -mindirect-branch-register -DRETPOLINE
> -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0
> -DCC_HAVE_ASM_GOTO -Wframe-larger-than=1024 -fstack-protector-strong
> -Wno-unused-but-set-variable -fno-var-tracking-assignments -g
> -gdwarf-4 -pg -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement
> -Wno-pointer-sign -fno-strict-overflow -fno-stack-check
> -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes
> -Werror=date-time -Werror=incompatible-pointer-types
> -Werror=designated-init  -DMODULE  -DKBUILD_BASENAME='"task1"'
> -DKBUILD_MODNAME='"mod1"' -c -o /home/lexa/module/module1/.tmp_task1.o
> /home/lexa/module/module1/task1.c
> /bin/sh: 1: scripts/basic/fixdep: not found
> /home/lexa/linux/scripts/Makefile.build:316: recipe for target
> '/home/lexa/module/module1/task1.o' failed

That's the error.


> make[3]: *** [/home/lexa/module/module1/task1.o] Error 127
> /home/lexa/linux/scripts/Makefile.build:575: recipe for target
> '/home/lexa/module/module1' failed
> make[2]: *** [/home/lexa/module/module1] Error 2
> /home/lexa/linux/Makefile:1509: recipe for target
> '_module_/home/lexa/module' failed
> make[1]: *** [_module_/home/lexa/module] Error 2
> make[1]: Leaving directory '/home/lexa/module/build_x86'
> Makefile:146: recipe for target 'sub-make' failed
> make: *** [sub-make] Error 2
> make: Leaving directory '/home/lexa/linux'
> 
> 
> 
> > And do you have a pointer to your Makefile, perhaps you are doing
> > something "wrong" in it?
> 
> I don't use Makefile in my module, I solely rely only on Kbuild files.
> Is that wrong?

Yes, you should have a simple Makefile to set all of the above up for
you correctly.  You do not need any Kbuild files for an external module.
Look at one of the many examples for how to do this properly, that's the
issue here.

good luck!

greg k-h

  parent reply	other threads:[~2018-03-15 14:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-15 12:14 Out-of-tree module build in a dedicated build directory Aleksei Fedotov
2018-03-15 13:00 ` Greg KH
2018-03-15 13:33   ` Aleksei Fedotov
2018-03-15 13:36     ` Denis Kirjanov
2018-03-15 14:01     ` Greg KH [this message]
2018-03-15 14:36       ` Aleksei Fedotov
2018-03-15 14:52         ` Aruna Hewapathirane
2018-03-15 15:27           ` Aruna Hewapathirane
2018-03-15 16:26             ` Greg KH
2018-03-15 16:39               ` Aleksei Fedotov
2018-03-15 17:14                 ` Greg KH
2018-03-15 18:58                 ` Aruna Hewapathirane

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180315140131.GA15029@kroah.com \
    --to=greg@kroah.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).