linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] MIPS: vdso: Wrap -mexplicit-relocs in cc-option
@ 2020-02-17 21:11 Nathan Chancellor
  2020-02-18 18:28 ` Nick Desaulniers
  2020-02-19 19:01 ` Paul Burton
  0 siblings, 2 replies; 4+ messages in thread
From: Nathan Chancellor @ 2020-02-17 21:11 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Paul Burton, linux-mips, linux-kernel, clang-built-linux,
	Nathan Chancellor

Clang does not support this option and errors out:

clang-11: error: unknown argument: '-mexplicit-relocs'

Clang does not appear to need this flag like GCC does because the jalr
check that was added in commit 976c23af3ee5 ("mips: vdso: add build
time check that no 'jalr t9' calls left") passes just fine with

$ make ARCH=mips CC=clang CROSS_COMPILE=mipsel-linux-gnu- malta_defconfig arch/mips/vdso/

even before commit d3f703c4359f ("mips: vdso: fix 'jalr t9' crash in
vdso code").

-mrelax-pic-calls has been supported since clang 9, which is the
earliest version that could build a working MIPS kernel, and it is the
default for clang so just leave it be.

Fixes: d3f703c4359f ("mips: vdso: fix 'jalr t9' crash in vdso code")
Link: https://github.com/ClangBuiltLinux/linux/issues/890
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 arch/mips/vdso/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile
index 77374c1f0c77..d7fe8408603e 100644
--- a/arch/mips/vdso/Makefile
+++ b/arch/mips/vdso/Makefile
@@ -33,7 +33,7 @@ endif
 cflags-vdso := $(ccflags-vdso) \
 	$(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
 	-O3 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \
-	-mrelax-pic-calls -mexplicit-relocs \
+	-mrelax-pic-calls $(call cc-option, -mexplicit-relocs) \
 	-fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \
 	$(call cc-option, -fno-asynchronous-unwind-tables) \
 	$(call cc-option, -fno-stack-protector)
-- 
2.25.1


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

* Re: [PATCH] MIPS: vdso: Wrap -mexplicit-relocs in cc-option
  2020-02-17 21:11 [PATCH] MIPS: vdso: Wrap -mexplicit-relocs in cc-option Nathan Chancellor
@ 2020-02-18 18:28 ` Nick Desaulniers
  2020-02-18 18:30   ` Nathan Chancellor
  2020-02-19 19:01 ` Paul Burton
  1 sibling, 1 reply; 4+ messages in thread
From: Nick Desaulniers @ 2020-02-18 18:28 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Ralf Baechle, Paul Burton, linux-mips, LKML, clang-built-linux

On Mon, Feb 17, 2020 at 1:11 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> Clang does not support this option and errors out:
>
> clang-11: error: unknown argument: '-mexplicit-relocs'
>
> Clang does not appear to need this flag like GCC does because the jalr
> check that was added in commit 976c23af3ee5 ("mips: vdso: add build
> time check that no 'jalr t9' calls left") passes just fine with
>
> $ make ARCH=mips CC=clang CROSS_COMPILE=mipsel-linux-gnu- malta_defconfig arch/mips/vdso/
>
> even before commit d3f703c4359f ("mips: vdso: fix 'jalr t9' crash in
> vdso code").
>
> -mrelax-pic-calls has been supported since clang 9, which is the
> earliest version that could build a working MIPS kernel, and it is the
> default for clang so just leave it be.
>
> Fixes: d3f703c4359f ("mips: vdso: fix 'jalr t9' crash in vdso code")
> Link: https://github.com/ClangBuiltLinux/linux/issues/890
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Thanks for the patch, and detailed context.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

With this patch applied:
$ make ARCH=mips CC=clang CROSS_COMPILE=mipsel-linux-gnu-
malta_defconfig arch/mips/vdso/
$ lvm-objdump --disassemble arch/mips/vdso/vdso.so.dbg.raw | egrep -h "jarl.*t9"
$ llvm-objdump --disassemble arch/mips/vdso/vdso.so.dbg.raw | grep jarl
So jarl instructions aren't emitted.

Tested-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>  arch/mips/vdso/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile
> index 77374c1f0c77..d7fe8408603e 100644
> --- a/arch/mips/vdso/Makefile
> +++ b/arch/mips/vdso/Makefile
> @@ -33,7 +33,7 @@ endif
>  cflags-vdso := $(ccflags-vdso) \
>         $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
>         -O3 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \
> -       -mrelax-pic-calls -mexplicit-relocs \
> +       -mrelax-pic-calls $(call cc-option, -mexplicit-relocs) \
>         -fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \
>         $(call cc-option, -fno-asynchronous-unwind-tables) \
>         $(call cc-option, -fno-stack-protector)
> --

-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH] MIPS: vdso: Wrap -mexplicit-relocs in cc-option
  2020-02-18 18:28 ` Nick Desaulniers
@ 2020-02-18 18:30   ` Nathan Chancellor
  0 siblings, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2020-02-18 18:30 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Ralf Baechle, Paul Burton, linux-mips, LKML, clang-built-linux

On Tue, Feb 18, 2020 at 10:28:15AM -0800, Nick Desaulniers wrote:
> On Mon, Feb 17, 2020 at 1:11 PM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > Clang does not support this option and errors out:
> >
> > clang-11: error: unknown argument: '-mexplicit-relocs'
> >
> > Clang does not appear to need this flag like GCC does because the jalr
> > check that was added in commit 976c23af3ee5 ("mips: vdso: add build
> > time check that no 'jalr t9' calls left") passes just fine with
> >
> > $ make ARCH=mips CC=clang CROSS_COMPILE=mipsel-linux-gnu- malta_defconfig arch/mips/vdso/
> >
> > even before commit d3f703c4359f ("mips: vdso: fix 'jalr t9' crash in
> > vdso code").
> >
> > -mrelax-pic-calls has been supported since clang 9, which is the
> > earliest version that could build a working MIPS kernel, and it is the
> > default for clang so just leave it be.
> >
> > Fixes: d3f703c4359f ("mips: vdso: fix 'jalr t9' crash in vdso code")
> > Link: https://github.com/ClangBuiltLinux/linux/issues/890
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> 
> Thanks for the patch, and detailed context.
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> 
> With this patch applied:
> $ make ARCH=mips CC=clang CROSS_COMPILE=mipsel-linux-gnu-
> malta_defconfig arch/mips/vdso/
> $ lvm-objdump --disassemble arch/mips/vdso/vdso.so.dbg.raw | egrep -h "jarl.*t9"
> $ llvm-objdump --disassemble arch/mips/vdso/vdso.so.dbg.raw | grep jarl
> So jarl instructions aren't emitted.
> 
> Tested-by: Nick Desaulniers <ndesaulniers@google.com>

Thank you for double checking and the review!

Cheers,
Nathan

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

* Re: [PATCH] MIPS: vdso: Wrap -mexplicit-relocs in cc-option
  2020-02-17 21:11 [PATCH] MIPS: vdso: Wrap -mexplicit-relocs in cc-option Nathan Chancellor
  2020-02-18 18:28 ` Nick Desaulniers
@ 2020-02-19 19:01 ` Paul Burton
  1 sibling, 0 replies; 4+ messages in thread
From: Paul Burton @ 2020-02-19 19:01 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Ralf Baechle, Paul Burton, linux-mips, linux-kernel,
	clang-built-linux, Nathan Chancellor, linux-mips

Hello,

Nathan Chancellor wrote:
> Clang does not support this option and errors out:
> 
> clang-11: error: unknown argument: '-mexplicit-relocs'
> 
> Clang does not appear to need this flag like GCC does because the jalr
> check that was added in commit 976c23af3ee5 ("mips: vdso: add build
> time check that no 'jalr t9' calls left") passes just fine with
> 
> $ make ARCH=mips CC=clang CROSS_COMPILE=mipsel-linux-gnu- malta_defconfig arch/mips/vdso/
> 
> even before commit d3f703c4359f ("mips: vdso: fix 'jalr t9' crash in
> vdso code").
> 
> -mrelax-pic-calls has been supported since clang 9, which is the
> earliest version that could build a working MIPS kernel, and it is the
> default for clang so just leave it be.

Applied to mips-fixes.

> commit 72cf3b3df423
> https://git.kernel.org/mips/c/72cf3b3df423
> 
> Fixes: d3f703c4359f ("mips: vdso: fix 'jalr t9' crash in vdso code")
> Link: https://github.com/ClangBuiltLinux/linux/issues/890
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> Tested-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Paul Burton <paulburton@kernel.org>

Thanks,
    Paul

[ This message was auto-generated; if you believe anything is incorrect
  then please email paulburton@kernel.org to report it. ]

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

end of thread, other threads:[~2020-02-19 19:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-17 21:11 [PATCH] MIPS: vdso: Wrap -mexplicit-relocs in cc-option Nathan Chancellor
2020-02-18 18:28 ` Nick Desaulniers
2020-02-18 18:30   ` Nathan Chancellor
2020-02-19 19:01 ` Paul Burton

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).