Message ID | 20201119204656.3261686-2-natechancellor@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | None | expand |
On Thu, Nov 19, 2020 at 12:57 PM Nathan Chancellor <natechancellor@gmail.com> wrote: > > ld.lld 10.0.1 spews a bunch of various warnings about .rela sections, > along with a few others. Newer versions of ld.lld do not have these > warnings. As a result, do not add '--orphan-handling=warn' to > LDFLAGS_vmlinux if ld.lld's version is not new enough. > > Link: https://github.com/ClangBuiltLinux/linux/issues/1187 > Link: https://github.com/ClangBuiltLinux/linux/issues/1193 > Reported-by: Arvind Sankar <nivedita@alum.mit.edu> > Reported-by: kernelci.org bot <bot@kernelci.org> > Reported-by: Mark Brown <broonie@kernel.org> > Reviewed-by: Kees Cook <keescook@chromium.org> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> Thanks for the additions in v2. Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> > --- > > v1 -> v2: > > * Add condition as a depends on line (Kees Cook) > > * Capture output of "$* --version" to avoid invoking linker twice (Nick > Desaulniers) > > * Improve documentation of script in comments (Nick Desaulniers) > > * Pick up review tag from Kees > > MAINTAINERS | 1 + > init/Kconfig | 5 +++++ > scripts/lld-version.sh | 20 ++++++++++++++++++++ > 3 files changed, 26 insertions(+) > create mode 100755 scripts/lld-version.sh > > diff --git a/MAINTAINERS b/MAINTAINERS > index e451dcce054f..e6f74f130ae1 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -4284,6 +4284,7 @@ B: https://github.com/ClangBuiltLinux/linux/issues > C: irc://chat.freenode.net/clangbuiltlinux > F: Documentation/kbuild/llvm.rst > F: scripts/clang-tools/ > +F: scripts/lld-version.sh > K: \b(?i:clang|llvm)\b > > CLEANCACHE API > diff --git a/init/Kconfig b/init/Kconfig > index 92c58b45abb8..b9037d6c5ab3 100644 > --- a/init/Kconfig > +++ b/init/Kconfig > @@ -47,6 +47,10 @@ config CLANG_VERSION > int > default $(shell,$(srctree)/scripts/clang-version.sh $(CC)) > > +config LLD_VERSION > + int > + default $(shell,$(srctree)/scripts/lld-version.sh $(LD)) > + > config CC_CAN_LINK > bool > default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m64-flag)) if 64BIT > @@ -1351,6 +1355,7 @@ config LD_DEAD_CODE_DATA_ELIMINATION > config LD_ORPHAN_WARN > def_bool y > depends on ARCH_WANT_LD_ORPHAN_WARN > + depends on !LD_IS_LLD || LLD_VERSION >= 110000 > depends on $(ld-option,--orphan-handling=warn) > > config SYSCTL > diff --git a/scripts/lld-version.sh b/scripts/lld-version.sh > new file mode 100755 > index 000000000000..d70edb4d8a4f > --- /dev/null > +++ b/scripts/lld-version.sh > @@ -0,0 +1,20 @@ > +#!/bin/sh > +# SPDX-License-Identifier: GPL-2.0 > +# > +# Usage: $ ./scripts/lld-version.sh ld.lld > +# > +# Print the linker version of `ld.lld' in a 5 or 6-digit form > +# such as `100001' for ld.lld 10.0.1 etc. > + > +linker_string="$($* --version)" > + > +if ! ( echo $linker_string | grep -q LLD ); then > + echo 0 > + exit 1 > +fi > + > +VERSION=$(echo $linker_string | cut -d ' ' -f 2) > +MAJOR=$(echo $VERSION | cut -d . -f 1) > +MINOR=$(echo $VERSION | cut -d . -f 2) > +PATCHLEVEL=$(echo $VERSION | cut -d . -f 3) > +printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL > -- > 2.29.2 >
On Thu, Nov 19, 2020 at 01:13:27PM -0800, Nick Desaulniers wrote: > On Thu, Nov 19, 2020 at 12:57 PM Nathan Chancellor > <natechancellor@gmail.com> wrote: > > > > ld.lld 10.0.1 spews a bunch of various warnings about .rela sections, > > along with a few others. Newer versions of ld.lld do not have these > > warnings. As a result, do not add '--orphan-handling=warn' to > > LDFLAGS_vmlinux if ld.lld's version is not new enough. > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/1187 > > Link: https://github.com/ClangBuiltLinux/linux/issues/1193 > > Reported-by: Arvind Sankar <nivedita@alum.mit.edu> > > Reported-by: kernelci.org bot <bot@kernelci.org> > > Reported-by: Mark Brown <broonie@kernel.org> > > Reviewed-by: Kees Cook <keescook@chromium.org> > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> > > Thanks for the additions in v2. > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> I'm going to carry this for a few days in -next, and if no one screams, ask Linus to pull it for v5.10-rc6. Thanks!
On Wed, Nov 25, 2020 at 7:22 AM Kees Cook <keescook@chromium.org> wrote: > > On Thu, Nov 19, 2020 at 01:13:27PM -0800, Nick Desaulniers wrote: > > On Thu, Nov 19, 2020 at 12:57 PM Nathan Chancellor > > <natechancellor@gmail.com> wrote: > > > > > > ld.lld 10.0.1 spews a bunch of various warnings about .rela sections, > > > along with a few others. Newer versions of ld.lld do not have these > > > warnings. As a result, do not add '--orphan-handling=warn' to > > > LDFLAGS_vmlinux if ld.lld's version is not new enough. > > > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/1187 > > > Link: https://github.com/ClangBuiltLinux/linux/issues/1193 > > > Reported-by: Arvind Sankar <nivedita@alum.mit.edu> > > > Reported-by: kernelci.org bot <bot@kernelci.org> > > > Reported-by: Mark Brown <broonie@kernel.org> > > > Reviewed-by: Kees Cook <keescook@chromium.org> > > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> > > > > Thanks for the additions in v2. > > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> > > I'm going to carry this for a few days in -next, and if no one screams, > ask Linus to pull it for v5.10-rc6. > > Thanks! > > -- > Kees Cook Sorry for the delay. Applied to linux-kbuild. But, I already see this in linux-next. Please let me know if I should drop it from my tree.
On Tue, Dec 01, 2020 at 10:31:37PM +0900, Masahiro Yamada wrote: > On Wed, Nov 25, 2020 at 7:22 AM Kees Cook <keescook@chromium.org> wrote: > > > > On Thu, Nov 19, 2020 at 01:13:27PM -0800, Nick Desaulniers wrote: > > > On Thu, Nov 19, 2020 at 12:57 PM Nathan Chancellor > > > <natechancellor@gmail.com> wrote: > > > > > > > > ld.lld 10.0.1 spews a bunch of various warnings about .rela sections, > > > > along with a few others. Newer versions of ld.lld do not have these > > > > warnings. As a result, do not add '--orphan-handling=warn' to > > > > LDFLAGS_vmlinux if ld.lld's version is not new enough. > > > > > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/1187 > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/1193 > > > > Reported-by: Arvind Sankar <nivedita@alum.mit.edu> > > > > Reported-by: kernelci.org bot <bot@kernelci.org> > > > > Reported-by: Mark Brown <broonie@kernel.org> > > > > Reviewed-by: Kees Cook <keescook@chromium.org> > > > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> > > > > > > Thanks for the additions in v2. > > > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> > > > > I'm going to carry this for a few days in -next, and if no one screams, > > ask Linus to pull it for v5.10-rc6. > > > > Thanks! > > > > -- > > Kees Cook > > > Sorry for the delay. > Applied to linux-kbuild. Great, thanks! > But, I already see this in linux-next. > Please let me know if I should drop it from my tree. My intention was to get this to Linus this week. Do you want to do that yourself, or Ack the patches in my tree and I'll send it? -Kees
On Wed, Dec 2, 2020 at 5:56 AM Kees Cook <keescook@chromium.org> wrote: > > On Tue, Dec 01, 2020 at 10:31:37PM +0900, Masahiro Yamada wrote: > > On Wed, Nov 25, 2020 at 7:22 AM Kees Cook <keescook@chromium.org> wrote: > > > > > > On Thu, Nov 19, 2020 at 01:13:27PM -0800, Nick Desaulniers wrote: > > > > On Thu, Nov 19, 2020 at 12:57 PM Nathan Chancellor > > > > <natechancellor@gmail.com> wrote: > > > > > > > > > > ld.lld 10.0.1 spews a bunch of various warnings about .rela sections, > > > > > along with a few others. Newer versions of ld.lld do not have these > > > > > warnings. As a result, do not add '--orphan-handling=warn' to > > > > > LDFLAGS_vmlinux if ld.lld's version is not new enough. > > > > > > > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/1187 > > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/1193 > > > > > Reported-by: Arvind Sankar <nivedita@alum.mit.edu> > > > > > Reported-by: kernelci.org bot <bot@kernelci.org> > > > > > Reported-by: Mark Brown <broonie@kernel.org> > > > > > Reviewed-by: Kees Cook <keescook@chromium.org> > > > > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> > > > > > > > > Thanks for the additions in v2. > > > > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> > > > > > > I'm going to carry this for a few days in -next, and if no one screams, > > > ask Linus to pull it for v5.10-rc6. > > > > > > Thanks! > > > > > > -- > > > Kees Cook > > > > > > Sorry for the delay. > > Applied to linux-kbuild. > > Great, thanks! > > > But, I already see this in linux-next. > > Please let me know if I should drop it from my tree. > > My intention was to get this to Linus this week. Do you want to do that > yourself, or Ack the patches in my tree and I'll send it? > > -Kees > > -- > Kees Cook I will send a kbuild pull request myself this week.
On Wed, Dec 02, 2020 at 11:37:38AM +0900, Masahiro Yamada wrote: > On Wed, Dec 2, 2020 at 5:56 AM Kees Cook <keescook@chromium.org> wrote: > > > > On Tue, Dec 01, 2020 at 10:31:37PM +0900, Masahiro Yamada wrote: > > > On Wed, Nov 25, 2020 at 7:22 AM Kees Cook <keescook@chromium.org> wrote: > > > > > > > > On Thu, Nov 19, 2020 at 01:13:27PM -0800, Nick Desaulniers wrote: > > > > > On Thu, Nov 19, 2020 at 12:57 PM Nathan Chancellor > > > > > <natechancellor@gmail.com> wrote: > > > > > > > > > > > > ld.lld 10.0.1 spews a bunch of various warnings about .rela sections, > > > > > > along with a few others. Newer versions of ld.lld do not have these > > > > > > warnings. As a result, do not add '--orphan-handling=warn' to > > > > > > LDFLAGS_vmlinux if ld.lld's version is not new enough. > > > > > > > > > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/1187 > > > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/1193 > > > > > > Reported-by: Arvind Sankar <nivedita@alum.mit.edu> > > > > > > Reported-by: kernelci.org bot <bot@kernelci.org> > > > > > > Reported-by: Mark Brown <broonie@kernel.org> > > > > > > Reviewed-by: Kees Cook <keescook@chromium.org> > > > > > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> > > > > > > > > > > Thanks for the additions in v2. > > > > > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> > > > > > > > > I'm going to carry this for a few days in -next, and if no one screams, > > > > ask Linus to pull it for v5.10-rc6. > > > > > > > > Thanks! > > > > > > > > -- > > > > Kees Cook > > > > > > > > > Sorry for the delay. > > > Applied to linux-kbuild. > > > > Great, thanks! > > > > > But, I already see this in linux-next. > > > Please let me know if I should drop it from my tree. > > > > My intention was to get this to Linus this week. Do you want to do that > > yourself, or Ack the patches in my tree and I'll send it? > > I will send a kbuild pull request myself this week. Okay, thanks! I've removed it from my -next tree now.
diff --git a/MAINTAINERS b/MAINTAINERS index e451dcce054f..e6f74f130ae1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4284,6 +4284,7 @@ B: https://github.com/ClangBuiltLinux/linux/issues C: irc://chat.freenode.net/clangbuiltlinux F: Documentation/kbuild/llvm.rst F: scripts/clang-tools/ +F: scripts/lld-version.sh K: \b(?i:clang|llvm)\b CLEANCACHE API diff --git a/init/Kconfig b/init/Kconfig index 92c58b45abb8..b9037d6c5ab3 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -47,6 +47,10 @@ config CLANG_VERSION int default $(shell,$(srctree)/scripts/clang-version.sh $(CC)) +config LLD_VERSION + int + default $(shell,$(srctree)/scripts/lld-version.sh $(LD)) + config CC_CAN_LINK bool default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m64-flag)) if 64BIT @@ -1351,6 +1355,7 @@ config LD_DEAD_CODE_DATA_ELIMINATION config LD_ORPHAN_WARN def_bool y depends on ARCH_WANT_LD_ORPHAN_WARN + depends on !LD_IS_LLD || LLD_VERSION >= 110000 depends on $(ld-option,--orphan-handling=warn) config SYSCTL diff --git a/scripts/lld-version.sh b/scripts/lld-version.sh new file mode 100755 index 000000000000..d70edb4d8a4f --- /dev/null +++ b/scripts/lld-version.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# +# Usage: $ ./scripts/lld-version.sh ld.lld +# +# Print the linker version of `ld.lld' in a 5 or 6-digit form +# such as `100001' for ld.lld 10.0.1 etc. + +linker_string="$($* --version)" + +if ! ( echo $linker_string | grep -q LLD ); then + echo 0 + exit 1 +fi + +VERSION=$(echo $linker_string | cut -d ' ' -f 2) +MAJOR=$(echo $VERSION | cut -d . -f 1) +MINOR=$(echo $VERSION | cut -d . -f 2) +PATCHLEVEL=$(echo $VERSION | cut -d . -f 3) +printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL