* Re: [PATCH 1/4] init/Kconfig: add config support for detecting linker
@ 2019-02-08 14:06 Sedat Dilek
0 siblings, 0 replies; 7+ messages in thread
From: Sedat Dilek @ 2019-02-08 14:06 UTC (permalink / raw)
To: Masahiro Yamada, Nick Desaulniers, Nathan Chancellor,
Sami Tolvanen, Andrew Morton, Peter Zijlstra (Intel),
Johannes Weiner, Kees Cook, Dominik Brodowski, Nicholas Piggin,
Mathieu Desnoyers, Vasily Gorbik, Adrian Reber,
Richard Guy Briggs, linux-kernel
Feel free to add my...
Suggested-by: Sedat Dilek <sedat.dilek@gmail.com> (see my comment in [1])
[1] https://github.com/ClangBuiltLinux/linux/issues/341#issuecomment-459788558
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/4] init/Kconfig: add config support for detecting linker
2019-02-08 5:41 ` Nathan Chancellor
@ 2019-02-11 15:08 ` Masahiro Yamada
0 siblings, 0 replies; 7+ messages in thread
From: Masahiro Yamada @ 2019-02-11 15:08 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Mathieu Desnoyers, Nick Desaulniers, Sami Tolvanen,
Andrew Morton, Peter Zijlstra (Intel),
Johannes Weiner, Kees Cook, Dominik Brodowski, Nicholas Piggin,
Vasily Gorbik, Adrian Reber, Richard Guy Briggs,
Linux Kernel Mailing List
On Fri, Feb 8, 2019 at 2:42 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> On Thu, Feb 07, 2019 at 07:57:20PM -0500, Mathieu Desnoyers wrote:
> >
> > ----- ndesaulniers@google.com wrote:
> > > Similar to how we differentiate between CONFIG_CC_IS_GCC and
> > > CONFIG_CC_IS_CLANG, add CONFIG_LD_IS_BFD, CONFIG_LD_IS_GOLD, and
> > > CONFIG_LD_IS_LLD.
> > >
> > > This simiplifies patches to Makefiles that need to do different things
> > > for different linkers.
> >
>
> Hi Mathieu,
>
> > What guarantees that the linker used for e.g. make defconfig is the same linker used for make ?
> >
> > Is it required with this patch ?
> >
>
> The build system ensures that the compiler (and after this patch, the
> linker) config values are correct before compiling (and prompting the
> user for the new choices that are available to them in that case).
>
> For example:
>
> $ make ARCH=arm64 CC=clang CROSS_COMPILE=aarch64-linux-gnu- defconfig
> ...
>
> $ rg "CONFIG_CC_IS|CONFIG_LD_IS" .config
> 10:CONFIG_CC_IS_CLANG=y
> 12:CONFIG_LD_IS_BFD=y
>
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LD=ld.lld
> scripts/kconfig/conf --syncconfig Kconfig
> *
> * Restart config...
> *
> *
> * General architecture-dependent options
> *
> Kprobes (KPROBES) [N/y/?] n
> Optimize very unlikely/likely branches (JUMP_LABEL) [N/y/?] (NEW)
> Stack Protector buffer overflow detection (STACKPROTECTOR) [Y/n/?] y
> Strong Stack Protector (STACKPROTECTOR_STRONG) [Y/n/?] y
> Use a virtually-mapped stack (VMAP_STACK) [Y/n/?] y
> Perform full reference count validation at the expense of speed (REFCOUNT_FULL) [Y/?] y
> *
> * GCC plugins
> *
> GCC plugins (GCC_PLUGINS) [N/y/?] (NEW)
> ...
>
> $ rg "CONFIG_CC_IS|CONFIG_LD_IS" .config
> 9:CONFIG_CC_IS_GCC=y
> 13:CONFIG_LD_IS_LLD=y
>
> > How does it work in a cross compile environment ?
> >
>
> Since $(LD) is defined based on $(CROSS_COMPILE), it should work fine.
> I tested it with both arm64 and x86_64 and CONFIG_LD_IS_BFD gets
> set by default and I can see CONFIG_LD_IS_GOLD get set with both
> LD=aarch64-linux-gnu-ld.gold and LD=ld.gold.
>
> If I misunderstood the questions or my explanation wasn't correct,
> please let me know!
With this patch,
include/config/auto.conf.cmd will include the following:
ifneq "$(LD)" "ld"
include/config/auto.conf: FORCE
endif
When $(LD) is changed, Kconfig will be re-run.
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/4] init/Kconfig: add config support for detecting linker
2019-02-08 0:57 ` Mathieu Desnoyers
@ 2019-02-08 5:41 ` Nathan Chancellor
2019-02-11 15:08 ` Masahiro Yamada
0 siblings, 1 reply; 7+ messages in thread
From: Nathan Chancellor @ 2019-02-08 5:41 UTC (permalink / raw)
To: Mathieu Desnoyers
Cc: ndesaulniers, yamada masahiro, Sami Tolvanen, Andrew Morton,
Peter Zijlstra (Intel),
Johannes Weiner, Kees Cook, Dominik Brodowski, Nicholas Piggin,
Vasily Gorbik, Adrian Reber, Richard Guy Briggs, linux-kernel
On Thu, Feb 07, 2019 at 07:57:20PM -0500, Mathieu Desnoyers wrote:
>
> ----- ndesaulniers@google.com wrote:
> > Similar to how we differentiate between CONFIG_CC_IS_GCC and
> > CONFIG_CC_IS_CLANG, add CONFIG_LD_IS_BFD, CONFIG_LD_IS_GOLD, and
> > CONFIG_LD_IS_LLD.
> >
> > This simiplifies patches to Makefiles that need to do different things
> > for different linkers.
>
Hi Mathieu,
> What guarantees that the linker used for e.g. make defconfig is the same linker used for make ?
>
> Is it required with this patch ?
>
The build system ensures that the compiler (and after this patch, the
linker) config values are correct before compiling (and prompting the
user for the new choices that are available to them in that case).
For example:
$ make ARCH=arm64 CC=clang CROSS_COMPILE=aarch64-linux-gnu- defconfig
...
$ rg "CONFIG_CC_IS|CONFIG_LD_IS" .config
10:CONFIG_CC_IS_CLANG=y
12:CONFIG_LD_IS_BFD=y
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LD=ld.lld
scripts/kconfig/conf --syncconfig Kconfig
*
* Restart config...
*
*
* General architecture-dependent options
*
Kprobes (KPROBES) [N/y/?] n
Optimize very unlikely/likely branches (JUMP_LABEL) [N/y/?] (NEW)
Stack Protector buffer overflow detection (STACKPROTECTOR) [Y/n/?] y
Strong Stack Protector (STACKPROTECTOR_STRONG) [Y/n/?] y
Use a virtually-mapped stack (VMAP_STACK) [Y/n/?] y
Perform full reference count validation at the expense of speed (REFCOUNT_FULL) [Y/?] y
*
* GCC plugins
*
GCC plugins (GCC_PLUGINS) [N/y/?] (NEW)
...
$ rg "CONFIG_CC_IS|CONFIG_LD_IS" .config
9:CONFIG_CC_IS_GCC=y
13:CONFIG_LD_IS_LLD=y
> How does it work in a cross compile environment ?
>
Since $(LD) is defined based on $(CROSS_COMPILE), it should work fine.
I tested it with both arm64 and x86_64 and CONFIG_LD_IS_BFD gets
set by default and I can see CONFIG_LD_IS_GOLD get set with both
LD=aarch64-linux-gnu-ld.gold and LD=ld.gold.
If I misunderstood the questions or my explanation wasn't correct,
please let me know!
Cheers,
Nathan
> Thanks,
>
> Mathieu
>
>
> >
> > Cc: Nathan Chancellor <natechancellor@gmail.com>
> > Cc: Sami Tolvanen <samitolvanen@google.com>
> > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> > ---
> > init/Kconfig | 9 +++++++++
> > 1 file changed, 9 insertions(+)
> >
> > diff --git a/init/Kconfig b/init/Kconfig
> > index c9386a365eea..b6046dcf7794 100644
> > --- a/init/Kconfig
> > +++ b/init/Kconfig
> > @@ -26,6 +26,15 @@ config CLANG_VERSION
> > config CC_HAS_ASM_GOTO
> > def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC))
> >
> > +config LD_IS_BFD
> > + def_bool $(success,$(LD) --version | head -n 1 | grep -q 'GNU ld')
> > +
> > +config LD_IS_GOLD
> > + def_bool $(success,$(LD) --version | head -n 1 | grep -q 'GNU gold')
> > +
> > +config LD_IS_LLD
> > + def_bool $(success,$(LD) --version | head -n 1 | grep -q 'LLD')
> > +
> > config CONSTRUCTORS
> > bool
> > depends on !UML
> > --
> > 2.20.1.791.gb4d0f1c61a-goog
> >
>
> --
> Mathieu Desnoyers
> EfficiOS Inc.
> http://www.efficios.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/4] init/Kconfig: add config support for detecting linker
2019-02-07 22:01 ndesaulniers
2019-02-08 0:48 ` Kees Cook
2019-02-08 0:57 ` Mathieu Desnoyers
@ 2019-02-08 5:14 ` Nathan Chancellor
2 siblings, 0 replies; 7+ messages in thread
From: Nathan Chancellor @ 2019-02-08 5:14 UTC (permalink / raw)
To: ndesaulniers
Cc: yamada.masahiro, Sami Tolvanen, Andrew Morton,
Peter Zijlstra (Intel),
Johannes Weiner, Kees Cook, Dominik Brodowski, Nicholas Piggin,
Mathieu Desnoyers, Vasily Gorbik, Adrian Reber,
Richard Guy Briggs, linux-kernel
On Thu, Feb 07, 2019 at 02:01:49PM -0800, ndesaulniers@google.com wrote:
> Similar to how we differentiate between CONFIG_CC_IS_GCC and
> CONFIG_CC_IS_CLANG, add CONFIG_LD_IS_BFD, CONFIG_LD_IS_GOLD, and
> CONFIG_LD_IS_LLD.
>
> This simiplifies patches to Makefiles that need to do different things
> for different linkers.
>
> Cc: Nathan Chancellor <natechancellor@gmail.com>
> Cc: Sami Tolvanen <samitolvanen@google.com>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> init/Kconfig | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/init/Kconfig b/init/Kconfig
> index c9386a365eea..b6046dcf7794 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -26,6 +26,15 @@ config CLANG_VERSION
> config CC_HAS_ASM_GOTO
> def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC))
>
> +config LD_IS_BFD
> + def_bool $(success,$(LD) --version | head -n 1 | grep -q 'GNU ld')
> +
> +config LD_IS_GOLD
> + def_bool $(success,$(LD) --version | head -n 1 | grep -q 'GNU gold')
> +
> +config LD_IS_LLD
> + def_bool $(success,$(LD) --version | head -n 1 | grep -q 'LLD')
> +
> config CONSTRUCTORS
> bool
> depends on !UML
> --
> 2.20.1.791.gb4d0f1c61a-goog
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/4] init/Kconfig: add config support for detecting linker
2019-02-07 22:01 ndesaulniers
2019-02-08 0:48 ` Kees Cook
@ 2019-02-08 0:57 ` Mathieu Desnoyers
2019-02-08 5:41 ` Nathan Chancellor
2019-02-08 5:14 ` Nathan Chancellor
2 siblings, 1 reply; 7+ messages in thread
From: Mathieu Desnoyers @ 2019-02-08 0:57 UTC (permalink / raw)
To: ndesaulniers
Cc: yamada masahiro, Nathan Chancellor, Sami Tolvanen, Andrew Morton,
Peter Zijlstra (Intel),
Johannes Weiner, Kees Cook, Dominik Brodowski, Nicholas Piggin,
Vasily Gorbik, Adrian Reber, Richard Guy Briggs, linux-kernel
----- ndesaulniers@google.com wrote:
> Similar to how we differentiate between CONFIG_CC_IS_GCC and
> CONFIG_CC_IS_CLANG, add CONFIG_LD_IS_BFD, CONFIG_LD_IS_GOLD, and
> CONFIG_LD_IS_LLD.
>
> This simiplifies patches to Makefiles that need to do different things
> for different linkers.
What guarantees that the linker used for e.g. make defconfig is the same linker used for make ?
Is it required with this patch ?
How does it work in a cross compile environment ?
Thanks,
Mathieu
>
> Cc: Nathan Chancellor <natechancellor@gmail.com>
> Cc: Sami Tolvanen <samitolvanen@google.com>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
> init/Kconfig | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/init/Kconfig b/init/Kconfig
> index c9386a365eea..b6046dcf7794 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -26,6 +26,15 @@ config CLANG_VERSION
> config CC_HAS_ASM_GOTO
> def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC))
>
> +config LD_IS_BFD
> + def_bool $(success,$(LD) --version | head -n 1 | grep -q 'GNU ld')
> +
> +config LD_IS_GOLD
> + def_bool $(success,$(LD) --version | head -n 1 | grep -q 'GNU gold')
> +
> +config LD_IS_LLD
> + def_bool $(success,$(LD) --version | head -n 1 | grep -q 'LLD')
> +
> config CONSTRUCTORS
> bool
> depends on !UML
> --
> 2.20.1.791.gb4d0f1c61a-goog
>
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/4] init/Kconfig: add config support for detecting linker
2019-02-07 22:01 ndesaulniers
@ 2019-02-08 0:48 ` Kees Cook
2019-02-08 0:57 ` Mathieu Desnoyers
2019-02-08 5:14 ` Nathan Chancellor
2 siblings, 0 replies; 7+ messages in thread
From: Kees Cook @ 2019-02-08 0:48 UTC (permalink / raw)
To: Nick Desaulniers
Cc: Masahiro Yamada, Nathan Chancellor, Sami Tolvanen, Andrew Morton,
Peter Zijlstra (Intel),
Johannes Weiner, Dominik Brodowski, Nicholas Piggin,
Mathieu Desnoyers, Vasily Gorbik, Adrian Reber,
Richard Guy Briggs, LKML
On Thu, Feb 7, 2019 at 10:02 PM <ndesaulniers@google.com> wrote:
>
> Similar to how we differentiate between CONFIG_CC_IS_GCC and
> CONFIG_CC_IS_CLANG, add CONFIG_LD_IS_BFD, CONFIG_LD_IS_GOLD, and
> CONFIG_LD_IS_LLD.
>
> This simiplifies patches to Makefiles that need to do different things
> for different linkers.
>
> Cc: Nathan Chancellor <natechancellor@gmail.com>
> Cc: Sami Tolvanen <samitolvanen@google.com>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
-Kees
> ---
> init/Kconfig | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/init/Kconfig b/init/Kconfig
> index c9386a365eea..b6046dcf7794 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -26,6 +26,15 @@ config CLANG_VERSION
> config CC_HAS_ASM_GOTO
> def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC))
>
> +config LD_IS_BFD
> + def_bool $(success,$(LD) --version | head -n 1 | grep -q 'GNU ld')
> +
> +config LD_IS_GOLD
> + def_bool $(success,$(LD) --version | head -n 1 | grep -q 'GNU gold')
> +
> +config LD_IS_LLD
> + def_bool $(success,$(LD) --version | head -n 1 | grep -q 'LLD')
> +
> config CONSTRUCTORS
> bool
> depends on !UML
> --
> 2.20.1.791.gb4d0f1c61a-goog
>
--
Kees Cook
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/4] init/Kconfig: add config support for detecting linker
@ 2019-02-07 22:01 ndesaulniers
2019-02-08 0:48 ` Kees Cook
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: ndesaulniers @ 2019-02-07 22:01 UTC (permalink / raw)
To: yamada.masahiro
Cc: Nick Desaulniers, Nathan Chancellor, Sami Tolvanen,
Andrew Morton, Peter Zijlstra (Intel),
Johannes Weiner, Kees Cook, Dominik Brodowski, Nicholas Piggin,
Mathieu Desnoyers, Vasily Gorbik, Adrian Reber,
Richard Guy Briggs, linux-kernel
Similar to how we differentiate between CONFIG_CC_IS_GCC and
CONFIG_CC_IS_CLANG, add CONFIG_LD_IS_BFD, CONFIG_LD_IS_GOLD, and
CONFIG_LD_IS_LLD.
This simiplifies patches to Makefiles that need to do different things
for different linkers.
Cc: Nathan Chancellor <natechancellor@gmail.com>
Cc: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
init/Kconfig | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/init/Kconfig b/init/Kconfig
index c9386a365eea..b6046dcf7794 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -26,6 +26,15 @@ config CLANG_VERSION
config CC_HAS_ASM_GOTO
def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC))
+config LD_IS_BFD
+ def_bool $(success,$(LD) --version | head -n 1 | grep -q 'GNU ld')
+
+config LD_IS_GOLD
+ def_bool $(success,$(LD) --version | head -n 1 | grep -q 'GNU gold')
+
+config LD_IS_LLD
+ def_bool $(success,$(LD) --version | head -n 1 | grep -q 'LLD')
+
config CONSTRUCTORS
bool
depends on !UML
--
2.20.1.791.gb4d0f1c61a-goog
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-02-11 15:09 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-08 14:06 [PATCH 1/4] init/Kconfig: add config support for detecting linker Sedat Dilek
-- strict thread matches above, loose matches on Subject: below --
2019-02-07 22:01 ndesaulniers
2019-02-08 0:48 ` Kees Cook
2019-02-08 0:57 ` Mathieu Desnoyers
2019-02-08 5:41 ` Nathan Chancellor
2019-02-11 15:08 ` Masahiro Yamada
2019-02-08 5:14 ` Nathan Chancellor
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).