All of lore.kernel.org
 help / color / mirror / Atom feed
* why scripts/link-vmlinux.sh has a final build of init/
@ 2018-02-12  4:22 Cao jin
  2018-02-12 14:48 ` Masahiro Yamada
  0 siblings, 1 reply; 5+ messages in thread
From: Cao jin @ 2018-02-12  4:22 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: Michal Marek, Linux Kbuild mailing list, linux-kernel

Hi Masahiro-san,

  As I remember, init/ is already built during recursive make, and I did
a clean build(make mrproper, make localmodconfig) with all plugins
included on x86_64 with following patch, the kernel can boot without any
obvious problem. So, I don't figure out why we need this final build?


diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index e6818b8e7141..086b2efd4d53 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -247,9 +247,6 @@ else
        expr 0$(cat .old_version) + 1 >.version;
 fi;

-# final build of init/
-${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}"
-
 archive_builtin

 #link vmlinux.o

 --
Sincerely,
Cao jin

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

* Re: why scripts/link-vmlinux.sh has a final build of init/
  2018-02-12  4:22 why scripts/link-vmlinux.sh has a final build of init/ Cao jin
@ 2018-02-12 14:48 ` Masahiro Yamada
  2018-02-13  7:08   ` Cao jin
  0 siblings, 1 reply; 5+ messages in thread
From: Masahiro Yamada @ 2018-02-12 14:48 UTC (permalink / raw)
  To: Cao jin; +Cc: Michal Marek, Linux Kbuild mailing list, linux-kernel

2018-02-12 13:22 GMT+09:00 Cao jin <caoj.fnst@cn.fujitsu.com>:
> Hi Masahiro-san,
>
>   As I remember, init/ is already built during recursive make, and I did
> a clean build(make mrproper, make localmodconfig) with all plugins
> included on x86_64 with following patch, the kernel can boot without any
> obvious problem. So, I don't figure out why we need this final build?
>
>
> diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
> index e6818b8e7141..086b2efd4d53 100755
> --- a/scripts/link-vmlinux.sh
> +++ b/scripts/link-vmlinux.sh
> @@ -247,9 +247,6 @@ else
>         expr 0$(cat .old_version) + 1 >.version;
>  fi;
>
> -# final build of init/
> -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
> GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}"
> -
>  archive_builtin
>
>  #link vmlinux.o
>


link-vmlinux.sh increments '.version'
so it must descend into init/
to update include/generated/compile.h
and re-compile init/version.o

We do not increment '.version'
at the first descend into init/
because we never know whether the kernel
is updated or not before the final link stage.


-- 
Best Regards
Masahiro Yamada

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

* Re: why scripts/link-vmlinux.sh has a final build of init/
  2018-02-12 14:48 ` Masahiro Yamada
@ 2018-02-13  7:08   ` Cao jin
  2018-02-14 11:31     ` Masahiro Yamada
  0 siblings, 1 reply; 5+ messages in thread
From: Cao jin @ 2018-02-13  7:08 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: Michal Marek, Linux Kbuild mailing list, linux-kernel



On 02/12/2018 10:48 PM, Masahiro Yamada wrote:
> 2018-02-12 13:22 GMT+09:00 Cao jin <caoj.fnst@cn.fujitsu.com>:
>> Hi Masahiro-san,
>>
>>   As I remember, init/ is already built during recursive make, and I did
>> a clean build(make mrproper, make localmodconfig) with all plugins
>> included on x86_64 with following patch, the kernel can boot without any
>> obvious problem. So, I don't figure out why we need this final build?
>>
>>
>> diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
>> index e6818b8e7141..086b2efd4d53 100755
>> --- a/scripts/link-vmlinux.sh
>> +++ b/scripts/link-vmlinux.sh
>> @@ -247,9 +247,6 @@ else
>>         expr 0$(cat .old_version) + 1 >.version;
>>  fi;
>>
>> -# final build of init/
>> -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
>> GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}"
>> -
>>  archive_builtin
>>
>>  #link vmlinux.o
>>
> 
> 
> link-vmlinux.sh increments '.version'
> so it must descend into init/
> to update include/generated/compile.h
> and re-compile init/version.o
> 
> We do not increment '.version'
> at the first descend into init/
> because we never know whether the kernel
> is updated or not before the final link stage.
> 

Oh, I wasn't aware of this process, now understood. Thanks Masahiro-san.

BTW, I still have 2 questions.

1. In final build, why need

   GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}"

Doesn't GCC_PLUGINS_CFLAGS already exist in the environment?

I also tested the Randomizing Structure Layout plugin with this patch,
the plugin seems works in my test.

2. scripts/link-vmlinux.sh seems just handle only one argument: clean.
So why shouldn't it be:

diff --git a/Makefile b/Makefile
index ccd981892ef2..21d93b545381 100644
--- a/Makefile
+++ b/Makefile
@@ -998,7 +998,7 @@ ARCH_POSTLINK := $(wildcard
$(srctree)/arch/$(SRCARCH)/Makefile.postlink)

 # Final link of vmlinux with optional arch pass after final link
 cmd_link-vmlinux =                                                 \
-       $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) ;    \
+       $(CONFIG_SHELL) $<;                                         \
        $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)

 vmlinux: scripts/link-vmlinux.sh vmlinux_prereq $(vmlinux-deps) FORCE

-- 
Sincerely,
Cao jin

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

* Re: why scripts/link-vmlinux.sh has a final build of init/
  2018-02-13  7:08   ` Cao jin
@ 2018-02-14 11:31     ` Masahiro Yamada
  2018-02-21  3:20       ` Cao jin
  0 siblings, 1 reply; 5+ messages in thread
From: Masahiro Yamada @ 2018-02-14 11:31 UTC (permalink / raw)
  To: Cao jin; +Cc: Michal Marek, Linux Kbuild mailing list, linux-kernel

2018-02-13 16:08 GMT+09:00 Cao jin <caoj.fnst@cn.fujitsu.com>:

> BTW, I still have 2 questions.
>
> 1. In final build, why need
>
>    GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}"
>
> Doesn't GCC_PLUGINS_CFLAGS already exist in the environment?
>
> I also tested the Randomizing Structure Layout plugin with this patch,
> the plugin seems works in my test.


I have not tested, but GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}"
is probably unnecessary.



> 2. scripts/link-vmlinux.sh seems just handle only one argument: clean.
> So why shouldn't it be:


To detect the change of $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux)
because link-vmlinux.sh depends on them.



> diff --git a/Makefile b/Makefile
> index ccd981892ef2..21d93b545381 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -998,7 +998,7 @@ ARCH_POSTLINK := $(wildcard
> $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
>
>  # Final link of vmlinux with optional arch pass after final link
>  cmd_link-vmlinux =                                                 \
> -       $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) ;    \
> +       $(CONFIG_SHELL) $<;                                         \
>         $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
>
>  vmlinux: scripts/link-vmlinux.sh vmlinux_prereq $(vmlinux-deps) FORCE



-- 
Best Regards
Masahiro Yamada

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

* Re: why scripts/link-vmlinux.sh has a final build of init/
  2018-02-14 11:31     ` Masahiro Yamada
@ 2018-02-21  3:20       ` Cao jin
  0 siblings, 0 replies; 5+ messages in thread
From: Cao jin @ 2018-02-21  3:20 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: Michal Marek, Linux Kbuild mailing list, linux-kernel

Sorry for late.

On 02/14/2018 07:31 PM, Masahiro Yamada wrote:
> 2018-02-13 16:08 GMT+09:00 Cao jin <caoj.fnst@cn.fujitsu.com>:
> 
>> BTW, I still have 2 questions.
>>
>> 1. In final build, why need
>>
>>    GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}"
>>
>> Doesn't GCC_PLUGINS_CFLAGS already exist in the environment?
>>
>> I also tested the Randomizing Structure Layout plugin with this patch,
>> the plugin seems works in my test.
> 
> 
> I have not tested, but GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}"
> is probably unnecessary.
> 
> 
> 
>> 2. scripts/link-vmlinux.sh seems just handle only one argument: clean.
>> So why shouldn't it be:
> 
> 
> To detect the change of $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux)
> because link-vmlinux.sh depends on them.
> 

I understood, I missed the existence of .vmlinux.cmd file.
Thanks very much, Masahiro-san.

-- 
Sincerely,
Cao jin

> 
>> diff --git a/Makefile b/Makefile
>> index ccd981892ef2..21d93b545381 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -998,7 +998,7 @@ ARCH_POSTLINK := $(wildcard
>> $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
>>
>>  # Final link of vmlinux with optional arch pass after final link
>>  cmd_link-vmlinux =                                                 \
>> -       $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) ;    \
>> +       $(CONFIG_SHELL) $<;                                         \
>>         $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
>>
>>  vmlinux: scripts/link-vmlinux.sh vmlinux_prereq $(vmlinux-deps) FORCE
> 
> 
> 

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

end of thread, other threads:[~2018-02-21  3:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-12  4:22 why scripts/link-vmlinux.sh has a final build of init/ Cao jin
2018-02-12 14:48 ` Masahiro Yamada
2018-02-13  7:08   ` Cao jin
2018-02-14 11:31     ` Masahiro Yamada
2018-02-21  3:20       ` Cao jin

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.