Skip to contentSkip to conversation

MIPS: vdso: Wrap -mexplicit-relocs in cc-option

PATCH Applied Nathan Chancellor 3 participants 4 messages Feb 17, 2020 – Feb 19, 2020 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS: vdso: Wrap -mexplicit-relocs in cc-option

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")
---
 arch/mips/vdso/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/vdso/Makefile +1 -1
index 77374c1f0c77..d7fe8408603e 100644
@@ -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)
Signature · 1 line
2.25.1
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 14 lines · 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").

Quoted 7 lines

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

Thanks for the patch, and detailed context.

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.
Quoted 18 lines
---
 arch/mips/vdso/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/vdso/Makefile +1 -2
index 77374c1f0c77..d7fe8408603e 100644
@@ -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)
--
Signature · 2 lines
Thanks,
~Nick Desaulniers
#2 lore raw
Quoted 27 lines · Nick Desaulniers
Quoted 14 lines · 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").

Quoted 7 lines

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

Thanks for the patch, and detailed context.

Quoted 8 lines

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.

Thank you for double checking and the review!

Cheers,
Nathan

Applied
#3 lore raw
In reply to Nathan Chancellor

Hello,

Quoted 8 lines · 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

Quoted 8 lines
$ 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.

Quoted 9 lines

commit 72cf3b3df423
https://git.kernel.org/mips/c/72cf3b3df423

Thanks,
Paul

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