All of lore.kernel.org
 help / color / mirror / Atom feed
From: Randy Dunlap <rdunlap@infradead.org>
To: Masahiro Yamada <masahiroy@kernel.org>, linux-kbuild@vger.kernel.org
Cc: Jonathan Corbet <corbet@lwn.net>,
	Michal Marek <michal.lkml@markovi.net>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 6/7] kbuild: doc: clarify the difference between extra-y and always-y
Date: Mon, 23 Nov 2020 10:00:46 -0800	[thread overview]
Message-ID: <92b910de-7039-a260-456c-865201ef7629@infradead.org> (raw)
In-Reply-To: <20201123045403.63402-6-masahiroy@kernel.org>

On 11/22/20 8:54 PM, Masahiro Yamada wrote:
> The difference between extra-y and always-y is obscure.
> 
> Basically, Kbuild builds targets listed in extra-y and always-y in
> visited Makefiles without relying on any dependency.
> 
> The difference is that extra-y is used to list the targets needed for
> vmlinux whereas always-y is used to list the targets that must be always
> built irrespective of final targets.
> 
> Kbuild skips extra-y when it is building only modules (i.e.
> 'make modules'). This is the long-standing behavior since extra-y was
> introduced in 2003, and it is explained in that commit log [1].
> 
> For clarification, this is the extra-y vs always-y table:
> 
>                   extra-y    always-y
>   'make'             o          o
>   'make vmlinux'     o          o
>   'make modules'     x          o

FWIW, I would find y/n easier to comprehend that x/o here.

> Kbuild skips extra-y also when building external modules since obviously
> it never builds vmlinux.
> 
> Unfortunately, extra-y is wrongly used in many places of upstream code,
> and even in external modules.
> 
> Using extra-y in external module Makefiles is wrong. What you should
> use is probably always-y or 'targets'.
> 
> The current documentation for extra-y is misleading. I rewrote it, and
> moved it to the section 3.7.
> 
> always-y is not documented anywhere. I added.
> 
> [1]: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=f94e5fd7e5d09a56a60670a9bb211a791654bba8
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  Documentation/kbuild/makefiles.rst | 110 +++++++++++++++++++----------
>  1 file changed, 71 insertions(+), 39 deletions(-)
> 
> diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst
> index 49afcb1d3695..159e470f2616 100644
> --- a/Documentation/kbuild/makefiles.rst
> +++ b/Documentation/kbuild/makefiles.rst
> @@ -15,13 +15,15 @@ This document describes the Linux kernel Makefiles.
>  	   --- 3.4 Objects which export symbols
>  	   --- 3.5 Library file goals - lib-y
>  	   --- 3.6 Descending down in directories
> -	   --- 3.7 Compilation flags
> -	   --- 3.8 Dependency tracking
> -	   --- 3.9 Custom Rules
> -	   --- 3.10 Command change detection
> -	   --- 3.11 $(CC) support functions
> -	   --- 3.12 $(LD) support functions
> -	   --- 3.13 Script Invocation
> +	   --- 3.7 Non-builtin vmlinux targets - extra-y
> +	   --- 3.8 Always built goals - always-

	Should that be always-y ?

> +	   --- 3.9 Compilation flags
> +	   --- 3.10 Dependency tracking
> +	   --- 3.11 Custom Rules
> +	   --- 3.12 Command change detection
> +	   --- 3.13 $(CC) support functions
> +	   --- 3.14 $(LD) support functions
> +	   --- 3.15 Script Invocation
>  
>  	=== 4 Host Program support
>  	   --- 4.1 Simple Host Program
> @@ -321,7 +323,60 @@ 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.7 Non-builtin vmlinux targets - extra-y
> +-----------------------------------------
> +
> +	extra-y specifies targets which are needed for building vmlinux,
> +	but not combined into built-in.a.
> +
> +	Examples are:
> +
> +	1) head objects
> +
> +	    Some objects must be placed at the head of vmlinux. They are
> +	    directly linked to vmlinux without going through built-in.a
> +	    A typical use-case is an object that contains the entry point.
> +
> +	    arch/$(SRCARCH)/Makefile should specify such objects as head-y.
> +
> +	    Discussion:
> +	      Given that we can control the section order in our linker script,
> +	      why do we need head-y?
> +
> +	2) vmlinux linker script
> +
> +	    The linker script for vmlinux is located at
> +	    arch/$(SRCARCH)/kernel/vmlinux.lds
> +
> +	Example::
> +
> +		# arch/x86/kernel/Makefile
> +		extra-y	:= head_$(BITS).o
> +		extra-y	+= head$(BITS).o
> +		extra-y	+= ebda.o
> +		extra-y	+= platform-quirks.o
> +		extra-y	+= vmlinux.lds
> +
> +	$(extra-y) should only contain targets needed for vmlinux.
> +
> +	Kbuild skips extra-y when vmlinux is apparently not a final goal.
> +	(e.g. 'make modules', or building external modules)
> +
> +	If you intend to build targets unconditionally, always-y (explained
> +	in the next section) is the correct syntax to use.
> +
> +3.8 Always built goals - always-y
> +---------------------------------
> +
> +	always-y specifies targets which are literally always built when
> +	Kbuild visited the Makefile.

	       visits

> +
> +	Example::
> +	  # ./Kbuild
> +	  offsets-file := include/generated/asm-offsets.h
> +	  always-y += $(offsets-file)
> +
> +3.9 Compilation flags
>  ---------------------
>  
>      ccflags-y, asflags-y and ldflags-y

Reviewed-by: Randy Dunlap <rdunlap@infradead.org>


thanks.
-- 
~Randy


  reply	other threads:[~2020-11-23 18:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-23  4:53 [PATCH 1/7] kbuild: doc: update the description about kbuild Makefiles Masahiro Yamada
2020-11-23  4:53 ` [PATCH 2/7] kbuild: doc: replace arch/$(ARCH)/ with arch/$(SRCARCH)/ Masahiro Yamada
2020-11-23 17:39   ` Randy Dunlap
2020-11-23  4:53 ` [PATCH 3/7] kbuild: doc: fix 'List directories to visit when descending' section Masahiro Yamada
2020-11-23  4:57   ` Masahiro Yamada
2020-11-23  4:54 ` [PATCH 4/7] kbuild: doc: merge 'Special Rules' and 'Custom kbuild commands' sections Masahiro Yamada
2020-11-23  4:54 ` [PATCH 5/7] kbuild: doc: split if_changed explanation to a separate section Masahiro Yamada
2020-11-23 17:51   ` Randy Dunlap
2020-11-23  4:54 ` [PATCH 6/7] kbuild: doc: clarify the difference between extra-y and always-y Masahiro Yamada
2020-11-23 18:00   ` Randy Dunlap [this message]
2020-11-23  4:54 ` [PATCH 7/7] kbuild: doc: document subdir-y syntax Masahiro Yamada
2020-11-23 18:03   ` Randy Dunlap
2020-11-28  8:58     ` Masahiro Yamada
2020-11-28 16:56       ` Randy Dunlap

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=92b910de-7039-a260-456c-865201ef7629@infradead.org \
    --to=rdunlap@infradead.org \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=michal.lkml@markovi.net \
    /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 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.